mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Fixes liquidation/transfer tests
This commit is contained in:
parent
db17958737
commit
fbc6205479
|
@ -90,14 +90,16 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
|
|||
);
|
||||
});
|
||||
|
||||
it('User 0 deposits 1 ETH and user tries to borrow, but the aTokens received as a transfer are not available as collateral (revert expected)', async () => {
|
||||
it('User 0 deposits 1 WETH and user 1 tries to borrow, but the aTokens received as a transfer are not available as collateral (revert expected)', async () => {
|
||||
const {users, pool, weth} = testEnv;
|
||||
|
||||
await weth.connect(users[0].signer).mint(await convertToCurrencyDecimals(weth.address, '1'));
|
||||
|
||||
await weth.connect(users[0].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
||||
|
||||
await pool
|
||||
.connect(users[0].signer)
|
||||
.deposit(weth.address, ethers.utils.parseEther('1.0'), '0', {
|
||||
value: ethers.utils.parseEther('1.0'),
|
||||
});
|
||||
.deposit(weth.address, ethers.utils.parseEther('1.0'), '0');
|
||||
await expect(
|
||||
pool
|
||||
.connect(users[1].signer)
|
||||
|
@ -132,11 +134,14 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
|
|||
|
||||
it('User 1 repays the borrow, transfers aDAI back to user 0', async () => {
|
||||
const {users, pool, aDai, dai, weth} = testEnv;
|
||||
|
||||
await weth.connect(users[1].signer).mint(await convertToCurrencyDecimals(weth.address, '2'));
|
||||
|
||||
await weth.connect(users[1].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
||||
|
||||
await pool
|
||||
.connect(users[1].signer)
|
||||
.repay(weth.address, MAX_UINT_AMOUNT, RateMode.Stable, users[1].address, {
|
||||
value: ethers.utils.parseEther('1'),
|
||||
});
|
||||
.repay(weth.address, MAX_UINT_AMOUNT, RateMode.Stable, users[1].address);
|
||||
|
||||
const aDAItoTransfer = await convertToCurrencyDecimals(aDai.address, '1000');
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
THE_COLLATERAL_CHOSEN_CANNOT_BE_LIQUIDATED,
|
||||
} = ProtocolErrors;
|
||||
|
||||
it('LIQUIDATION - Deposits ETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => {
|
||||
it('LIQUIDATION - Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => {
|
||||
const {dai, weth, users, pool, oracle} = testEnv;
|
||||
const depositor = users[0];
|
||||
const borrower = users[1];
|
||||
|
@ -35,15 +35,20 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
const amountDAItoDeposit = await convertToCurrencyDecimals(dai.address, '1000');
|
||||
await pool.connect(depositor.signer).deposit(dai.address, amountDAItoDeposit, '0');
|
||||
|
||||
//user 2 deposits 1 ETH
|
||||
|
||||
const amountETHtoDeposit = await convertToCurrencyDecimals(weth.address, '1');
|
||||
|
||||
//mints WETH to borrower
|
||||
await weth.connect(borrower.signer).mint(amountETHtoDeposit);
|
||||
|
||||
//approve protocol to access borrower wallet
|
||||
await weth.connect(borrower.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
||||
|
||||
//user 2 deposits 1 WETH
|
||||
await pool
|
||||
.connect(borrower.signer)
|
||||
.deposit(weth.address, amountETHtoDeposit, '0', {value: amountETHtoDeposit});
|
||||
.deposit(weth.address, amountETHtoDeposit, '0');
|
||||
|
||||
await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0', {
|
||||
value: amountETHtoDeposit,
|
||||
});
|
||||
|
||||
//user 2 borrows
|
||||
const userGlobalData = await pool.getUserAccountData(borrower.address);
|
||||
|
@ -75,7 +80,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
});
|
||||
|
||||
it('LIQUIDATION - Drop the health factor below 1', async () => {
|
||||
const {dai, weth, users, pool, oracle} = testEnv;
|
||||
const {dai, users, pool, oracle} = testEnv;
|
||||
const borrower = users[1];
|
||||
|
||||
const daiPrice = await oracle.getAssetPrice(dai.address);
|
||||
|
@ -215,7 +220,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
);
|
||||
});
|
||||
|
||||
it('User 3 deposits 1000 USDC, user 4 1 ETH, user 4 borrows - drops HF, liquidates the borrow', async () => {
|
||||
it('User 3 deposits 1000 USDC, user 4 1 WETH, user 4 borrows - drops HF, liquidates the borrow', async () => {
|
||||
const {users, pool, usdc, oracle, weth} = testEnv;
|
||||
const depositor = users[3];
|
||||
const borrower = users[4];
|
||||
|
@ -235,6 +240,12 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
//user 4 deposits 1 ETH
|
||||
const amountETHtoDeposit = await convertToCurrencyDecimals(weth.address, '1');
|
||||
|
||||
//mints WETH to borrower
|
||||
await weth.connect(borrower.signer).mint(amountETHtoDeposit);
|
||||
|
||||
//approve protocol to access borrower wallet
|
||||
await weth.connect(borrower.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
||||
|
||||
await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0', {
|
||||
value: amountETHtoDeposit,
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
THE_COLLATERAL_CHOSEN_CANNOT_BE_LIQUIDATED,
|
||||
} = ProtocolErrors;
|
||||
|
||||
it('LIQUIDATION - Deposits ETH, borrows DAI', async () => {
|
||||
it('LIQUIDATION - Deposits WETH, borrows DAI', async () => {
|
||||
const {dai, weth, users, pool, oracle} = testEnv;
|
||||
const depositor = users[0];
|
||||
const borrower = users[1];
|
||||
|
@ -68,6 +68,12 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
//user 2 deposits 1 ETH
|
||||
const amountETHtoDeposit = await convertToCurrencyDecimals(weth.address, '1');
|
||||
|
||||
//mints WETH to borrower
|
||||
await weth.connect(borrower.signer).mint(await convertToCurrencyDecimals(weth.address, '1000'));
|
||||
|
||||
//approve protocol to access the borrower wallet
|
||||
await weth.connect(borrower.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
||||
|
||||
await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0', {
|
||||
value: amountETHtoDeposit,
|
||||
});
|
||||
|
@ -207,7 +213,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
);
|
||||
});
|
||||
|
||||
it('User 3 deposits 1000 USDC, user 4 1 ETH, user 4 borrows - drops HF, liquidates the borrow', async () => {
|
||||
it('User 3 deposits 1000 USDC, user 4 1 WETH, user 4 borrows - drops HF, liquidates the borrow', async () => {
|
||||
const {usdc, users, pool, oracle, weth} = testEnv;
|
||||
|
||||
const depositor = users[3];
|
||||
|
@ -230,6 +236,12 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
//borrower deposits 1 ETH
|
||||
const amountETHtoDeposit = await convertToCurrencyDecimals(weth.address, '1');
|
||||
|
||||
//mints WETH to borrower
|
||||
await weth.connect(borrower.signer).mint(await convertToCurrencyDecimals(weth.address, '1000'));
|
||||
|
||||
//approve protocol to access the borrower wallet
|
||||
await weth.connect(borrower.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
|
||||
|
||||
await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0', {
|
||||
value: amountETHtoDeposit,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user