diff --git a/markets/aave/index.ts b/markets/aave/index.ts index 11b401ef..eefcdd3b 100644 --- a/markets/aave/index.ts +++ b/markets/aave/index.ts @@ -3,14 +3,15 @@ import { IAaveConfiguration, EthereumNetwork, eEthereumNetwork } from '../../hel import { CommonsConfig } from './commons'; import { - stablecoinStrategyBUSD, - stablecoinStrategyDAI, - stablecoinStrategySUSD, - stablecoinStrategyTUSD, - stablecoinStrategyUSDC, - stablecoinStrategyUSDT, + strategyBUSD, + strategyDAI, + strategySUSD, + strategyTUSD, + strategyUSDC, + strategyUSDT, strategyAAVE, - strategyBase, + strategyBAT, + strategyZRX, strategyKNC, strategyLINK, strategyMANA, @@ -33,9 +34,9 @@ export const AaveConfig: IAaveConfiguration = { ProviderId: 1, ReservesConfig: { AAVE: strategyAAVE, - BAT: strategyBase, - BUSD: stablecoinStrategyBUSD, - DAI: stablecoinStrategyDAI, + BAT: strategyBAT, + BUSD: strategyBUSD, + DAI: strategyDAI, ENJ: strategyREN, KNC: strategyKNC, LINK: strategyLINK, @@ -43,15 +44,15 @@ export const AaveConfig: IAaveConfiguration = { MKR: strategyMKR, REN: strategyREN, SNX: strategySNX, - SUSD: stablecoinStrategySUSD, - TUSD: stablecoinStrategyTUSD, + SUSD: strategySUSD, + TUSD: strategyTUSD, UNI: strategyUNI, - USDC: stablecoinStrategyUSDC, - USDT: stablecoinStrategyUSDT, + USDC: strategyUSDC, + USDT: strategyUSDT, WBTC: strategyWBTC, WETH: strategyWETH, YFI: strategyYFI, - ZRX: strategyBase, + ZRX: strategyZRX, }, ReserveAssets: { [eEthereumNetwork.buidlerevm]: {}, diff --git a/markets/aave/reservesConfigs.ts b/markets/aave/reservesConfigs.ts index 5abf0a7a..68ec93d6 100644 --- a/markets/aave/reservesConfigs.ts +++ b/markets/aave/reservesConfigs.ts @@ -2,9 +2,213 @@ import BigNumber from 'bignumber.js'; import { oneRay } from '../../helpers/constants'; import { eContractid, IReserveParams } from '../../helpers/types'; -export const strategyBase: IReserveParams = { +export const strategyBUSD: IReserveParams = { optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), + stableRateSlope1: '0', + stableRateSlope2: '0', + baseLTVAsCollateral: '0', + liquidationThreshold: '0', + liquidationBonus: '0', + borrowingEnabled: true, + stableBorrowRateEnabled: false, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '1000' +}; + +export const strategyDAI: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(0.75).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.02).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(0.75).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '7500', + liquidationThreshold: '8000', + liquidationBonus: '10500', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '1000' +}; + +export const strategySUSD: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), + stableRateSlope1: '0', + stableRateSlope2: '0', + baseLTVAsCollateral: '0', + liquidationThreshold: '0', + liquidationBonus: '0', + borrowingEnabled: true, + stableBorrowRateEnabled: false, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '2000' +}; + +export const strategyTUSD: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(0.75).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.02).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(0.75).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '7500', + liquidationThreshold: '8000', + liquidationBonus: '10500', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '1000' +}; + +export const strategyUSDC: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.9).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(0.60).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.02).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(0.60).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '8000', + liquidationThreshold: '8500', + liquidationBonus: '10500', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '6', + aTokenImpl: eContractid.AToken, + reserveFactor: '1000' +}; + +export const strategyUSDT: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.9).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(0.60).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.02).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(0.60).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '8000', + liquidationThreshold: '8500', + liquidationBonus: '10500', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '6', + aTokenImpl: eContractid.AToken, + reserveFactor: '1000' +}; + +export const strategyAAVE: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: '0', + variableRateSlope1: '0', + variableRateSlope2: '0', + stableRateSlope1: '0', + stableRateSlope2: '0', + baseLTVAsCollateral: '5000', + liquidationThreshold: '6500', + liquidationBonus: '11000', + borrowingEnabled: false, + stableBorrowRateEnabled: false, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '0' +}; + +export const strategyBAT: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '7000', + liquidationThreshold: '7500', + liquidationBonus: '11000', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '2000' +}; + +export const strategyENJ: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '5500', + liquidationThreshold: '6000', + liquidationBonus: '11000', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '2000' +}; + +export const strategyWETH: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.65).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '8000', + liquidationThreshold: '8250', + liquidationBonus: '10500', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '1000' +}; + +export const strategyKNC: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.65).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '6000', + liquidationThreshold: '6500', + liquidationBonus: '11000', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '2000' +}; + +export const strategyLINK: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '7000', + liquidationThreshold: '7500', + liquidationBonus: '11000', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '2000' +}; + +export const strategyMANA: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), @@ -16,210 +220,124 @@ export const strategyBase: IReserveParams = { stableBorrowRateEnabled: true, reserveDecimals: '18', aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + reserveFactor: '3500' }; -export const stablecoinStrategyBase: IReserveParams = { - optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), - baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(), +export const strategyMKR: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(1.5).multipliedBy(oneRay).toFixed(), - stableRateSlope1: new BigNumber(0.06).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(1.5).multipliedBy(oneRay).toFixed(), - baseLTVAsCollateral: '7500', - liquidationThreshold: '8000', - liquidationBonus: '10500', + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '6000', + liquidationThreshold: '6500', + liquidationBonus: '11000', borrowingEnabled: true, stableBorrowRateEnabled: true, reserveDecimals: '18', aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + reserveFactor: '2000' }; -export const stablecoinStrategyCentralized: IReserveParams = { - optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), - baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(), +export const strategyREN: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), - stableRateSlope1: new BigNumber(0.06).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), - baseLTVAsCollateral: '7500', - liquidationThreshold: '8000', - liquidationBonus: '10500', + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '5500', + liquidationThreshold: '6000', + liquidationBonus: '11000', borrowingEnabled: true, stableBorrowRateEnabled: true, - reserveDecimals: '6', - aTokenImpl: eContractid.AToken, - reserveFactor: '1000' -}; - -export const strategyGovernanceTokens: IReserveParams = { - ...strategyBase, - baseLTVAsCollateral: '4000', - liquidationBonus: '11500', -}; - -export const stablecoinStrategyBUSD: IReserveParams = { - ...stablecoinStrategyCentralized, reserveDecimals: '18', - baseLTVAsCollateral: '-1', - liquidationThreshold: '0', - liquidationBonus: '0', - baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(), - variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(), + aTokenImpl: eContractid.AToken, + reserveFactor: '2000' +}; + +export const strategySNX: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: new BigNumber(0.03).multipliedBy(oneRay).toFixed(), + variableRateSlope1: new BigNumber(0.12).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), + stableRateSlope1: '0', + stableRateSlope2: '0', + baseLTVAsCollateral: '1500', + liquidationThreshold: '4000', + liquidationBonus: '11000', + borrowingEnabled: true, stableBorrowRateEnabled: false, - stableRateSlope1: new BigNumber(0.14).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '3500' }; -export const strategyAAVE: IReserveParams = { - ...strategyBase, - baseLTVAsCollateral: '5000', +export const strategyUNI: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: '0', + variableRateSlope1: '0', + variableRateSlope2: '0', + stableRateSlope1: '0', + stableRateSlope2: '0', + baseLTVAsCollateral: '6000', liquidationThreshold: '6500', liquidationBonus: '11000', borrowingEnabled: false, stableBorrowRateEnabled: false, reserveDecimals: '18', -}; - -export const stablecoinStrategyDAI: IReserveParams = { - ...stablecoinStrategyBase, -}; - -export const strategyENJ: IReserveParams = { - ...strategyBase, - baseLTVAsCollateral: '5500', - stableBorrowRateEnabled: false, -}; - -export const strategyKNC: IReserveParams = { - ...strategyBase, - variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(), -}; - -export const strategyLINK: IReserveParams = { - ...strategyBase, - baseLTVAsCollateral: '6500', - liquidationThreshold: '7000', -}; - -export const strategyMANA: IReserveParams = { - ...strategyBase, - variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), -}; - -export const strategyMKR: IReserveParams = { - ...strategyBase, - baseLTVAsCollateral: '3500', -}; - -export const strategyREN: IReserveParams = { - ...strategyBase, - baseLTVAsCollateral: '5000', - liquidationThreshold: '6500', - liquidationBonus: '11000', - borrowingEnabled: true, - stableBorrowRateEnabled: false, -}; - -export const stablecoinStrategySUSD: IReserveParams = { - optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), - baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(), - variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), - stableRateSlope1: new BigNumber(0.14).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), - baseLTVAsCollateral: '-1', - liquidationThreshold: '0', - liquidationBonus: '0', - borrowingEnabled: true, - stableBorrowRateEnabled: false, - reserveDecimals: '18', - aTokenImpl: eContractid.AToken, - reserveFactor: '1000' -}; - -export const strategySNX: IReserveParams = { - ...strategyBase, - baseLTVAsCollateral: '1500', - liquidationThreshold: '4000', - baseVariableBorrowRate: new BigNumber(0.03).multipliedBy(oneRay).toFixed(), - variableRateSlope1: new BigNumber(0.12).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), - stableBorrowRateEnabled: false, -}; - -export const stablecoinStrategyTUSD: IReserveParams = { - ...stablecoinStrategyCentralized, - baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(), - variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(1.5).multipliedBy(oneRay).toFixed(), - stableRateSlope1: new BigNumber(0.14).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), - borrowingEnabled: true, - stableBorrowRateEnabled: false, - reserveDecimals: '18', -}; - -export const strategyUNI: IReserveParams = { - ...strategyGovernanceTokens, - stableBorrowRateEnabled: false, aTokenImpl: eContractid.DelegationAwareAToken, -}; - -export const stablecoinStrategyUSDC: IReserveParams = { - ...stablecoinStrategyBase, - variableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), - reserveDecimals: '6', -}; - -export const stablecoinStrategyUSDT: IReserveParams = { - ...stablecoinStrategyBase, - baseLTVAsCollateral: '-1', - liquidationThreshold: '7000', - liquidationBonus: '0', - borrowingEnabled: true, - stableBorrowRateEnabled: true, - reserveDecimals: '6', + reserveFactor: '2000' }; export const strategyWBTC: IReserveParams = { - optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), - baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), + optimalUtilizationRate: new BigNumber(0.65).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: '0', variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(), - baseLTVAsCollateral: '6000', - liquidationThreshold: '6500', - liquidationBonus: '11500', + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '7000', + liquidationThreshold: '7500', + liquidationBonus: '11000', borrowingEnabled: true, stableBorrowRateEnabled: true, reserveDecimals: '8', aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + reserveFactor: '2000' }; -export const strategyWETH: IReserveParams = { - optimalUtilizationRate: new BigNumber(0.8).multipliedBy(oneRay).toFixed(), - baseVariableBorrowRate: new BigNumber(0).multipliedBy(oneRay).toFixed(), - variableRateSlope1: new BigNumber(0.08).multipliedBy(oneRay).toFixed(), - variableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), +export const strategyYFI: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: '0', + variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), - stableRateSlope2: new BigNumber(1).multipliedBy(oneRay).toFixed(), - baseLTVAsCollateral: '7500', - liquidationThreshold: '8000', - liquidationBonus: '10500', + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '4000', + liquidationThreshold: '5500', + liquidationBonus: '11500', borrowingEnabled: true, stableBorrowRateEnabled: true, reserveDecimals: '18', aTokenImpl: eContractid.AToken, - reserveFactor: '1000' + reserveFactor: '2000' }; -export const strategyYFI: IReserveParams = { - ...strategyGovernanceTokens, -}; +export const strategyZRX: IReserveParams = { + optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(), + baseVariableBorrowRate: '0', + variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), + variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(), + stableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), + baseLTVAsCollateral: '6000', + liquidationThreshold: '6500', + liquidationBonus: '11000', + borrowingEnabled: true, + stableBorrowRateEnabled: true, + reserveDecimals: '18', + aTokenImpl: eContractid.AToken, + reserveFactor: '2000' +}; \ No newline at end of file diff --git a/test/configurator.spec.ts b/test/configurator.spec.ts index 6a5dd66f..e92b70bd 100644 --- a/test/configurator.spec.ts +++ b/test/configurator.spec.ts @@ -2,6 +2,7 @@ import {TestEnv, makeSuite} from './helpers/make-suite'; import {APPROVAL_AMOUNT_LENDING_POOL, RAY} from '../helpers/constants'; import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; import {ProtocolErrors} from '../helpers/types'; +import { strategyWETH } from '../markets/aave/reservesConfigs'; const {expect} = require('chai'); @@ -58,7 +59,10 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { }); it('Freezes the ETH reserve', async () => { - const {configurator, pool, weth, helpersContract} = testEnv; + const {configurator, weth, helpersContract} = testEnv; + + + await configurator.freezeReserve(weth.address); const { decimals, @@ -75,12 +79,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(true); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(true); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); - expect(stableBorrowRateEnabled).to.be.equal(true); - expect(reserveFactor).to.be.equal(1000); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); + expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); }); it('Unfreezes the ETH reserve', async () => { @@ -102,12 +106,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(true); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(false); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); - expect(stableBorrowRateEnabled).to.be.equal(true); - expect(reserveFactor).to.be.equal(1000); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); + expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); }); it('Check the onlyAaveAdmin on freezeReserve ', async () => { @@ -144,12 +148,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(false); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(false); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); - expect(stableBorrowRateEnabled).to.be.equal(true); - expect(reserveFactor).to.be.equal(1000); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); + expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); }); it('Activates the ETH reserve for borrowing', async () => { @@ -172,12 +176,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(true); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(false); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); - expect(stableBorrowRateEnabled).to.be.equal(true); - expect(reserveFactor).to.be.equal(1000); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); + expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); expect(variableBorrowIndex.toString()).to.be.equal(RAY); }); @@ -222,12 +226,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(liquidationThreshold).to.be.equal(0); expect(liquidationBonus).to.be.equal(0); expect(stableBorrowRateEnabled).to.be.equal(true); - expect(reserveFactor).to.be.equal(1000); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); }); it('Activates the ETH reserve as collateral', async () => { const {configurator, helpersContract, weth} = testEnv; - await configurator.configureReserveAsCollateral(weth.address, '7500', '8000', '10500'); + await configurator.configureReserveAsCollateral(weth.address, '8000', '8250', '10500'); const { decimals, @@ -244,12 +248,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(true); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(false); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); - expect(stableBorrowRateEnabled).to.be.equal(true); - expect(reserveFactor).to.be.equal(1000); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); + expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); }); it('Check the onlyAaveAdmin on configureReserveAsCollateral ', async () => { @@ -280,12 +284,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(true); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(false); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); expect(stableBorrowRateEnabled).to.be.equal(false); - expect(reserveFactor).to.be.equal(1000); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); }); it('Enables stable borrow rate on the ETH reserve', async () => { @@ -306,12 +310,12 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(true); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(false); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); expect(stableBorrowRateEnabled).to.be.equal(true); - expect(reserveFactor).to.be.equal(1000); + expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor); }); it('Check the onlyAaveAdmin on disableReserveStableRate', async () => { @@ -348,11 +352,11 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(borrowingEnabled).to.be.equal(true); expect(isActive).to.be.equal(true); expect(isFrozen).to.be.equal(false); - expect(decimals).to.be.equal(18); - expect(ltv).to.be.equal(7500); - expect(liquidationThreshold).to.be.equal(8000); - expect(liquidationBonus).to.be.equal(10500); - expect(stableBorrowRateEnabled).to.be.equal(true); + expect(decimals).to.be.equal(strategyWETH.reserveDecimals); + expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral); + expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold); + expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus); + expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled); expect(reserveFactor).to.be.equal(1000); }); diff --git a/test/helpers/utils/calculations.ts b/test/helpers/utils/calculations.ts index db923176..512741dd 100644 --- a/test/helpers/utils/calculations.ts +++ b/test/helpers/utils/calculations.ts @@ -3,8 +3,6 @@ import { ONE_YEAR, RAY, MAX_UINT_AMOUNT, - OPTIMAL_UTILIZATION_RATE, - EXCESS_UTILIZATION_RATE, PERCENTAGE_FACTOR, } from '../../../helpers/constants'; import { @@ -1210,6 +1208,7 @@ export const calcExpectedInterestRates = ( ): BigNumber[] => { const { reservesParams } = configuration; + const reserveIndex = Object.keys(reservesParams).findIndex((value) => value === reserveSymbol); const [, reserveConfiguration] = (Object.entries(reservesParams) as [string, IReserveParams][])[ reserveIndex @@ -1218,10 +1217,12 @@ export const calcExpectedInterestRates = ( let stableBorrowRate: BigNumber = marketStableRate; let variableBorrowRate: BigNumber = new BigNumber(reserveConfiguration.baseVariableBorrowRate); - if (utilizationRate.gt(OPTIMAL_UTILIZATION_RATE)) { + const optimalRate = new BigNumber(reserveConfiguration.optimalUtilizationRate); + const excessRate = new BigNumber(RAY).minus(optimalRate); + if (utilizationRate.gt(optimalRate)) { const excessUtilizationRateRatio = utilizationRate - .minus(OPTIMAL_UTILIZATION_RATE) - .rayDiv(EXCESS_UTILIZATION_RATE); + .minus(reserveConfiguration.optimalUtilizationRate) + .rayDiv(excessRate); stableBorrowRate = stableBorrowRate .plus(reserveConfiguration.stableRateSlope1) @@ -1237,13 +1238,13 @@ export const calcExpectedInterestRates = ( } else { stableBorrowRate = stableBorrowRate.plus( new BigNumber(reserveConfiguration.stableRateSlope1).rayMul( - utilizationRate.rayDiv(new BigNumber(OPTIMAL_UTILIZATION_RATE)) + utilizationRate.rayDiv(new BigNumber(optimalRate)) ) ); variableBorrowRate = variableBorrowRate.plus( utilizationRate - .rayDiv(OPTIMAL_UTILIZATION_RATE) + .rayDiv(optimalRate) .rayMul(new BigNumber(reserveConfiguration.variableRateSlope1)) ); } diff --git a/test/liquidation-atoken.spec.ts b/test/liquidation-atoken.spec.ts index 8b94dabb..6483162c 100644 --- a/test/liquidation-atoken.spec.ts +++ b/test/liquidation-atoken.spec.ts @@ -20,7 +20,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => LP_IS_PAUSED, } = ProtocolErrors; - it('LIQUIDATION - Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => { + it('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]; @@ -69,7 +69,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => const userGlobalDataAfter = await pool.getUserAccountData(borrower.address); expect(userGlobalDataAfter.currentLiquidationThreshold.toString()).to.be.bignumber.equal( - '8000', + '8250', 'Invalid liquidation threshold' ); @@ -79,7 +79,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => ).to.be.revertedWith(LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD); }); - it('LIQUIDATION - Drop the health factor below 1', async () => { + it('Drop the health factor below 1', async () => { const { dai, users, pool, oracle } = testEnv; const borrower = users[1]; @@ -98,7 +98,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => ); }); - it('LIQUIDATION - Tries to liquidate a different currency than the loan principal', async () => { + it('Tries to liquidate a different currency than the loan principal', async () => { const { pool, users, weth } = testEnv; const borrower = users[1]; //user 2 tries to borrow @@ -107,7 +107,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => ).revertedWith(LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER); }); - it('LIQUIDATION - Tries to liquidate a different collateral than the borrower collateral', async () => { + it('Tries to liquidate a different collateral than the borrower collateral', async () => { const { pool, dai, users } = testEnv; const borrower = users[1]; @@ -116,7 +116,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => ).revertedWith(LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED); }); - it('LIQUIDATION - Liquidates the borrow', async () => { + it('Liquidates the borrow', async () => { const { pool, dai, weth, aWETH, aDai, users, oracle, helpersContract, deployer } = testEnv; const borrower = users[1]; @@ -284,7 +284,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => await oracle.setAssetPrice( usdc.address, - new BigNumber(usdcPrice.toString()).multipliedBy(1.2).toFixed(0) + new BigNumber(usdcPrice.toString()).multipliedBy(1.12).toFixed(0) ); //mints dai to the liquidator diff --git a/test/liquidation-underlying.spec.ts b/test/liquidation-underlying.spec.ts index 553a574a..3d28eaa1 100644 --- a/test/liquidation-underlying.spec.ts +++ b/test/liquidation-underlying.spec.ts @@ -46,7 +46,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', await configurator.activateReserve(dai.address); }); - it('LIQUIDATION - Deposits WETH, borrows DAI', async () => { + it('Deposits WETH, borrows DAI', async () => { const {dai, weth, users, pool, oracle} = testEnv; const depositor = users[0]; const borrower = users[1]; @@ -96,12 +96,12 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', const userGlobalDataAfter = await pool.getUserAccountData(borrower.address); expect(userGlobalDataAfter.currentLiquidationThreshold.toString()).to.be.bignumber.equal( - '8000', + '8250', INVALID_HF ); }); - it('LIQUIDATION - Drop the health factor below 1', async () => { + it('Drop the health factor below 1', async () => { const {dai, weth, users, pool, oracle} = testEnv; const borrower = users[1]; @@ -109,7 +109,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', await oracle.setAssetPrice( dai.address, - new BigNumber(daiPrice.toString()).multipliedBy(1.25).toFixed(0) + new BigNumber(daiPrice.toString()).multipliedBy(1.18).toFixed(0) ); const userGlobalData = await pool.getUserAccountData(borrower.address); @@ -120,7 +120,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', ); }); - it('LIQUIDATION - Liquidates the borrow', async () => { + it('Liquidates the borrow', async () => { const {dai, weth, users, pool, oracle, helpersContract} = testEnv; const liquidator = users[3]; const borrower = users[1]; @@ -280,7 +280,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', //drops HF below 1 await oracle.setAssetPrice( usdc.address, - new BigNumber(usdcPrice.toString()).multipliedBy(1.2).toFixed(0) + new BigNumber(usdcPrice.toString()).multipliedBy(1.12).toFixed(0) ); //mints dai to the liquidator @@ -402,7 +402,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', //drops HF below 1 await oracle.setAssetPrice( usdc.address, - new BigNumber(usdcPrice.toString()).multipliedBy(1.12).toFixed(0) + new BigNumber(usdcPrice.toString()).multipliedBy(1.14).toFixed(0) ); //mints usdc to the liquidator