Skip to content

Commit

Permalink
fix: Bump aave dependencies and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Mar 6, 2024
1 parent 9da6c73 commit 5d28f58
Show file tree
Hide file tree
Showing 38 changed files with 251 additions and 104 deletions.
2 changes: 1 addition & 1 deletion contracts/mocks/flashloan/MockFlashLoanReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract MockFlashLoanReceiver is FlashLoanReceiverBase {
: amounts[i] + premiums[i];
//execution does not fail - mint tokens and return them to the _destination

token.mint(premiums[i]);
token.mint(address(this), premiums[i]);

IERC20(assets[i]).approve(address(POOL), amountToReturn);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/flashloan/MockSimpleFlashLoanReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract MockFlashLoanSimpleReceiver is FlashLoanSimpleReceiverBase {
uint256 amountToReturn = (_amountToApprove != 0) ? _amountToApprove : amount.add(premium);
//execution does not fail - mint tokens and return them to the _destination

token.mint(premium);
token.mint(address(this), premium);

IERC20(asset).approve(address(POOL), amountToReturn);

Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/tests/FlashloanAttacker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract FlashloanAttacker is FlashLoanSimpleReceiverBase {

function supplyAsset(address asset, uint256 amount) public {
MintableERC20 token = MintableERC20(asset);
token.mint(amount);
token.mint(address(this), amount);
token.approve(address(_pool), type(uint256).max);
_pool.supply(asset, amount, address(this), 0);
}
Expand All @@ -49,7 +49,7 @@ contract FlashloanAttacker is FlashLoanSimpleReceiverBase {
// Also do a normal borrow here in the middle
_innerBorrow(asset);

token.mint(premium);
token.mint(address(this), premium);
IERC20(asset).approve(address(POOL), amountToReturn);

return true;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aave/core-v3",
"version": "1.19.2-beta.1",
"version": "1.19.2-beta.2",
"description": "Aave Protocol V3 core smart contracts",
"files": [
"contracts",
Expand Down Expand Up @@ -33,8 +33,8 @@
"prepublish": "npm run compile && npm run build"
},
"devDependencies": {
"@aave/deploy-v3": "1.56.0",
"@aave/periphery-v3": "2.5.0",
"@aave/deploy-v3": "1.56.0-beta.5",
"@aave/periphery-v3": "2.5.0-beta.8",
"@ethersproject/bignumber": "^5.6.2",
"@nomicfoundation/hardhat-chai-matchers": "1.0.5",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
Expand Down
5 changes: 4 additions & 1 deletion test-suites/atoken-event-accounting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ makeSuite('AToken: Mint and Burn Event Accounting', (testEnv) => {
await waitForTx(
await weth
.connect(borrower.signer)
['mint(uint256)'](await convertToCurrencyDecimals(weth.address, '20000'))
['mint(address,uint256)'](
borrower.address,
await convertToCurrencyDecimals(weth.address, '20000')
)
);

// approve protocol to access the borrower wallet
Expand Down
7 changes: 5 additions & 2 deletions test-suites/atoken-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ const increaseSupplyIndex = async (

await collateralToken
.connect(borrower.signer)
['mint(uint256)'](await convertToCurrencyDecimals(collateralToken.address, '10000000'));
['mint(address,uint256)'](
borrower.address,
await convertToCurrencyDecimals(collateralToken.address, '10000000')
);
await collateralToken.connect(borrower.signer).approve(pool.address, MAX_UINT_AMOUNT);
await pool
.connect(borrower.signer)
Expand Down Expand Up @@ -111,7 +114,7 @@ makeSuite('AToken: Events', (testEnv: TestEnv) => {
const usersToInit = [alice, bob, eve, borrower, borrower2];
for (const user of usersToInit) {
await dai.connect(user.signer)['mint(uint256)'](amountToMint);
await weth.connect(user.signer)['mint(uint256)'](amountToMint);
await weth.connect(user.signer)['mint(address,uint256)'](user.address, amountToMint);
await dai.connect(user.signer).approve(pool.address, MAX_UINT_AMOUNT);
await weth.connect(user.signer).approve(pool.address, MAX_UINT_AMOUNT);
}
Expand Down
6 changes: 4 additions & 2 deletions test-suites/atoken-repay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ makeSuite('AToken: Repay', (testEnv: TestEnv) => {
const daiAmount = utils.parseEther('100');
const wethAmount = utils.parseEther('1');
await waitForTx(await dai.connect(user0.signer)['mint(uint256)'](daiAmount));
await waitForTx(await weth.connect(user1.signer)['mint(uint256)'](wethAmount));
await waitForTx(
await weth.connect(user1.signer)['mint(address,uint256)'](user1.address, wethAmount)
);

await waitForTx(await dai.connect(user0.signer).approve(pool.address, MAX_UINT_AMOUNT));
await waitForTx(await weth.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT));
Expand Down Expand Up @@ -223,7 +225,7 @@ makeSuite('AToken: Repay', (testEnv: TestEnv) => {
await pool.connect(user.signer).supply(dai.address, depositAmount, user.address, 0);

const collateralAmount = parseUnits('100', 18);
await weth.connect(user.signer)['mint(uint256)'](collateralAmount);
await weth.connect(user.signer)['mint(address,uint256)'](user.address, collateralAmount);
await weth.connect(user.signer).approve(pool.address, MAX_UINT_AMOUNT);
await pool.connect(user.signer).supply(weth.address, collateralAmount, user.address, 0);

Expand Down
6 changes: 5 additions & 1 deletion test-suites/atoken-transfer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
const amountWETHtoDeposit = await convertToCurrencyDecimals(weth.address, '1');
const amountWETHtoBorrow = await convertToCurrencyDecimals(weth.address, '0.1');

expect(await weth.connect(users[0].signer)['mint(uint256)'](amountWETHtoDeposit));
expect(
await weth
.connect(users[0].signer)
['mint(address,uint256)'](users[0].address, amountWETHtoDeposit)
);

expect(await weth.connect(users[0].signer).approve(pool.address, MAX_UINT_AMOUNT));

Expand Down
5 changes: 3 additions & 2 deletions test-suites/configurator-borrow-cap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ makeSuite('PoolConfigurator: Borrow Cap', (testEnv: TestEnv) => {
dai,
usdc,
users: [user1],
deployer,
} = testEnv;

const mintedAmount = utils.parseEther('1000000000');
// minting for main user
expect(await dai['mint(uint256)'](mintedAmount));
expect(await weth['mint(uint256)'](mintedAmount));
expect(await weth['mint(address,uint256)'](deployer.address, mintedAmount));
expect(await usdc['mint(uint256)'](mintedAmount));

// minting for lp user
expect(await dai.connect(user1.signer)['mint(uint256)'](mintedAmount));
expect(await weth.connect(user1.signer)['mint(uint256)'](mintedAmount));
expect(await weth.connect(user1.signer)['mint(address,uint256)'](user1.address, mintedAmount));
expect(await usdc.connect(user1.signer)['mint(uint256)'](mintedAmount));

expect(await dai.approve(pool.address, MAX_UINT_AMOUNT));
Expand Down
4 changes: 2 additions & 2 deletions test-suites/configurator-liquidation-protocol-fee.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ makeSuite('PoolConfigurator: Liquidation Protocol Fee', (testEnv: TestEnv) => {
const { INVALID_LIQUIDATION_PROTOCOL_FEE } = ProtocolErrors;

before(async () => {
const { weth, pool, dai, usdc } = testEnv;
const { weth, pool, dai, usdc, deployer } = testEnv;

const mintedAmount = utils.parseEther('1000000000');
await dai['mint(uint256)'](mintedAmount);
await weth['mint(uint256)'](mintedAmount);
await weth['mint(address,uint256)'](deployer.address, mintedAmount);
await usdc['mint(uint256)'](mintedAmount);

await dai.approve(pool.address, MAX_UINT_AMOUNT);
Expand Down
18 changes: 14 additions & 4 deletions test-suites/configurator-rate-strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ makeSuite('PoolConfigurator: Set Rate Strategy', (testEnv: TestEnv) => {
expect(
await pool.connect(depositor.signer).deposit(dai.address, mintedAmount, depositor.address, 0)
);
expect(await weth.connect(borrower.signer)['mint(uint256)'](mintedAmount));
expect(
await weth.connect(borrower.signer)['mint(address,uint256)'](borrower.address, mintedAmount)
);
expect(await weth.connect(borrower.signer).approve(pool.address, MAX_UINT_AMOUNT));
expect(
await pool.connect(borrower.signer).deposit(weth.address, mintedAmount, borrower.address, 0)
Expand Down Expand Up @@ -116,7 +118,9 @@ makeSuite('PoolConfigurator: Set Rate Strategy', (testEnv: TestEnv) => {
expect(
await pool.connect(depositor.signer).deposit(dai.address, mintedAmount, depositor.address, 0)
);
expect(await weth.connect(borrower.signer)['mint(uint256)'](mintedAmount));
expect(
await weth.connect(borrower.signer)['mint(address,uint256)'](borrower.address, mintedAmount)
);
expect(await weth.connect(borrower.signer).approve(pool.address, MAX_UINT_AMOUNT));
expect(
await pool.connect(borrower.signer).deposit(weth.address, mintedAmount, borrower.address, 0)
Expand Down Expand Up @@ -210,7 +214,9 @@ makeSuite('PoolConfigurator: Set Rate Strategy', (testEnv: TestEnv) => {
expect(
await pool.connect(depositor.signer).deposit(dai.address, mintedAmount, depositor.address, 0)
);
expect(await weth.connect(borrower.signer)['mint(uint256)'](mintedAmount));
expect(
await weth.connect(borrower.signer)['mint(address,uint256)'](borrower.address, mintedAmount)
);
expect(await weth.connect(borrower.signer).approve(pool.address, MAX_UINT_AMOUNT));
expect(
await pool.connect(borrower.signer).deposit(weth.address, mintedAmount, borrower.address, 0)
Expand All @@ -220,7 +226,11 @@ makeSuite('PoolConfigurator: Set Rate Strategy', (testEnv: TestEnv) => {
.connect(borrower.signer)
.borrow(dai.address, utils.parseEther('1'), 2, 0, borrower.address)
);
expect(await weth.connect(stableBorrower.signer)['mint(uint256)'](mintedAmount));
expect(
await weth
.connect(stableBorrower.signer)
['mint(address,uint256)'](stableBorrower.address, mintedAmount)
);
expect(await weth.connect(stableBorrower.signer).approve(pool.address, MAX_UINT_AMOUNT));
expect(
await pool
Expand Down
4 changes: 2 additions & 2 deletions test-suites/configurator-supply-cap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ makeSuite('PoolConfigurator: Supply Cap', (testEnv: TestEnv) => {
const { SUPPLY_CAP_EXCEEDED, INVALID_SUPPLY_CAP } = ProtocolErrors;

before(async () => {
const { weth, pool, dai, usdc } = testEnv;
const { weth, pool, dai, usdc, deployer } = testEnv;

const mintedAmount = utils.parseEther('1000000000');
await dai['mint(uint256)'](mintedAmount);
await weth['mint(uint256)'](mintedAmount);
await weth['mint(address,uint256)'](deployer.address, mintedAmount);
await usdc['mint(uint256)'](mintedAmount);

await dai.approve(pool.address, MAX_UINT_AMOUNT);
Expand Down
4 changes: 2 additions & 2 deletions test-suites/configurator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => {
const wethAmount = utils.parseEther('1');
const daiAmount = utils.parseEther('1000');
// user 1 supplies WETH
await weth.connect(user1.signer)['mint(uint256)'](wethAmount);
await weth.connect(user1.signer)['mint(address,uint256)'](user1.address, wethAmount);

await weth.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT);

Expand Down Expand Up @@ -1020,7 +1020,7 @@ makeSuite('PoolConfigurator', (testEnv: TestEnv) => {
await configurator.connect(riskAdmin.signer).setDebtCeiling(weth.address, '0');

// user 1 deposits
await weth.connect(user1.signer)['mint(uint256)']('100');
await weth.connect(user1.signer)['mint(address,uint256)'](user1.address, '100');

await weth.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT);

Expand Down
4 changes: 3 additions & 1 deletion test-suites/debt-token-delegation-permit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ makeSuite('DebtToken: Permit Delegation', (testEnv: TestEnv) => {
expect(await dai['mint(uint256)'](daiMintedAmount));
expect(await dai.approve(pool.address, daiMintedAmount));
expect(await pool.deposit(dai.address, daiMintedAmount, user1.address, 0));
expect(await weth.connect(user2.signer)['mint(uint256)'](wethMintedAmount));
expect(
await weth.connect(user2.signer)['mint(address,uint256)'](user2.address, wethMintedAmount)
);
expect(await weth.connect(user2.signer).approve(pool.address, wethMintedAmount));
expect(
await pool.connect(user2.signer).deposit(weth.address, wethMintedAmount, user2.address, 0)
Expand Down
24 changes: 15 additions & 9 deletions test-suites/emode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { convertToCurrencyDecimals } from '../helpers/contracts-helpers';
import { makeSuite, TestEnv } from './helpers/make-suite';
import './helpers/utils/wadraymath';
import { parseUnits, formatUnits, parseEther } from '@ethersproject/units';
import { evmSnapshot, evmRevert, VariableDebtToken__factory } from '@aave/deploy-v3';
import { evmSnapshot, evmRevert, VariableDebtToken__factory, aave } from '@aave/deploy-v3';

makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
const {
Expand Down Expand Up @@ -45,14 +45,16 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
weth,
users: [user0, user1, user2],
aaveOracle,
aave,
oracle,
} = testEnv;
const mintAmount = utils.parseEther('10000');

await dai.connect(user0.signer)['mint(uint256)'](mintAmount);
await usdc.connect(user0.signer)['mint(uint256)'](mintAmount);
await weth.connect(user0.signer)['mint(uint256)'](mintAmount);
await weth.connect(user0.signer)['mint(address,uint256)'](user0.address, mintAmount);
await usdc.connect(user1.signer)['mint(uint256)'](mintAmount);
await weth.connect(user1.signer)['mint(uint256)'](mintAmount);
await weth.connect(user1.signer)['mint(address,uint256)'](user1.address, mintAmount);
await dai.connect(user2.signer)['mint(uint256)'](mintAmount);

await dai.connect(user0.signer).approve(pool.address, MAX_UINT_AMOUNT);
Expand Down Expand Up @@ -251,9 +253,9 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
helpersContract,
weth,
users: [, user1],
oracle,
aaveOracle,
} = testEnv;
const wethPrice = await oracle.getAssetPrice(weth.address);
const wethPrice = await aaveOracle.getAssetPrice(weth.address);

const userDataBeforeSupply = await pool.getUserAccountData(user1.address);

Expand Down Expand Up @@ -456,7 +458,11 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
user4.signer
);

expect(await weth.connect(user3.signer)['mint(uint256)'](parseUnits('100', 18)));
expect(
await weth
.connect(user3.signer)
['mint(address,uint256)'](user3.address, parseUnits('100', 18))
);
expect(await weth.connect(user3.signer).approve(pool.address, MAX_UINT_AMOUNT));
expect(
await pool.connect(user3.signer).supply(weth.address, parseUnits('100', 18), user3.address, 0)
Expand Down Expand Up @@ -760,7 +766,7 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
pool,
dai,
usdc,
oracle,
aaveOracle,
users: [, , user2],
} = testEnv;

Expand All @@ -769,8 +775,8 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {

expect(await pool.connect(user2.signer).supply(dai.address, daiAmount, user2.address, 0));

const daiPrice = await oracle.getAssetPrice(dai.address);
const usdcPrice = await oracle.getAssetPrice(usdc.address);
const daiPrice = await aaveOracle.getAssetPrice(dai.address);
const usdcPrice = await aaveOracle.getAssetPrice(usdc.address);

const dataBefore = await pool.getUserAccountData(user2.address);
const expectedCollateralDaiPrice = daiAmount.wadMul(daiPrice);
Expand Down
2 changes: 1 addition & 1 deletion test-suites/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const mint = async (reserveSymbol: string, amount: string, user: SignerWi
await waitForTx(
await token
.connect(user.signer)
['mint(uint256)'](await convertToCurrencyDecimals(reserve, amount))
['mint(address,uint256)'](user.address, await convertToCurrencyDecimals(reserve, amount))
);
};

Expand Down
Loading

0 comments on commit 5d28f58

Please sign in to comment.