mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
add logic to set usageAsCollateralEnabled for the user if his balance was 0 before swap
This commit is contained in:
parent
1b61edc6ff
commit
83e0318bc6
|
@ -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,
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user