mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Renamed collateralSwap() to swapDeposit().
- Added docs to sw
This commit is contained in:
parent
65775ca3bf
commit
172cb05b64
|
@ -290,7 +290,15 @@ interface ILendingPool {
|
|||
uint16 referralCode
|
||||
) external;
|
||||
|
||||
function collateralSwap(
|
||||
/**
|
||||
* @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral.
|
||||
* - It's not possible to release one asset to swap for the same
|
||||
* @param receiverAddress The address of the contract receiving the funds. The receiver should implement the ISwapAdapter interface
|
||||
* @param fromAsset Asset to swap from
|
||||
* @param toAsset Asset to swap to
|
||||
* @param params a bytes array to be sent (if needed) to the receiver contract with extra data
|
||||
**/
|
||||
function swapLiquidity(
|
||||
address receiverAddress,
|
||||
address fromAsset,
|
||||
address toAsset,
|
||||
|
|
|
@ -580,7 +580,15 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
}
|
||||
}
|
||||
|
||||
function collateralSwap(
|
||||
/**
|
||||
* @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral.
|
||||
* - It's not possible to release one asset to swap for the same
|
||||
* @param receiverAddress The address of the contract receiving the funds. The receiver should implement the ISwapAdapter interface
|
||||
* @param fromAsset Asset to swap from
|
||||
* @param toAsset Asset to swap to
|
||||
* @param params a bytes array to be sent (if needed) to the receiver contract with extra data
|
||||
**/
|
||||
function swapLiquidity(
|
||||
address receiverAddress,
|
||||
address fromAsset,
|
||||
address toAsset,
|
||||
|
@ -592,7 +600,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
//solium-disable-next-line
|
||||
(bool success, bytes memory result) = liquidationManager.delegatecall(
|
||||
abi.encodeWithSignature(
|
||||
'collateralSwap(address,address,address,uint256,bytes)',
|
||||
'swapLiquidity(address,address,address,uint256,bytes)',
|
||||
receiverAddress,
|
||||
fromAsset,
|
||||
toAsset,
|
||||
|
|
|
@ -518,7 +518,15 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
|||
return (collateralAmount, principalAmountNeeded);
|
||||
}
|
||||
|
||||
function collateralSwap(
|
||||
/**
|
||||
* @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral.
|
||||
* - It's not possible to release one asset to swap for the same
|
||||
* @param receiverAddress The address of the contract receiving the funds. The receiver should implement the ISwapAdapter interface
|
||||
* @param fromAsset Asset to swap from
|
||||
* @param toAsset Asset to swap to
|
||||
* @param params a bytes array to be sent (if needed) to the receiver contract with extra data
|
||||
**/
|
||||
function swapLiquidity(
|
||||
address receiverAddress,
|
||||
address fromAsset,
|
||||
address toAsset,
|
||||
|
|
|
@ -11,7 +11,7 @@ import {advanceBlock, timeLatest} from '../helpers/misc-utils';
|
|||
|
||||
const {expect} = require('chai');
|
||||
|
||||
makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
||||
makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => {
|
||||
let _mockSwapAdapter = {} as MockSwapAdapter;
|
||||
const {HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD} = ProtocolErrors;
|
||||
|
||||
|
@ -35,7 +35,7 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
|||
it('User tries to swap more then he can, revert expected', async () => {
|
||||
const {pool, weth, dai} = testEnv;
|
||||
await expect(
|
||||
pool.collateralSwap(
|
||||
pool.swapLiquidity(
|
||||
_mockSwapAdapter.address,
|
||||
weth.address,
|
||||
dai.address,
|
||||
|
@ -48,7 +48,7 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
|||
it('User tries to swap asset on equal asset, revert expected', async () => {
|
||||
const {pool, weth} = testEnv;
|
||||
await expect(
|
||||
pool.collateralSwap(
|
||||
pool.swapLiquidity(
|
||||
_mockSwapAdapter.address,
|
||||
weth.address,
|
||||
weth.address,
|
||||
|
@ -65,7 +65,7 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
|||
await pool.connect(users[2].signer).withdraw(weth.address, ethers.utils.parseEther('1'));
|
||||
|
||||
await expect(
|
||||
pool.collateralSwap(
|
||||
pool.swapLiquidity(
|
||||
_mockSwapAdapter.address,
|
||||
weth.address,
|
||||
dai.address,
|
||||
|
@ -98,7 +98,7 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
|||
const reserveBalanceDAIBefore = await dai.balanceOf(aDai.address);
|
||||
|
||||
const txReceipt = await waitForTx(
|
||||
await pool.collateralSwap(
|
||||
await pool.swapLiquidity(
|
||||
_mockSwapAdapter.address,
|
||||
weth.address,
|
||||
dai.address,
|
||||
|
@ -146,7 +146,7 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
|||
await pool.borrow(weth.address, ethers.utils.parseEther('0.3'), 1, 0, deployer.address);
|
||||
|
||||
await expect(
|
||||
pool.collateralSwap(_mockSwapAdapter.address, weth.address, dai.address, amountToSwap, '0x10')
|
||||
pool.swapLiquidity(_mockSwapAdapter.address, weth.address, dai.address, amountToSwap, '0x10')
|
||||
).to.be.revertedWith(HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD);
|
||||
});
|
||||
|
||||
|
@ -178,7 +178,7 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
|||
|
||||
await advanceBlock(txTimestamp.toNumber());
|
||||
|
||||
await pool.collateralSwap(
|
||||
await pool.swapLiquidity(
|
||||
_mockSwapAdapter.address,
|
||||
weth.address,
|
||||
dai.address,
|
||||
|
|
Loading…
Reference in New Issue
Block a user