mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: Add Avalanche network configuration
This commit is contained in:
parent
ca74be898b
commit
a0a6210902
|
@ -3,7 +3,13 @@ import fs from 'fs';
|
||||||
import { HardhatUserConfig } from 'hardhat/types';
|
import { HardhatUserConfig } from 'hardhat/types';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { accounts } from './test-wallets.js';
|
import { accounts } from './test-wallets.js';
|
||||||
import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
|
import {
|
||||||
|
eAvalancheNetwork,
|
||||||
|
eEthereumNetwork,
|
||||||
|
eNetwork,
|
||||||
|
ePolygonNetwork,
|
||||||
|
eXDaiNetwork,
|
||||||
|
} from './helpers/types';
|
||||||
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
|
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
|
||||||
import {
|
import {
|
||||||
NETWORKS_RPC_URL,
|
NETWORKS_RPC_URL,
|
||||||
|
@ -100,6 +106,8 @@ const buidlerConfig: HardhatUserConfig = {
|
||||||
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
|
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
|
||||||
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
|
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
|
||||||
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
|
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
|
||||||
|
avalanche: getCommonNetworkConfig(eAvalancheNetwork.avalanche, 43114),
|
||||||
|
fuji: getCommonNetworkConfig(eAvalancheNetwork.fuji, 43113),
|
||||||
hardhat: {
|
hardhat: {
|
||||||
hardfork: 'berlin',
|
hardfork: 'berlin',
|
||||||
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
|
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types';
|
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types';
|
||||||
import {
|
import {
|
||||||
|
eAvalancheNetwork,
|
||||||
eEthereumNetwork,
|
eEthereumNetwork,
|
||||||
ePolygonNetwork,
|
ePolygonNetwork,
|
||||||
eXDaiNetwork,
|
eXDaiNetwork,
|
||||||
|
@ -49,6 +50,8 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
|
||||||
[ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com',
|
[ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com',
|
||||||
[ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network',
|
[ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network',
|
||||||
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
|
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
|
||||||
|
[eAvalancheNetwork.avalanche]: 'https://cchain.explorer.avax.network/',
|
||||||
|
[eAvalancheNetwork.fuji]: 'https://api.avax-test.network/ext/bc/C/rpc'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
|
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
|
||||||
|
@ -62,6 +65,8 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
|
||||||
[ePolygonNetwork.mumbai]: 1 * GWEI,
|
[ePolygonNetwork.mumbai]: 1 * GWEI,
|
||||||
[ePolygonNetwork.matic]: 1 * GWEI,
|
[ePolygonNetwork.matic]: 1 * GWEI,
|
||||||
[eXDaiNetwork.xdai]: 1 * GWEI,
|
[eXDaiNetwork.xdai]: 1 * GWEI,
|
||||||
|
[eAvalancheNetwork.avalanche]: 255 * GWEI,
|
||||||
|
[eAvalancheNetwork.fuji]: 255 * GWEI
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
|
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
|
||||||
|
@ -75,4 +80,6 @@ export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
|
||||||
[ePolygonNetwork.mumbai]: undefined,
|
[ePolygonNetwork.mumbai]: undefined,
|
||||||
[ePolygonNetwork.matic]: undefined,
|
[ePolygonNetwork.matic]: undefined,
|
||||||
[eXDaiNetwork.xdai]: undefined,
|
[eXDaiNetwork.xdai]: undefined,
|
||||||
|
[eAvalancheNetwork.avalanche]: undefined,
|
||||||
|
[eAvalancheNetwork.fuji]: undefined
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {
|
||||||
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
|
import { getEthersSignersAddresses, 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 AvalancheConfig from '../markets/avalanche';
|
||||||
import AmmConfig from '../markets/amm';
|
import AmmConfig from '../markets/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';
|
||||||
|
@ -21,6 +22,7 @@ export enum ConfigNames {
|
||||||
Aave = 'Aave',
|
Aave = 'Aave',
|
||||||
Matic = 'Matic',
|
Matic = 'Matic',
|
||||||
Amm = 'Amm',
|
Amm = 'Amm',
|
||||||
|
Avalanche = 'Avalanche'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
|
export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
|
||||||
|
@ -31,6 +33,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
|
||||||
return MaticConfig;
|
return MaticConfig;
|
||||||
case ConfigNames.Amm:
|
case ConfigNames.Amm:
|
||||||
return AmmConfig;
|
return AmmConfig;
|
||||||
|
case ConfigNames.Avalanche:
|
||||||
|
return AvalancheConfig;
|
||||||
case ConfigNames.Commons:
|
case ConfigNames.Commons:
|
||||||
return CommonsConfig;
|
return CommonsConfig;
|
||||||
default:
|
default:
|
||||||
|
@ -54,6 +58,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
||||||
[AavePools.matic]: {
|
[AavePools.matic]: {
|
||||||
...MaticConfig.ReservesConfig,
|
...MaticConfig.ReservesConfig,
|
||||||
},
|
},
|
||||||
|
[AavePools.avalanche]: {
|
||||||
|
...AvalancheConfig.ReservesConfig,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
pool
|
pool
|
||||||
);
|
);
|
||||||
|
|
|
@ -69,5 +69,6 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
|
||||||
WMATIC: oneEther.multipliedBy('0.003620948469').toFixed(),
|
WMATIC: oneEther.multipliedBy('0.003620948469').toFixed(),
|
||||||
STAKE: oneEther.multipliedBy('0.003620948469').toFixed(),
|
STAKE: oneEther.multipliedBy('0.003620948469').toFixed(),
|
||||||
xSUSHI: oneEther.multipliedBy('0.00913428586').toFixed(),
|
xSUSHI: oneEther.multipliedBy('0.00913428586').toFixed(),
|
||||||
|
AVAX: oneEther.multipliedBy('0.006051936629').toFixed(),
|
||||||
USD: '5848466240000000',
|
USD: '5848466240000000',
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,8 @@ import {
|
||||||
iEthereumParamsPerNetwork,
|
iEthereumParamsPerNetwork,
|
||||||
iPolygonParamsPerNetwork,
|
iPolygonParamsPerNetwork,
|
||||||
iXDaiParamsPerNetwork,
|
iXDaiParamsPerNetwork,
|
||||||
|
iAvalancheParamsPerNetwork,
|
||||||
|
eAvalancheNetwork,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { MintableERC20 } from '../types/MintableERC20';
|
import { MintableERC20 } from '../types/MintableERC20';
|
||||||
import { Artifact } from 'hardhat/types';
|
import { Artifact } from 'hardhat/types';
|
||||||
|
@ -142,16 +144,11 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
|
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
|
||||||
const {
|
const { main, ropsten, kovan, coverage, buidlerevm, tenderlyMain } =
|
||||||
main,
|
param as iEthereumParamsPerNetwork<T>;
|
||||||
ropsten,
|
|
||||||
kovan,
|
|
||||||
coverage,
|
|
||||||
buidlerevm,
|
|
||||||
tenderlyMain,
|
|
||||||
} = param as iEthereumParamsPerNetwork<T>;
|
|
||||||
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
|
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
|
||||||
const { xdai } = param as iXDaiParamsPerNetwork<T>;
|
const { xdai } = param as iXDaiParamsPerNetwork<T>;
|
||||||
|
const { avalanche, fuji } = param as iAvalancheParamsPerNetwork<T>;
|
||||||
if (process.env.FORK) {
|
if (process.env.FORK) {
|
||||||
return param[process.env.FORK as eNetwork] as T;
|
return param[process.env.FORK as eNetwork] as T;
|
||||||
}
|
}
|
||||||
|
@ -177,10 +174,14 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
|
||||||
return mumbai;
|
return mumbai;
|
||||||
case eXDaiNetwork.xdai:
|
case eXDaiNetwork.xdai:
|
||||||
return xdai;
|
return xdai;
|
||||||
|
case eAvalancheNetwork.avalanche:
|
||||||
|
return avalanche;
|
||||||
|
case eAvalancheNetwork.fuji:
|
||||||
|
return fuji;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, pool: AavePools) => {
|
export const getParamPerPool = <T>({ proto, amm, matic, avalanche }: iParamsPerPool<T>, pool: AavePools) => {
|
||||||
switch (pool) {
|
switch (pool) {
|
||||||
case AavePools.proto:
|
case AavePools.proto:
|
||||||
return proto;
|
return proto;
|
||||||
|
@ -188,6 +189,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.avalanche:
|
||||||
|
return avalanche;
|
||||||
default:
|
default:
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,7 +349,7 @@ export const configureReservesByHelper = async (
|
||||||
for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) {
|
for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) {
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex], {
|
await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex], {
|
||||||
gasLimit: 12000000,
|
gasLimit: 8000000, // TODO: Change this
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
||||||
|
|
|
@ -4,7 +4,7 @@ export interface SymbolMap<T> {
|
||||||
[symbol: string]: T;
|
[symbol: string]: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type eNetwork = eEthereumNetwork | ePolygonNetwork | eXDaiNetwork;
|
export type eNetwork = eEthereumNetwork | ePolygonNetwork | eXDaiNetwork | eAvalancheNetwork;
|
||||||
|
|
||||||
export enum eEthereumNetwork {
|
export enum eEthereumNetwork {
|
||||||
buidlerevm = 'buidlerevm',
|
buidlerevm = 'buidlerevm',
|
||||||
|
@ -25,6 +25,11 @@ export enum eXDaiNetwork {
|
||||||
xdai = 'xdai',
|
xdai = 'xdai',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum eAvalancheNetwork {
|
||||||
|
avalanche = 'avalanche',
|
||||||
|
fuji = 'fuji',
|
||||||
|
}
|
||||||
|
|
||||||
export enum EthereumNetworkNames {
|
export enum EthereumNetworkNames {
|
||||||
kovan = 'kovan',
|
kovan = 'kovan',
|
||||||
ropsten = 'ropsten',
|
ropsten = 'ropsten',
|
||||||
|
@ -32,12 +37,16 @@ export enum EthereumNetworkNames {
|
||||||
matic = 'matic',
|
matic = 'matic',
|
||||||
mumbai = 'mumbai',
|
mumbai = 'mumbai',
|
||||||
xdai = 'xdai',
|
xdai = 'xdai',
|
||||||
|
avalanche = 'avalanche',
|
||||||
|
fuji = 'fuji'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AavePools {
|
export enum AavePools {
|
||||||
proto = 'proto',
|
proto = 'proto',
|
||||||
matic = 'matic',
|
matic = 'matic',
|
||||||
amm = 'amm',
|
amm = 'amm',
|
||||||
|
avalanche = 'avalanche'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum eContractid {
|
export enum eContractid {
|
||||||
|
@ -239,6 +248,7 @@ export interface iAssetBase<T> {
|
||||||
WMATIC: T;
|
WMATIC: T;
|
||||||
STAKE: T;
|
STAKE: T;
|
||||||
xSUSHI: T;
|
xSUSHI: T;
|
||||||
|
AVAX: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>;
|
export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>;
|
||||||
|
@ -305,6 +315,11 @@ export type iXDAIPoolAssets<T> = Pick<
|
||||||
'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'STAKE'
|
'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'STAKE'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
export type iAvalanchePoolAssets<T> = Pick<
|
||||||
|
iAssetsWithoutUSD<T>,
|
||||||
|
'WETH' | 'DAI' | 'USDC' | 'USDT' | 'AAVE' | 'WBTC' | 'AVAX'
|
||||||
|
>;
|
||||||
|
|
||||||
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;
|
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;
|
||||||
|
|
||||||
export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>;
|
export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>;
|
||||||
|
@ -352,6 +367,7 @@ export enum TokenContractId {
|
||||||
WMATIC = 'WMATIC',
|
WMATIC = 'WMATIC',
|
||||||
STAKE = 'STAKE',
|
STAKE = 'STAKE',
|
||||||
xSUSHI = 'xSUSHI',
|
xSUSHI = 'xSUSHI',
|
||||||
|
AVAX = 'AVAX'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {
|
export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {
|
||||||
|
@ -394,7 +410,8 @@ export interface IMarketRates {
|
||||||
export type iParamsPerNetwork<T> =
|
export type iParamsPerNetwork<T> =
|
||||||
| iEthereumParamsPerNetwork<T>
|
| iEthereumParamsPerNetwork<T>
|
||||||
| iPolygonParamsPerNetwork<T>
|
| iPolygonParamsPerNetwork<T>
|
||||||
| iXDaiParamsPerNetwork<T>;
|
| iXDaiParamsPerNetwork<T>
|
||||||
|
| iAvalancheParamsPerNetwork<T>;
|
||||||
|
|
||||||
export interface iParamsPerNetworkAll<T>
|
export interface iParamsPerNetworkAll<T>
|
||||||
extends iEthereumParamsPerNetwork<T>,
|
extends iEthereumParamsPerNetwork<T>,
|
||||||
|
@ -420,10 +437,16 @@ export interface iXDaiParamsPerNetwork<T> {
|
||||||
[eXDaiNetwork.xdai]: T;
|
[eXDaiNetwork.xdai]: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface iAvalancheParamsPerNetwork<T> {
|
||||||
|
[eAvalancheNetwork.avalanche]: T;
|
||||||
|
[eAvalancheNetwork.fuji]: T;
|
||||||
|
}
|
||||||
|
|
||||||
export interface iParamsPerPool<T> {
|
export interface iParamsPerPool<T> {
|
||||||
[AavePools.proto]: T;
|
[AavePools.proto]: T;
|
||||||
[AavePools.matic]: T;
|
[AavePools.matic]: T;
|
||||||
[AavePools.amm]: T;
|
[AavePools.amm]: T;
|
||||||
|
[AavePools.avalanche]: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface iBasicDistributionParams {
|
export interface iBasicDistributionParams {
|
||||||
|
@ -512,6 +535,10 @@ export interface IXDAIConfiguration extends ICommonConfiguration {
|
||||||
ReservesConfig: iXDAIPoolAssets<IReserveParams>;
|
ReservesConfig: iXDAIPoolAssets<IReserveParams>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IAvalancheConfiguration extends ICommonConfiguration {
|
||||||
|
ReservesConfig: iAvalanchePoolAssets<IReserveParams>;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ITokenAddress {
|
export interface ITokenAddress {
|
||||||
[token: string]: tEthereumAddress;
|
[token: string]: tEthereumAddress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
USD: USD_ADDRESS,
|
USD: USD_ADDRESS,
|
||||||
STAKE: mockTokens.STAKE.address,
|
STAKE: mockTokens.STAKE.address,
|
||||||
xSUSHI: mockTokens.xSUSHI.address,
|
xSUSHI: mockTokens.xSUSHI.address,
|
||||||
|
AVAX: mockTokens.AVAX.address
|
||||||
},
|
},
|
||||||
fallbackOracle
|
fallbackOracle
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user