feat: Added USD Curve scripts. Added misc task to update asset sources to Aave Oracle for development. Changes to typings to support new market. Fixed scripts to support new market. Added OracleQuoteCurrency to determine the quote currency of the Aave Oracle inside a Market.

This commit is contained in:
David Racero 2021-05-26 19:33:15 +02:00
parent fe43e0a72a
commit 0242731f76
20 changed files with 186 additions and 68 deletions

View File

@ -62,8 +62,6 @@ const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({
}, },
}); });
let forkMode;
const buidlerConfig: HardhatUserConfig = { const buidlerConfig: HardhatUserConfig = {
solidity: { solidity: {
version: '0.6.12', version: '0.6.12',
@ -113,16 +111,6 @@ const buidlerConfig: HardhatUserConfig = {
})), })),
forking: buildForkConfig(), forking: buildForkConfig(),
}, },
buidlerevm_docker: {
hardfork: 'berlin',
blockGasLimit: 9500000,
gas: 9500000,
gasPrice: 8000000000,
chainId: BUIDLEREVM_CHAINID,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
url: 'http://localhost:8545',
},
ganache: { ganache: {
url: 'http://ganache:8545', url: 'http://ganache:8545',
accounts: { accounts: {

View File

@ -5,11 +5,15 @@ import {
PoolConfiguration, PoolConfiguration,
ICommonConfiguration, ICommonConfiguration,
eNetwork, eNetwork,
IUsdAmmConfiguration,
IBaseConfiguration,
} from './types'; } from './types';
import { getParamPerPool } from './contracts-helpers'; import { getParamPerPool } from './contracts-helpers';
import AaveConfig from '../markets/aave'; import AaveConfig from '../markets/aave';
import MaticConfig from '../markets/matic'; import MaticConfig from '../markets/matic';
import AmmConfig from '../markets/amm'; import AmmConfig from '../markets/amm';
import UsdConfig from '../markets/usd-amm';
import { CommonsConfig } from '../markets/aave/commons'; import { CommonsConfig } from '../markets/aave/commons';
import { DRE, filterMapBy } from './misc-utils'; import { DRE, filterMapBy } from './misc-utils';
import { tEthereumAddress } from './types'; import { tEthereumAddress } from './types';
@ -21,6 +25,7 @@ export enum ConfigNames {
Aave = 'Aave', Aave = 'Aave',
Matic = 'Matic', Matic = 'Matic',
Amm = 'Amm', Amm = 'Amm',
Usd = 'Usd',
} }
export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
@ -31,6 +36,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
return MaticConfig; return MaticConfig;
case ConfigNames.Amm: case ConfigNames.Amm:
return AmmConfig; return AmmConfig;
case ConfigNames.Usd:
return UsdConfig;
case ConfigNames.Commons: case ConfigNames.Commons:
return CommonsConfig; return CommonsConfig;
default: default:
@ -54,12 +61,15 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
[AavePools.matic]: { [AavePools.matic]: {
...MaticConfig.ReservesConfig, ...MaticConfig.ReservesConfig,
}, },
[AavePools.usd]: {
...UsdConfig.ReservesConfig,
},
}, },
pool pool
); );
export const getGenesisPoolAdmin = async ( export const getGenesisPoolAdmin = async (
config: ICommonConfiguration config: IBaseConfiguration
): Promise<tEthereumAddress> => { ): Promise<tEthereumAddress> => {
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork); const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork);
@ -73,9 +83,7 @@ export const getGenesisPoolAdmin = async (
return addressList[addressIndex]; return addressList[addressIndex];
}; };
export const getEmergencyAdmin = async ( export const getEmergencyAdmin = async (config: IBaseConfiguration): Promise<tEthereumAddress> => {
config: ICommonConfiguration
): Promise<tEthereumAddress> => {
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork); const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork);
if (targetAddress) { if (targetAddress) {
@ -88,19 +96,17 @@ export const getEmergencyAdmin = async (
return addressList[addressIndex]; return addressList[addressIndex];
}; };
export const getTreasuryAddress = async ( export const getTreasuryAddress = async (config: IBaseConfiguration): Promise<tEthereumAddress> => {
config: ICommonConfiguration
): Promise<tEthereumAddress> => {
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork); return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork);
}; };
export const getATokenDomainSeparatorPerNetwork = ( export const getATokenDomainSeparatorPerNetwork = (
network: eNetwork, network: eNetwork,
config: ICommonConfiguration config: IBaseConfiguration
): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network); ): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network);
export const getWethAddress = async (config: ICommonConfiguration) => { export const getWethAddress = async (config: IBaseConfiguration) => {
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork); const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork);
if (wethAddress) { if (wethAddress) {
@ -113,7 +119,7 @@ export const getWethAddress = async (config: ICommonConfiguration) => {
return weth.address; return weth.address;
}; };
export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration) => { export const getWrappedNativeTokenAddress = async (config: IBaseConfiguration) => {
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
const wethAddress = getParamPerNetwork(config.WrappedNativeToken, <eNetwork>currentNetwork); const wethAddress = getParamPerNetwork(config.WrappedNativeToken, <eNetwork>currentNetwork);
if (wethAddress) { if (wethAddress) {
@ -126,7 +132,7 @@ export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration)
return weth.address; return weth.address;
}; };
export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => { export const getLendingRateOracles = (poolConfig: IBaseConfiguration) => {
const { const {
ProtocolGlobalParams: { UsdAddress }, ProtocolGlobalParams: { UsdAddress },
LendingRateOracleRatesCommon, LendingRateOracleRatesCommon,

View File

@ -73,10 +73,8 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
xSUSHI: oneEther.multipliedBy('0.00913428586').toFixed(), xSUSHI: oneEther.multipliedBy('0.00913428586').toFixed(),
USD: '5848466240000000', USD: '5848466240000000',
REW: oneEther.multipliedBy('0.00137893825230').toFixed(), REW: oneEther.multipliedBy('0.00137893825230').toFixed(),
'3Crv': '0', 'a3CRV-gauge': '0',
'cDAI+cUSDC': '0', 'saCRV-gauge': '0',
a3CRV: '0',
saCRV: '0',
}; };
export const MOCK_CHAINLINK_AGGREGATORS_USD_CURVE_AMM_PRICES = { export const MOCK_CHAINLINK_AGGREGATORS_USD_CURVE_AMM_PRICES = {
@ -89,12 +87,11 @@ export const MOCK_CHAINLINK_AGGREGATORS_USD_CURVE_AMM_PRICES = {
USDC: oneUsd.toFixed(), USDC: oneUsd.toFixed(),
USDT: oneUsd.toFixed(), USDT: oneUsd.toFixed(),
USD: oneUsd.toFixed(), USD: oneUsd.toFixed(),
'3Crv': oneUsd.multipliedBy('1.0168').toFixed(), 'a3CRV-gauge': oneUsd.multipliedBy('1.0536').toFixed(),
'cDAI+cUSDC': oneUsd.multipliedBy('1.0758').toFixed(), 'saCRV-gauge': oneUsd.multipliedBy('1.0318').toFixed(),
a3CRV: oneUsd.multipliedBy('1.0536').toFixed(),
saCRV: oneUsd.multipliedBy('1.0318').toFixed(),
}; };
export const CRV_TOKEN = { export const CRV_TOKEN = {
[eEthereumNetwork.main]: '0xD533a949740bb3306d119CC777fa900bA034cd52', [eEthereumNetwork.main]: '0xD533a949740bb3306d119CC777fa900bA034cd52',
[eEthereumNetwork.tenderlyMain]: '0xD533a949740bb3306d119CC777fa900bA034cd52',
}; };

View File

@ -35,7 +35,7 @@ import {
} from '../types'; } from '../types';
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory'; import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
import { MockTokenMap } from './contracts-helpers'; import { MockTokenMap } from './contracts-helpers';
import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils'; import { DRE, getDb, notFalsyOrZeroAddress, omit } from './misc-utils';
import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types'; import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types';
export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0]; export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0];
@ -168,15 +168,30 @@ export const getAllMockedTokens = async () => {
return tokens; return tokens;
}; };
export const getQuoteCurrencies = (oracleQuoteCurrency: string): string[] => {
switch (oracleQuoteCurrency) {
case 'USD':
return ['USD'];
case 'ETH':
case 'WETH':
default:
return ['ETH', 'WETH'];
}
};
export const getPairsTokenAggregator = ( export const getPairsTokenAggregator = (
allAssetsAddresses: { allAssetsAddresses: {
[tokenSymbol: string]: tEthereumAddress; [tokenSymbol: string]: tEthereumAddress;
}, },
aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress } aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress },
oracleQuoteCurrency: string
): [string[], string[]] => { ): [string[], string[]] => {
const { ETH, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses; const assetsWithoutQuoteCurrency = omit(
allAssetsAddresses,
getQuoteCurrencies(oracleQuoteCurrency)
);
const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => { const pairs = Object.entries(assetsWithoutQuoteCurrency).map(([tokenSymbol, tokenAddress]) => {
//if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) { //if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) {
const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex( const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
(value) => value === tokenSymbol (value) => value === tokenSymbol

View File

@ -27,7 +27,7 @@ import { getFirstSigner, getIErc20Detailed } from './contracts-getters';
import { usingTenderly, verifyAtTenderly } from './tenderly-utils'; import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
import { usingPolygon, verifyAtPolygon } from './polygon-utils'; import { usingPolygon, verifyAtPolygon } from './polygon-utils';
import { ConfigNames, loadPoolConfig } from './configuration'; import { ConfigNames, loadPoolConfig } from './configuration';
import { ZERO_ADDRESS } from './constants'; import { USD_ADDRESS, ZERO_ADDRESS } from './constants';
import { RewardsTokenFactory, RewardsATokenMockFactory } from '../types'; import { RewardsTokenFactory, RewardsATokenMockFactory } from '../types';
export type MockTokenMap = { [symbol: string]: MintableERC20 }; export type MockTokenMap = { [symbol: string]: MintableERC20 };
@ -185,7 +185,10 @@ export const getOptionalParamAddressPerNetwork = (
return getParamPerNetwork(param, network); return getParamPerNetwork(param, network);
}; };
export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, pool: AavePools) => { export const getParamPerPool = <T>(
{ proto, amm, matic, usd }: iParamsPerPool<T>,
pool: AavePools
) => {
switch (pool) { switch (pool) {
case AavePools.proto: case AavePools.proto:
return proto; return proto;
@ -193,6 +196,8 @@ export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, poo
return amm; return amm;
case AavePools.matic: case AavePools.matic:
return matic; return matic;
case AavePools.usd:
return usd;
default: default:
return proto; return proto;
} }

View File

@ -143,6 +143,7 @@ export const initReservesByHelper = async (
console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`); console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`);
for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) { for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) {
console.log(chunkedInitInputParams[chunkIndex]);
const tx3 = await waitForTx( const tx3 = await waitForTx(
await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex]) await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex])
); );

View File

@ -129,3 +129,9 @@ export const impersonateAddress = async (address: tEthereumAddress): Promise<Sig
address, address,
}; };
}; };
export const omit = <T, U extends keyof T>(obj: T, keys: U[]): Omit<T, U> =>
(Object.keys(obj) as U[]).reduce(
(acc, curr) => (keys.includes(curr) ? acc : { ...acc, [curr]: obj[curr] }),
{} as Omit<T, U>
);

View File

@ -38,6 +38,7 @@ export enum AavePools {
proto = 'proto', proto = 'proto',
matic = 'matic', matic = 'matic',
amm = 'amm', amm = 'amm',
usd = 'usd',
} }
export enum eContractid { export enum eContractid {
@ -243,10 +244,8 @@ export interface iAssetBase<T> {
xSUSHI: T; xSUSHI: T;
STAKE: T; STAKE: T;
REW: T; REW: T;
'3Crv': T; 'a3CRV-gauge': T;
'cDAI+cUSDC': T; 'saCRV-gauge': T;
a3CRV: T;
saCRV: T;
} }
export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>; export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>;
@ -305,7 +304,7 @@ export type iLpPoolAssets<T> = Pick<
export type iUsdLpPoolAssets<T> = Pick< export type iUsdLpPoolAssets<T> = Pick<
iAssetsWithoutUSD<T>, iAssetsWithoutUSD<T>,
'WETH' | 'WBTC' | 'DAI' | 'SUSD' | 'USDC' | 'USDT' | '3Crv' | 'cDAI+cUSDC' | 'a3CRV' | 'saCRV' 'WETH' | 'WBTC' | 'DAI' | 'SUSD' | 'USDC' | 'USDT' | 'a3CRV-gauge' | 'saCRV-gauge'
>; >;
export type iMaticPoolAssets<T> = Pick< export type iMaticPoolAssets<T> = Pick<
@ -438,6 +437,7 @@ export interface iParamsPerPool<T> {
[AavePools.proto]: T; [AavePools.proto]: T;
[AavePools.matic]: T; [AavePools.matic]: T;
[AavePools.amm]: T; [AavePools.amm]: T;
[AavePools.usd]: T;
} }
export interface iBasicDistributionParams { export interface iBasicDistributionParams {
@ -508,6 +508,7 @@ export interface IBaseConfiguration {
StableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>; StableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>;
VariableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>; VariableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>;
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>; ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
OracleQuoteCurrency: string;
} }
export interface ICommonConfiguration extends IBaseConfiguration { export interface ICommonConfiguration extends IBaseConfiguration {
@ -544,4 +545,4 @@ export interface ITokenAddress {
[token: string]: tEthereumAddress; [token: string]: tEthereumAddress;
} }
export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration; export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration | IUsdAmmConfiguration;

View File

@ -12,6 +12,7 @@ export const CommonsConfig: ICommonConfiguration = {
VariableDebtTokenNamePrefix: 'Aave variable debt bearing', VariableDebtTokenNamePrefix: 'Aave variable debt bearing',
SymbolPrefix: '', SymbolPrefix: '',
ProviderId: 0, // Overriden in index.ts ProviderId: 0, // Overriden in index.ts
OracleQuoteCurrency: 'ETH',
ProtocolGlobalParams: { ProtocolGlobalParams: {
TokenDistributorPercentageBase: '10000', TokenDistributorPercentageBase: '10000',
MockUsdPriceInWei: '5848466240000000', MockUsdPriceInWei: '5848466240000000',

View File

@ -19,6 +19,7 @@ export const CommonsConfig: ICommonConfiguration = {
VariableDebtTokenNamePrefix: 'Aave AMM Market variable debt', VariableDebtTokenNamePrefix: 'Aave AMM Market variable debt',
SymbolPrefix: 'Amm', SymbolPrefix: 'Amm',
ProviderId: 0, // Overriden in index.ts ProviderId: 0, // Overriden in index.ts
OracleQuoteCurrency: 'ETH',
ProtocolGlobalParams: { ProtocolGlobalParams: {
TokenDistributorPercentageBase: '10000', TokenDistributorPercentageBase: '10000',
MockUsdPriceInWei: '5848466240000000', MockUsdPriceInWei: '5848466240000000',

View File

@ -19,6 +19,7 @@ export const CommonsConfig: ICommonConfiguration = {
VariableDebtTokenNamePrefix: 'Aave Matic Market variable debt', VariableDebtTokenNamePrefix: 'Aave Matic Market variable debt',
SymbolPrefix: 'm', SymbolPrefix: 'm',
ProviderId: 0, // Overriden in index.ts ProviderId: 0, // Overriden in index.ts
OracleQuoteCurrency: 'ETH',
ProtocolGlobalParams: { ProtocolGlobalParams: {
TokenDistributorPercentageBase: '10000', TokenDistributorPercentageBase: '10000',
MockUsdPriceInWei: '5848466240000000', MockUsdPriceInWei: '5848466240000000',

View File

@ -20,11 +20,12 @@ import {
export const AmmConfig: IUsdAmmConfiguration = { export const AmmConfig: IUsdAmmConfiguration = {
MarketId: 'Aave AMM market', MarketId: 'Aave AMM market',
ProviderId: 3, ProviderId: 4,
ATokenNamePrefix: 'Aave USD AMM Market', ATokenNamePrefix: 'Aave USD AMM Market',
StableDebtTokenNamePrefix: 'Aave USD AMM Market stable debt', StableDebtTokenNamePrefix: 'Aave USD AMM Market stable debt',
VariableDebtTokenNamePrefix: 'Aave USD AMM Market variable debt', VariableDebtTokenNamePrefix: 'Aave USD AMM Market variable debt',
SymbolPrefix: 'usdAmm', SymbolPrefix: 'usdAmm',
OracleQuoteCurrency: 'USD',
ProtocolGlobalParams: { ProtocolGlobalParams: {
TokenDistributorPercentageBase: '10000', TokenDistributorPercentageBase: '10000',
MockUsdPriceInWei: '10000000', MockUsdPriceInWei: '10000000',
@ -173,10 +174,8 @@ export const AmmConfig: IUsdAmmConfiguration = {
SUSD: '0xad35Bd71b9aFE6e4bDc266B345c198eaDEf9Ad94', SUSD: '0xad35Bd71b9aFE6e4bDc266B345c198eaDEf9Ad94',
USDC: '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6', USDC: '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6',
USDT: '0x3E7d1eAB13ad0104d2750B8863b489D65364e32D', USDT: '0x3E7d1eAB13ad0104d2750B8863b489D65364e32D',
'3Crv': ZERO_ADDRESS, 'a3CRV-gauge': ZERO_ADDRESS,
'cDAI+cUSDC': ZERO_ADDRESS, 'saCRV-gauge': ZERO_ADDRESS,
a3CRV: ZERO_ADDRESS,
saCRV: ZERO_ADDRESS,
}, },
[eEthereumNetwork.tenderlyMain]: { [eEthereumNetwork.tenderlyMain]: {
WETH: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e', WETH: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
@ -185,10 +184,8 @@ export const AmmConfig: IUsdAmmConfiguration = {
SUSD: '0xad35Bd71b9aFE6e4bDc266B345c198eaDEf9Ad94', SUSD: '0xad35Bd71b9aFE6e4bDc266B345c198eaDEf9Ad94',
USDC: '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6', USDC: '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6',
USDT: '0x3E7d1eAB13ad0104d2750B8863b489D65364e32D', USDT: '0x3E7d1eAB13ad0104d2750B8863b489D65364e32D',
'3Crv': ZERO_ADDRESS, 'a3CRV-gauge': ZERO_ADDRESS,
'cDAI+cUSDC': ZERO_ADDRESS, 'saCRV-gauge': ZERO_ADDRESS,
a3CRV: ZERO_ADDRESS,
saCRV: ZERO_ADDRESS,
}, },
}, },
ATokenDomainSeparator: { ATokenDomainSeparator: {
@ -246,10 +243,8 @@ export const AmmConfig: IUsdAmmConfiguration = {
SUSD: strategySUSD, SUSD: strategySUSD,
USDC: strategyUSDC, USDC: strategyUSDC,
USDT: strategyUSDT, USDT: strategyUSDT,
'3Crv': strategyCurveLP, 'a3CRV-gauge': strategyCurveLP,
'cDAI+cUSDC': strategyCurveLP, 'saCRV-gauge': strategyCurveLP,
a3CRV: strategyCurveLP,
saCRV: strategyCurveLP,
}, },
ReserveAssets: { ReserveAssets: {
[eEthereumNetwork.buidlerevm]: {}, [eEthereumNetwork.buidlerevm]: {},
@ -264,10 +259,8 @@ export const AmmConfig: IUsdAmmConfiguration = {
SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51', SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51',
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7', USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
'3Crv': '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', 'a3CRV-gauge': '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d',
'cDAI+cUSDC': '0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2', 'saCRV-gauge': '0x462253b8F74B72304c145DB0e4Eebd326B22ca39',
a3CRV: '0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900',
saCRV: '0x02d341CcB60fAaf662bC0554d13778015d1b285C',
}, },
[eEthereumNetwork.tenderlyMain]: { [eEthereumNetwork.tenderlyMain]: {
WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
@ -276,10 +269,8 @@ export const AmmConfig: IUsdAmmConfiguration = {
SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51', SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51',
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7', USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
'3Crv': '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', 'a3CRV-gauge': '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d',
'cDAI+cUSDC': '0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2', 'saCRV-gauge': '0x462253b8F74B72304c145DB0e4Eebd326B22ca39',
a3CRV: '0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900',
saCRV: '0x02d341CcB60fAaf662bC0554d13778015d1b285C',
}, },
}, },
}; };

View File

@ -19,6 +19,7 @@ export const CommonsConfig: ICommonConfiguration = {
VariableDebtTokenNamePrefix: 'Aave XDAI Market variable debt', VariableDebtTokenNamePrefix: 'Aave XDAI Market variable debt',
SymbolPrefix: 'm', SymbolPrefix: 'm',
ProviderId: 0, // Overriden in index.ts ProviderId: 0, // Overriden in index.ts
OracleQuoteCurrency: 'ETH',
ProtocolGlobalParams: { ProtocolGlobalParams: {
TokenDistributorPercentageBase: '10000', TokenDistributorPercentageBase: '10000',
MockUsdPriceInWei: '5848466240000000', MockUsdPriceInWei: '5848466240000000',

View File

@ -32,11 +32,13 @@
"matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic --skip-registry", "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic --skip-registry",
"matic:matic:full:migration": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic --skip-registry", "matic:matic:full:migration": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic --skip-registry",
"amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --skip-registry", "amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --skip-registry",
"usd:main:full:migration": "npm run compile && npm run hardhat:main -- usd:mainnet --skip-registry",
"aave:docker:full:migration:add-registry": "npm run compile && npm run hardhat:docker -- aave:mainnet", "aave:docker:full:migration:add-registry": "npm run compile && npm run hardhat:docker -- aave:mainnet",
"aave:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- aave:mainnet", "aave:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- aave:mainnet",
"matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic", "matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic",
"matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic", "matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic",
"amm:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- amm:mainnet", "amm:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- amm:mainnet",
"usd:main:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- usd:mainnet",
"aave:docker:add-market-to-registry-from-config": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave", "aave:docker:add-market-to-registry-from-config": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave",
"aave:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave", "aave:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave",
"matic:mumbai:add-market-to-registry-from-config": "npm run compile && npm run hardhat:mumbai add-market-to-registry --pool Matic", "matic:mumbai:add-market-to-registry-from-config": "npm run compile && npm run hardhat:mumbai add-market-to-registry --pool Matic",
@ -51,6 +53,7 @@
"aave:main:add-market-to-new-registry": "npm run compile && npm run hardhat:matic -- add-market-to-registry --pool Matic --verify --deploy-registry", "aave:main:add-market-to-new-registry": "npm run compile && npm run hardhat:matic -- add-market-to-registry --pool Matic --verify --deploy-registry",
"aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave", "aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave",
"aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify", "aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify",
"usd:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- usd:mainnet --skip-registry",
"aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet", "aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet",
"aave:fork:main": "npm run compile && FORK=main hardhat aave:mainnet", "aave:fork:main": "npm run compile && FORK=main hardhat aave:mainnet",
"aave:fork:kovan": "npm run compile && FORK=kovan hardhat aave:mainnet", "aave:fork:kovan": "npm run compile && FORK=kovan hardhat aave:mainnet",

View File

@ -29,6 +29,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
Mocks: { AllAssetsInitialPrices }, Mocks: { AllAssetsInitialPrices },
ProtocolGlobalParams: { UsdAddress, MockUsdPriceInWei }, ProtocolGlobalParams: { UsdAddress, MockUsdPriceInWei },
LendingRateOracleRatesCommon, LendingRateOracleRatesCommon,
OracleQuoteCurrency,
} = poolConfig as ICommonConfiguration; } = poolConfig as ICommonConfiguration;
const defaultTokenList = { const defaultTokenList = {
@ -54,7 +55,8 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
const [tokens, aggregators] = getPairsTokenAggregator( const [tokens, aggregators] = getPairsTokenAggregator(
allTokenAddresses, allTokenAddresses,
allAggregatorsAddresses allAggregatorsAddresses,
OracleQuoteCurrency
); );
await deployAaveOracle( await deployAaveOracle(

View File

@ -46,7 +46,11 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
...reserveAssets, ...reserveAssets,
USD: UsdAddress, USD: UsdAddress,
}; };
const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators); const [tokens, aggregators] = getPairsTokenAggregator(
tokensToWatch,
chainlinkAggregators,
poolConfig.OracleQuoteCurrency
);
let aaveOracle: AaveOracle; let aaveOracle: AaveOracle;
let lendingRateOracle: LendingRateOracle; let lendingRateOracle: LendingRateOracle;

View File

@ -0,0 +1,57 @@
import { task } from 'hardhat/config';
import { checkVerification } from '../../helpers/etherscan-verification';
import { ConfigNames } from '../../helpers/configuration';
import { printContracts } from '../../helpers/misc-utils';
import { usingTenderly } from '../../helpers/tenderly-utils';
task('usd:mainnet', 'Deploy development enviroment')
.addFlag('verify', 'Verify contracts at Etherscan')
.addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry')
.setAction(async ({ verify, skipRegistry }, DRE) => {
const POOL_NAME = ConfigNames.Usd;
await DRE.run('set-DRE');
// Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) {
checkVerification();
}
console.log('Migration started\n');
console.log('1. Deploy address provider');
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry });
console.log('2. Deploy lending pool');
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
console.log('3. Deploy oracles');
await DRE.run('full:deploy-oracles', { pool: POOL_NAME });
console.log('4. Deploy Data Provider');
await DRE.run('full:data-provider', { pool: POOL_NAME });
console.log('5. Deploy WETH Gateway');
await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME });
console.log('6. Initialize lending pool');
await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME });
if (verify) {
printContracts();
console.log('7. Veryfing contracts');
await DRE.run('verify:general', { all: true, pool: POOL_NAME });
console.log('8. Veryfing aTokens and debtTokens');
await DRE.run('verify:tokens', { pool: POOL_NAME });
}
if (usingTenderly()) {
const postDeployHead = DRE.tenderlyRPC.getHead();
const postDeployFork = DRE.tenderlyRPC.getFork();
console.log('Tenderly Info');
console.log('- Head', postDeployHead);
console.log('- Fork', postDeployFork);
}
console.log('\nFinished migrations');
printContracts();
});

View File

@ -0,0 +1,30 @@
import { task } from 'hardhat/config';
import { getAaveOracle } from '../../helpers/contracts-getters';
import { waitForTx } from '../../helpers/misc-utils';
import { usingTenderly } from '../../helpers/tenderly-utils';
task('dev:set-price-providers-to-aave-oracle', 'Set price providers ')
.addParam('aaveOracle', 'Aave Oracle where you are the owner')
.addParam('tokens', 'Token addresses separated by comma')
.addParam('priceProviders', 'Token address price providers separated by comma')
.setAction(async ({ aaveOracle, tokens, priceProviders }, localBRE) => {
await localBRE.run('set-DRE');
const oracle = await getAaveOracle(aaveOracle);
const tokenAddresses = tokens.split(',');
const priceProviderAddresses = priceProviders.split(',');
await waitForTx(await oracle.setAssetSources(tokenAddresses, priceProviderAddresses));
console.log('- Set asset sources for AaveOracle:');
tokenAddresses.forEach((element, i) => {
console.log(' Asset:', element);
console.log(' Source:', priceProviderAddresses[i]);
});
if (usingTenderly()) {
const postDeployHead = localBRE.tenderlyRPC.getHead();
const postDeployFork = localBRE.tenderlyRPC.getFork();
console.log('Tenderly Info');
console.log('- Head', postDeployHead);
console.log('- Fork', postDeployFork);
}
});

View File

@ -220,7 +220,11 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
{} {}
); );
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses); const [tokens, aggregators] = getPairsTokenAggregator(
allTokenAddresses,
allAggregatorsAddresses,
config.OracleQuoteCurrency
);
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]); await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address)); await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));

View File

@ -220,7 +220,11 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
{} {}
); );
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses); const [tokens, aggregators] = getPairsTokenAggregator(
allTokenAddresses,
allAggregatorsAddresses,
config.OracleQuoteCurrency
);
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]); await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address)); await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));