@gearbox-protocol/sdk 1.26.2 → 1.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { NetworkType } from "../core/chains";
2
+ import { AaveV2LPToken } from "../tokens/aave";
2
3
  import { ConvexStakedPhantomToken } from "../tokens/convex";
3
4
  import type { CurveLPToken } from "../tokens/curveLP";
4
5
  import { NormalToken } from "../tokens/normal";
@@ -9,7 +10,10 @@ export type UniswapV2Contract = "UNISWAP_V2_ROUTER" | "SUSHISWAP_ROUTER";
9
10
  export type CurvePoolContract = "CURVE_3CRV_POOL" | "CURVE_FRAX_USDC_POOL" | "CURVE_STETH_GATEWAY" | "CURVE_FRAX_POOL" | "CURVE_LUSD_POOL" | "CURVE_GUSD_POOL" | "CURVE_SUSD_POOL" | "CURVE_SUSD_DEPOSIT" | "CURVE_OHMFRAXBP_POOL" | "CURVE_CRVETH_POOL" | "CURVE_CVXETH_POOL" | "CURVE_3CRYPTO_POOL" | "CURVE_MIM_POOL" | "CURVE_LDOETH_POOL";
10
11
  export type YearnVaultContract = "YEARN_DAI_VAULT" | "YEARN_USDC_VAULT" | "YEARN_WETH_VAULT" | "YEARN_WBTC_VAULT" | "YEARN_CURVE_FRAX_VAULT" | "YEARN_CURVE_STETH_VAULT";
11
12
  export type ConvexPoolContract = "CONVEX_3CRV_POOL" | "CONVEX_FRAX_USDC_POOL" | "CONVEX_GUSD_POOL" | "CONVEX_SUSD_POOL" | "CONVEX_STECRV_POOL" | "CONVEX_FRAX3CRV_POOL" | "CONVEX_LUSD3CRV_POOL" | "CONVEX_OHMFRAXBP_POOL" | "CONVEX_MIM3CRV_POOL" | "CONVEX_CRVETH_POOL" | "CONVEX_CVXETH_POOL" | "CONVEX_3CRYPTO_POOL" | "CONVEX_LDOETH_POOL";
12
- export type SupportedContract = UniswapV2Contract | "UNISWAP_V3_ROUTER" | CurvePoolContract | "CURVE_GEAR_POOL" | YearnVaultContract | "CONVEX_BOOSTER" | ConvexPoolContract | "CONVEX_CLAIM_ZAP" | "LIDO_STETH_GATEWAY" | "LIDO_WSTETH" | "UNIVERSAL_ADAPTER" | "BALANCER_VAULT";
13
+ export type AaveV2PoolContract = "AAVE_V2_DAI_POOL" | "AAVE_V2_USDC_POOL" | "AAVE_V2_USDT_POOL" | "AAVE_V2_WETH_POOL";
14
+ export type AaveV2TokenWrapperContract = "AAVE_V2_DAI_TOKEN_WRAPPER" | "AAVE_V2_USDC_TOKEN_WRAPPER" | "AAVE_V2_USDT_TOKEN_WRAPPER" | "AAVE_V2_WETH_TOKEN_WRAPPER";
15
+ export type CompoundV2PoolContract = "COMPOUND_V2_DAI_POOL" | "COMPOUND_V2_USDC_POOL" | "COMPOUND_V2_USDT_POOL" | "COMPOUND_V2_WETH_POOL";
16
+ export type SupportedContract = UniswapV2Contract | "UNISWAP_V3_ROUTER" | CurvePoolContract | "CURVE_GEAR_POOL" | YearnVaultContract | "CONVEX_BOOSTER" | ConvexPoolContract | "CONVEX_CLAIM_ZAP" | "LIDO_STETH_GATEWAY" | "LIDO_WSTETH" | "UNIVERSAL_ADAPTER" | "BALANCER_VAULT" | AaveV2PoolContract | AaveV2TokenWrapperContract | CompoundV2PoolContract;
13
17
  export declare const contractsByNetwork: Record<NetworkType, Record<SupportedContract, string>>;
14
18
  export declare const UNISWAP_V3_QUOTER = "NOT DEPLOYED";
15
19
  export interface BaseContractParams {
@@ -83,7 +87,22 @@ export type BalancerParams = {
83
87
  protocol: Protocols.Balancer;
84
88
  type: AdapterInterface.BALANCER_VAULT;
85
89
  } & BaseContractParams;
86
- export type ContractParams = UniswapV2Params | UniswapV3Params | CurveParams | CurveSteCRVPoolParams | CurveGEARPoolParams | YearnParams | ConvexParams | ConvexPoolParams | LidoParams | LidoWsthETHParams | UniversalParams | BalancerParams;
90
+ export type AaveV2Params = {
91
+ protocol: Protocols.AaveV2;
92
+ type: AdapterInterface.AAVE_V2_LENDING_POOL;
93
+ underlying: NormalToken;
94
+ } & BaseContractParams;
95
+ export type WrapperAaveV2Params = {
96
+ protocol: Protocols.AaveV2;
97
+ type: AdapterInterface.AAVE_V2_WRAPPED_ATOKEN;
98
+ underlying: AaveV2LPToken;
99
+ } & BaseContractParams;
100
+ export type CompoundV2Params = {
101
+ protocol: Protocols.CompoundV2;
102
+ type: AdapterInterface.COMPOUND_V2_CERC20 | AdapterInterface.COMPOUND_V2_CETHER;
103
+ underlying: NormalToken;
104
+ } & BaseContractParams;
105
+ export type ContractParams = UniswapV2Params | UniswapV3Params | CurveParams | CurveSteCRVPoolParams | CurveGEARPoolParams | YearnParams | ConvexParams | ConvexPoolParams | LidoParams | LidoWsthETHParams | UniversalParams | BalancerParams | AaveV2Params | WrapperAaveV2Params | CompoundV2Params;
87
106
  export declare const contractParams: Record<SupportedContract, ContractParams>;
88
107
  export declare const contractsByAddress: Record<string, SupportedContract>;
89
108
  export declare const isSupportedContract: (t: unknown) => t is SupportedContract;
@@ -57,6 +57,19 @@ exports.contractsByNetwork = {
57
57
  BALANCER_VAULT: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
58
58
  // GEARBOX
59
59
  UNIVERSAL_ADAPTER: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
60
+ // AAVE
61
+ AAVE_V2_DAI_POOL: constants_1.NOT_DEPLOYED,
62
+ AAVE_V2_USDC_POOL: constants_1.NOT_DEPLOYED,
63
+ AAVE_V2_USDT_POOL: constants_1.NOT_DEPLOYED,
64
+ AAVE_V2_WETH_POOL: constants_1.NOT_DEPLOYED,
65
+ AAVE_V2_DAI_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Mainnet.waDAI,
66
+ AAVE_V2_USDC_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Mainnet.waUSDC,
67
+ AAVE_V2_USDT_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Mainnet.waUSDT,
68
+ AAVE_V2_WETH_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Mainnet.waWETH,
69
+ COMPOUND_V2_DAI_POOL: token_1.tokenDataByNetwork.Mainnet.cDAI,
70
+ COMPOUND_V2_USDC_POOL: token_1.tokenDataByNetwork.Mainnet.cUSDC,
71
+ COMPOUND_V2_USDT_POOL: token_1.tokenDataByNetwork.Mainnet.cUSDT,
72
+ COMPOUND_V2_WETH_POOL: token_1.tokenDataByNetwork.Mainnet.cWETH,
60
73
  },
61
74
  //
62
75
  //
@@ -117,6 +130,19 @@ exports.contractsByNetwork = {
117
130
  BALANCER_VAULT: constants_1.NOT_DEPLOYED,
118
131
  // GEARBOX
119
132
  UNIVERSAL_ADAPTER: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
133
+ // AAVE
134
+ AAVE_V2_DAI_POOL: constants_1.NOT_DEPLOYED,
135
+ AAVE_V2_USDC_POOL: constants_1.NOT_DEPLOYED,
136
+ AAVE_V2_USDT_POOL: constants_1.NOT_DEPLOYED,
137
+ AAVE_V2_WETH_POOL: constants_1.NOT_DEPLOYED,
138
+ AAVE_V2_DAI_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Arbitrum.waDAI,
139
+ AAVE_V2_USDC_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Arbitrum.waUSDC,
140
+ AAVE_V2_USDT_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Arbitrum.waUSDT,
141
+ AAVE_V2_WETH_TOKEN_WRAPPER: token_1.tokenDataByNetwork.Arbitrum.waWETH,
142
+ COMPOUND_V2_DAI_POOL: token_1.tokenDataByNetwork.Arbitrum.cDAI,
143
+ COMPOUND_V2_USDC_POOL: token_1.tokenDataByNetwork.Arbitrum.cUSDC,
144
+ COMPOUND_V2_USDT_POOL: token_1.tokenDataByNetwork.Arbitrum.cUSDT,
145
+ COMPOUND_V2_WETH_POOL: token_1.tokenDataByNetwork.Arbitrum.cWETH,
120
146
  },
121
147
  };
122
148
  exports.UNISWAP_V3_QUOTER = constants_1.NOT_DEPLOYED;
@@ -482,6 +508,78 @@ exports.contractParams = {
482
508
  protocol: protocols_1.Protocols.Balancer,
483
509
  type: adapters_1.AdapterInterface.BALANCER_VAULT,
484
510
  },
511
+ AAVE_V2_DAI_POOL: {
512
+ name: "Aave V2 DAI",
513
+ protocol: protocols_1.Protocols.AaveV2,
514
+ type: adapters_1.AdapterInterface.AAVE_V2_LENDING_POOL,
515
+ underlying: "DAI",
516
+ },
517
+ AAVE_V2_USDC_POOL: {
518
+ name: "Aave V2 USDC",
519
+ protocol: protocols_1.Protocols.AaveV2,
520
+ type: adapters_1.AdapterInterface.AAVE_V2_LENDING_POOL,
521
+ underlying: "USDC",
522
+ },
523
+ AAVE_V2_USDT_POOL: {
524
+ name: "Aave V2 USDT",
525
+ protocol: protocols_1.Protocols.AaveV2,
526
+ type: adapters_1.AdapterInterface.AAVE_V2_LENDING_POOL,
527
+ underlying: "USDT",
528
+ },
529
+ AAVE_V2_WETH_POOL: {
530
+ name: "Aave V2 WETH",
531
+ protocol: protocols_1.Protocols.AaveV2,
532
+ type: adapters_1.AdapterInterface.AAVE_V2_LENDING_POOL,
533
+ underlying: "WETH",
534
+ },
535
+ AAVE_V2_DAI_TOKEN_WRAPPER: {
536
+ name: "Aave V2 DAI Token Wrapper",
537
+ protocol: protocols_1.Protocols.AaveV2,
538
+ type: adapters_1.AdapterInterface.AAVE_V2_WRAPPED_ATOKEN,
539
+ underlying: "aDAI",
540
+ },
541
+ AAVE_V2_USDC_TOKEN_WRAPPER: {
542
+ name: "Aave V2 USDC Token Wrapper",
543
+ protocol: protocols_1.Protocols.AaveV2,
544
+ type: adapters_1.AdapterInterface.AAVE_V2_WRAPPED_ATOKEN,
545
+ underlying: "aUSDC",
546
+ },
547
+ AAVE_V2_USDT_TOKEN_WRAPPER: {
548
+ name: "Aave V2 USDT Token Wrapper",
549
+ protocol: protocols_1.Protocols.AaveV2,
550
+ type: adapters_1.AdapterInterface.AAVE_V2_WRAPPED_ATOKEN,
551
+ underlying: "aUSDT",
552
+ },
553
+ AAVE_V2_WETH_TOKEN_WRAPPER: {
554
+ name: "Aave V2 WETH Token Wrapper",
555
+ protocol: protocols_1.Protocols.AaveV2,
556
+ type: adapters_1.AdapterInterface.AAVE_V2_WRAPPED_ATOKEN,
557
+ underlying: "aWETH",
558
+ },
559
+ COMPOUND_V2_DAI_POOL: {
560
+ name: "Compound V2 DAI",
561
+ protocol: protocols_1.Protocols.CompoundV2,
562
+ type: adapters_1.AdapterInterface.COMPOUND_V2_CERC20,
563
+ underlying: "DAI",
564
+ },
565
+ COMPOUND_V2_USDC_POOL: {
566
+ name: "Compound V2 DAI",
567
+ protocol: protocols_1.Protocols.CompoundV2,
568
+ type: adapters_1.AdapterInterface.COMPOUND_V2_CERC20,
569
+ underlying: "USDT",
570
+ },
571
+ COMPOUND_V2_USDT_POOL: {
572
+ name: "Compound V2 DAI",
573
+ protocol: protocols_1.Protocols.CompoundV2,
574
+ type: adapters_1.AdapterInterface.COMPOUND_V2_CERC20,
575
+ underlying: "USDT",
576
+ },
577
+ COMPOUND_V2_WETH_POOL: {
578
+ name: "Compound V2 DAI",
579
+ protocol: protocols_1.Protocols.CompoundV2,
580
+ type: adapters_1.AdapterInterface.COMPOUND_V2_CETHER,
581
+ underlying: "WETH",
582
+ },
485
583
  };
486
584
  exports.contractsByAddress = mappers_1.TypedObjectUtils.entries(exports.contractsByNetwork).reduce((acc, [, contracts]) => ({
487
585
  ...acc,
@@ -6,7 +6,9 @@ export declare enum Protocols {
6
6
  Convex = 4,
7
7
  Lido = 5,
8
8
  Gearbox = 6,
9
- Balancer = 7
9
+ Balancer = 7,
10
+ AaveV2 = 8,
11
+ CompoundV2 = 9
10
12
  }
11
13
  export interface ProtocolData {
12
14
  name: string;
@@ -11,6 +11,8 @@ var Protocols;
11
11
  Protocols[Protocols["Lido"] = 5] = "Lido";
12
12
  Protocols[Protocols["Gearbox"] = 6] = "Gearbox";
13
13
  Protocols[Protocols["Balancer"] = 7] = "Balancer";
14
+ Protocols[Protocols["AaveV2"] = 8] = "AaveV2";
15
+ Protocols[Protocols["CompoundV2"] = 9] = "CompoundV2";
14
16
  })(Protocols = exports.Protocols || (exports.Protocols = {}));
15
17
  exports.protocolData = {
16
18
  [Protocols.Uniswap]: {
@@ -45,4 +47,12 @@ exports.protocolData = {
45
47
  name: "Balancer",
46
48
  icon: "",
47
49
  },
50
+ [Protocols.AaveV2]: {
51
+ name: "AaveV2",
52
+ icon: "",
53
+ },
54
+ [Protocols.CompoundV2]: {
55
+ name: "CompoundV2",
56
+ icon: "",
57
+ },
48
58
  };
@@ -1,4 +1,6 @@
1
1
  import { NetworkType } from "../core/chains";
2
+ import { AaveV2LPToken } from "../tokens/aave";
3
+ import { NormalToken } from "../tokens/normal";
2
4
  import { SupportedToken } from "../tokens/token";
3
5
  export interface PriceFeed {
4
6
  token: string;
@@ -14,14 +16,15 @@ export declare enum OracleType {
14
16
  WSTETH_ORACLE = 6,
15
17
  BOUNDED_ORACLE = 7,
16
18
  COMPOSITE_ORACLE = 8,
17
- AAVE_ORACLE = 9,
18
- COMPOUND_ORACLE = 10,
19
+ WRAPPED_AAVE_V2_ORACLE = 9,
20
+ COMPOUND_V2_ORACLE = 10,
19
21
  BALANCER_STABLE_LP_ORACLE = 11,
20
22
  BALANCER_WEIGHTED_LP_ORACLE = 12,
21
23
  CURVE_CRYPTO_ORACLE = 13,
22
- LIKE_CURVE_LP_TOKEN_ORACLE = 14,
24
+ THE_SAME_AS = 14,
23
25
  REDSTONE_ORACLE = 15,
24
- ERC4626_VAULT_ORACLE = 16
26
+ ERC4626_VAULT_ORACLE = 16,
27
+ NETWORK_DIFFERENT = 17
25
28
  }
26
29
  export type PriceFeedData = {
27
30
  type: OracleType.CHAINLINK_ORACLE;
@@ -58,6 +61,17 @@ export type PriceFeedData = {
58
61
  type: OracleType.BALANCER_WEIGHTED_LP_ORACLE;
59
62
  assets: Array<SupportedToken>;
60
63
  } | {
61
- type: OracleType.LIKE_CURVE_LP_TOKEN_ORACLE;
62
- curveSymbol: SupportedToken;
64
+ type: OracleType.THE_SAME_AS;
65
+ token: SupportedToken;
66
+ } | {
67
+ type: OracleType.WRAPPED_AAVE_V2_ORACLE;
68
+ underlying: AaveV2LPToken;
69
+ } | {
70
+ type: OracleType.COMPOUND_V2_ORACLE;
71
+ underlying: NormalToken;
72
+ } | {
73
+ type: OracleType.REDSTONE_ORACLE;
74
+ dataId: string;
75
+ signers: Array<string>;
76
+ signersThreshold: number;
63
77
  };
@@ -12,12 +12,13 @@ var OracleType;
12
12
  OracleType[OracleType["WSTETH_ORACLE"] = 6] = "WSTETH_ORACLE";
13
13
  OracleType[OracleType["BOUNDED_ORACLE"] = 7] = "BOUNDED_ORACLE";
14
14
  OracleType[OracleType["COMPOSITE_ORACLE"] = 8] = "COMPOSITE_ORACLE";
15
- OracleType[OracleType["AAVE_ORACLE"] = 9] = "AAVE_ORACLE";
16
- OracleType[OracleType["COMPOUND_ORACLE"] = 10] = "COMPOUND_ORACLE";
15
+ OracleType[OracleType["WRAPPED_AAVE_V2_ORACLE"] = 9] = "WRAPPED_AAVE_V2_ORACLE";
16
+ OracleType[OracleType["COMPOUND_V2_ORACLE"] = 10] = "COMPOUND_V2_ORACLE";
17
17
  OracleType[OracleType["BALANCER_STABLE_LP_ORACLE"] = 11] = "BALANCER_STABLE_LP_ORACLE";
18
18
  OracleType[OracleType["BALANCER_WEIGHTED_LP_ORACLE"] = 12] = "BALANCER_WEIGHTED_LP_ORACLE";
19
19
  OracleType[OracleType["CURVE_CRYPTO_ORACLE"] = 13] = "CURVE_CRYPTO_ORACLE";
20
- OracleType[OracleType["LIKE_CURVE_LP_TOKEN_ORACLE"] = 14] = "LIKE_CURVE_LP_TOKEN_ORACLE";
20
+ OracleType[OracleType["THE_SAME_AS"] = 14] = "THE_SAME_AS";
21
21
  OracleType[OracleType["REDSTONE_ORACLE"] = 15] = "REDSTONE_ORACLE";
22
22
  OracleType[OracleType["ERC4626_VAULT_ORACLE"] = 16] = "ERC4626_VAULT_ORACLE";
23
+ OracleType[OracleType["NETWORK_DIFFERENT"] = 17] = "NETWORK_DIFFERENT";
23
24
  })(OracleType = exports.OracleType || (exports.OracleType = {}));
@@ -227,6 +227,12 @@ exports.priceFeedsByNetwork = {
227
227
  Arbitrum: "0xb2a824043730fe05f3da2efafa1cbbe83fa548d6",
228
228
  },
229
229
  },
230
+ SHIB: {
231
+ type: oracles_1.OracleType.REDSTONE_ORACLE,
232
+ dataId: "redstone-main-demo",
233
+ signers: ["0x0C39486f770B26F5527BBBf942726537986Cd7eb"],
234
+ signersThreshold: 1,
235
+ },
230
236
  RDNT: {
231
237
  type: oracles_1.OracleType.CHAINLINK_ORACLE,
232
238
  address: {
@@ -321,109 +327,109 @@ exports.priceFeedsByNetwork = {
321
327
  },
322
328
  // CVX tokens
323
329
  cvx3Crv: {
324
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
325
- curveSymbol: "3Crv",
330
+ type: oracles_1.OracleType.THE_SAME_AS,
331
+ token: "3Crv",
326
332
  },
327
333
  cvxcrvFRAX: {
328
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
329
- curveSymbol: "crvFRAX",
334
+ type: oracles_1.OracleType.THE_SAME_AS,
335
+ token: "crvFRAX",
330
336
  },
331
337
  cvxsteCRV: {
332
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
333
- curveSymbol: "steCRV",
338
+ type: oracles_1.OracleType.THE_SAME_AS,
339
+ token: "steCRV",
334
340
  },
335
341
  cvxFRAX3CRV: {
336
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
337
- curveSymbol: "FRAX3CRV",
342
+ type: oracles_1.OracleType.THE_SAME_AS,
343
+ token: "FRAX3CRV",
338
344
  },
339
345
  cvxLUSD3CRV: {
340
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
341
- curveSymbol: "LUSD3CRV",
346
+ type: oracles_1.OracleType.THE_SAME_AS,
347
+ token: "LUSD3CRV",
342
348
  },
343
349
  cvxcrvPlain3andSUSD: {
344
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
345
- curveSymbol: "crvPlain3andSUSD",
350
+ type: oracles_1.OracleType.THE_SAME_AS,
351
+ token: "crvPlain3andSUSD",
346
352
  },
347
353
  cvxgusd3CRV: {
348
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
349
- curveSymbol: "gusd3CRV",
354
+ type: oracles_1.OracleType.THE_SAME_AS,
355
+ token: "gusd3CRV",
350
356
  },
351
357
  cvxOHMFRAXBP: {
352
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
353
- curveSymbol: "OHMFRAXBP",
358
+ type: oracles_1.OracleType.THE_SAME_AS,
359
+ token: "OHMFRAXBP",
354
360
  },
355
361
  cvxMIM_3LP3CRV: {
356
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
357
- curveSymbol: "MIM_3LP3CRV",
362
+ type: oracles_1.OracleType.THE_SAME_AS,
363
+ token: "MIM_3LP3CRV",
358
364
  },
359
365
  cvxcrvCRVETH: {
360
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
361
- curveSymbol: "crvCRVETH",
366
+ type: oracles_1.OracleType.THE_SAME_AS,
367
+ token: "crvCRVETH",
362
368
  },
363
369
  cvxcrvCVXETH: {
364
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
365
- curveSymbol: "crvCVXETH",
370
+ type: oracles_1.OracleType.THE_SAME_AS,
371
+ token: "crvCVXETH",
366
372
  },
367
373
  cvxcrvUSDTWBTCWETH: {
368
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
369
- curveSymbol: "crvUSDTWBTCWETH",
374
+ type: oracles_1.OracleType.THE_SAME_AS,
375
+ token: "crvUSDTWBTCWETH",
370
376
  },
371
377
  cvxLDOETH: {
372
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
373
- curveSymbol: "LDOETH",
378
+ type: oracles_1.OracleType.THE_SAME_AS,
379
+ token: "LDOETH",
374
380
  },
375
381
  // CVX tokens
376
382
  stkcvx3Crv: {
377
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
378
- curveSymbol: "3Crv",
383
+ type: oracles_1.OracleType.THE_SAME_AS,
384
+ token: "3Crv",
379
385
  },
380
386
  stkcvxcrvFRAX: {
381
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
382
- curveSymbol: "crvFRAX",
387
+ type: oracles_1.OracleType.THE_SAME_AS,
388
+ token: "crvFRAX",
383
389
  },
384
390
  stkcvxsteCRV: {
385
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
386
- curveSymbol: "steCRV",
391
+ type: oracles_1.OracleType.THE_SAME_AS,
392
+ token: "steCRV",
387
393
  },
388
394
  stkcvxFRAX3CRV: {
389
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
390
- curveSymbol: "FRAX3CRV",
395
+ type: oracles_1.OracleType.THE_SAME_AS,
396
+ token: "FRAX3CRV",
391
397
  },
392
398
  stkcvxLUSD3CRV: {
393
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
394
- curveSymbol: "LUSD3CRV",
399
+ type: oracles_1.OracleType.THE_SAME_AS,
400
+ token: "LUSD3CRV",
395
401
  },
396
402
  stkcvxcrvPlain3andSUSD: {
397
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
398
- curveSymbol: "crvPlain3andSUSD",
403
+ type: oracles_1.OracleType.THE_SAME_AS,
404
+ token: "crvPlain3andSUSD",
399
405
  },
400
406
  stkcvxgusd3CRV: {
401
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
402
- curveSymbol: "gusd3CRV",
407
+ type: oracles_1.OracleType.THE_SAME_AS,
408
+ token: "gusd3CRV",
403
409
  },
404
410
  stkcvxOHMFRAXBP: {
405
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
406
- curveSymbol: "OHMFRAXBP",
411
+ type: oracles_1.OracleType.THE_SAME_AS,
412
+ token: "OHMFRAXBP",
407
413
  },
408
414
  stkcvxMIM_3LP3CRV: {
409
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
410
- curveSymbol: "MIM_3LP3CRV",
415
+ type: oracles_1.OracleType.THE_SAME_AS,
416
+ token: "MIM_3LP3CRV",
411
417
  },
412
418
  stkcvxcrvCRVETH: {
413
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
414
- curveSymbol: "crvCRVETH",
419
+ type: oracles_1.OracleType.THE_SAME_AS,
420
+ token: "crvCRVETH",
415
421
  },
416
422
  stkcvxcrvCVXETH: {
417
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
418
- curveSymbol: "crvCVXETH",
423
+ type: oracles_1.OracleType.THE_SAME_AS,
424
+ token: "crvCVXETH",
419
425
  },
420
426
  stkcvxcrvUSDTWBTCWETH: {
421
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
422
- curveSymbol: "crvUSDTWBTCWETH",
427
+ type: oracles_1.OracleType.THE_SAME_AS,
428
+ token: "crvUSDTWBTCWETH",
423
429
  },
424
430
  stkcvxLDOETH: {
425
- type: oracles_1.OracleType.LIKE_CURVE_LP_TOKEN_ORACLE,
426
- curveSymbol: "LDOETH",
431
+ type: oracles_1.OracleType.THE_SAME_AS,
432
+ token: "LDOETH",
427
433
  },
428
434
  "50OHM_50DAI": {
429
435
  type: oracles_1.OracleType.BALANCER_WEIGHTED_LP_ORACLE,
@@ -466,4 +472,52 @@ exports.priceFeedsByNetwork = {
466
472
  type: oracles_1.OracleType.CHAINLINK_ORACLE,
467
473
  address: { Mainnet: "", Arbitrum: "" },
468
474
  },
475
+ aDAI: {
476
+ type: oracles_1.OracleType.THE_SAME_AS,
477
+ token: "DAI",
478
+ },
479
+ aUSDC: {
480
+ type: oracles_1.OracleType.THE_SAME_AS,
481
+ token: "USDC",
482
+ },
483
+ aUSDT: {
484
+ type: oracles_1.OracleType.THE_SAME_AS,
485
+ token: "USDT",
486
+ },
487
+ aWETH: {
488
+ type: oracles_1.OracleType.THE_SAME_AS,
489
+ token: "WETH",
490
+ },
491
+ waDAI: {
492
+ type: oracles_1.OracleType.WRAPPED_AAVE_V2_ORACLE,
493
+ underlying: "aDAI",
494
+ },
495
+ waUSDC: {
496
+ type: oracles_1.OracleType.WRAPPED_AAVE_V2_ORACLE,
497
+ underlying: "aUSDC",
498
+ },
499
+ waUSDT: {
500
+ type: oracles_1.OracleType.WRAPPED_AAVE_V2_ORACLE,
501
+ underlying: "aUSDT",
502
+ },
503
+ waWETH: {
504
+ type: oracles_1.OracleType.WRAPPED_AAVE_V2_ORACLE,
505
+ underlying: "aWETH",
506
+ },
507
+ cDAI: {
508
+ type: oracles_1.OracleType.COMPOUND_V2_ORACLE,
509
+ underlying: "DAI",
510
+ },
511
+ cUSDC: {
512
+ type: oracles_1.OracleType.COMPOUND_V2_ORACLE,
513
+ underlying: "USDC",
514
+ },
515
+ cUSDT: {
516
+ type: oracles_1.OracleType.COMPOUND_V2_ORACLE,
517
+ underlying: "USDT",
518
+ },
519
+ cWETH: {
520
+ type: oracles_1.OracleType.COMPOUND_V2_ORACLE,
521
+ underlying: "WETH",
522
+ },
469
523
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chai_1 = require("chai");
7
+ const ethers_1 = require("ethers");
8
+ const chains_1 = require("../core/chains");
9
+ const token_1 = require("../tokens/token");
10
+ const types_1 = require("../types");
11
+ const formatter_1 = require("../utils/formatter");
12
+ const multicall_1 = __importDefault(require("../utils/multicall"));
13
+ const oracles_1 = require("./oracles");
14
+ const priceFeeds_1 = require("./priceFeeds");
15
+ class PriceFeedsSuite {
16
+ networkTypes;
17
+ calls;
18
+ constructor(...networkTypes) {
19
+ this.networkTypes = networkTypes;
20
+ this.calls = networkTypes.map(c => this.collectCalls(c));
21
+ }
22
+ async getAnswers() {
23
+ const providers = this.networkTypes.map(c => {
24
+ const url = process.env[`${c.toUpperCase()}_TESTS_FORK`];
25
+ if (!url) {
26
+ throw new Error(`Provider for ${c} not found in env`);
27
+ }
28
+ return new ethers_1.ethers.providers.StaticJsonRpcProvider(url, chains_1.CHAINS[c]);
29
+ });
30
+ const resps = await Promise.all(this.networkTypes.map((_, i) => (0, multicall_1.default)(this.calls[i], providers[i])));
31
+ return resps.map((_, i) => this.buildDict(this.calls[i], resps[i]));
32
+ }
33
+ collectCalls(c) {
34
+ const iFeed = types_1.AggregatorV3Interface__factory.createInterface();
35
+ const entries = Object.entries(priceFeeds_1.priceFeedsByNetwork).filter(([_, f]) => {
36
+ return ((f.type === oracles_1.OracleType.CHAINLINK_ORACLE &&
37
+ f.address[c]?.startsWith("0x")) ||
38
+ (f.type === oracles_1.OracleType.COMPOSITE_ORACLE &&
39
+ f.baseToUsdPriceFeed[c]?.startsWith("0x") &&
40
+ f.targetToBasePriceFeed[c]?.startsWith("0x")) ||
41
+ (f.type === oracles_1.OracleType.BOUNDED_ORACLE &&
42
+ f.targetPriceFeed[c]?.startsWith("0x")));
43
+ });
44
+ const calls = [];
45
+ for (const [symb, f] of entries) {
46
+ const tok = token_1.tokenDataByNetwork[c][symb];
47
+ if (!tok.startsWith("0x")) {
48
+ continue;
49
+ }
50
+ switch (f.type) {
51
+ case oracles_1.OracleType.CHAINLINK_ORACLE:
52
+ calls.push({
53
+ address: f.address[c],
54
+ interface: iFeed,
55
+ method: "latestRoundData()",
56
+ key: symb,
57
+ });
58
+ break;
59
+ case oracles_1.OracleType.BOUNDED_ORACLE:
60
+ calls.push({
61
+ address: f.targetPriceFeed[c],
62
+ interface: iFeed,
63
+ method: "latestRoundData()",
64
+ key: symb,
65
+ });
66
+ break;
67
+ case oracles_1.OracleType.COMPOSITE_ORACLE:
68
+ calls.push({
69
+ address: f.baseToUsdPriceFeed[c],
70
+ interface: iFeed,
71
+ method: "latestRoundData()",
72
+ key: `${symb}.baseToUsdPriceFeed`,
73
+ });
74
+ calls.push({
75
+ address: f.targetToBasePriceFeed[c],
76
+ interface: iFeed,
77
+ method: "latestRoundData()",
78
+ key: `${symb}.targetToBasePriceFeed`,
79
+ });
80
+ break;
81
+ }
82
+ }
83
+ return calls;
84
+ }
85
+ buildDict(calls, responses) {
86
+ return calls.reduce((acc, call, i) => ({
87
+ ...acc,
88
+ [call.key]: responses[i],
89
+ }), {});
90
+ }
91
+ }
92
+ describe("Price feeds", () => {
93
+ const suite = new PriceFeedsSuite("Mainnet", "Arbitrum");
94
+ const PERCENTAGE_FACTOR = 1_00_00;
95
+ const THRESHOLD = 100; // 1%
96
+ let answers = [];
97
+ before(async function () {
98
+ this.timeout(10000);
99
+ answers = await suite.getAnswers();
100
+ });
101
+ describe(`should not deviate for more than ${(100 * THRESHOLD) / PERCENTAGE_FACTOR}% from mainnet`, () => {
102
+ // have to use suite.calls here, because answers are empty atm
103
+ // this is how mocha works, it builds test tree before execution
104
+ const [_, ...chainCalls] = suite.calls;
105
+ for (let i = 0; i < chainCalls.length; i++) {
106
+ const calls = chainCalls[i];
107
+ const chain = suite.networkTypes[i + 1];
108
+ for (const call of calls) {
109
+ it(`${chain}.${call.key} deviation`, () => {
110
+ const mainDict = answers[0];
111
+ const chainDict = answers[i + 1];
112
+ const chainPrice = chainDict[call.key].value?.answer;
113
+ const mainPrice = mainDict[call.key]?.value?.answer;
114
+ if (!mainPrice) {
115
+ // some tokens do not exist on mainnet
116
+ return;
117
+ }
118
+ const deviation = chainPrice
119
+ ?.sub(mainPrice)
120
+ .mul(PERCENTAGE_FACTOR)
121
+ .div(mainPrice)
122
+ .abs()
123
+ .toNumber();
124
+ // console.log(
125
+ // call.key,
126
+ // deviation,
127
+ // chainPrice?.toNumber(),
128
+ // mainPrice.toNumber(),
129
+ // );
130
+ (0, chai_1.expect)(deviation, `Mainnet price: ${(0, formatter_1.formatBN)(mainPrice, 8)}$, ${chain} price: ${(0, formatter_1.formatBN)(chainPrice, 8)}$ at ${call.address}`).to.be.below(THRESHOLD);
131
+ });
132
+ }
133
+ }
134
+ });
135
+ });
@@ -1,5 +1,7 @@
1
- import type { ConvexPoolContract, CurvePoolContract, UniswapV2Contract, YearnVaultContract } from "../contracts/contracts";
1
+ import type { AaveV2PoolContract, CompoundV2PoolContract, ConvexPoolContract, CurvePoolContract, UniswapV2Contract, YearnVaultContract } from "../contracts/contracts";
2
+ import { AaveV2LPToken } from "../tokens/aave";
2
3
  import { BalancerLPToken } from "../tokens/balancer";
4
+ import { CompoundV2LPToken } from "../tokens/compound";
3
5
  import type { ConvexLPToken, ConvexStakedPhantomToken } from "../tokens/convex";
4
6
  import type { CurveLPToken } from "../tokens/curveLP";
5
7
  import type { NormalToken } from "../tokens/normal";
@@ -21,7 +23,12 @@ export declare enum TradeType {
21
23
  ConvexWithdraw = 13,
22
24
  ConvexWithdrawAndUnwrap = 14,
23
25
  BalancerJoin = 15,
24
- BalancerExit = 16
26
+ BalancerExit = 16,
27
+ AaveV2Deposit = 17,
28
+ AaveV2Withdraw = 18,
29
+ AaveV2Unwrap = 19,
30
+ CompoundV2Deposit = 20,
31
+ CompoundV2Withdraw = 21
25
32
  }
26
33
  export type TradeAction = {
27
34
  type: TradeType.UniswapV2Swap;
@@ -87,4 +94,20 @@ export type TradeAction = {
87
94
  type: TradeType.BalancerExit;
88
95
  contract: "BALANCER_VAULT";
89
96
  tokenOut: Array<NormalToken | BalancerLPToken>;
97
+ } | {
98
+ type: TradeType.AaveV2Deposit;
99
+ contract: AaveV2PoolContract;
100
+ tokenOut: AaveV2LPToken;
101
+ } | {
102
+ type: TradeType.AaveV2Withdraw;
103
+ contract: AaveV2PoolContract;
104
+ tokenOut: NormalToken;
105
+ } | {
106
+ type: TradeType.CompoundV2Deposit;
107
+ contract: CompoundV2PoolContract;
108
+ tokenOut: CompoundV2LPToken;
109
+ } | {
110
+ type: TradeType.CompoundV2Withdraw;
111
+ contract: CompoundV2PoolContract;
112
+ tokenOut: NormalToken;
90
113
  };