diff --git a/contracts/lendingpool/LendingPoolLiquidationManager.sol b/contracts/lendingpool/LendingPoolLiquidationManager.sol index 6adc18d9..dfdcaaf6 100644 --- a/contracts/lendingpool/LendingPoolLiquidationManager.sol +++ b/contracts/lendingpool/LendingPoolLiquidationManager.sol @@ -514,6 +514,11 @@ contract LendingPoolLiquidationManager is VersionedInitializable { address(vars.toReserveAToken), vars.amountToReceive ); + + if (vars.toReserveAToken.balanceOf(msg.sender) == 0) { + usersConfig[msg.sender].setUsingAsCollateral(toReserve.id, true); + } + vars.toReserveAToken.mint(msg.sender, vars.amountToReceive, toReserve.liquidityIndex); toReserve.updateInterestRates( toAsset, diff --git a/test/collateral-swap.spec.ts b/test/collateral-swap.spec.ts index 7e692659..c2bd9024 100644 --- a/test/collateral-swap.spec.ts +++ b/test/collateral-swap.spec.ts @@ -83,6 +83,7 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => { .deposit(weth.address, amountToDeposit, await signer.getAddress(), '0'); } }); + it('User tries to swap more then he can, revert expected', async () => { const {pool, weth, dai} = testEnv; await expect( @@ -96,19 +97,6 @@ makeSuite('LendingPool SwapDeposit 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.swapLiquidity( - _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; @@ -185,6 +173,9 @@ makeSuite('LendingPool SwapDeposit function', (testEnv: TestEnv) => { reserveBalanceDAIBefore.add(amountToReturn).toString(), 'was received incorrect amount if reserve funds' ); + expect( + (await pool.getUserReserveData(dai.address, userAddress)).usageAsCollateralEnabled + ).to.be.equal(true, 'usage as collateral was not enabled on destination reserve for the user'); }); it('User tries to drop HF below one', async () => {