Added migration scripts for Uniswap and Aave with configuration and common tasks

This commit is contained in:
David Racero 2020-08-31 12:10:40 +02:00
parent b3896fa4e3
commit 84d1ed0cb7
23 changed files with 390 additions and 254 deletions

View File

@ -1,4 +1,4 @@
FROM ethereum/solc:0.6.8 as build-deps
FROM node:13
FROM node:14
COPY --from=build-deps /usr/bin/solc /usr/bin/solc

View File

@ -28,7 +28,7 @@ const MNEMONICS: {[network: string]: string} = {
// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
['misc', 'migrations', 'dev-deployment'].forEach((folder) => {
['misc', 'migrations', 'dev', 'full'].forEach((folder) => {
const tasksPath = path.join(__dirname, 'tasks', folder);
fs.readdirSync(tasksPath)
.filter((pth) => pth.includes('.ts'))

View File

@ -1,6 +1,6 @@
import BigNumber from 'bignumber.js';
import {oneRay} from '../helpers/constants';
import {IAaveConfiguration} from '../helpers/types';
import {IAaveConfiguration, EthereumNetwork} from '../helpers/types';
import {CommonsConfig} from './commons';
@ -13,7 +13,7 @@ export const AaveConfig: IAaveConfiguration = {
ConfigName: 'Aave',
ProviderId: 1,
ReserveSymbols: [
'ETH',
'WETH',
'DAI',
'LEND',
'TUSD',
@ -254,6 +254,65 @@ export const AaveConfig: IAaveConfiguration = {
reserveDecimals: '18',
},
},
ReserveAssets: {
[EthereumNetwork.kovan]: {
WETH: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
DAI: '0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD',
TUSD: '0x016750AC630F711882812f24Dba6c95b9D35856d',
USDC: '0xe22da380ee6B445bb8273C81944ADEB6E8450422',
USDT: '0x13512979ADE267AB5100878E2e0f485B568328a4',
SUSD: '0xD868790F57B39C9B2B51b12de046975f986675f9',
LEND: '0x690eAcA024935Aaff9B14b9FF9e9C8757a281f3C',
BAT: '0x2d12186Fbb9f9a8C28B3FfdD4c42920f8539D738',
REP: '0x260071C8D61DAf730758f8BD0d6370353956AE0E',
MKR: '0x61e4CAE3DA7FD189e52a4879C7B8067D7C2Cc0FA',
LINK: '0xAD5ce863aE3E4E9394Ab43d4ba0D80f419F61789',
KNC: '0x3F80c39c0b96A0945f9F0E9f55d8A8891c5671A8',
WBTC: '0x3b92f58feD223E2cB1bCe4c286BD97e42f2A12EA',
MANA: '0x738Dc6380157429e957d223e6333Dc385c85Fec7',
ZRX: '0xD0d76886cF8D952ca26177EB7CfDf83bad08C00C',
SNX: '0x7FDb81B0b8a010dd4FFc57C3fecbf145BA8Bd947',
BUSD: '0x4c6E1EFC12FDfD568186b7BAEc0A43fFfb4bCcCf',
},
[EthereumNetwork.ropsten]: {
WETH: '0xc778417e063141139fce010982780140aa0cd5ab',
DAI: '0xf80A32A835F79D7787E8a8ee5721D0fEaFd78108',
TUSD: '0xa2EA00Df6d8594DBc76b79beFe22db9043b8896F',
USDC: '0x851dEf71f0e6A903375C1e536Bd9ff1684BAD802',
USDT: '0xB404c51BBC10dcBE948077F18a4B8E553D160084',
SUSD: '0xc374eB17f665914c714Ac4cdC8AF3a3474228cc5',
LEND: '0xB47F338EC1e3857BB188E63569aeBAB036EE67c6',
BAT: '0x85B24b3517E3aC7bf72a14516160541A60cFF19d',
REP: '0xBeb13523503d35F9b3708ca577CdCCAdbFB236bD',
MKR: '0x2eA9df3bABe04451c9C3B06a2c844587c59d9C37',
LINK: '0x1a906E71FF9e28d8E01460639EB8CF0a6f0e2486',
KNC: '0xCe4aA1dE3091033Ba74FA2Ad951f6adc5E5cF361',
WBTC: '0xa0E54Ab6AA5f0bf1D62EC3526436F3c05b3348A0',
MANA: '0x78b1F763857C8645E46eAdD9540882905ff32Db7',
ZRX: '0x02d7055704EfF050323A2E5ee4ba05DB2A588959',
SNX: '0xF80Aa7e2Fda4DA065C55B8061767F729dA1476c7',
BUSD: '0xFA6adcFf6A90c11f31Bc9bb59eC0a6efB38381C6',
},
[EthereumNetwork.main]: {
WETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
DAI: '0x6b175474e89094c44da98b954eedeac495271d0f',
TUSD: '0x0000000000085d4780B73119b644AE5ecd22b376',
USDC: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
USDT: '0xdac17f958d2ee523a2206206994597c13d831ec7',
SUSD: '0x57ab1ec28d129707052df4df418d58a2d46d5f51',
LEND: '0x80fB784B7eD66730e8b1DBd9820aFD29931aab03',
BAT: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
REP: '0x1985365e9f78359a9B6AD760e32412f4a445E862',
MKR: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
LINK: '0x514910771af9ca656af840dff83e8264ecf986ca',
KNC: '0xdd974d5c2e2928dea5f71b9825b8b646686bd200',
WBTC: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
MANA: '0x0f5d2fb29fb7d3cfee444a200298f468908cc942',
ZRX: '0xe41d2489571d322189246dafa5ebde1f4699f498',
SNX: '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F',
BUSD: '0x4Fabb145d64652a948d72533023f6E7A623C7C53',
},
},
};
export default AaveConfig;

View File

@ -126,9 +126,9 @@ export const CommonsConfig: ICommonConfiguration = {
},
LendingPoolManagerAddressIndex: 0,
ProviderRegistry: {
[EthereumNetwork.kovan]: '',
[EthereumNetwork.ropsten]: '',
[EthereumNetwork.main]: '',
[EthereumNetwork.kovan]: undefined,
[EthereumNetwork.ropsten]: undefined,
[EthereumNetwork.main]: undefined,
},
LendingRateOracle: {
[EthereumNetwork.kovan]: '0xdcde9bb6a49e37fa433990832ab541ae2d4feb4a',
@ -227,4 +227,10 @@ export const CommonsConfig: ICommonConfiguration = {
UNI_MKR_ETH: '0xEe40a5E8F3732bE6ECDb5A90e23D0b7bF0D4a73c',
},
},
ReserveAssets: {
[EthereumNetwork.main]: {},
[EthereumNetwork.kovan]: {},
[EthereumNetwork.ropsten]: {},
},
ReservesConfig: {},
};

View File

@ -13,7 +13,7 @@ export const UniswapConfig: IUniswapConfiguration = {
ConfigName: 'Uniswap',
ProviderId: 2,
ReserveSymbols: [
'ETH',
'WETH',
'DAI',
'USDC',
'USDT',
@ -158,6 +158,9 @@ export const UniswapConfig: IUniswapConfiguration = {
},
ChainlinkAggregator: {
[EthereumNetwork.kovan]: {
DAI: '0x6F47077D3B6645Cb6fb7A29D280277EC1e5fFD90',
USDC: '0x672c1C0d1130912D83664011E7960a42E8cA05D5',
USDT: '0xCC833A6522721B3252e7578c5BCAF65738B75Fc3',
UNI_DAI_ETH: '0x0338C40020Bf886c11406115fD1ba205Ef1D9Ff9',
UNI_USDC_ETH: '0x7f5E5D34591e9a70D187BBA94260C30B92aC0961',
UNI_SETH_ETH: '0xc5F1eA001c1570783b3af418fa775237Eb129EDC',
@ -166,6 +169,9 @@ export const UniswapConfig: IUniswapConfiguration = {
UNI_MKR_ETH: '0x6eBF25AB0A18B8F6243619f1AE6b94373169A069',
},
[EthereumNetwork.ropsten]: {
DAI: '0x64b8e49baded7bfb2fd5a9235b2440c0ee02971b',
USDC: '0xe1480303dde539e2c241bdc527649f37c9cbef7d',
USDT: '0xc08fe0c4d97ccda6b40649c6da621761b628c288',
UNI_DAI_ETH: '0x16048819e3f77b7112eB033624A0bA9d33743028',
UNI_USDC_ETH: '0x6952A2678D574073DB97963886c2F38CD09C8Ba3',
UNI_SETH_ETH: '0x23Ee5188806BD2D31103368B0EA0259bc6706Af1',
@ -174,6 +180,9 @@ export const UniswapConfig: IUniswapConfiguration = {
UNI_MKR_ETH: '0x594ae5421f378b8B4AF9e758C461d2A1FF990BC5',
},
[EthereumNetwork.main]: {
DAI: '0x037E8F2125bF532F3e228991e051c8A7253B642c',
USDC: '0xdE54467873c3BCAA76421061036053e371721708',
USDT: '0xa874fe207DF445ff19E7482C746C4D3fD0CB9AcE',
UNI_DAI_ETH: '0x1bAB293850289Bf161C5DA79ff3d1F02A950555b',
UNI_USDC_ETH: '0x444315Ee92F2bb3579293C17B07194227fA99bF0',
UNI_SETH_ETH: '0x517D40E49660c7705b2e99eEFA6d7B0E9Ba5BF10',
@ -182,8 +191,12 @@ export const UniswapConfig: IUniswapConfiguration = {
UNI_MKR_ETH: '0xEe40a5E8F3732bE6ECDb5A90e23D0b7bF0D4a73c',
},
},
UniAssetsAddresses: {
ReserveAssets: {
[EthereumNetwork.kovan]: {
WETH: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
DAI: '0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD',
USDC: '0xe22da380ee6B445bb8273C81944ADEB6E8450422',
USDT: '0x13512979ADE267AB5100878E2e0f485B568328a4',
UNI_DAI_ETH: '0x2e0086b5343101203ADeE40160ca1BD91E29fF75',
UNI_USDC_ETH: '0x34eA1aB2a43ee696914fc3C0d3e517fA666B9e8D',
UNI_SETH_ETH: '0xCF457d8Bb8D8f54Af1ea1B3710231e89bd6CFbfe',
@ -192,6 +205,10 @@ export const UniswapConfig: IUniswapConfiguration = {
UNI_MKR_ETH: '0xB31a1c30f38cD68e8177566Ef950d7bc3C81DaCF',
},
[EthereumNetwork.ropsten]: {
WETH: '0xc778417e063141139fce010982780140aa0cd5ab',
DAI: '0xf80A32A835F79D7787E8a8ee5721D0fEaFd78108',
USDC: '0x851dEf71f0e6A903375C1e536Bd9ff1684BAD802',
USDT: '0xB404c51BBC10dcBE948077F18a4B8E553D160084',
UNI_DAI_ETH: '0xC245A7d35E652Cae438A1FdB13E474DF53DBB81D',
UNI_USDC_ETH: '0x2BD65323955D08eb600074291305881d1295c4D2',
UNI_SETH_ETH: '0xed4597DCd234867d7A260AD24bAb8253F64940a5',
@ -200,6 +217,10 @@ export const UniswapConfig: IUniswapConfiguration = {
UNI_MKR_ETH: '0xd8b7B99a9205FD0D0abFB6D7a2c13Db2681bff43',
},
[EthereumNetwork.main]: {
WETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
DAI: '0x6b175474e89094c44da98b954eedeac495271d0f',
USDC: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
USDT: '0xdac17f958d2ee523a2206206994597c13d831ec7',
UNI_DAI_ETH: '0x2a1530c4c41db0b0b2bb646cb5eb1a67b7158667',
UNI_USDC_ETH: '0x97dec872013f6b5fb443861090ad931542878126',
UNI_SETH_ETH: '0xe9cf7887b93150d4f2da7dfc6d502b216438f244',

View File

@ -111,7 +111,7 @@
},
"DefaultReserveInterestRateStrategy": {
"buidlerevm": {
"address": "0x626FdE749F9d499d3777320CAf29484B624ab84a",
"address": "0xA0AB1cB92A4AF81f84dCd258155B5c25D247b54E",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
},
"localhost": {
@ -166,7 +166,7 @@
},
"MockFlashLoanReceiver": {
"buidlerevm": {
"address": "0x2B681757d757fbB80cc51c6094cEF5eE75bF55aA"
"address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4"
},
"localhost": {
"address": "0x3bDA11B584dDff7F66E0cFe1da1562c92B45db60"
@ -174,7 +174,7 @@
},
"WalletBalanceProvider": {
"buidlerevm": {
"address": "0xBEF0d4b9c089a5883741fC14cbA352055f35DDA2",
"address": "0xC6bA6049F86d528698B5924B8fC2FE7289D38578",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
},
"localhost": {
@ -414,7 +414,7 @@
},
"AaveProtocolTestHelpers": {
"buidlerevm": {
"address": "0xDf73fC454FA018051D4a1509e63D11530A59DE10"
"address": "0xde9595927B00361Ed7987a181Fb09EC6f31b451c"
},
"localhost": {
"address": "0x3b050AFb4ac4ACE646b31fF3639C1CD43aC31460"
@ -422,7 +422,7 @@
},
"StableDebtToken": {
"buidlerevm": {
"address": "0xB660Fdd109a95718cB9d20E3A89EE6cE342aDcB6",
"address": "0x5f7134cd38C826a7649f9Cc47dda24d834DD2967",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
},
"localhost": {
@ -432,7 +432,7 @@
},
"VariableDebtToken": {
"buidlerevm": {
"address": "0x830bceA96E56DBC1F8578f75fBaC0AF16B32A07d",
"address": "0xE91bBe8ee03560E3dda2786f95335F5399813Ca0",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
},
"localhost": {
@ -446,7 +446,7 @@
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
},
"buidlerevm": {
"address": "0xA0AB1cB92A4AF81f84dCd258155B5c25D247b54E",
"address": "0x3870a14c5057f596e385ea21537792fE4fF4C1BE",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},

View File

@ -333,72 +333,89 @@ export const deployAaveProtocolTestHelpers = async (
export const deployMintableERC20 = async ([name, symbol, decimals]: [string, string, number]) =>
await deployContract<MintableERC20>(eContractid.MintableERC20, [name, symbol, decimals]);
export const deployDefaultReserveInterestRateStrategy = async ([
addressesProvider,
baseVariableBorrowRate,
variableSlope1,
variableSlope2,
stableSlope1,
stableSlope2,
]: [tEthereumAddress, string, string, string, string, string]) =>
await deployContract<DefaultReserveInterestRateStrategy>(
eContractid.DefaultReserveInterestRateStrategy,
[
addressesProvider,
baseVariableBorrowRate,
variableSlope1,
variableSlope2,
stableSlope1,
stableSlope2,
]
);
export const deployDefaultReserveInterestRateStrategy = async (
[
addressesProvider,
baseVariableBorrowRate,
variableSlope1,
variableSlope2,
stableSlope1,
stableSlope2,
]: [tEthereumAddress, string, string, string, string, string],
verify: boolean
) => {
const id = eContractid.DefaultReserveInterestRateStrategy;
const args = [
addressesProvider,
baseVariableBorrowRate,
variableSlope1,
variableSlope2,
stableSlope1,
stableSlope2,
];
const instance = await deployContract<DefaultReserveInterestRateStrategy>(id, args);
export const deployStableDebtToken = async ([name, symbol, underlyingAsset, poolAddress]: [
string,
string,
tEthereumAddress,
tEthereumAddress
]) => {
const token = await deployContract<StableDebtToken>(eContractid.StableDebtToken, [
poolAddress,
underlyingAsset,
name,
symbol,
]);
return token;
if (verify) {
await verifyContract(id, instance.address, args);
}
return instance;
};
export const deployVariableDebtToken = async ([name, symbol, underlyingAsset, poolAddress]: [
string,
string,
tEthereumAddress,
tEthereumAddress
]) => {
const token = await deployContract<VariableDebtToken>(eContractid.VariableDebtToken, [
poolAddress,
underlyingAsset,
name,
symbol,
]);
export const deployStableDebtToken = async (
[name, symbol, underlyingAsset, poolAddress]: [
string,
string,
tEthereumAddress,
tEthereumAddress
],
verify: boolean
) => {
const id = eContractid.StableDebtToken;
const args = [poolAddress, underlyingAsset, name, symbol];
const instance = await deployContract<StableDebtToken>(id, args);
return token;
if (verify) {
await verifyContract(id, instance.address, args);
}
return instance;
};
export const deployGenericAToken = async ([poolAddress, underlyingAssetAddress, name, symbol]: [
tEthereumAddress,
tEthereumAddress,
string,
string
]) => {
const token = await deployContract<AToken>(eContractid.AToken, [
poolAddress,
underlyingAssetAddress,
name,
symbol,
]);
export const deployVariableDebtToken = async (
[name, symbol, underlyingAsset, poolAddress]: [
string,
string,
tEthereumAddress,
tEthereumAddress
],
verify: boolean
) => {
const id = eContractid.VariableDebtToken;
const args = [poolAddress, underlyingAsset, name, symbol];
const instance = await deployContract<VariableDebtToken>(id, args);
return token;
if (verify) {
await verifyContract(id, instance.address, args);
}
return instance;
};
export const deployGenericAToken = async (
[poolAddress, underlyingAssetAddress, name, symbol]: [
tEthereumAddress,
tEthereumAddress,
string,
string
],
verify: boolean
) => {
const id = eContractid.AToken;
const args = [poolAddress, underlyingAssetAddress, name, symbol];
const instance = await deployContract<AToken>(id, args);
if (verify) {
await verifyContract(id, instance.address, args);
}
return instance;
};
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => {
@ -664,10 +681,10 @@ export const getPairsTokenAggregator = (
},
aggregatorsAddresses: {[tokenSymbol: string]: tEthereumAddress}
): [string[], string[]] => {
const {ETH, ...assetsAddressesWithoutEth} = allAssetsAddresses;
const {ETH, USD, WETH, ...assetsAddressesWithoutEth} = allAssetsAddresses;
const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => {
if (tokenSymbol !== 'ETH') {
if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') {
const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
(value) => value === tokenSymbol
);
@ -691,7 +708,8 @@ export const initReserves = async (
lendingPoolAddressesProvider: LendingPoolAddressesProvider,
lendingPool: LendingPool,
lendingPoolConfigurator: LendingPoolConfigurator,
aavePool: AavePools
aavePool: AavePools,
verify: boolean
) => {
if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
console.log(`Invalid Aave pool ${aavePool}`);
@ -732,35 +750,47 @@ export const initReserves = async (
stableRateSlope2,
},
] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex];
const rateStrategyContract = await deployDefaultReserveInterestRateStrategy([
lendingPoolAddressesProvider.address,
baseVariableBorrowRate,
variableRateSlope1,
variableRateSlope2,
stableRateSlope1,
stableRateSlope2,
]);
const rateStrategyContract = await deployDefaultReserveInterestRateStrategy(
[
lendingPoolAddressesProvider.address,
baseVariableBorrowRate,
variableRateSlope1,
variableRateSlope2,
stableRateSlope1,
stableRateSlope2,
],
verify
);
const stableDebtToken = await deployStableDebtToken([
`Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
tokenAddress,
lendingPool.address,
]);
const stableDebtToken = await deployStableDebtToken(
[
`Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
tokenAddress,
lendingPool.address,
],
verify
);
const variableDebtToken = await deployVariableDebtToken([
`Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
tokenAddress,
lendingPool.address,
]);
const variableDebtToken = await deployVariableDebtToken(
[
`Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
tokenAddress,
lendingPool.address,
],
verify
);
const aToken = await deployGenericAToken([
lendingPool.address,
tokenAddress,
`Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
]);
const aToken = await deployGenericAToken(
[
lendingPool.address,
tokenAddress,
`Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
`a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
],
verify
);
if (process.env.POOL === AavePools.secondary) {
if (assetSymbol.search('UNI') === -1) {

View File

@ -1,4 +1,5 @@
import BigNumber from 'bignumber.js';
import {MockTokenMap} from './contracts-helpers';
export interface SymbolMap<T> {
[symbol: string]: T;
@ -77,6 +78,9 @@ export type tBigNumberTokenBigUnits = BigNumber;
export type tStringTokenSmallUnits = string; // 1 wei, or 1 basic unit of USDC, or 1 basic unit of DAI
export type tBigNumberTokenSmallUnits = BigNumber;
export interface iAssetCommon<T> {
[key: string]: T;
}
export interface iAssetBase<T> {
WETH: T;
DAI: T;
@ -112,7 +116,6 @@ export type iAssetsWithoutUSD<T> = Omit<iAssetBase<T>, 'USD'>;
export type iAavePoolAssets<T> = Pick<
iAssetsWithoutUSD<T>,
| 'WETH'
| 'DAI'
| 'TUSD'
| 'USDC'
@ -151,7 +154,7 @@ export type iAaveSecondPoolAssets<T> = Pick<
| 'UNI_LINK_ETH'
>;
export type iMultiPoolsAssets<T> = iAavePoolAssets<T> | iAaveSecondPoolAssets<T>;
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T> | iAaveSecondPoolAssets<T>;
export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>;
@ -272,7 +275,7 @@ export interface ICommonConfiguration {
ReserveSymbols: string[];
ProtocolGlobalParams: IProtocolGlobalConfig;
Mocks: IMocksConfig;
ProviderRegistry: iParamsPerNetwork<tEthereumAddress>;
ProviderRegistry: iParamsPerNetwork<tEthereumAddress | undefined>;
LendingRateOracleRatesCommon: iMultiPoolsAssets<IMarketRates>;
LendingRateOracle: iParamsPerNetwork<tEthereumAddress>;
TokenDistributor: iParamsPerNetwork<tEthereumAddress>;
@ -281,19 +284,20 @@ export interface ICommonConfiguration {
ChainlinkAggregator: iParamsPerNetwork<ITokenAddress>;
LendingPoolManagerAddress: iParamsPerNetwork<tEthereumAddress | undefined>;
LendingPoolManagerAddressIndex: number;
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
}
export interface IAaveConfiguration extends ICommonConfiguration {
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
ReservesConfig: iAavePoolAssets<IReserveParams>;
}
export interface IUniswapConfiguration extends ICommonConfiguration {
ReservesConfig: iAaveSecondPoolAssets<IReserveParams>;
}
export interface ITokenAddress {
[token: string]: tEthereumAddress;
}
export interface IUniswapConfiguration extends ICommonConfiguration {
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
UniAssetsAddresses: iParamsPerNetwork<ITokenAddress>;
}
export type PoolConfiguration = IAaveConfiguration | IUniswapConfiguration;

View File

@ -21,7 +21,14 @@
"aave:ropsten:full:migration": "npm run buidler:ropsten -- aave:full --verify",
"aave:main:dev:migration": "npm run buidler:main -- aave:dev --verify",
"aave:main:full:migration": "npm run buidler:main -- aave:full --verify",
"uniswap:evm:dev:migration": "npm run buidler:uniswap -- uniswap:dev",
"uniswap:evm:dev:migration": "buidler uniswap:dev",
"uniswap:evm:full:migration": "buidler uniswap:full",
"uniswap:kovan:dev:migration": "npm run buidler:kovan -- uniswap:dev --verify",
"uniswap:kovan:full:migration": "npm run buidler:kovan -- uniswap:full --verify",
"uniswap:ropsten:dev:migration": "npm run buidler:ropsten -- uniswap:dev --verify",
"uniswap:ropsten:full:migration": "npm run buidler:ropsten -- uniswap:full --verify",
"uniswap:main:dev:migration": "npm run buidler:main -- uniswap:dev --verify",
"uniswap:main:full:migration": "npm run buidler:main -- uniswap:full --verify",
"dev:coverage": "buidler coverage",
"dev:deployment": "buidler dev-deployment",
"dev:deployExample": "buidler deploy-Example",

View File

@ -1,6 +1,6 @@
import {task} from '@nomiclabs/buidler/config';
import {deployAllMockTokens} from '../../helpers/contracts-helpers';
task('deploy-mock-tokens', 'Deploy mock tokens for dev enviroment')
task('dev:deploy-mock-tokens', 'Deploy mock tokens for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre');

View File

@ -6,7 +6,7 @@ import {
import {waitForTx} from '../../helpers/misc-utils';
task(
'deploy-address-provider',
'dev:deploy-address-provider',
'Deploy address provider, registry and fee provider for dev enviroment'
)
.addOptionalParam('verify', 'Verify contracts at Etherscan')

View File

@ -10,7 +10,7 @@ import {
import {eContractid} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
task('deploy-lending-pool', 'Deploy lending pool for dev enviroment')
task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre');

View File

@ -19,7 +19,7 @@ import {waitForTx} from '../../helpers/misc-utils';
import {getAllAggregatorsAddresses, getAllTokenAddresses} from '../../helpers/mock-helpers';
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
task('deploy-oracles', 'Deploy oracles for dev enviroment')
task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({verify, pool}, localBRE) => {

View File

@ -18,7 +18,7 @@ import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
task('initialize-lending-pool', 'Initialize lending pool configuration.')
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre');
@ -36,14 +36,14 @@ task('initialize-lending-pool', 'Initialize lending pool configuration.')
const reservesParams = getReservesConfigByPool(AavePools.proto);
console.log('Initialize configuration');
await initReserves(
reservesParams,
protoPoolReservesAddresses,
addressesProvider,
lendingPoolProxy,
lendingPoolConfiguratorProxy,
AavePools.proto
AavePools.proto,
verify
);
await enableReservesToBorrow(
reservesParams,

View File

@ -3,7 +3,6 @@ import {
deployLendingPoolAddressesProvider,
deployLendingPoolAddressesProviderRegistry,
getParamPerNetwork,
getLendingPoolAddressesProvider,
getLendingPoolAddressesProviderRegistry,
} from '../../helpers/contracts-helpers';
import {waitForTx} from '../../helpers/misc-utils';

View File

@ -10,16 +10,17 @@ import {
import {eContractid} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
task('deploy-lending-pool', 'Deploy lending pool for dev enviroment')
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre');
const addressesProvider = await getLendingPoolAddressesProvider();
// Deploy lending pool
const lendingPoolImpl = await deployLendingPool(verify);
// Set lending pool impl to Address Provider
// Set lending pool impl to address provider
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address));
const address = await addressesProvider.getLendingPool();
@ -27,6 +28,7 @@ task('deploy-lending-pool', 'Deploy lending pool for dev enviroment')
await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address);
// Deploy lending pool configurator
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify);
// Set lending pool conf impl to Address Provider
@ -37,6 +39,7 @@ task('deploy-lending-pool', 'Deploy lending pool for dev enviroment')
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(
await addressesProvider.getLendingPoolConfigurator()
);
await insertContractAddressInDb(
eContractid.LendingPoolConfigurator,
lendingPoolConfiguratorProxy.address

58
tasks/full/3_oracles.ts Normal file
View File

@ -0,0 +1,58 @@
import {task} from '@nomiclabs/buidler/config';
import {
getLendingPoolAddressesProvider,
getPairsTokenAggregator,
deployChainlinkProxyPriceProvider,
deployLendingRateOracle,
getParamPerNetwork,
} from '../../helpers/contracts-helpers';
import {setInitialMarketRatesInRatesOracle} from '../../helpers/oracles-helpers';
import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types';
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({verify, pool}, localBRE) => {
await localBRE.run('set-bre');
const network = <eEthereumNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool);
const {
ProtocolGlobalParams: {UsdAddress},
LendingRateOracleRatesCommon,
ReserveAssets,
ReserveSymbols,
FallbackOracle,
ChainlinkAggregator,
} = poolConfig as ICommonConfiguration;
const lendingRateOracles = filterMapBy(LendingRateOracleRatesCommon, (key) =>
ReserveSymbols.includes(key)
);
const addressesProvider = await getLendingPoolAddressesProvider();
const fallbackOracle = await getParamPerNetwork(FallbackOracle, network);
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
const chainlinkAggregators = await getParamPerNetwork(ChainlinkAggregator, network);
const tokensToWatch: SymbolMap<string> = {
...reserveAssets,
USD: UsdAddress,
};
const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators);
await deployChainlinkProxyPriceProvider([tokens, aggregators, fallbackOracle], verify);
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle));
const lendingRateOracle = await deployLendingRateOracle(verify);
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));
const {USD, ...tokensAddressesWithoutUsd} = tokensToWatch;
await setInitialMarketRatesInRatesOracle(
lendingRateOracles,
tokensAddressesWithoutUsd,
lendingRateOracle
);
});

View File

@ -1,74 +0,0 @@
import {task} from '@nomiclabs/buidler/config';
import {
getLendingPoolAddressesProvider,
deployPriceOracle,
getMockedTokens,
getPairsTokenAggregator,
deployChainlinkProxyPriceProvider,
deployLendingRateOracle,
getAllMockedTokens,
} from '../../helpers/contracts-helpers';
import {
setInitialAssetPricesInOracle,
setInitialMarketRatesInRatesOracle,
deployAllMockAggregators,
} from '../../helpers/oracles-helpers';
import {ICommonConfiguration, iAssetBase, TokenContractId} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
import {getAllAggregatorsAddresses, getAllTokenAddresses} from '../../helpers/mock-helpers';
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
task('deploy-oracles', 'Deploy oracles for dev enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({verify, pool}, localBRE) => {
await localBRE.run('set-bre');
const poolConfig = loadPoolConfig(pool);
const {
Mocks: {ChainlinkAggregatorPrices, AllAssetsInitialPrices},
ProtocolGlobalParams: {UsdAddress, MockUsdPriceInWei},
LendingRateOracleRatesCommon,
} = poolConfig as ICommonConfiguration;
const defaultTokenList = {
...Object.fromEntries(Object.keys(TokenContractId).map((symbol) => [symbol, ''])),
USD: UsdAddress,
} as iAssetBase<string>;
const mockTokens = await getAllMockedTokens();
const mockTokensAddress = Object.keys(mockTokens).reduce<iAssetBase<string>>((prev, curr) => {
prev[curr as keyof iAssetBase<string>] = mockTokens[curr].address;
return prev;
}, defaultTokenList);
const addressesProvider = await getLendingPoolAddressesProvider();
const fallbackOracle = await deployPriceOracle(verify);
await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei));
await setInitialAssetPricesInOracle(AllAssetsInitialPrices, mockTokensAddress, fallbackOracle);
const mockAggregators = await deployAllMockAggregators(ChainlinkAggregatorPrices, verify);
const allTokenAddresses = getAllTokenAddresses(mockTokens);
const allAggregatorsAddresses = getAllAggregatorsAddresses(mockAggregators);
const [tokens, aggregators] = getPairsTokenAggregator(
allTokenAddresses,
allAggregatorsAddresses
);
await deployChainlinkProxyPriceProvider([tokens, aggregators, fallbackOracle.address], verify);
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
const lendingRateOracle = await deployLendingRateOracle(verify);
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));
const {USD, ...tokensAddressesWithoutUsd} = allTokenAddresses;
const allReservesAddresses = {
...tokensAddressesWithoutUsd,
};
await setInitialMarketRatesInRatesOracle(
LendingRateOracleRatesCommon,
allReservesAddresses,
lendingRateOracle
);
});

View File

@ -4,56 +4,51 @@ import {
initReserves,
deployLendingPoolLiquidationManager,
insertContractAddressInDb,
deployMockFlashLoanReceiver,
deployWalletBalancerProvider,
deployAaveProtocolTestHelpers,
getLendingPool,
getLendingPoolConfiguratorProxy,
getAllMockedTokens,
getParamPerNetwork,
} from '../../helpers/contracts-helpers';
import {getReservesConfigByPool} from '../../helpers/configuration';
import {loadPoolConfig, ConfigNames} from '../../helpers/configuration';
import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types';
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
import {AavePools, eContractid, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
task('initialize-lending-pool', 'Initialize lending pool configuration.')
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({verify, pool}, localBRE) => {
await localBRE.run('set-bre');
const network = <eEthereumNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool);
const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration;
const mockTokens = await getAllMockedTokens();
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
const lendingPoolProxy = await getLendingPool();
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy();
const allTokenAddresses = getAllTokenAddresses(mockTokens);
const addressesProvider = await getLendingPoolAddressesProvider();
const protoPoolReservesAddresses = <{[symbol: string]: tEthereumAddress}>(
filterMapBy(allTokenAddresses, (key: string) => !key.includes('UNI'))
);
const reservesParams = getReservesConfigByPool(AavePools.proto);
console.log('Initialize configuration');
await initReserves(
reservesParams,
protoPoolReservesAddresses,
ReservesConfig,
reserveAssets,
addressesProvider,
lendingPoolProxy,
lendingPoolConfiguratorProxy,
AavePools.proto
AavePools.proto,
verify
);
await enableReservesToBorrow(
reservesParams,
protoPoolReservesAddresses,
ReservesConfig,
reserveAssets,
lendingPoolProxy,
lendingPoolConfiguratorProxy
);
await enableReservesAsCollateral(
reservesParams,
protoPoolReservesAddresses,
ReservesConfig,
reserveAssets,
lendingPoolProxy,
lendingPoolConfiguratorProxy
);
@ -63,15 +58,6 @@ task('initialize-lending-pool', 'Initialize lending pool configuration.')
await addressesProvider.setLendingPoolLiquidationManager(liquidationManager.address)
);
const mockFlashLoanReceiver = await deployMockFlashLoanReceiver(
addressesProvider.address,
verify
);
await insertContractAddressInDb(
eContractid.MockFlashLoanReceiver,
mockFlashLoanReceiver.address
);
await deployWalletBalancerProvider(addressesProvider.address, verify);
const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address, verify);

View File

@ -5,6 +5,8 @@ import {ConfigNames} from '../../helpers/configuration';
task('aave:dev', 'Deploy development enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
const POOL_NAME = ConfigNames.Aave;
await localBRE.run('set-bre');
// Prevent loss of gas verifying all the needed ENVs for Etherscan verification
@ -15,19 +17,19 @@ task('aave:dev', 'Deploy development enviroment')
console.log('Migration started\n');
console.log('1. Deploy mock tokens');
await localBRE.run('deploy-mock-tokens', {verify});
await localBRE.run('dev:deploy-mock-tokens', {verify});
console.log('2. Deploy address provider');
await localBRE.run('deploy-address-provider', {verify});
await localBRE.run('dev:deploy-address-provider', {verify});
console.log('3. Deploy lending pool');
await localBRE.run('deploy-lending-pool', {verify});
await localBRE.run('dev:deploy-lending-pool', {verify});
console.log('4. Deploy oracles');
await localBRE.run('deploy-oracles', {verify, pool: ConfigNames.Aave});
await localBRE.run('dev:deploy-oracles', {verify, pool: POOL_NAME});
console.log('5. Initialize lending pool');
await localBRE.run('initialize-lending-pool', {verify});
await localBRE.run('dev:initialize-lending-pool', {verify});
console.log('\nFinished migration');
});

View File

@ -5,11 +5,8 @@ import {ConfigNames} from '../../helpers/configuration';
task('aave:full', 'Deploy development enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre');
// Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) {
checkVerification();
}
const POOL_NAME = ConfigNames.Aave;
await localBRE.run('set-bre');
// Prevent loss of gas verifying all the needed ENVs for Etherscan verification
@ -20,19 +17,16 @@ task('aave:full', 'Deploy development enviroment')
console.log('Migration started\n');
console.log('1. Deploy address provider');
await localBRE.run('full:deploy-address-provider', {verify, pool: ConfigNames.Aave});
await localBRE.run('full:deploy-address-provider', {verify, pool: POOL_NAME});
/*
console.log('3. Deploy lending pool');
await localBRE.run('deploy-lending-pool', {verify});
console.log('2. Deploy lending pool');
await localBRE.run('full:deploy-lending-pool', {verify});
console.log('4. Deploy oracles');
await localBRE.run('deploy-oracles', {verify, pool: ConfigNames.Aave});
console.log('3. Deploy oracles');
await localBRE.run('full:deploy-oracles', {verify, pool: POOL_NAME});
console.log('5. Initialize lending pool');
await localBRE.run('initialize-lending-pool', {verify});
console.log('4. Initialize lending pool');
await localBRE.run('full:initialize-lending-pool', {verify, pool: POOL_NAME});
// console.log('\nFinished migration');
*/
console.log('TODO: Pending to migrate');
console.log('\nFinished migrations');
});

View File

@ -1,13 +1,35 @@
import {task} from '@nomiclabs/buidler/config';
import {checkVerification} from '../../helpers/etherscan-verification';
import {ConfigNames} from '../../helpers/configuration';
task('uniswap:dev', 'Deploy development enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
const POOL_NAME = ConfigNames.Uniswap;
await localBRE.run('set-bre');
// Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) {
checkVerification();
}
console.log('TODO: Pending to migrate');
console.log('Migration started\n');
console.log('1. Deploy mock tokens');
await localBRE.run('dev:deploy-mock-tokens', {verify});
console.log('2. Deploy address provider');
await localBRE.run('dev:deploy-address-provider', {verify});
console.log('3. Deploy lending pool');
await localBRE.run('dev:deploy-lending-pool', {verify});
console.log('4. Deploy oracles');
await localBRE.run('dev:deploy-oracles', {verify, pool: POOL_NAME});
console.log('5. Initialize lending pool');
await localBRE.run('dev:initialize-lending-pool', {verify});
console.log('\nFinished migration');
});

View File

@ -1,13 +1,32 @@
import {task} from '@nomiclabs/buidler/config';
import {checkVerification} from '../../helpers/etherscan-verification';
import {ConfigNames} from '../../helpers/configuration';
task('uniswap:full', 'Deploy development enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => {
const POOL_NAME = ConfigNames.Uniswap;
await localBRE.run('set-bre');
// Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) {
checkVerification();
}
console.log('TODO: Pending to migrate');
console.log('Migration started\n');
console.log('1. Deploy address provider');
await localBRE.run('full:deploy-address-provider', {verify, pool: POOL_NAME});
console.log('2. Deploy lending pool');
await localBRE.run('full:deploy-lending-pool', {verify});
console.log('3. Deploy oracles');
await localBRE.run('full:deploy-oracles', {verify, pool: POOL_NAME});
console.log('4. Initialize lending pool');
await localBRE.run('full:initialize-lending-pool', {verify, pool: POOL_NAME});
console.log('\nFinished migrations');
});