From ef56ee987c73d482ef45a5172e74ade4a446e3a7 Mon Sep 17 00:00:00 2001 From: "Michele \"Ubik\" De Simoni" Date: Tue, 1 Sep 2020 18:57:44 +0200 Subject: [PATCH] Fix docs --- .../farming/IUnifiedStableFarming.sol | 2 +- .../farming/UnifiedStableFarming.sol | 52 ++++++++----------- docs/build | 2 +- docs/mkdocs.yml | 2 + 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/contracts/stableCoin/farming/IUnifiedStableFarming.sol b/contracts/stableCoin/farming/IUnifiedStableFarming.sol index 29a1bcd..823e268 100644 --- a/contracts/stableCoin/farming/IUnifiedStableFarming.sol +++ b/contracts/stableCoin/farming/IUnifiedStableFarming.sol @@ -69,7 +69,7 @@ interface IUnifiedStableFarming { * equilibrium. * @param stableCoinAddress Address of the $uSD stablecoin * @param pairIndex Index of the pair inside the whitelisted pairs array - * @param pairAmount + * @param pairAmount Amount of Uniswap liquidity tokens to send back to the pool * @param amountAMin The minimum amount of tokenA that must be received for the transaction not to revert * @param amountBMin The minimum amount of tokenB that must be received for the transaction not to revert * @param tokenAddress Address of the token to swap to get $uSD diff --git a/contracts/stableCoin/farming/UnifiedStableFarming.sol b/contracts/stableCoin/farming/UnifiedStableFarming.sol index 20e9a76..0d9667c 100644 --- a/contracts/stableCoin/farming/UnifiedStableFarming.sol +++ b/contracts/stableCoin/farming/UnifiedStableFarming.sol @@ -4,24 +4,23 @@ pragma solidity ^0.6.0; import "./IUnifiedStableFarming.sol"; -/** -* @inheritdoc IUnifiedStableFarming -*/ contract UnifiedStableFarming is IUnifiedStableFarming { address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256[] private _percentage; - constructor(uint256[] memory percentage) { + constructor(uint256[] memory percentage) public { assert(percentage.length == 2); _percentage = percentage; } - function percentage() public override view returns(uint256[] memory) { + function percentage() public view returns (uint256[] memory) { return _percentage; } - //Earn pumping uSD - Means swap a chosen stableCoin for uSD, then burn the difference of uSD to obtain a greater uSD value in Uniswap Pool tokens + /** + * @inheritdoc IUnifiedStableFarming + */ function earnByPump( address stableCoinAddress, uint256 pairIndex, @@ -48,8 +47,8 @@ contract UnifiedStableFarming is IUnifiedStableFarming { (uint256 returnA, uint256 returnB) = IStableCoin(stableCoinAddress).burn( pairIndex, pairAmount, - amountA, - amountB + amountAMin, + amountBMin ); (address tokenA, address tokenB, ) = _getPairData(stableCoinAddress, pairIndex); // Check that the pump was successful @@ -81,18 +80,13 @@ contract UnifiedStableFarming is IUnifiedStableFarming { uint256 stableCoinAmount ) private view returns (bool) { IStableCoin stableCoin = IStableCoin(stableCoinAddress); - uint256 cumulative = stableCoin.fromTokenToStable( - tokenAddress, - tokenValue - ); + uint256 cumulative = stableCoin.fromTokenToStable(tokenAddress, tokenValue); cumulative += stableCoin.fromTokenToStable(token0, return0); cumulative += stableCoin.fromTokenToStable(token1, return1); uint256 percentage = (cumulative * _percentage[0]) / _percentage[1]; uint256 cumulativePlus = cumulative + percentage; uint256 cumulativeMinus = cumulative - percentage; - return - stableCoinAmount >= cumulativeMinus && - stableCoinAmount <= cumulativePlus; + return stableCoinAmount >= cumulativeMinus && stableCoinAmount <= cumulativePlus; } /** @@ -124,29 +118,29 @@ contract UnifiedStableFarming is IUnifiedStableFarming { amountB ); // Mint $uSD - IStableCoin(stableCoinAddress).mint(pairIndex, amount0, amount1, amount0Min, amount1Min); + IStableCoin(stableCoinAddress).mint(pairIndex, amountA, amountB, amountAMin, amountBMin); // For each of the chosen output pair swap $uSD to obtain the desired amount of stablecoin for (uint256 i = 0; i < tokenIndices.length; i++) { _swap( stableCoinAddress, - tokenIndices[i] == 0 ? token0 : token1, + tokenIndices[i] == 0 ? tokenA : tokenB, stableCoinAmounts[i], msg.sender ); } // Send the tokens back to their owner - _flushToSender(token0, token1, stableCoinAddress); + _flushToSender(tokenA, tokenB, stableCoinAddress); } function _transferTokens( address stableCoinAddress, uint256 pairIndex, - uint256 amount0, - uint256 amount1 + uint256 amountA, + uint256 amountB ) private { - (address token0, address token1, ) = _getPairData(stableCoinAddress, pairIndex); - IERC20(token0).transferFrom(msg.sender, address(this), amount0); - IERC20(token1).transferFrom(msg.sender, address(this), amount1); + (address tokenA, address tokenB, ) = _getPairData(stableCoinAddress, pairIndex); + IERC20(tokenA).transferFrom(msg.sender, address(this), amountA); + IERC20(tokenB).transferFrom(msg.sender, address(this), amountB); } function _getPairData(address stableCoinAddress, uint256 pairIndex) @@ -200,13 +194,13 @@ contract UnifiedStableFarming is IUnifiedStableFarming { } function _flushToSender( - address token0, - address token1, - address token2 + address tokenA, + address tokenB, + address tokenC ) private { - _flushToSender(token0); - _flushToSender(token1); - _flushToSender(token2); + _flushToSender(tokenA); + _flushToSender(tokenB); + _flushToSender(tokenC); } /** diff --git a/docs/build b/docs/build index 4910af7..411f57a 160000 --- a/docs/build +++ b/docs/build @@ -1 +1 @@ -Subproject commit 4910af7fdd9d8cbfd719c65ea83dba87dca26a95 +Subproject commit 411f57a6ea4abe33cb9f121fadb0d85e4121b028 diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 739f0a8..1eb8487 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -12,6 +12,8 @@ nav: - IMVDProxy: stableCoin/standalone/IMVDProxy.md - IStateHolder: stableCoin/standalone/IStateHolder.md - IStableCoin: stableCoin/standalone/IStableCoin.md + - Farming: + - IUnifiedStableFarming: stableCoin/farming/IUnifiedStableFarming.md - Microservices: - MintNewVotingTokensForStableCoinFunctionality: stableCoin/microservices/MintNewVotingTokensForStableCoinFunctionality.md