fix-test: fixed max Borrow Cap, adapted test asset init, asset config

This commit is contained in:
Hadrien Charlanes 2021-04-28 17:42:41 +02:00
parent 6054fa0bd5
commit 32cfe739c7
7 changed files with 62 additions and 30 deletions

View File

@ -37,7 +37,7 @@ library ReserveConfiguration {
uint256 constant MAX_VALID_LIQUIDATION_BONUS = 65535;
uint256 constant MAX_VALID_DECIMALS = 255;
uint256 constant MAX_VALID_RESERVE_FACTOR = 65535;
uint256 constant MAX_VALID_BORROW_CAP = 4294967296;
uint256 constant MAX_VALID_BORROW_CAP = 4294967295;
/**
* @dev Sets the Loan to Value of the reserve

View File

@ -15,6 +15,7 @@ export const oneEther = new BigNumber(Math.pow(10, 18));
export const oneRay = new BigNumber(Math.pow(10, 27));
export const MAX_UINT_AMOUNT =
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
export const MAX_BORROW_CAP = '4294967295';
export const ONE_YEAR = '31536000';
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
export const ONE_ADDRESS = '0x0000000000000000000000000000000000000001';

View File

@ -275,6 +275,7 @@ export const configureReservesByHelper = async (
const liquidationThresholds: string[] = [];
const liquidationBonuses: string[] = [];
const reserveFactors: string[] = [];
const borrowCaps: string[] = [];
const stableRatesEnabled: boolean[] = [];
const inputParams: {
@ -283,6 +284,7 @@ export const configureReservesByHelper = async (
liquidationThreshold: BigNumberish;
liquidationBonus: BigNumberish;
reserveFactor: BigNumberish;
borrowCap: BigNumberish;
stableBorrowingEnabled: boolean;
}[] = [];
@ -293,6 +295,7 @@ export const configureReservesByHelper = async (
liquidationBonus,
liquidationThreshold,
reserveFactor,
borrowCap,
stableBorrowRateEnabled,
},
] of Object.entries(reservesParams) as [string, IReserveParams][]) {
@ -317,9 +320,10 @@ export const configureReservesByHelper = async (
inputParams.push({
asset: tokenAddress,
baseLTV: baseLTVAsCollateral,
liquidationThreshold: liquidationThreshold,
liquidationBonus: liquidationBonus,
reserveFactor: reserveFactor,
liquidationThreshold,
liquidationBonus,
reserveFactor,
borrowCap,
stableBorrowingEnabled: stableBorrowRateEnabled,
});
@ -329,6 +333,7 @@ export const configureReservesByHelper = async (
liquidationThresholds.push(liquidationThreshold);
liquidationBonuses.push(liquidationBonus);
reserveFactors.push(reserveFactor);
borrowCaps.push(borrowCap);
stableRatesEnabled.push(stableBorrowRateEnabled);
}
if (tokens.length) {
@ -342,6 +347,7 @@ export const configureReservesByHelper = async (
console.log(`- Configure reserves in ${chunkedInputParams.length} txs`);
for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) {
console.log('chunk ', chunkedInputParams[chunkIndex]);
await waitForTx(
await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex], {
gasLimit: 12000000,

View File

@ -386,6 +386,7 @@ export interface IReserveCollateralParams {
baseLTVAsCollateral: string;
liquidationThreshold: string;
liquidationBonus: string;
borrowCap: string;
}
export interface IMarketRates {
borrowRate: string;

View File

@ -1,3 +1,4 @@
import { MAX_BORROW_CAP } from '../../helpers/constants';
import { eContractid, IReserveParams } from '../../helpers/types';
import {
@ -21,7 +22,8 @@ export const strategyBUSD: IReserveParams = {
stableBorrowRateEnabled: false,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
reserveFactor: '1000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyDAI: IReserveParams = {
@ -33,7 +35,8 @@ export const strategyDAI: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
reserveFactor: '1000',
borrowCap: MAX_BORROW_CAP,
};
export const strategySUSD: IReserveParams = {
@ -45,7 +48,8 @@ export const strategySUSD: IReserveParams = {
stableBorrowRateEnabled: false,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyTUSD: IReserveParams = {
@ -57,7 +61,8 @@ export const strategyTUSD: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
reserveFactor: '1000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyUSDC: IReserveParams = {
@ -69,7 +74,8 @@ export const strategyUSDC: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '6',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
reserveFactor: '1000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyUSDT: IReserveParams = {
@ -81,7 +87,8 @@ export const strategyUSDT: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '6',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
reserveFactor: '1000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyAAVE: IReserveParams = {
@ -93,7 +100,8 @@ export const strategyAAVE: IReserveParams = {
stableBorrowRateEnabled: false,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '0'
reserveFactor: '0',
borrowCap: MAX_BORROW_CAP,
};
export const strategyBAT: IReserveParams = {
@ -105,7 +113,8 @@ export const strategyBAT: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyENJ: IReserveParams = {
@ -117,7 +126,8 @@ export const strategyENJ: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyWETH: IReserveParams = {
@ -129,7 +139,8 @@ export const strategyWETH: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
reserveFactor: '1000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyKNC: IReserveParams = {
@ -141,7 +152,8 @@ export const strategyKNC: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyLINK: IReserveParams = {
@ -153,7 +165,8 @@ export const strategyLINK: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyMANA: IReserveParams = {
@ -165,7 +178,8 @@ export const strategyMANA: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '3500'
reserveFactor: '3500',
borrowCap: MAX_BORROW_CAP,
};
export const strategyMKR: IReserveParams = {
@ -177,7 +191,8 @@ export const strategyMKR: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyREN: IReserveParams = {
@ -189,7 +204,8 @@ export const strategyREN: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategySNX: IReserveParams = {
@ -201,7 +217,8 @@ export const strategySNX: IReserveParams = {
stableBorrowRateEnabled: false,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '3500'
reserveFactor: '3500',
borrowCap: MAX_BORROW_CAP,
};
// Invalid borrow rates in params currently, replaced with snx params
@ -214,7 +231,8 @@ export const strategyUNI: IReserveParams = {
stableBorrowRateEnabled: false,
reserveDecimals: '18',
aTokenImpl: eContractid.DelegationAwareAToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyWBTC: IReserveParams = {
@ -226,7 +244,8 @@ export const strategyWBTC: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '8',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyYFI: IReserveParams = {
@ -238,7 +257,8 @@ export const strategyYFI: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyZRX: IReserveParams = {
@ -250,7 +270,8 @@ export const strategyZRX: IReserveParams = {
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
reserveFactor: '2000',
borrowCap: MAX_BORROW_CAP,
};
export const strategyXSUSHI: IReserveParams = {
@ -263,4 +284,5 @@ export const strategyXSUSHI: IReserveParams = {
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '3500',
borrowCap: MAX_BORROW_CAP,
};

View File

@ -1,5 +1,5 @@
import { TestEnv, makeSuite } from './helpers/make-suite';
import { APPROVAL_AMOUNT_LENDING_POOL, RAY } from '../../helpers/constants';
import { APPROVAL_AMOUNT_LENDING_POOL, MAX_UINT_AMOUNT, RAY, MAX_BORROW_CAP } from '../../helpers/constants';
import { convertToCurrencyDecimals } from '../../helpers/contracts-helpers';
import { ProtocolErrors } from '../../helpers/types';
import { strategyWETH } from '../../markets/aave/reservesConfigs';
@ -156,7 +156,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
it('Activates the ETH reserve for borrowing', async () => {
const { configurator, weth, helpersContract } = testEnv;
await configurator.enableBorrowingOnReserve(weth.address, true);
await configurator.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true);
const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address);
const {
@ -195,7 +195,9 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => {
const { configurator, users, weth } = testEnv;
await expect(
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, true),
configurator
.connect(users[2].signer)
.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});

View File

@ -1,5 +1,5 @@
import { TestEnv, makeSuite } from './helpers/make-suite';
import { APPROVAL_AMOUNT_LENDING_POOL, RAY } from '../../helpers/constants';
import { APPROVAL_AMOUNT_LENDING_POOL, MAX_BORROW_CAP, RAY } from '../../helpers/constants';
import { convertToCurrencyDecimals } from '../../helpers/contracts-helpers';
import { ProtocolErrors } from '../../helpers/types';
import { strategyWETH } from '../../markets/amm/reservesConfigs';
@ -156,7 +156,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
it('Activates the ETH reserve for borrowing', async () => {
const { configurator, weth, helpersContract } = testEnv;
await configurator.enableBorrowingOnReserve(weth.address, true);
await configurator.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true);
const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address);
const {
@ -195,7 +195,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => {
const { configurator, users, weth } = testEnv;
await expect(
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, true),
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});