diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 69dee3a3..592e604b 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -592,7 +592,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { //solium-disable-next-line (bool success, bytes memory result) = liquidationManager.delegatecall( abi.encodeWithSignature( - 'collateralSwap(address,address,address,uint256,address,bytes)', + 'collateralSwap(address,address,address,uint256,bytes)', receiverAddress, fromAsset, toAsset, diff --git a/test/collateral-swap.spec.ts b/test/collateral-swap.spec.ts index a267162b..04e223fc 100644 --- a/test/collateral-swap.spec.ts +++ b/test/collateral-swap.spec.ts @@ -27,10 +27,12 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => { const connectedWETH = weth.connect(signer); await connectedWETH.mint(amountToDeposit); 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; await expect( pool.collateralSwap( @@ -43,6 +45,19 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => { ).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 () => { const {pool, weth, dai, users, aEth, deployer} = testEnv; @@ -61,7 +76,7 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => { }); it('User tries to swap correct amount', async () => { - const {pool, weth, dai, aEth, aDai} = testEnv; + const {pool, weth, dai, aEth, aDai} = testEnv; const userAddress = await pool.signer.getAddress(); const amountToSwap = ethers.utils.parseEther('0.25'); @@ -141,7 +156,9 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => { // add more liquidity to allow user 0 to swap everything he has 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 const amountToRepay = ethers.utils.parseEther('0.5');