@gearbox-protocol/sdk 2.1.32 → 2.1.33
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/lib/tokens/balancer.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TradeType } from "../pathfinder/tradeTypes";
|
|
|
2
2
|
import { NormalToken } from "./normal";
|
|
3
3
|
import type { TokenBase } from "./token";
|
|
4
4
|
import { TokenType } from "./tokenType";
|
|
5
|
-
export type BalancerLPToken = "50OHM_50DAI" | "50OHM_50WETH" | "OHM_wstETH" | "
|
|
5
|
+
export type BalancerLPToken = "50OHM_50DAI" | "50OHM_50WETH" | "OHM_wstETH" | "USDC_DAI_USDT";
|
|
6
6
|
export type BalancerLpTokenData = {
|
|
7
7
|
symbol: BalancerLPToken;
|
|
8
8
|
type: TokenType.BALANCER_LP_TOKEN;
|
package/lib/tokens/balancer.js
CHANGED
|
@@ -46,9 +46,9 @@ exports.balancerLpTokens = {
|
|
|
46
46
|
},
|
|
47
47
|
],
|
|
48
48
|
},
|
|
49
|
-
|
|
50
|
-
name: "Balancer
|
|
51
|
-
symbol: "
|
|
49
|
+
USDC_DAI_USDT: {
|
|
50
|
+
name: "Balancer USDC_DAI_USDT",
|
|
51
|
+
symbol: "USDC_DAI_USDT",
|
|
52
52
|
type: tokenType_1.TokenType.BALANCER_LP_TOKEN,
|
|
53
53
|
underlying: ["USDC", "DAI", "USDT"],
|
|
54
54
|
poolId: "0x79c58f70905f734641735bc61e45c19dd9ad60bc0000000000000000000004e7",
|
package/lib/tokens/decimals.js
CHANGED
package/lib/tokens/token.js
CHANGED
|
@@ -125,7 +125,7 @@ exports.tokenDataByNetwork = {
|
|
|
125
125
|
"50OHM_50DAI": "0x76FCf0e8C7Ff37A47a799FA2cd4c13cDe0D981C9",
|
|
126
126
|
"50OHM_50WETH": "0xD1eC5e215E8148D76F4460e4097FD3d5ae0A3558",
|
|
127
127
|
OHM_wstETH: "0xd4f79CA0Ac83192693bce4699d0c10C66Aa6Cf0F",
|
|
128
|
-
|
|
128
|
+
USDC_DAI_USDT: "0x79c58f70905F734641735BC61e45c19dD9Ad60bC",
|
|
129
129
|
// GEARBOX
|
|
130
130
|
dDAI: "0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA",
|
|
131
131
|
dUSDC: "0xc411dB5f5Eb3f7d552F9B8454B2D74097ccdE6E3",
|
|
@@ -251,7 +251,7 @@ exports.tokenDataByNetwork = {
|
|
|
251
251
|
"50OHM_50DAI": constants_1.NOT_DEPLOYED,
|
|
252
252
|
"50OHM_50WETH": "0x89dc7e71e362faF88D92288fE2311D25c6a1B5E0",
|
|
253
253
|
OHM_wstETH: constants_1.NOT_DEPLOYED,
|
|
254
|
-
|
|
254
|
+
USDC_DAI_USDT: constants_1.NOT_DEPLOYED,
|
|
255
255
|
// GEARBOX
|
|
256
256
|
dDAI: constants_1.NOT_DEPLOYED,
|
|
257
257
|
dUSDC: constants_1.NOT_DEPLOYED,
|
|
@@ -7,6 +7,21 @@ const types_1 = require("../types");
|
|
|
7
7
|
const multicall_1 = require("../utils/multicall");
|
|
8
8
|
const token_1 = require("./token");
|
|
9
9
|
const erc20 = types_1.IERC20Metadata__factory.createInterface();
|
|
10
|
+
// Some contracts return something other than string for symbol
|
|
11
|
+
const NON_ERC20_SYMBOLS = {
|
|
12
|
+
[token_1.tokenDataByNetwork.Mainnet.MKR]: {
|
|
13
|
+
interface: new ethers_1.ethers.utils.Interface([
|
|
14
|
+
"function symbol() view returns (bytes32)",
|
|
15
|
+
]),
|
|
16
|
+
// convert bytes32 to string
|
|
17
|
+
stringifySymbol: (result) => ethers_1.ethers.utils
|
|
18
|
+
.toUtf8String(ethers_1.ethers.utils.arrayify(result))
|
|
19
|
+
.replaceAll(String.fromCharCode(0), ""), // trim tail of zeroes
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
function identity(value) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
10
25
|
const EXCEPTIONS_IN_SYMBOLS = {
|
|
11
26
|
Mainnet: {
|
|
12
27
|
// Our Symbol <-> On-chain Symbol
|
|
@@ -38,7 +53,7 @@ class TokenSuite {
|
|
|
38
53
|
const entries = Object.entries(token_1.tokenDataByNetwork[network]).filter(([_, addr]) => addr?.startsWith("0x"));
|
|
39
54
|
this.calls = entries.map(([symbol, address]) => ({
|
|
40
55
|
address,
|
|
41
|
-
interface: erc20,
|
|
56
|
+
interface: NON_ERC20_SYMBOLS[address]?.interface ?? erc20,
|
|
42
57
|
method: "symbol()",
|
|
43
58
|
key: symbol,
|
|
44
59
|
}));
|
|
@@ -46,6 +61,7 @@ class TokenSuite {
|
|
|
46
61
|
async fetchSymbols() {
|
|
47
62
|
// even safe multicall fails when one of addresses is an EOA and not contract address
|
|
48
63
|
if (this.network === "Arbitrum") {
|
|
64
|
+
// if (true) {
|
|
49
65
|
for (const call of this.calls) {
|
|
50
66
|
const c = types_1.IERC20Metadata__factory.connect(call.address, this.provider);
|
|
51
67
|
try {
|
|
@@ -68,10 +84,15 @@ class TokenSuite {
|
|
|
68
84
|
for (let i = 0; i < resps.length; i++) {
|
|
69
85
|
const call = this.calls[i];
|
|
70
86
|
const resp = resps[i];
|
|
87
|
+
// most symbols are ok, but some return non-string value for symbol.
|
|
88
|
+
// stringifySymbol makes sure that we get symbol as string
|
|
89
|
+
const stringifySymbol = NON_ERC20_SYMBOLS[call.address]?.stringifySymbol ?? identity;
|
|
71
90
|
this.responses[call.key] = {
|
|
72
91
|
address: call.address,
|
|
73
|
-
symbol: resp.error
|
|
74
|
-
|
|
92
|
+
symbol: resp.error
|
|
93
|
+
? undefined
|
|
94
|
+
: this.sanitize(stringifySymbol(resp.value ?? "")),
|
|
95
|
+
error: resp.error,
|
|
75
96
|
};
|
|
76
97
|
}
|
|
77
98
|
}
|
|
@@ -84,7 +105,7 @@ class TokenSuite {
|
|
|
84
105
|
assertSymbol(sdkSymbol) {
|
|
85
106
|
const r = this.responses[sdkSymbol];
|
|
86
107
|
if (r.error) {
|
|
87
|
-
throw new Error(`failed to verify ${sdkSymbol} on address ${r.address}: ${
|
|
108
|
+
throw new Error(`failed to verify ${sdkSymbol} on address ${r.address}: ${r.error}`);
|
|
88
109
|
}
|
|
89
110
|
const expectedSymbol = EXCEPTIONS_IN_SYMBOLS[this.network][r.address] ?? sdkSymbol;
|
|
90
111
|
if (r.symbol !== expectedSymbol) {
|
package/lib/utils/multicall.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function multicall<R extends Array<any>>(calls: Array<MCall<any>>
|
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
24
|
export declare function safeMulticall<V = any, T extends MCall<any> = MCall<any>>(calls: T[], p: Signer | ethers.providers.Provider, overrides?: CallOverrides): Promise<Array<{
|
|
25
|
-
error
|
|
25
|
+
error?: Error;
|
|
26
26
|
value?: V;
|
|
27
27
|
}>>;
|
|
28
28
|
export declare class MultiCallContract<T extends ethers.utils.Interface> {
|
package/lib/utils/multicall.js
CHANGED
|
@@ -30,12 +30,27 @@ async function safeMulticall(calls, p, overrides) {
|
|
|
30
30
|
target: c.address,
|
|
31
31
|
callData: c.interface.encodeFunctionData(c.method, c.params),
|
|
32
32
|
})), overrides ?? {});
|
|
33
|
-
return resp.map((d, num) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
return resp.map((d, num) => {
|
|
34
|
+
let value;
|
|
35
|
+
let error;
|
|
36
|
+
if (d.success) {
|
|
37
|
+
try {
|
|
38
|
+
value = unwrapArray(calls[num].interface.decodeFunctionResult(calls[num].method, d.returnData));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (e instanceof Error) {
|
|
42
|
+
error = e;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
error = new Error(`${e}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
error = new Error("multicall call failed");
|
|
51
|
+
}
|
|
52
|
+
return { error, value };
|
|
53
|
+
});
|
|
39
54
|
}
|
|
40
55
|
exports.safeMulticall = safeMulticall;
|
|
41
56
|
function unwrapArray(data) {
|