@gearbox-protocol/sdk 1.26.2 → 1.27.0
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.
- package/contracts/AdapterData.sol +76 -239
- package/contracts/AdapterType.sol +23 -23
- package/contracts/PriceFeedDataLive.sol +369 -284
- package/contracts/PriceFeedType.sol +19 -18
- package/contracts/SupportedContracts.sol +110 -262
- package/contracts/Tokens.sol +106 -90
- package/contracts/TokensData.sol +197 -664
- package/lib/contracts/contracts.d.ts +21 -2
- package/lib/contracts/contracts.js +98 -0
- package/lib/contracts/protocols.d.ts +3 -1
- package/lib/contracts/protocols.js +10 -0
- package/lib/oracles/oracles.d.ts +20 -6
- package/lib/oracles/oracles.js +4 -3
- package/lib/oracles/priceFeeds.js +106 -52
- package/lib/oracles/priceFeeds.spec.d.ts +1 -0
- package/lib/oracles/priceFeeds.spec.js +135 -0
- package/lib/pathfinder/tradeTypes.d.ts +25 -2
- package/lib/pathfinder/tradeTypes.js +5 -0
- package/lib/tokens/aave.d.ts +23 -0
- package/lib/tokens/aave.js +119 -0
- package/lib/tokens/compound.d.ts +13 -0
- package/lib/tokens/compound.js +61 -0
- package/lib/tokens/decimals.js +13 -0
- package/lib/tokens/normal.d.ts +1 -1
- package/lib/tokens/normal.js +16 -0
- package/lib/tokens/token.d.ts +4 -2
- package/lib/tokens/token.js +36 -2
- package/lib/tokens/tokenType.d.ts +4 -2
- package/lib/tokens/tokenType.js +3 -1
- package/lib/tokens/tokens.spec.d.ts +1 -0
- package/lib/tokens/tokens.spec.js +110 -0
- package/lib/utils/multicall.d.ts +14 -0
- package/lib/utils/multicall.js +34 -1
- package/package.json +3 -2
|
@@ -20,4 +20,9 @@ var TradeType;
|
|
|
20
20
|
TradeType[TradeType["ConvexWithdrawAndUnwrap"] = 14] = "ConvexWithdrawAndUnwrap";
|
|
21
21
|
TradeType[TradeType["BalancerJoin"] = 15] = "BalancerJoin";
|
|
22
22
|
TradeType[TradeType["BalancerExit"] = 16] = "BalancerExit";
|
|
23
|
+
TradeType[TradeType["AaveV2Deposit"] = 17] = "AaveV2Deposit";
|
|
24
|
+
TradeType[TradeType["AaveV2Withdraw"] = 18] = "AaveV2Withdraw";
|
|
25
|
+
TradeType[TradeType["AaveV2Unwrap"] = 19] = "AaveV2Unwrap";
|
|
26
|
+
TradeType[TradeType["CompoundV2Deposit"] = 20] = "CompoundV2Deposit";
|
|
27
|
+
TradeType[TradeType["CompoundV2Withdraw"] = 21] = "CompoundV2Withdraw";
|
|
23
28
|
})(TradeType = exports.TradeType || (exports.TradeType = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AaveV2PoolContract } from "../contracts/contracts";
|
|
2
|
+
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
3
|
+
import { NormalToken } from "./normal";
|
|
4
|
+
import type { TokenBase } from "./token";
|
|
5
|
+
import { TokenType } from "./tokenType";
|
|
6
|
+
export type AaveV2LPToken = "aDAI" | "aUSDC" | "aWETH" | "aUSDT";
|
|
7
|
+
export type WrappedAaveV2LPToken = "waDAI" | "waUSDC" | "waWETH" | "waUSDT";
|
|
8
|
+
export type AaveV2PoolTokenData = {
|
|
9
|
+
symbol: AaveV2LPToken;
|
|
10
|
+
type: TokenType.AAVE_V2_A_TOKEN;
|
|
11
|
+
underlying: NormalToken;
|
|
12
|
+
lpActions: Array<TradeAction>;
|
|
13
|
+
pool: AaveV2PoolContract;
|
|
14
|
+
} & TokenBase;
|
|
15
|
+
export type WrappedAaveV2PoolTokenData = {
|
|
16
|
+
symbol: WrappedAaveV2LPToken;
|
|
17
|
+
type: TokenType.WRAPPED_AAVE_V2_TOKEN;
|
|
18
|
+
underlying: AaveV2LPToken;
|
|
19
|
+
lpActions: Array<TradeAction>;
|
|
20
|
+
} & TokenBase;
|
|
21
|
+
export declare const aaveV2Tokens: Record<AaveV2LPToken, AaveV2PoolTokenData>;
|
|
22
|
+
export declare const wrappedAaveV2Tokens: Record<WrappedAaveV2LPToken, WrappedAaveV2PoolTokenData>;
|
|
23
|
+
export declare const isAaveV2LPToken: (t: unknown) => t is AaveV2LPToken;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAaveV2LPToken = exports.wrappedAaveV2Tokens = exports.aaveV2Tokens = void 0;
|
|
4
|
+
const tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
|
+
const tokenType_1 = require("./tokenType");
|
|
6
|
+
exports.aaveV2Tokens = {
|
|
7
|
+
aDAI: {
|
|
8
|
+
name: "AaveV2 aDAI",
|
|
9
|
+
symbol: "aDAI",
|
|
10
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
11
|
+
underlying: "DAI",
|
|
12
|
+
pool: "AAVE_V2_DAI_POOL",
|
|
13
|
+
lpActions: [
|
|
14
|
+
{
|
|
15
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
16
|
+
contract: "AAVE_V2_DAI_POOL",
|
|
17
|
+
tokenOut: "DAI",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
aUSDC: {
|
|
22
|
+
name: "AaveV2 aUSDC",
|
|
23
|
+
symbol: "aUSDC",
|
|
24
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
25
|
+
underlying: "USDC",
|
|
26
|
+
pool: "AAVE_V2_USDC_POOL",
|
|
27
|
+
lpActions: [
|
|
28
|
+
{
|
|
29
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
30
|
+
contract: "AAVE_V2_USDC_POOL",
|
|
31
|
+
tokenOut: "USDC",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
aUSDT: {
|
|
36
|
+
name: "AaveV2 aUSDT",
|
|
37
|
+
symbol: "aUSDT",
|
|
38
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
39
|
+
underlying: "USDT",
|
|
40
|
+
pool: "AAVE_V2_USDT_POOL",
|
|
41
|
+
lpActions: [
|
|
42
|
+
{
|
|
43
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
44
|
+
contract: "AAVE_V2_USDT_POOL",
|
|
45
|
+
tokenOut: "USDT",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
aWETH: {
|
|
50
|
+
name: "AaveV2 aWETH",
|
|
51
|
+
symbol: "aWETH",
|
|
52
|
+
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
53
|
+
underlying: "WETH",
|
|
54
|
+
pool: "AAVE_V2_WETH_POOL",
|
|
55
|
+
lpActions: [
|
|
56
|
+
{
|
|
57
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
58
|
+
contract: "AAVE_V2_WETH_POOL",
|
|
59
|
+
tokenOut: "WETH",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
exports.wrappedAaveV2Tokens = {
|
|
65
|
+
waDAI: {
|
|
66
|
+
name: "Wrapped AaveV2 aDAI",
|
|
67
|
+
symbol: "waDAI",
|
|
68
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
69
|
+
underlying: "aDAI",
|
|
70
|
+
lpActions: [
|
|
71
|
+
{
|
|
72
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
73
|
+
contract: "AAVE_V2_DAI_POOL",
|
|
74
|
+
tokenOut: "DAI",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
waUSDC: {
|
|
79
|
+
name: "Wrapped AaveV2 aUSDC",
|
|
80
|
+
symbol: "waUSDC",
|
|
81
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
82
|
+
underlying: "aUSDC",
|
|
83
|
+
lpActions: [
|
|
84
|
+
{
|
|
85
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
86
|
+
contract: "AAVE_V2_USDC_POOL",
|
|
87
|
+
tokenOut: "USDC",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
waUSDT: {
|
|
92
|
+
name: "Wrapped AaveV2 aUSDT",
|
|
93
|
+
symbol: "waUSDT",
|
|
94
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
95
|
+
underlying: "aUSDT",
|
|
96
|
+
lpActions: [
|
|
97
|
+
{
|
|
98
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
99
|
+
contract: "AAVE_V2_USDT_POOL",
|
|
100
|
+
tokenOut: "USDT",
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
waWETH: {
|
|
105
|
+
name: "Wrapped AaveV2 aWETH",
|
|
106
|
+
symbol: "waWETH",
|
|
107
|
+
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
108
|
+
underlying: "aWETH",
|
|
109
|
+
lpActions: [
|
|
110
|
+
{
|
|
111
|
+
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
112
|
+
contract: "AAVE_V2_WETH_POOL",
|
|
113
|
+
tokenOut: "WETH",
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
const isAaveV2LPToken = (t) => typeof t === "string" && !!exports.aaveV2Tokens[t];
|
|
119
|
+
exports.isAaveV2LPToken = isAaveV2LPToken;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
|
+
import { NormalToken } from "./normal";
|
|
3
|
+
import type { TokenBase } from "./token";
|
|
4
|
+
import { TokenType } from "./tokenType";
|
|
5
|
+
export type CompoundV2LPToken = "cDAI" | "cUSDC" | "cWETH" | "cUSDT";
|
|
6
|
+
export type CompoundV2PoolTokenData = {
|
|
7
|
+
symbol: CompoundV2LPToken;
|
|
8
|
+
type: TokenType.COMPOUND_V2_C_TOKEN;
|
|
9
|
+
underlying: NormalToken;
|
|
10
|
+
lpActions: Array<TradeAction>;
|
|
11
|
+
} & TokenBase;
|
|
12
|
+
export declare const compoundV2Tokens: Record<CompoundV2LPToken, CompoundV2PoolTokenData>;
|
|
13
|
+
export declare const isCompoundV2LPToken: (t: unknown) => t is CompoundV2LPToken;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCompoundV2LPToken = exports.compoundV2Tokens = void 0;
|
|
4
|
+
const tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
|
+
const tokenType_1 = require("./tokenType");
|
|
6
|
+
exports.compoundV2Tokens = {
|
|
7
|
+
cDAI: {
|
|
8
|
+
name: "CompoundV2 cDAI",
|
|
9
|
+
symbol: "cDAI",
|
|
10
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
11
|
+
underlying: "DAI",
|
|
12
|
+
lpActions: [
|
|
13
|
+
{
|
|
14
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
15
|
+
contract: "COMPOUND_V2_DAI_POOL",
|
|
16
|
+
tokenOut: "DAI",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
cUSDC: {
|
|
21
|
+
name: "CompoundV2 cUSDC",
|
|
22
|
+
symbol: "cUSDC",
|
|
23
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
24
|
+
underlying: "USDC",
|
|
25
|
+
lpActions: [
|
|
26
|
+
{
|
|
27
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
28
|
+
contract: "COMPOUND_V2_USDC_POOL",
|
|
29
|
+
tokenOut: "USDC",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
cUSDT: {
|
|
34
|
+
name: "CompoundV2 cUSDT",
|
|
35
|
+
symbol: "cUSDT",
|
|
36
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
37
|
+
underlying: "USDT",
|
|
38
|
+
lpActions: [
|
|
39
|
+
{
|
|
40
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
41
|
+
contract: "COMPOUND_V2_USDT_POOL",
|
|
42
|
+
tokenOut: "USDT",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
cWETH: {
|
|
47
|
+
name: "CompoundV2 cWETH",
|
|
48
|
+
symbol: "cWETH",
|
|
49
|
+
type: tokenType_1.TokenType.COMPOUND_V2_C_TOKEN,
|
|
50
|
+
underlying: "WETH",
|
|
51
|
+
lpActions: [
|
|
52
|
+
{
|
|
53
|
+
type: tradeTypes_1.TradeType.CompoundV2Withdraw,
|
|
54
|
+
contract: "COMPOUND_V2_WETH_POOL",
|
|
55
|
+
tokenOut: "WETH",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const isCompoundV2LPToken = (t) => typeof t === "string" && !!exports.compoundV2Tokens[t];
|
|
61
|
+
exports.isCompoundV2LPToken = isCompoundV2LPToken;
|
package/lib/tokens/decimals.js
CHANGED
|
@@ -89,4 +89,17 @@ exports.decimals = {
|
|
|
89
89
|
"50OHM_50DAI": 18,
|
|
90
90
|
"50OHM_50WETH": 18,
|
|
91
91
|
OHM_wstETH: 18,
|
|
92
|
+
aDAI: 18,
|
|
93
|
+
aUSDC: 6,
|
|
94
|
+
aUSDT: 6,
|
|
95
|
+
aWETH: 18,
|
|
96
|
+
waDAI: 18,
|
|
97
|
+
waUSDC: 6,
|
|
98
|
+
waUSDT: 6,
|
|
99
|
+
waWETH: 18,
|
|
100
|
+
cDAI: 18,
|
|
101
|
+
cUSDC: 6,
|
|
102
|
+
cUSDT: 6,
|
|
103
|
+
cWETH: 18,
|
|
104
|
+
SHIB: 18,
|
|
92
105
|
};
|
package/lib/tokens/normal.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
2
|
import type { TokenBase } from "./token";
|
|
3
3
|
import { TokenType } from "./tokenType";
|
|
4
|
-
export type NormalToken = "1INCH" | "AAVE" | "COMP" | "CRV" | "DPI" | "FEI" | "LINK" | "SNX" | "UNI" | "USDT" | "USDC" | "DAI" | "WETH" | "WBTC" | "YFI" | "STETH" | "wstETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "OHM" | "MIM" | "SPELL" | "GMX" | "ARB" | "RDNT" | "BAL";
|
|
4
|
+
export type NormalToken = "1INCH" | "AAVE" | "COMP" | "CRV" | "DPI" | "FEI" | "LINK" | "SNX" | "UNI" | "USDT" | "USDC" | "DAI" | "WETH" | "WBTC" | "YFI" | "STETH" | "wstETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "OHM" | "MIM" | "SPELL" | "GMX" | "ARB" | "RDNT" | "BAL" | "ARB" | "SHIB";
|
|
5
5
|
export type NormalTokenData = {
|
|
6
6
|
symbol: NormalToken;
|
|
7
7
|
type: TokenType.NORMAL_TOKEN;
|
package/lib/tokens/normal.js
CHANGED
|
@@ -807,6 +807,22 @@ exports.normalTokens = {
|
|
|
807
807
|
],
|
|
808
808
|
lpActions: [],
|
|
809
809
|
},
|
|
810
|
+
SHIB: {
|
|
811
|
+
name: "SHIB",
|
|
812
|
+
symbol: "SHIB",
|
|
813
|
+
type: tokenType_1.TokenType.NORMAL_TOKEN,
|
|
814
|
+
swapActions: [
|
|
815
|
+
{
|
|
816
|
+
type: tradeTypes_1.TradeType.UniswapV3Swap,
|
|
817
|
+
contract: "UNISWAP_V3_ROUTER",
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
type: tradeTypes_1.TradeType.UniswapV2Swap,
|
|
821
|
+
contract: "UNISWAP_V2_ROUTER",
|
|
822
|
+
},
|
|
823
|
+
],
|
|
824
|
+
lpActions: [],
|
|
825
|
+
},
|
|
810
826
|
};
|
|
811
827
|
const isNormalToken = (t) => typeof t === "string" && !!exports.normalTokens[t];
|
|
812
828
|
exports.isNormalToken = isNormalToken;
|
package/lib/tokens/token.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { NetworkType } from "../core/chains";
|
|
2
|
+
import { AaveV2LPToken, AaveV2PoolTokenData, WrappedAaveV2LPToken, WrappedAaveV2PoolTokenData } from "./aave";
|
|
2
3
|
import { BalancerLPToken, BalancerLpTokenData } from "./balancer";
|
|
4
|
+
import { CompoundV2LPToken, CompoundV2PoolTokenData } from "./compound";
|
|
3
5
|
import { ConvexLPToken, ConvexLPTokenData, ConvexPhantomTokenData, ConvexStakedPhantomToken } from "./convex";
|
|
4
6
|
import { CurveLPToken, CurveLPTokenData, MetaCurveLPTokenData } from "./curveLP";
|
|
5
7
|
import { DieselTokenData, DieselTokenTypes, GearboxToken, GearboxTokenData } from "./gear";
|
|
6
8
|
import { NormalToken, NormalTokenData } from "./normal";
|
|
7
9
|
import { YearnLPToken, YearnVaultOfCurveLPTokenData, YearnVaultOfMetaCurveLPTokenData, YearnVaultTokenData } from "./yearn";
|
|
8
|
-
export type LPTokens = YearnLPToken | CurveLPToken | ConvexLPToken | ConvexStakedPhantomToken | BalancerLPToken;
|
|
10
|
+
export type LPTokens = YearnLPToken | CurveLPToken | ConvexLPToken | ConvexStakedPhantomToken | BalancerLPToken | AaveV2LPToken | WrappedAaveV2LPToken | CompoundV2LPToken;
|
|
9
11
|
export type SupportedToken = NormalToken | LPTokens | DieselTokenTypes | GearboxToken;
|
|
10
12
|
export interface TokenBase {
|
|
11
13
|
name: string;
|
|
12
14
|
symbol: string;
|
|
13
15
|
}
|
|
14
|
-
export type LPTokenDataI = CurveLPTokenData | MetaCurveLPTokenData | YearnVaultTokenData | YearnVaultOfCurveLPTokenData | YearnVaultOfMetaCurveLPTokenData | ConvexLPTokenData | ConvexPhantomTokenData | BalancerLpTokenData;
|
|
16
|
+
export type LPTokenDataI = CurveLPTokenData | MetaCurveLPTokenData | YearnVaultTokenData | YearnVaultOfCurveLPTokenData | YearnVaultOfMetaCurveLPTokenData | ConvexLPTokenData | ConvexPhantomTokenData | BalancerLpTokenData | AaveV2PoolTokenData | WrappedAaveV2PoolTokenData | CompoundV2PoolTokenData;
|
|
15
17
|
export type TokenDataI = NormalTokenData | LPTokenDataI | DieselTokenData | GearboxTokenData;
|
|
16
18
|
export declare const lpTokens: Record<LPTokens, LPTokenDataI>;
|
|
17
19
|
export declare const supportedTokens: Record<SupportedToken, TokenDataI>;
|
package/lib/tokens/token.js
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.extractTokenData = exports.getDecimals = exports.isLPToken = exports.isSupportedToken = exports.tokenSymbolByAddress = exports.tokenDataByNetwork = exports.supportedTokens = exports.lpTokens = void 0;
|
|
4
4
|
const constants_1 = require("../core/constants");
|
|
5
5
|
const mappers_1 = require("../utils/mappers");
|
|
6
|
+
const aave_1 = require("./aave");
|
|
6
7
|
const balancer_1 = require("./balancer");
|
|
8
|
+
const compound_1 = require("./compound");
|
|
7
9
|
const convex_1 = require("./convex");
|
|
8
10
|
const curveLP_1 = require("./curveLP");
|
|
9
11
|
const decimals_1 = require("./decimals");
|
|
@@ -15,6 +17,9 @@ exports.lpTokens = {
|
|
|
15
17
|
...convex_1.convexTokens,
|
|
16
18
|
...yearn_1.yearnTokens,
|
|
17
19
|
...balancer_1.balancerLpTokens,
|
|
20
|
+
...aave_1.aaveV2Tokens,
|
|
21
|
+
...aave_1.wrappedAaveV2Tokens,
|
|
22
|
+
...compound_1.compoundV2Tokens,
|
|
18
23
|
};
|
|
19
24
|
exports.supportedTokens = {
|
|
20
25
|
...normal_1.normalTokens,
|
|
@@ -44,9 +49,10 @@ exports.tokenDataByNetwork = {
|
|
|
44
49
|
MIM: "0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3",
|
|
45
50
|
SPELL: "0x090185f2135308BaD17527004364eBcC2D37e5F6",
|
|
46
51
|
GMX: constants_1.NOT_DEPLOYED,
|
|
47
|
-
ARB:
|
|
52
|
+
ARB: "0xB50721BCf8d664c30412Cfbc6cf7a15145234ad1",
|
|
48
53
|
RDNT: constants_1.NOT_DEPLOYED,
|
|
49
54
|
BAL: "0xba100000625a3754423978a60c9317c58a424e3D",
|
|
55
|
+
SHIB: "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE",
|
|
50
56
|
/// UPDATE
|
|
51
57
|
STETH: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
|
|
52
58
|
wstETH: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
|
@@ -119,6 +125,19 @@ exports.tokenDataByNetwork = {
|
|
|
119
125
|
dwstETH: "0x2158034dB06f06dcB9A786D2F1F8c38781bA779d",
|
|
120
126
|
dFRAX: "0x8A1112AFef7F4FC7c066a77AABBc01b3Fff31D47",
|
|
121
127
|
GEAR: "0xBa3335588D9403515223F109EdC4eB7269a9Ab5D",
|
|
128
|
+
// AAVE
|
|
129
|
+
aUSDC: "0xBcca60bB61934080951369a648Fb03DF4F96263C",
|
|
130
|
+
aDAI: "0x028171bCA77440897B824Ca71D1c56caC55b68A3",
|
|
131
|
+
aUSDT: "0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
|
|
132
|
+
aWETH: "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e",
|
|
133
|
+
waDAI: constants_1.NOT_DEPLOYED,
|
|
134
|
+
waUSDC: constants_1.NOT_DEPLOYED,
|
|
135
|
+
waUSDT: constants_1.NOT_DEPLOYED,
|
|
136
|
+
waWETH: constants_1.NOT_DEPLOYED,
|
|
137
|
+
cDAI: constants_1.NOT_DEPLOYED,
|
|
138
|
+
cUSDC: constants_1.NOT_DEPLOYED,
|
|
139
|
+
cUSDT: constants_1.NOT_DEPLOYED,
|
|
140
|
+
cWETH: constants_1.NOT_DEPLOYED,
|
|
122
141
|
},
|
|
123
142
|
///
|
|
124
143
|
///
|
|
@@ -153,12 +172,14 @@ exports.tokenDataByNetwork = {
|
|
|
153
172
|
wstETH: "0x5979D7b546E38E414F7E9822514be443A4800529",
|
|
154
173
|
CVX: "0xb952A807345991BD529FDded05009F5e80Fe8F45",
|
|
155
174
|
FRAX: "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
|
|
156
|
-
FXS: "
|
|
175
|
+
FXS: "0x9d2F299715D94d8A7E6F5eaa8E654E8c74a988A7",
|
|
157
176
|
LDO: "0x13Ad51ed4F1B7e9Dc168d8a00cB3f4dDD85EfA60",
|
|
158
177
|
LUSD: "0x93b346b6BC2548dA6A1E7d98E9a421B42541425b",
|
|
159
178
|
sUSD: "0xA970AF1a584579B618be4d69aD6F73459D112F95",
|
|
160
179
|
GUSD: constants_1.NOT_DEPLOYED,
|
|
161
180
|
LQTY: "0xfb9E5D956D889D91a82737B9bFCDaC1DCE3e1449",
|
|
181
|
+
// REDSTONE
|
|
182
|
+
SHIB: constants_1.NOT_DEPLOYED,
|
|
162
183
|
// YEARN TOKENS
|
|
163
184
|
yvDAI: constants_1.NOT_DEPLOYED,
|
|
164
185
|
yvUSDC: constants_1.NOT_DEPLOYED,
|
|
@@ -220,6 +241,19 @@ exports.tokenDataByNetwork = {
|
|
|
220
241
|
dwstETH: constants_1.NOT_DEPLOYED,
|
|
221
242
|
dFRAX: constants_1.NOT_DEPLOYED,
|
|
222
243
|
GEAR: constants_1.NOT_DEPLOYED,
|
|
244
|
+
// AAVE
|
|
245
|
+
aUSDC: "0x724dc807b04555b71ed48a6896b6F41593b8C637",
|
|
246
|
+
aDAI: "0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE",
|
|
247
|
+
aUSDT: "0x6ab707Aca953eDAeFBc4fD23bA73294241490620",
|
|
248
|
+
aWETH: "0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8",
|
|
249
|
+
waDAI: constants_1.NOT_DEPLOYED,
|
|
250
|
+
waUSDC: constants_1.NOT_DEPLOYED,
|
|
251
|
+
waUSDT: constants_1.NOT_DEPLOYED,
|
|
252
|
+
waWETH: constants_1.NOT_DEPLOYED,
|
|
253
|
+
cDAI: constants_1.NOT_DEPLOYED,
|
|
254
|
+
cUSDC: constants_1.NOT_DEPLOYED,
|
|
255
|
+
cUSDT: constants_1.NOT_DEPLOYED,
|
|
256
|
+
cWETH: constants_1.NOT_DEPLOYED,
|
|
223
257
|
},
|
|
224
258
|
};
|
|
225
259
|
exports.tokenSymbolByAddress = mappers_1.TypedObjectUtils.entries(exports.tokenDataByNetwork).reduce((acc, [, tokens]) => ({
|
package/lib/tokens/tokenType.js
CHANGED
|
@@ -12,6 +12,8 @@ var TokenType;
|
|
|
12
12
|
TokenType[TokenType["CONVEX_STAKED_TOKEN"] = 6] = "CONVEX_STAKED_TOKEN";
|
|
13
13
|
TokenType[TokenType["DIESEL_LP_TOKEN"] = 7] = "DIESEL_LP_TOKEN";
|
|
14
14
|
TokenType[TokenType["GEAR_TOKEN"] = 8] = "GEAR_TOKEN";
|
|
15
|
-
TokenType[TokenType["
|
|
15
|
+
TokenType[TokenType["COMPOUND_V2_C_TOKEN"] = 9] = "COMPOUND_V2_C_TOKEN";
|
|
16
16
|
TokenType[TokenType["BALANCER_LP_TOKEN"] = 10] = "BALANCER_LP_TOKEN";
|
|
17
|
+
TokenType[TokenType["AAVE_V2_A_TOKEN"] = 11] = "AAVE_V2_A_TOKEN";
|
|
18
|
+
TokenType[TokenType["WRAPPED_AAVE_V2_TOKEN"] = 12] = "WRAPPED_AAVE_V2_TOKEN";
|
|
17
19
|
})(TokenType = exports.TokenType || (exports.TokenType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
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 ethers_1 = require("ethers");
|
|
7
|
+
const chains_1 = require("../core/chains");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const multicall_1 = __importDefault(require("../utils/multicall"));
|
|
10
|
+
const token_1 = require("./token");
|
|
11
|
+
const erc20 = types_1.IERC20Metadata__factory.createInterface();
|
|
12
|
+
const EXCEPTIONS_IN_SYMBOLS = {
|
|
13
|
+
Mainnet: {
|
|
14
|
+
// Our Symbol <-> On-chain Symbol
|
|
15
|
+
[token_1.tokenDataByNetwork.Mainnet.STETH]: "stETH",
|
|
16
|
+
},
|
|
17
|
+
Arbitrum: {
|
|
18
|
+
// Our Symbol <-> On-chain Symbol
|
|
19
|
+
[token_1.tokenDataByNetwork.Arbitrum.crvUSDTWBTCWETH]: "crv3crypto",
|
|
20
|
+
[token_1.tokenDataByNetwork.Arbitrum["50OHM_50WETH"]]: "50WETH_50OHM",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
class TokenSuite {
|
|
24
|
+
provider;
|
|
25
|
+
network;
|
|
26
|
+
calls;
|
|
27
|
+
responses = {};
|
|
28
|
+
constructor(network) {
|
|
29
|
+
this.network = network;
|
|
30
|
+
const url = process.env[`${network.toUpperCase()}_TESTS_FORK`];
|
|
31
|
+
if (!url) {
|
|
32
|
+
throw new Error(`${network} provder not found in env`);
|
|
33
|
+
}
|
|
34
|
+
this.provider = new ethers_1.ethers.providers.StaticJsonRpcProvider(url, chains_1.CHAINS[network]);
|
|
35
|
+
// Omit NOT DEPLOYED
|
|
36
|
+
const entries = Object.entries(token_1.tokenDataByNetwork[network]).filter(([_, addr]) => addr?.startsWith("0x"));
|
|
37
|
+
this.calls = entries.map(([symbol, address]) => ({
|
|
38
|
+
address,
|
|
39
|
+
interface: erc20,
|
|
40
|
+
method: "symbol()",
|
|
41
|
+
key: symbol,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
async fetchSymbols() {
|
|
45
|
+
// even safe multicall fails when one of addresses is an EOA and not contract address
|
|
46
|
+
if (this.network === "Arbitrum") {
|
|
47
|
+
for (const call of this.calls) {
|
|
48
|
+
const c = types_1.IERC20Metadata__factory.connect(call.address, this.provider);
|
|
49
|
+
try {
|
|
50
|
+
const s = await c.symbol();
|
|
51
|
+
this.responses[call.key] = {
|
|
52
|
+
address: call.address,
|
|
53
|
+
symbol: this.sanitize(s),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
this.responses[call.key] = {
|
|
58
|
+
address: call.address,
|
|
59
|
+
error: e,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const resps = await (0, multicall_1.default)(this.calls, this.provider);
|
|
66
|
+
for (let i = 0; i < resps.length; i++) {
|
|
67
|
+
const call = this.calls[i];
|
|
68
|
+
const resp = resps[i];
|
|
69
|
+
this.responses[call.key] = {
|
|
70
|
+
address: call.address,
|
|
71
|
+
symbol: resp.error ? undefined : this.sanitize(resp.value ?? ""),
|
|
72
|
+
error: resp.error ? new Error("multicall error") : undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Given <symbol, address> token map on our sdk, asserts that symbol found on chain for this address is the same
|
|
79
|
+
* Takes into account some exceptions
|
|
80
|
+
* @param sdkSymbol Symbol of token in SDK
|
|
81
|
+
*/
|
|
82
|
+
assertSymbol(sdkSymbol) {
|
|
83
|
+
const r = this.responses[sdkSymbol];
|
|
84
|
+
if (r.error) {
|
|
85
|
+
throw new Error(`failed to verify ${sdkSymbol} on address ${r.address}: ${console.error}`);
|
|
86
|
+
}
|
|
87
|
+
const expectedSymbol = EXCEPTIONS_IN_SYMBOLS[this.network][r.address] ?? sdkSymbol;
|
|
88
|
+
if (r.symbol !== expectedSymbol) {
|
|
89
|
+
throw new Error(`Expected ${expectedSymbol} but found ${r.symbol} at ${r.address}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
sanitize(symbol) {
|
|
93
|
+
return symbol.replace(/\-f$/, "").replaceAll("-", "_");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
describe("Tokens", () => {
|
|
97
|
+
const suites = chains_1.supportedChains.map(n => new TokenSuite(n));
|
|
98
|
+
before(async function () {
|
|
99
|
+
this.timeout(60000);
|
|
100
|
+
await Promise.all(suites.map(s => s.fetchSymbols()));
|
|
101
|
+
});
|
|
102
|
+
suites.forEach(suite => {
|
|
103
|
+
suite.calls.forEach(call => {
|
|
104
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
105
|
+
it(`${call.key} on ${suite.network}`, () => {
|
|
106
|
+
suite.assertSymbol(call.key);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
package/lib/utils/multicall.d.ts
CHANGED
|
@@ -10,7 +10,21 @@ export interface MCall<T extends ethers.utils.Interface> {
|
|
|
10
10
|
method: keyof T["functions"];
|
|
11
11
|
params?: any;
|
|
12
12
|
}
|
|
13
|
+
export interface KeyedCall<T extends ethers.utils.Interface> extends MCall<T> {
|
|
14
|
+
key: string;
|
|
15
|
+
}
|
|
13
16
|
export declare function multicall<R extends Array<any>>(calls: Array<MCall<any>>, p: Signer | ethers.providers.Provider, overrides?: CallOverrides): Promise<R>;
|
|
17
|
+
/**
|
|
18
|
+
* Like multicall from sdk, but uses tryAggregate instead of aggregate
|
|
19
|
+
* @param calls
|
|
20
|
+
* @param p
|
|
21
|
+
* @param overrides
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export default function safeMulticall<V = any, T extends MCall<any> = MCall<any>>(calls: T[], p: Signer | ethers.providers.Provider, overrides?: CallOverrides): Promise<Array<{
|
|
25
|
+
error: boolean;
|
|
26
|
+
value?: V;
|
|
27
|
+
}>>;
|
|
14
28
|
export declare class MultiCallContract<T extends ethers.utils.Interface> {
|
|
15
29
|
private readonly _address;
|
|
16
30
|
private readonly _interface;
|
package/lib/utils/multicall.js
CHANGED
|
@@ -11,9 +11,42 @@ async function multicall(calls, p, overrides) {
|
|
|
11
11
|
})), overrides || {});
|
|
12
12
|
return returnData
|
|
13
13
|
.map((d, num) => calls[num].interface.decodeFunctionResult(calls[num].method, d))
|
|
14
|
-
.map(
|
|
14
|
+
.map(unwrapArray);
|
|
15
15
|
}
|
|
16
16
|
exports.multicall = multicall;
|
|
17
|
+
/**
|
|
18
|
+
* Like multicall from sdk, but uses tryAggregate instead of aggregate
|
|
19
|
+
* @param calls
|
|
20
|
+
* @param p
|
|
21
|
+
* @param overrides
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
async function safeMulticall(calls, p, overrides) {
|
|
25
|
+
if (!calls.length) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const multiCallContract = types_1.Multicall2__factory.connect("0xcA11bde05977b3631167028862bE2a173976CA11", p);
|
|
29
|
+
const resp = await multiCallContract.callStatic.tryAggregate(false, calls.map(c => ({
|
|
30
|
+
target: c.address,
|
|
31
|
+
callData: c.interface.encodeFunctionData(c.method, c.params),
|
|
32
|
+
})), overrides ?? {});
|
|
33
|
+
return resp.map((d, num) => ({
|
|
34
|
+
error: !d.success,
|
|
35
|
+
value: d.success
|
|
36
|
+
? unwrapArray(calls[num].interface.decodeFunctionResult(calls[num].method, d.returnData))
|
|
37
|
+
: undefined,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
exports.default = safeMulticall;
|
|
41
|
+
function unwrapArray(data) {
|
|
42
|
+
if (!data) {
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(data)) {
|
|
46
|
+
return data.length === 1 ? data[0] : data;
|
|
47
|
+
}
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
17
50
|
class MultiCallContract {
|
|
18
51
|
_address;
|
|
19
52
|
_interface;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lint": "eslint \"**/*.ts\" --fix",
|
|
24
24
|
"lint:ci": "eslint \"**/*.ts\"",
|
|
25
25
|
"typecheck:ci": "tsc --noEmit",
|
|
26
|
-
"test": "npx mocha
|
|
26
|
+
"test": "npx mocha -r ts-node/register -r dotenv/config src/**/*.spec.ts"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@types/deep-eql": "^4.0.0",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@typechain/ethers-v5": "10.0.0",
|
|
41
41
|
"@types/chai": "^4.3.3",
|
|
42
42
|
"@types/jest": "^28.1.7",
|
|
43
|
+
"@types/mocha": "^10.0.1",
|
|
43
44
|
"@types/node": "^18.7.6",
|
|
44
45
|
"@types/rimraf": "^3.0.2",
|
|
45
46
|
"chai": "^4.3.6",
|