Update adapter docs

This commit is contained in:
Gerardo Nardelli 2020-11-25 15:49:11 -03:00
parent bc969d926e
commit 3415204216
2 changed files with 42 additions and 18 deletions

View File

@ -10,7 +10,7 @@ import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol';
/** /**
* @title UniswapLiquiditySwapAdapter * @title UniswapLiquiditySwapAdapter
* @notice Uniswap V2 Adapter to swap liquidity using a flash loan. * @notice Uniswap V2 Adapter to swap liquidity.
* @author Aave * @author Aave
**/ **/
contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver { contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
@ -43,8 +43,8 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
* The received funds from the swap are then deposited into the protocol on behalf of the user. * The received funds from the swap are then deposited into the protocol on behalf of the user.
* The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset and * The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset and
* repay the flash loan. * repay the flash loan.
* @param assets Address to be swapped * @param assets Address of asset to be swapped
* @param amounts Amount of the reserve to be swapped * @param amounts Amount of the asset to be swapped
* @param premiums Fee of the flash loan * @param premiums Fee of the flash loan
* @param initiator Address of the user * @param initiator Address of the user
* @param params Additional variadic field to include extra params. Expected parameters: * @param params Additional variadic field to include extra params. Expected parameters:
@ -103,8 +103,9 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
} }
/** /**
* @dev Swaps an `amountToSwap` of an asset to another and deposits the funds on behalf of the user without using a flashloan. * @dev Swaps an amount of an asset to another and deposits the new asset amount on behalf of the user without using
* This method can be used when the user has no debts. * a flash loan. This method can be used when the temporary transfer of the collateral asset to this contract
* does not affect the user position.
* The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset and * The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset and
* perform the swap. * perform the swap.
* @param assetToSwapFromList List of addresses of the underlying asset to be swap from * @param assetToSwapFromList List of addresses of the underlying asset to be swap from
@ -208,7 +209,7 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
} }
/** /**
* @dev Decodes debt information encoded in flashloan params * @dev Decodes the information encoded in the flash loan params
* @param params Additional variadic field to include extra params. Expected parameters: * @param params Additional variadic field to include extra params. Expected parameters:
* address[] assetToSwapToList List of the addresses of the reserve to be swapped to and deposited * address[] assetToSwapToList List of the addresses of the reserve to be swapped to and deposited
* uint256[] minAmountsToReceive List of min amounts to be received from the swap * uint256[] minAmountsToReceive List of min amounts to be received from the swap
@ -232,6 +233,17 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
bytes32[] memory s bytes32[] memory s
) = abi.decode(params, (address[], uint256[], bool[], uint256[], uint256[], uint8[], bytes32[], bytes32[])); ) = abi.decode(params, (address[], uint256[], bool[], uint256[], uint256[], uint8[], bytes32[], bytes32[]));
return SwapParams(assetToSwapToList, minAmountsToReceive, swapAllBalance, PermitParams(permitAmount, deadline, v, r, s)); return SwapParams(
assetToSwapToList,
minAmountsToReceive,
swapAllBalance,
PermitParams(
permitAmount,
deadline,
v,
r,
s
)
);
} }
} }

View File

@ -11,7 +11,7 @@ import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
/** /**
* @title UniswapRepayAdapter * @title UniswapRepayAdapter
* @notice Uniswap V2 Adapter to perform a repay of a debt using a flash loan. * @notice Uniswap V2 Adapter to perform a repay of a debt with collateral.
* @author Aave * @author Aave
**/ **/
contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver { contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
@ -33,18 +33,18 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
/** /**
* @dev Uses the received funds from the flash loan to repay a debt on the protocol on behalf of the user. Then pulls * @dev Uses the received funds from the flash loan to repay a debt on the protocol on behalf of the user. Then pulls
* the collateral from the user and swaps it to repay the flash loan. * the collateral from the user and swaps it to the debt asset to repay the flash loan.
* The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset, swap it * The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset, swap it
* and repay the flash loan. * and repay the flash loan.
* @param assets Address to be swapped * Supports only one asset on the flash loan.
* @param amounts Amount of the reserve to be swapped * @param assets Address of debt asset
* @param amounts Amount of the debt to be repaid
* @param premiums Fee of the flash loan * @param premiums Fee of the flash loan
* @param initiator Address of the user * @param initiator Address of the user
* @param params Additional variadic field to include extra params. Expected parameters: * @param params Additional variadic field to include extra params. Expected parameters:
* address collateralAsset Address of the reserve to be swapped * address collateralAsset Address of the reserve to be swapped
* uint256 collateralAmount Amount of reserve to be swapped * uint256 collateralAmount Amount of reserve to be swapped
* uint256 rateMode Rate modes of the debt to be repaid * uint256 rateMode Rate modes of the debt to be repaid
* RepayMode repayMode Enum indicating the repaid mode
* uint256 permitAmount Amount for the permit signature * uint256 permitAmount Amount for the permit signature
* uint256 deadline Deadline for the permit signature * uint256 deadline Deadline for the permit signature
* uint8 v V param for the permit signature * uint8 v V param for the permit signature
@ -76,6 +76,18 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
return true; return true;
} }
/**
* @dev Swaps the user collateral for the debt asset and then repay the debt on the protocol on behalf of the user
* without using flash loans. This method can be used when the temporary transfer of the collateral asset to this
* contract does not affect the user position.
* The user should give this contract allowance to pull the ATokens in order to withdraw the underlying asset
* @param collateralAsset Address of asset to be swapped
* @param debtAsset Address of debt asset
* @param collateralAmount Amount of the collateral to be swapped
* @param debtRepayAmount Amount of the debt to be repaid
* @param debtRateMode Rate mode of the debt to be repaid
* @param permitSignature struct containing the permit signature
*/
function swapAndRepay( function swapAndRepay(
address collateralAsset, address collateralAsset,
address debtAsset, address debtAsset,
@ -187,7 +199,7 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
} }
/** /**
* @dev Decodes debt information encoded in flashloan params * @dev Decodes debt information encoded in the flash loan params
* @param params Additional variadic field to include extra params. Expected parameters: * @param params Additional variadic field to include extra params. Expected parameters:
* address collateralAsset Address of the reserve to be swapped * address collateralAsset Address of the reserve to be swapped
* uint256 collateralAmount Amount of reserve to be swapped * uint256 collateralAmount Amount of reserve to be swapped