Skip to content

Commit a0a6210

Browse files
committed
feat: Add Avalanche network configuration
1 parent ca74be8 commit a0a6210

File tree

8 files changed

+67
-13
lines changed

8 files changed

+67
-13
lines changed

hardhat.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import fs from 'fs';
33
import { HardhatUserConfig } from 'hardhat/types';
44
// @ts-ignore
55
import { accounts } from './test-wallets.js';
6-
import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
6+
import {
7+
eAvalancheNetwork,
8+
eEthereumNetwork,
9+
eNetwork,
10+
ePolygonNetwork,
11+
eXDaiNetwork,
12+
} from './helpers/types';
713
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
814
import {
915
NETWORKS_RPC_URL,
@@ -100,6 +106,8 @@ const buidlerConfig: HardhatUserConfig = {
100106
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
101107
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
102108
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
109+
avalanche: getCommonNetworkConfig(eAvalancheNetwork.avalanche, 43114),
110+
fuji: getCommonNetworkConfig(eAvalancheNetwork.fuji, 43113),
103111
hardhat: {
104112
hardfork: 'berlin',
105113
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,

helper-hardhat-config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @ts-ignore
22
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types';
33
import {
4+
eAvalancheNetwork,
45
eEthereumNetwork,
56
ePolygonNetwork,
67
eXDaiNetwork,
@@ -49,6 +50,8 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
4950
[ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com',
5051
[ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network',
5152
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
53+
[eAvalancheNetwork.avalanche]: 'https://cchain.explorer.avax.network/',
54+
[eAvalancheNetwork.fuji]: 'https://api.avax-test.network/ext/bc/C/rpc'
5255
};
5356

5457
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
@@ -62,6 +65,8 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
6265
[ePolygonNetwork.mumbai]: 1 * GWEI,
6366
[ePolygonNetwork.matic]: 1 * GWEI,
6467
[eXDaiNetwork.xdai]: 1 * GWEI,
68+
[eAvalancheNetwork.avalanche]: 255 * GWEI,
69+
[eAvalancheNetwork.fuji]: 255 * GWEI
6570
};
6671

6772
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
@@ -75,4 +80,6 @@ export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
7580
[ePolygonNetwork.mumbai]: undefined,
7681
[ePolygonNetwork.matic]: undefined,
7782
[eXDaiNetwork.xdai]: undefined,
83+
[eAvalancheNetwork.avalanche]: undefined,
84+
[eAvalancheNetwork.fuji]: undefined
7885
};

helpers/configuration.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
1010
import AaveConfig from '../markets/aave';
1111
import MaticConfig from '../markets/matic';
12+
import AvalancheConfig from '../markets/avalanche';
1213
import AmmConfig from '../markets/amm';
1314
import { CommonsConfig } from '../markets/aave/commons';
1415
import { DRE, filterMapBy } from './misc-utils';
@@ -21,6 +22,7 @@ export enum ConfigNames {
2122
Aave = 'Aave',
2223
Matic = 'Matic',
2324
Amm = 'Amm',
25+
Avalanche = 'Avalanche'
2426
}
2527

2628
export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
@@ -31,6 +33,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
3133
return MaticConfig;
3234
case ConfigNames.Amm:
3335
return AmmConfig;
36+
case ConfigNames.Avalanche:
37+
return AvalancheConfig;
3438
case ConfigNames.Commons:
3539
return CommonsConfig;
3640
default:
@@ -54,6 +58,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
5458
[AavePools.matic]: {
5559
...MaticConfig.ReservesConfig,
5660
},
61+
[AavePools.avalanche]: {
62+
...AvalancheConfig.ReservesConfig,
63+
}
5764
},
5865
pool
5966
);

helpers/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
6969
WMATIC: oneEther.multipliedBy('0.003620948469').toFixed(),
7070
STAKE: oneEther.multipliedBy('0.003620948469').toFixed(),
7171
xSUSHI: oneEther.multipliedBy('0.00913428586').toFixed(),
72+
AVAX: oneEther.multipliedBy('0.006051936629').toFixed(),
7273
USD: '5848466240000000',
7374
};

helpers/contracts-helpers.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
iEthereumParamsPerNetwork,
1919
iPolygonParamsPerNetwork,
2020
iXDaiParamsPerNetwork,
21+
iAvalancheParamsPerNetwork,
22+
eAvalancheNetwork,
2123
} from './types';
2224
import { MintableERC20 } from '../types/MintableERC20';
2325
import { Artifact } from 'hardhat/types';
@@ -142,16 +144,11 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an
142144
};
143145

144146
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
145-
const {
146-
main,
147-
ropsten,
148-
kovan,
149-
coverage,
150-
buidlerevm,
151-
tenderlyMain,
152-
} = param as iEthereumParamsPerNetwork<T>;
147+
const { main, ropsten, kovan, coverage, buidlerevm, tenderlyMain } =
148+
param as iEthereumParamsPerNetwork<T>;
153149
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
154150
const { xdai } = param as iXDaiParamsPerNetwork<T>;
151+
const { avalanche, fuji } = param as iAvalancheParamsPerNetwork<T>;
155152
if (process.env.FORK) {
156153
return param[process.env.FORK as eNetwork] as T;
157154
}
@@ -177,17 +174,23 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
177174
return mumbai;
178175
case eXDaiNetwork.xdai:
179176
return xdai;
177+
case eAvalancheNetwork.avalanche:
178+
return avalanche;
179+
case eAvalancheNetwork.fuji:
180+
return fuji;
180181
}
181182
};
182183

183-
export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, pool: AavePools) => {
184+
export const getParamPerPool = <T>({ proto, amm, matic, avalanche }: iParamsPerPool<T>, pool: AavePools) => {
184185
switch (pool) {
185186
case AavePools.proto:
186187
return proto;
187188
case AavePools.amm:
188189
return amm;
189190
case AavePools.matic:
190191
return matic;
192+
case AavePools.avalanche:
193+
return avalanche;
191194
default:
192195
return proto;
193196
}

helpers/init-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export const configureReservesByHelper = async (
349349
for (let chunkIndex = 0; chunkIndex < chunkedInputParams.length; chunkIndex++) {
350350
await waitForTx(
351351
await atokenAndRatesDeployer.configureReserves(chunkedInputParams[chunkIndex], {
352-
gasLimit: 12000000,
352+
gasLimit: 8000000, // TODO: Change this
353353
})
354354
);
355355
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);

helpers/types.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface SymbolMap<T> {
44
[symbol: string]: T;
55
}
66

7-
export type eNetwork = eEthereumNetwork | ePolygonNetwork | eXDaiNetwork;
7+
export type eNetwork = eEthereumNetwork | ePolygonNetwork | eXDaiNetwork | eAvalancheNetwork;
88

99
export enum eEthereumNetwork {
1010
buidlerevm = 'buidlerevm',
@@ -25,19 +25,28 @@ export enum eXDaiNetwork {
2525
xdai = 'xdai',
2626
}
2727

28+
export enum eAvalancheNetwork {
29+
avalanche = 'avalanche',
30+
fuji = 'fuji',
31+
}
32+
2833
export enum EthereumNetworkNames {
2934
kovan = 'kovan',
3035
ropsten = 'ropsten',
3136
main = 'main',
3237
matic = 'matic',
3338
mumbai = 'mumbai',
3439
xdai = 'xdai',
40+
avalanche = 'avalanche',
41+
fuji = 'fuji'
42+
3543
}
3644

3745
export enum AavePools {
3846
proto = 'proto',
3947
matic = 'matic',
4048
amm = 'amm',
49+
avalanche = 'avalanche'
4150
}
4251

4352
export enum eContractid {
@@ -239,6 +248,7 @@ export interface iAssetBase<T> {
239248
WMATIC: T;
240249
STAKE: T;
241250
xSUSHI: T;
251+
AVAX: T;
242252
}
243253

244254
export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>;
@@ -305,6 +315,11 @@ export type iXDAIPoolAssets<T> = Pick<
305315
'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'STAKE'
306316
>;
307317

318+
export type iAvalanchePoolAssets<T> = Pick<
319+
iAssetsWithoutUSD<T>,
320+
'WETH' | 'DAI' | 'USDC' | 'USDT' | 'AAVE' | 'WBTC' | 'AVAX'
321+
>;
322+
308323
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;
309324

310325
export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>;
@@ -352,6 +367,7 @@ export enum TokenContractId {
352367
WMATIC = 'WMATIC',
353368
STAKE = 'STAKE',
354369
xSUSHI = 'xSUSHI',
370+
AVAX = 'AVAX'
355371
}
356372

357373
export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {
@@ -394,7 +410,8 @@ export interface IMarketRates {
394410
export type iParamsPerNetwork<T> =
395411
| iEthereumParamsPerNetwork<T>
396412
| iPolygonParamsPerNetwork<T>
397-
| iXDaiParamsPerNetwork<T>;
413+
| iXDaiParamsPerNetwork<T>
414+
| iAvalancheParamsPerNetwork<T>;
398415

399416
export interface iParamsPerNetworkAll<T>
400417
extends iEthereumParamsPerNetwork<T>,
@@ -420,10 +437,16 @@ export interface iXDaiParamsPerNetwork<T> {
420437
[eXDaiNetwork.xdai]: T;
421438
}
422439

440+
export interface iAvalancheParamsPerNetwork<T> {
441+
[eAvalancheNetwork.avalanche]: T;
442+
[eAvalancheNetwork.fuji]: T;
443+
}
444+
423445
export interface iParamsPerPool<T> {
424446
[AavePools.proto]: T;
425447
[AavePools.matic]: T;
426448
[AavePools.amm]: T;
449+
[AavePools.avalanche]: T;
427450
}
428451

429452
export interface iBasicDistributionParams {
@@ -512,6 +535,10 @@ export interface IXDAIConfiguration extends ICommonConfiguration {
512535
ReservesConfig: iXDAIPoolAssets<IReserveParams>;
513536
}
514537

538+
export interface IAvalancheConfiguration extends ICommonConfiguration {
539+
ReservesConfig: iAvalanchePoolAssets<IReserveParams>;
540+
}
541+
515542
export interface ITokenAddress {
516543
[token: string]: tEthereumAddress;
517544
}

test-suites/test-aave/__setup.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
191191
USD: USD_ADDRESS,
192192
STAKE: mockTokens.STAKE.address,
193193
xSUSHI: mockTokens.xSUSHI.address,
194+
AVAX: mockTokens.AVAX.address
194195
},
195196
fallbackOracle
196197
);

0 commit comments

Comments
 (0)