mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
update collateralSwap signature in the delegate call
This commit is contained in:
parent
c4904bc41c
commit
65775ca3bf
|
@ -592,7 +592,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
(bool success, bytes memory result) = liquidationManager.delegatecall(
|
(bool success, bytes memory result) = liquidationManager.delegatecall(
|
||||||
abi.encodeWithSignature(
|
abi.encodeWithSignature(
|
||||||
'collateralSwap(address,address,address,uint256,address,bytes)',
|
'collateralSwap(address,address,address,uint256,bytes)',
|
||||||
receiverAddress,
|
receiverAddress,
|
||||||
fromAsset,
|
fromAsset,
|
||||||
toAsset,
|
toAsset,
|
||||||
|
|
|
@ -27,10 +27,12 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
||||||
const connectedWETH = weth.connect(signer);
|
const connectedWETH = weth.connect(signer);
|
||||||
await connectedWETH.mint(amountToDeposit);
|
await connectedWETH.mint(amountToDeposit);
|
||||||
await connectedWETH.approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
await connectedWETH.approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
||||||
await pool.connect(signer).deposit(weth.address, amountToDeposit, await signer.getAddress(), '0',);
|
await pool
|
||||||
|
.connect(signer)
|
||||||
|
.deposit(weth.address, amountToDeposit, await signer.getAddress(), '0');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('User tries to swap more then he can', async () => {
|
it('User tries to swap more then he can, revert expected', async () => {
|
||||||
const {pool, weth, dai} = testEnv;
|
const {pool, weth, dai} = testEnv;
|
||||||
await expect(
|
await expect(
|
||||||
pool.collateralSwap(
|
pool.collateralSwap(
|
||||||
|
@ -43,6 +45,19 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
||||||
).to.be.revertedWith('55');
|
).to.be.revertedWith('55');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('User tries to swap asset on equal asset, revert expected', async () => {
|
||||||
|
const {pool, weth} = testEnv;
|
||||||
|
await expect(
|
||||||
|
pool.collateralSwap(
|
||||||
|
_mockSwapAdapter.address,
|
||||||
|
weth.address,
|
||||||
|
weth.address,
|
||||||
|
ethers.utils.parseEther('0.1'),
|
||||||
|
'0x10'
|
||||||
|
)
|
||||||
|
).to.be.revertedWith('56');
|
||||||
|
});
|
||||||
|
|
||||||
it('User tries to swap more then available on the reserve', async () => {
|
it('User tries to swap more then available on the reserve', async () => {
|
||||||
const {pool, weth, dai, users, aEth, deployer} = testEnv;
|
const {pool, weth, dai, users, aEth, deployer} = testEnv;
|
||||||
|
|
||||||
|
@ -141,7 +156,9 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
// add more liquidity to allow user 0 to swap everything he has
|
// add more liquidity to allow user 0 to swap everything he has
|
||||||
await weth.connect(users[2].signer).mint(ethers.utils.parseEther('1'));
|
await weth.connect(users[2].signer).mint(ethers.utils.parseEther('1'));
|
||||||
await pool.connect(users[2].signer).deposit(weth.address, ethers.utils.parseEther('1'), users[2].address, '0');
|
await pool
|
||||||
|
.connect(users[2].signer)
|
||||||
|
.deposit(weth.address, ethers.utils.parseEther('1'), users[2].address, '0');
|
||||||
|
|
||||||
// cleanup borrowings, to be abe to swap whole weth
|
// cleanup borrowings, to be abe to swap whole weth
|
||||||
const amountToRepay = ethers.utils.parseEther('0.5');
|
const amountToRepay = ethers.utils.parseEther('0.5');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user