Prepared XDAI configs, updated matic with new LendingPool and LendingPoolConfigurator

This commit is contained in:
Hadrien Charlanes 2021-02-23 09:26:48 +01:00
parent 599c2759f1
commit 029a349d90
9 changed files with 359 additions and 0 deletions

View File

@ -66,5 +66,6 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
UniYFIWETH: oneEther.multipliedBy('22.407436').toFixed(),
BptWBTCWETH: oneEther.multipliedBy('22.407436').toFixed(),
WMATIC: oneEther.multipliedBy('0.003620948469').toFixed(),
STAKE: oneEther.multipliedBy('0.003620948469').toFixed(),
USD: '5848466240000000',
};

View File

@ -239,6 +239,7 @@ export interface iAssetBase<T> {
UniYFIWETH: T;
BptWBTCWETH: T;
WMATIC: T;
STAKE: T;
}
export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>;
@ -298,6 +299,11 @@ export type iMaticPoolAssets<T> = Pick<
'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'WMATIC'
>;
export type iXDAIPoolAssets<T> = Pick<
iAssetsWithoutUSD<T>,
'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'STAKE'
>;
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;
export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>;
@ -347,6 +353,7 @@ export enum TokenContractId {
UniYFIWETH = 'UniYFIWETH',
BptWBTCWETH = 'BptWBTCWETH',
WMATIC = 'WMATIC',
STAKE = 'STAKE',
}
export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {
@ -496,6 +503,10 @@ export interface IMaticConfiguration extends ICommonConfiguration {
ReservesConfig: iMaticPoolAssets<IReserveParams>;
}
export interface IXDAIConfiguration extends ICommonConfiguration {
ReservesConfig: iXDAIPoolAssets<IReserveParams>;
}
export interface ITokenAddress {
[token: string]: tEthereumAddress;
}

View File

@ -66,6 +66,14 @@ export const CommonsConfig: ICommonConfiguration = {
[ePolygonNetwork.mumbai]: undefined,
[ePolygonNetwork.matic]: undefined,
},
LendingPool: {
[ePolygonNetwork.mumbai]: '',
[ePolygonNetwork.matic]: '0x15Ec48a46d2D26cf4ADf5A39123E4c75e6887fE0',
},
LendingPoolConfigurator: {
[ePolygonNetwork.mumbai]: '',
[ePolygonNetwork.matic]: '0x268F48E09c72f6008DA50D6465a174C10167918e',
},
EmergencyAdminIndex: 1,
ProviderRegistry: {
[ePolygonNetwork.mumbai]: '0x569859d41499B4dDC28bfaA43915051FF0A38a6F', // TEMP

View File

@ -0,0 +1,120 @@
import BigNumber from 'bignumber.js';
import { oneEther, oneRay, RAY, ZERO_ADDRESS, MOCK_CHAINLINK_AGGREGATORS_PRICES } from '../../helpers/constants';
import { ICommonConfiguration, eXDaiNetwork } from '../../helpers/types';
// ----------------
// PROTOCOL GLOBAL PARAMS
// ----------------
export const CommonsConfig: ICommonConfiguration = {
MarketId: 'Commons',
ATokenNamePrefix: 'Aave XDAI Market',
StableDebtTokenNamePrefix: 'Aave XDAI Market stable debt',
VariableDebtTokenNamePrefix: 'Aave XDAI Market variable debt',
SymbolPrefix: 'm',
ProviderId: 0, // Overriden in index.ts
ProtocolGlobalParams: {
TokenDistributorPercentageBase: '10000',
MockUsdPriceInWei: '5848466240000000',
UsdAddress: '0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96',
NilAddress: '0x0000000000000000000000000000000000000000',
OneAddress: '0x0000000000000000000000000000000000000001',
AaveReferral: '0',
},
// ----------------
// COMMON PROTOCOL PARAMS ACROSS POOLS AND NETWORKS
// ----------------
Mocks: {
AllAssetsInitialPrices: {
...MOCK_CHAINLINK_AGGREGATORS_PRICES,
},
},
// TODO: reorg alphabetically, checking the reason of tests failing
LendingRateOracleRatesCommon: {
WETH: {
borrowRate: oneRay.multipliedBy(0.03).toFixed(),
},
DAI: {
borrowRate: oneRay.multipliedBy(0.039).toFixed(),
},
USDC: {
borrowRate: oneRay.multipliedBy(0.039).toFixed(),
},
USDT: {
borrowRate: oneRay.multipliedBy(0.035).toFixed(),
},
WBTC: {
borrowRate: oneRay.multipliedBy(0.03).toFixed(),
},
STAKE: {
borrowRate: oneRay.multipliedBy(0.05).toFixed(), // TEMP
},
},
// ----------------
// COMMON PROTOCOL ADDRESSES ACROSS POOLS
// ----------------
// If PoolAdmin/emergencyAdmin is set, will take priority over PoolAdminIndex/emergencyAdminIndex
PoolAdmin: {
[eXDaiNetwork.xdai]: undefined,
},
PoolAdminIndex: 0,
EmergencyAdmin: {
[eXDaiNetwork.xdai]: undefined,
},
EmergencyAdminIndex: 1,
ProviderRegistry: {
[eXDaiNetwork.xdai]: '',
},
ProviderRegistryOwner: {
[eXDaiNetwork.xdai]: '',
},
LendingPoolConfigurator: {
[eXDaiNetwork.xdai]: '0',
},
LendingPool: {
[eXDaiNetwork.xdai]: '0',
},
LendingRateOracle: {
[eXDaiNetwork.xdai]: '',
},
LendingPoolCollateralManager: {
[eXDaiNetwork.xdai]: '',
},
TokenDistributor: {
[eXDaiNetwork.xdai]: '',
},
WethGateway: {
[eXDaiNetwork.xdai]: '',
},
AaveOracle: {
[eXDaiNetwork.xdai]: '',
},
FallbackOracle: {
[eXDaiNetwork.xdai]: ZERO_ADDRESS,
},
ChainlinkAggregator: {
[eXDaiNetwork.xdai]: {
DAI: ZERO_ADDRESS,
USDC: ZERO_ADDRESS,
USDT: ZERO_ADDRESS,
WBTC: ZERO_ADDRESS,
STAKE: ZERO_ADDRESS,
},
},
ReserveAssets: {
[eXDaiNetwork.xdai]: {},
},
ReservesConfig: {},
ATokenDomainSeparator: {
[eXDaiNetwork.xdai]: '',
},
WETH: {
[eXDaiNetwork.xdai]: '', // DAI: xDAI is the base token, DAI is also there, We need WXDAI
},
ReserveFactorTreasuryAddress: {
[eXDaiNetwork.xdai]: '', // TEMP
},
};

View File

@ -1 +1,42 @@
import { oneRay, ZERO_ADDRESS } from '../../helpers/constants';
import { IXDAIConfiguration, eXDaiNetwork } from '../../helpers/types';
import { CommonsConfig } from './commons';
import {
strategyDAI,
strategyUSDC,
strategyUSDT,
strategyWBTC,
strategyWETH,
strategySTAKE,
} from './reservesConfigs';
// ----------------
// POOL--SPECIFIC PARAMS
// ----------------
export const XDAIConfig: IXDAIConfiguration = {
...CommonsConfig,
MarketId: 'XDAI Market',
ProviderId: 4, // Unknown?
ReservesConfig: {
DAI: strategyDAI,
USDC: strategyUSDC,
USDT: strategyUSDT,
WBTC: strategyWBTC,
WETH: strategyWETH,
STAKE: strategySTAKE,
},
ReserveAssets: {
[eXDaiNetwork.xdai]: {
DAI: '0x44fA8E6f47987339850636F88629646662444217',
USDC: '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83',
USDT: '0x4ECaBa5870353805a9F068101A40E0f32ed605C6',
WBTC: '0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252',
WETH: '0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1',
STAKE: '0xb7D311E2Eb55F2f68a9440da38e7989210b9A05e'
},
},
};
export default XDAIConfig;

View File

@ -0,0 +1,91 @@
import BigNumber from 'bignumber.js';
import { oneRay } from '../../helpers/constants';
import { IInterestRateStrategyParams } from '../../helpers/types';
// BUSD SUSD
export const rateStrategyStableOne: IInterestRateStrategyParams = {
name: "rateStrategyStableOne",
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',
};
// DAI TUSD
export const rateStrategyStableTwo: IInterestRateStrategyParams = {
name: "rateStrategyStableTwo",
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(),
}
// USDC USDT
export const rateStrategyStableThree: IInterestRateStrategyParams = {
name: "rateStrategyStableThree",
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(),
}
// WETH
export const rateStrategyWETH: IInterestRateStrategyParams = {
name: "rateStrategyWETH",
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(),
}
// AAVE
export const rateStrategyAAVE: IInterestRateStrategyParams = {
name: "rateStrategyAAVE",
optimalUtilizationRate: new BigNumber(0.45).multipliedBy(oneRay).toFixed(),
baseVariableBorrowRate: '0',
variableRateSlope1: '0',
variableRateSlope2: '0',
stableRateSlope1: '0',
stableRateSlope2: '0',
}
// BAT ENJ LINK MANA MKR REN YFI ZRX
export const rateStrategyVolatileOne: IInterestRateStrategyParams = {
name: "rateStrategyVolatileOne",
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(),
}
// KNC WBTC
export const rateStrategyVolatileTwo: IInterestRateStrategyParams = {
name: "rateStrategyVolatileTwo",
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(),
}
// SNX
export const rateStrategyVolatileThree: IInterestRateStrategyParams = {
name: "rateStrategyVolatileThree",
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(),
}

View File

@ -0,0 +1,85 @@
// import BigNumber from 'bignumber.js';
// import { oneRay } from '../../helpers/constants';
import { eContractid, IReserveParams } from '../../helpers/types';
import {
rateStrategyStableOne,
rateStrategyStableTwo,
rateStrategyStableThree,
rateStrategyWETH,
rateStrategyAAVE,
rateStrategyVolatileOne,
rateStrategyVolatileTwo,
rateStrategyVolatileThree,
} from './rateStrategies';
export const strategyDAI: IReserveParams = {
strategy: rateStrategyStableTwo,
baseLTVAsCollateral: '7500',
liquidationThreshold: '8000',
liquidationBonus: '10500',
borrowingEnabled: true,
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
};
export const strategyUSDC: IReserveParams = {
strategy: rateStrategyStableThree,
baseLTVAsCollateral: '8000',
liquidationThreshold: '8500',
liquidationBonus: '10500',
borrowingEnabled: true,
stableBorrowRateEnabled: true,
reserveDecimals: '6',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
};
export const strategyUSDT: IReserveParams = {
strategy: rateStrategyStableThree,
baseLTVAsCollateral: '8000',
liquidationThreshold: '8500',
liquidationBonus: '10500',
borrowingEnabled: true,
stableBorrowRateEnabled: true,
reserveDecimals: '6',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
};
export const strategyWETH: IReserveParams = {
strategy: rateStrategyWETH,
baseLTVAsCollateral: '8000',
liquidationThreshold: '8250',
liquidationBonus: '10500',
borrowingEnabled: true,
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '1000'
};
export const strategyWBTC: IReserveParams = {
strategy: rateStrategyVolatileTwo,
baseLTVAsCollateral: '7000',
liquidationThreshold: '7500',
liquidationBonus: '11000',
borrowingEnabled: true,
stableBorrowRateEnabled: true,
reserveDecimals: '8',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
};
export const strategySTAKE: IReserveParams = {
strategy: rateStrategyVolatileOne, //Temp?
baseLTVAsCollateral: '5000',
liquidationThreshold: '6500',
liquidationBonus: '11000',
borrowingEnabled: true,
stableBorrowRateEnabled: true,
reserveDecimals: '18',
aTokenImpl: eContractid.AToken,
reserveFactor: '2000'
};

View File

@ -189,6 +189,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
BptWBTCWETH: mockTokens.BptWBTCWETH.address,
WMATIC: mockTokens.WMATIC.address,
USD: USD_ADDRESS,
STAKE: mockTokens.STAKE.address,
},
fallbackOracle
);

View File

@ -188,6 +188,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
BptWBTCWETH: mockTokens.BptWBTCWETH.address,
WMATIC: mockTokens.WMATIC.address,
USD: USD_ADDRESS,
STAKE: mockTokens.STAKE.address,
},
fallbackOracle
);