mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
refactor: refactored tests, removed last exposure ceiling references
This commit is contained in:
parent
c1db1f8953
commit
89e03892f1
|
@ -113,7 +113,6 @@ library Errors {
|
||||||
string public constant RL_STABLE_DEBT_NOT_ZERO = '89';
|
string public constant RL_STABLE_DEBT_NOT_ZERO = '89';
|
||||||
string public constant RL_VARIABLE_DEBT_SUPPLY_NOT_ZERO = '90';
|
string public constant RL_VARIABLE_DEBT_SUPPLY_NOT_ZERO = '90';
|
||||||
string public constant LP_CALLER_NOT_EOA = '91';
|
string public constant LP_CALLER_NOT_EOA = '91';
|
||||||
string public constant RC_INVALID_EXPOSURE_CAP = '92';
|
|
||||||
string public constant VL_LTV_VALIDATION_FAILED = '93';
|
string public constant VL_LTV_VALIDATION_FAILED = '93';
|
||||||
string public constant VL_SAME_BLOCK_BORROW_REPAY = '94';
|
string public constant VL_SAME_BLOCK_BORROW_REPAY = '94';
|
||||||
string public constant LPC_FLASHLOAN_PREMIUMS_MISMATCH = '95';
|
string public constant LPC_FLASHLOAN_PREMIUMS_MISMATCH = '95';
|
||||||
|
|
|
@ -60,7 +60,7 @@ library GenericLogic {
|
||||||
* @param userConfig The configuration of the user
|
* @param userConfig The configuration of the user
|
||||||
* @param reserves The list of the available reserves
|
* @param reserves The list of the available reserves
|
||||||
* @param oracle The price oracle address
|
* @param oracle The price oracle address
|
||||||
* @return The total collateral and total debt of the user in ETH, the avg ltv, liquidation threshold, the HF and the uncapped avg ltv (without exposure ceiling)
|
* @return The total collateral and total debt of the user in ETH, the avg ltv, liquidation threshold, the HF and the uncapped avg ltv
|
||||||
**/
|
**/
|
||||||
function calculateUserAccountData(
|
function calculateUserAccountData(
|
||||||
address user,
|
address user,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {IAToken} from '../../../interfaces/IAToken.sol';
|
||||||
import {DataTypes} from '../types/DataTypes.sol';
|
import {DataTypes} from '../types/DataTypes.sol';
|
||||||
import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol';
|
import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol';
|
||||||
import {Address} from '../../../dependencies/openzeppelin/contracts/Address.sol';
|
import {Address} from '../../../dependencies/openzeppelin/contracts/Address.sol';
|
||||||
import "hardhat/console.sol";
|
|
||||||
/**
|
/**
|
||||||
* @title ReserveLogic library
|
* @title ReserveLogic library
|
||||||
* @author Aave
|
* @author Aave
|
||||||
|
@ -517,7 +517,7 @@ library ValidationLogic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Validates the health factor of a user and the ltv of the asset being withdrawn
|
* @dev Validates the health factor of a user and the ltv of the asset being withdrawn
|
||||||
* @param asset The asset for which the exposure cap will be validated
|
* @param asset The asset for which the ltv will be validated
|
||||||
* @param from The user from which the aTokens are being transferred
|
* @param from The user from which the aTokens are being transferred
|
||||||
* @param reservesData The state of all the reserves
|
* @param reservesData The state of all the reserves
|
||||||
* @param userConfig The state of the user for the specific reserve
|
* @param userConfig The state of the user for the specific reserve
|
||||||
|
@ -552,9 +552,6 @@ library ValidationLogic {
|
||||||
|
|
||||||
vars.assetLtv = reserve.configuration.getLtvMemory();
|
vars.assetLtv = reserve.configuration.getLtvMemory();
|
||||||
|
|
||||||
console.log("asset ltv is ", vars.assetLtv);
|
|
||||||
console.log("has 0 ltv collateral ", vars.hasZeroLtvCollateral);
|
|
||||||
|
|
||||||
require(vars.assetLtv == 0 || !vars.hasZeroLtvCollateral, Errors.VL_LTV_VALIDATION_FAILED);
|
require(vars.assetLtv == 0 || !vars.hasZeroLtvCollateral, Errors.VL_LTV_VALIDATION_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ export const MAX_UINT_AMOUNT =
|
||||||
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
||||||
export const MAX_BORROW_CAP = '68719476735';
|
export const MAX_BORROW_CAP = '68719476735';
|
||||||
export const MAX_SUPPLY_CAP = '68719476735';
|
export const MAX_SUPPLY_CAP = '68719476735';
|
||||||
export const MAX_EXPOSURE_CAP = '68719476735';
|
|
||||||
export const ONE_YEAR = '31536000';
|
export const ONE_YEAR = '31536000';
|
||||||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||||
export const ONE_ADDRESS = '0x0000000000000000000000000000000000000001';
|
export const ONE_ADDRESS = '0x0000000000000000000000000000000000000001';
|
||||||
|
|
|
@ -285,7 +285,6 @@ export const configureReservesByHelper = async (
|
||||||
reserveFactor: BigNumberish;
|
reserveFactor: BigNumberish;
|
||||||
borrowCap: BigNumberish;
|
borrowCap: BigNumberish;
|
||||||
supplyCap: BigNumberish;
|
supplyCap: BigNumberish;
|
||||||
exposureCap: BigNumberish;
|
|
||||||
stableBorrowingEnabled: boolean;
|
stableBorrowingEnabled: boolean;
|
||||||
borrowingEnabled: boolean;
|
borrowingEnabled: boolean;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
@ -299,7 +298,6 @@ export const configureReservesByHelper = async (
|
||||||
reserveFactor,
|
reserveFactor,
|
||||||
borrowCap,
|
borrowCap,
|
||||||
supplyCap,
|
supplyCap,
|
||||||
exposureCap,
|
|
||||||
stableBorrowRateEnabled,
|
stableBorrowRateEnabled,
|
||||||
borrowingEnabled,
|
borrowingEnabled,
|
||||||
},
|
},
|
||||||
|
@ -336,7 +334,6 @@ export const configureReservesByHelper = async (
|
||||||
reserveFactor,
|
reserveFactor,
|
||||||
borrowCap,
|
borrowCap,
|
||||||
supplyCap,
|
supplyCap,
|
||||||
exposureCap,
|
|
||||||
stableBorrowingEnabled: stableBorrowRateEnabled,
|
stableBorrowingEnabled: stableBorrowRateEnabled,
|
||||||
borrowingEnabled: borrowingEnabled,
|
borrowingEnabled: borrowingEnabled,
|
||||||
});
|
});
|
||||||
|
|
|
@ -188,7 +188,6 @@ export enum ProtocolErrors {
|
||||||
RL_STABLE_DEBT_NOT_ZERO = '89',
|
RL_STABLE_DEBT_NOT_ZERO = '89',
|
||||||
RL_VARIABLE_DEBT_SUPPLY_NOT_ZERO = '90',
|
RL_VARIABLE_DEBT_SUPPLY_NOT_ZERO = '90',
|
||||||
LP_CALLER_NOT_EOA = '91',
|
LP_CALLER_NOT_EOA = '91',
|
||||||
RC_INVALID_EXPOSURE_CAP = '92',
|
|
||||||
VL_LTV_VALIDATION_FAILED = '93',
|
VL_LTV_VALIDATION_FAILED = '93',
|
||||||
VL_SAME_BLOCK_BORROW_REPAY = '94',
|
VL_SAME_BLOCK_BORROW_REPAY = '94',
|
||||||
LPC_FLASHLOAN_PREMIUMS_MISMATCH = '95',
|
LPC_FLASHLOAN_PREMIUMS_MISMATCH = '95',
|
||||||
|
@ -403,7 +402,6 @@ export interface IReserveCollateralParams {
|
||||||
baseLTVAsCollateral: string;
|
baseLTVAsCollateral: string;
|
||||||
liquidationThreshold: string;
|
liquidationThreshold: string;
|
||||||
liquidationBonus: string;
|
liquidationBonus: string;
|
||||||
exposureCap: string;
|
|
||||||
}
|
}
|
||||||
export interface IMarketRates {
|
export interface IMarketRates {
|
||||||
borrowRate: string;
|
borrowRate: string;
|
||||||
|
|
|
@ -24,7 +24,7 @@ export const strategyBUSD: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyDAI: IReserveParams = {
|
export const strategyDAI: IReserveParams = {
|
||||||
|
@ -39,7 +39,7 @@ export const strategyDAI: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategySUSD: IReserveParams = {
|
export const strategySUSD: IReserveParams = {
|
||||||
|
@ -54,7 +54,7 @@ export const strategySUSD: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyTUSD: IReserveParams = {
|
export const strategyTUSD: IReserveParams = {
|
||||||
|
@ -69,7 +69,7 @@ export const strategyTUSD: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUSDC: IReserveParams = {
|
export const strategyUSDC: IReserveParams = {
|
||||||
|
@ -84,7 +84,7 @@ export const strategyUSDC: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUSDT: IReserveParams = {
|
export const strategyUSDT: IReserveParams = {
|
||||||
|
@ -99,7 +99,7 @@ export const strategyUSDT: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyAAVE: IReserveParams = {
|
export const strategyAAVE: IReserveParams = {
|
||||||
|
@ -114,7 +114,7 @@ export const strategyAAVE: IReserveParams = {
|
||||||
reserveFactor: '0',
|
reserveFactor: '0',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyBAT: IReserveParams = {
|
export const strategyBAT: IReserveParams = {
|
||||||
|
@ -129,7 +129,7 @@ export const strategyBAT: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyENJ: IReserveParams = {
|
export const strategyENJ: IReserveParams = {
|
||||||
|
@ -144,7 +144,7 @@ export const strategyENJ: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyWETH: IReserveParams = {
|
export const strategyWETH: IReserveParams = {
|
||||||
|
@ -159,7 +159,7 @@ export const strategyWETH: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyKNC: IReserveParams = {
|
export const strategyKNC: IReserveParams = {
|
||||||
|
@ -174,7 +174,7 @@ export const strategyKNC: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyLINK: IReserveParams = {
|
export const strategyLINK: IReserveParams = {
|
||||||
|
@ -189,7 +189,7 @@ export const strategyLINK: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyMANA: IReserveParams = {
|
export const strategyMANA: IReserveParams = {
|
||||||
|
@ -204,7 +204,7 @@ export const strategyMANA: IReserveParams = {
|
||||||
reserveFactor: '3500',
|
reserveFactor: '3500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyMKR: IReserveParams = {
|
export const strategyMKR: IReserveParams = {
|
||||||
|
@ -219,7 +219,7 @@ export const strategyMKR: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyREN: IReserveParams = {
|
export const strategyREN: IReserveParams = {
|
||||||
|
@ -234,7 +234,7 @@ export const strategyREN: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategySNX: IReserveParams = {
|
export const strategySNX: IReserveParams = {
|
||||||
|
@ -249,7 +249,7 @@ export const strategySNX: IReserveParams = {
|
||||||
reserveFactor: '3500',
|
reserveFactor: '3500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Invalid borrow rates in params currently, replaced with snx params
|
// Invalid borrow rates in params currently, replaced with snx params
|
||||||
|
@ -265,7 +265,7 @@ export const strategyUNI: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyWBTC: IReserveParams = {
|
export const strategyWBTC: IReserveParams = {
|
||||||
|
@ -280,7 +280,7 @@ export const strategyWBTC: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyYFI: IReserveParams = {
|
export const strategyYFI: IReserveParams = {
|
||||||
|
@ -295,7 +295,7 @@ export const strategyYFI: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyZRX: IReserveParams = {
|
export const strategyZRX: IReserveParams = {
|
||||||
|
@ -310,7 +310,7 @@ export const strategyZRX: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyXSUSHI: IReserveParams = {
|
export const strategyXSUSHI: IReserveParams = {
|
||||||
|
@ -325,5 +325,5 @@ export const strategyXSUSHI: IReserveParams = {
|
||||||
reserveFactor: '3500',
|
reserveFactor: '3500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ export const strategyWETH: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyWBTC: IReserveParams = {
|
export const strategyWBTC: IReserveParams = {
|
||||||
|
@ -28,7 +28,7 @@ export const strategyWBTC: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyDAI: IReserveParams = {
|
export const strategyDAI: IReserveParams = {
|
||||||
|
@ -43,7 +43,7 @@ export const strategyDAI: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUSDC: IReserveParams = {
|
export const strategyUSDC: IReserveParams = {
|
||||||
|
@ -58,7 +58,7 @@ export const strategyUSDC: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUSDT: IReserveParams = {
|
export const strategyUSDT: IReserveParams = {
|
||||||
|
@ -73,7 +73,7 @@ export const strategyUSDT: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyDAIWETH: IReserveParams = {
|
export const strategyDAIWETH: IReserveParams = {
|
||||||
|
@ -88,7 +88,7 @@ export const strategyDAIWETH: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyWBTCWETH: IReserveParams = {
|
export const strategyWBTCWETH: IReserveParams = {
|
||||||
|
@ -103,7 +103,7 @@ export const strategyWBTCWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyAAVEWETH: IReserveParams = {
|
export const strategyAAVEWETH: IReserveParams = {
|
||||||
|
@ -118,7 +118,7 @@ export const strategyAAVEWETH: IReserveParams = {
|
||||||
reserveFactor: '500',
|
reserveFactor: '500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyBATWETH: IReserveParams = {
|
export const strategyBATWETH: IReserveParams = {
|
||||||
|
@ -133,7 +133,7 @@ export const strategyBATWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyDAIUSDC: IReserveParams = {
|
export const strategyDAIUSDC: IReserveParams = {
|
||||||
|
@ -148,7 +148,7 @@ export const strategyDAIUSDC: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyCRVWETH: IReserveParams = {
|
export const strategyCRVWETH: IReserveParams = {
|
||||||
|
@ -163,7 +163,7 @@ export const strategyCRVWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyLINKWETH: IReserveParams = {
|
export const strategyLINKWETH: IReserveParams = {
|
||||||
|
@ -178,7 +178,7 @@ export const strategyLINKWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyMKRWETH: IReserveParams = {
|
export const strategyMKRWETH: IReserveParams = {
|
||||||
|
@ -193,7 +193,7 @@ export const strategyMKRWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyRENWETH: IReserveParams = {
|
export const strategyRENWETH: IReserveParams = {
|
||||||
|
@ -208,7 +208,7 @@ export const strategyRENWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategySNXWETH: IReserveParams = {
|
export const strategySNXWETH: IReserveParams = {
|
||||||
|
@ -223,7 +223,7 @@ export const strategySNXWETH: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUNIWETH: IReserveParams = {
|
export const strategyUNIWETH: IReserveParams = {
|
||||||
|
@ -238,7 +238,7 @@ export const strategyUNIWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUSDCWETH: IReserveParams = {
|
export const strategyUSDCWETH: IReserveParams = {
|
||||||
|
@ -253,7 +253,7 @@ export const strategyUSDCWETH: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyWBTCUSDC: IReserveParams = {
|
export const strategyWBTCUSDC: IReserveParams = {
|
||||||
|
@ -268,7 +268,7 @@ export const strategyWBTCUSDC: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyYFIWETH: IReserveParams = {
|
export const strategyYFIWETH: IReserveParams = {
|
||||||
|
@ -283,7 +283,7 @@ export const strategyYFIWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyBALWETH: IReserveParams = {
|
export const strategyBALWETH: IReserveParams = {
|
||||||
|
@ -298,5 +298,5 @@ export const strategyBALWETH: IReserveParams = {
|
||||||
reserveFactor: '1500',
|
reserveFactor: '1500',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ export const strategyDAI: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUSDC: IReserveParams = {
|
export const strategyUSDC: IReserveParams = {
|
||||||
|
@ -37,7 +37,7 @@ export const strategyUSDC: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyUSDT: IReserveParams = {
|
export const strategyUSDT: IReserveParams = {
|
||||||
|
@ -52,7 +52,7 @@ export const strategyUSDT: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyWETH: IReserveParams = {
|
export const strategyWETH: IReserveParams = {
|
||||||
|
@ -67,7 +67,7 @@ export const strategyWETH: IReserveParams = {
|
||||||
reserveFactor: '1000',
|
reserveFactor: '1000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyWBTC: IReserveParams = {
|
export const strategyWBTC: IReserveParams = {
|
||||||
|
@ -82,7 +82,7 @@ export const strategyWBTC: IReserveParams = {
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const strategyMATIC: IReserveParams = {
|
export const strategyMATIC: IReserveParams = {
|
||||||
|
@ -96,7 +96,7 @@ export const strategyMATIC: IReserveParams = {
|
||||||
aTokenImpl: eContractid.AToken,
|
aTokenImpl: eContractid.AToken,
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
reserveFactor: '2000',
|
reserveFactor: '2000',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,6 +111,6 @@ export const strategyAAVE: IReserveParams = {
|
||||||
aTokenImpl: eContractid.AToken,
|
aTokenImpl: eContractid.AToken,
|
||||||
borrowCap: '0',
|
borrowCap: '0',
|
||||||
supplyCap: '0',
|
supplyCap: '0',
|
||||||
exposureCap: '0',
|
|
||||||
reserveFactor: '0',
|
reserveFactor: '0',
|
||||||
};
|
};
|
||||||
|
|
|
@ -677,7 +677,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
it('Deactivates the ETH reserve as collateral via pool admin', async () => {
|
it('Deactivates the ETH reserve as collateral via pool admin', async () => {
|
||||||
const { configurator, helpersContract, weth } = testEnv;
|
const { configurator, helpersContract, weth } = testEnv;
|
||||||
await configurator.configureReserveAsCollateral(weth.address, 0, 0, 0, 0);
|
await configurator.configureReserveAsCollateral(weth.address, 0, 0, 0);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
decimals,
|
decimals,
|
||||||
|
@ -711,7 +711,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
it('Activates the ETH reserve as collateral via pool admin', async () => {
|
it('Activates the ETH reserve as collateral via pool admin', async () => {
|
||||||
const { configurator, helpersContract, weth } = testEnv;
|
const { configurator, helpersContract, weth } = testEnv;
|
||||||
await configurator.configureReserveAsCollateral(weth.address, '8000', '8250', '10500', '0');
|
await configurator.configureReserveAsCollateral(weth.address, '8000', '8250', '10500');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
decimals,
|
decimals,
|
||||||
|
@ -747,7 +747,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
|
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
|
||||||
await configurator
|
await configurator
|
||||||
.connect(riskAdmin.signer)
|
.connect(riskAdmin.signer)
|
||||||
.configureReserveAsCollateral(weth.address, 0, 0, 0, 0);
|
.configureReserveAsCollateral(weth.address, 0, 0, 0);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
decimals,
|
decimals,
|
||||||
|
@ -783,7 +783,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
|
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
|
||||||
await configurator
|
await configurator
|
||||||
.connect(riskAdmin.signer)
|
.connect(riskAdmin.signer)
|
||||||
.configureReserveAsCollateral(weth.address, '8000', '8250', '10500', '0');
|
.configureReserveAsCollateral(weth.address, '8000', '8250', '10500');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
decimals,
|
decimals,
|
||||||
|
@ -820,7 +820,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
await expect(
|
await expect(
|
||||||
configurator
|
configurator
|
||||||
.connect(emergencyAdmin.signer)
|
.connect(emergencyAdmin.signer)
|
||||||
.configureReserveAsCollateral(weth.address, '7500', '8000', '10500', '0'),
|
.configureReserveAsCollateral(weth.address, '7500', '8000', '10500'),
|
||||||
CALLER_NOT_POOL_ADMIN
|
CALLER_NOT_POOL_ADMIN
|
||||||
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
|
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,32 +1,15 @@
|
||||||
import { TestEnv, makeSuite } from './helpers/make-suite';
|
import { TestEnv, makeSuite } from './helpers/make-suite';
|
||||||
import {
|
import {
|
||||||
APPROVAL_AMOUNT_LENDING_POOL,
|
|
||||||
MAX_UINT_AMOUNT,
|
MAX_UINT_AMOUNT,
|
||||||
RAY,
|
|
||||||
MAX_EXPOSURE_CAP,
|
|
||||||
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
|
||||||
oneEther,
|
|
||||||
} from '../../helpers/constants';
|
} from '../../helpers/constants';
|
||||||
import { ProtocolErrors } from '../../helpers/types';
|
import { ProtocolErrors } from '../../helpers/types';
|
||||||
import { MintableERC20, WETH9, WETH9Mocked } from '../../types';
|
|
||||||
import { parseEther } from '@ethersproject/units';
|
|
||||||
import { BigNumber } from '@ethersproject/bignumber';
|
|
||||||
import { strategyDAI } from '../../markets/amm/reservesConfigs';
|
|
||||||
import { strategyUSDC } from '../../markets/amm/reservesConfigs';
|
|
||||||
import { ethers } from 'ethers';
|
|
||||||
import { convertToCurrencyDecimals } from '../../helpers/contracts-helpers';
|
import { convertToCurrencyDecimals } from '../../helpers/contracts-helpers';
|
||||||
|
|
||||||
const { expect } = require('chai');
|
const { expect } = require('chai');
|
||||||
makeSuite('LTV validation tests', (testEnv: TestEnv) => {
|
makeSuite('LTV validation tests', (testEnv: TestEnv) => {
|
||||||
const {
|
const {
|
||||||
VL_LTV_VALIDATION_FAILED,
|
VL_LTV_VALIDATION_FAILED,
|
||||||
RC_INVALID_EXPOSURE_CAP,
|
|
||||||
VL_COLLATERAL_CANNOT_COVER_NEW_BORROW,
|
|
||||||
} = ProtocolErrors;
|
} = ProtocolErrors;
|
||||||
const daiPrice = Number(MOCK_CHAINLINK_AGGREGATORS_PRICES.DAI);
|
|
||||||
const usdcPrice = Number(MOCK_CHAINLINK_AGGREGATORS_PRICES.USDC);
|
|
||||||
const daiLTV = Number(strategyDAI.baseLTVAsCollateral);
|
|
||||||
const usdcLTV = Number(strategyUSDC.baseLTVAsCollateral);
|
|
||||||
|
|
||||||
it('User 1 deposits 10 Dai, 10 USDC, user 2 deposits 1 WETH', async () => {
|
it('User 1 deposits 10 Dai, 10 USDC, user 2 deposits 1 WETH', async () => {
|
||||||
const {
|
const {
|
||||||
|
@ -86,7 +69,7 @@ makeSuite('LTV validation tests', (testEnv: TestEnv) => {
|
||||||
const {
|
const {
|
||||||
pool,
|
pool,
|
||||||
usdc,
|
usdc,
|
||||||
users: [user1, , , receiver],
|
users: [user1],
|
||||||
} = testEnv;
|
} = testEnv;
|
||||||
|
|
||||||
const withdrawnAmount = await convertToCurrencyDecimals(usdc.address, "1");
|
const withdrawnAmount = await convertToCurrencyDecimals(usdc.address, "1");
|
||||||
|
@ -95,4 +78,25 @@ makeSuite('LTV validation tests', (testEnv: TestEnv) => {
|
||||||
pool.connect(user1.signer).withdraw(usdc.address, withdrawnAmount, user1.address)
|
pool.connect(user1.signer).withdraw(usdc.address, withdrawnAmount, user1.address)
|
||||||
).to.be.revertedWith(VL_LTV_VALIDATION_FAILED);
|
).to.be.revertedWith(VL_LTV_VALIDATION_FAILED);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Withdraws DAI', async () => {
|
||||||
|
const {
|
||||||
|
pool,
|
||||||
|
dai,
|
||||||
|
aDai,
|
||||||
|
users: [user1],
|
||||||
|
} = testEnv;
|
||||||
|
|
||||||
|
const aDaiBalanceBefore = await aDai.balanceOf(user1.address);
|
||||||
|
|
||||||
|
const withdrawnAmount = await convertToCurrencyDecimals(dai.address, "1");
|
||||||
|
|
||||||
|
await pool.connect(user1.signer).withdraw(dai.address, withdrawnAmount, user1.address);
|
||||||
|
|
||||||
|
const aDaiBalanceAfter = await aDai.balanceOf(user1.address);
|
||||||
|
|
||||||
|
expect(aDaiBalanceAfter.toString()).to.be.bignumber.equal(aDaiBalanceBefore.sub(withdrawnAmount));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user