@gearbox-protocol/sdk 2.1.35 → 2.1.37

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.
Files changed (41) hide show
  1. package/lib/apy/curveAPY.js +2 -1
  2. package/lib/apy/yearnAPY.js +1 -1
  3. package/lib/contracts/adapters.d.ts +1 -24
  4. package/lib/contracts/adapters.js +15 -26
  5. package/lib/contracts/contracts.d.ts +1 -112
  6. package/lib/contracts/contracts.js +15 -652
  7. package/lib/contracts/protocols.d.ts +1 -12
  8. package/lib/contracts/protocols.js +15 -14
  9. package/lib/contracts/utilsContracts.d.ts +1 -7
  10. package/lib/contracts/utilsContracts.js +15 -26
  11. package/lib/tokens/aave.d.ts +1 -20
  12. package/lib/tokens/aave.js +15 -60
  13. package/lib/tokens/balancer.d.ts +1 -12
  14. package/lib/tokens/balancer.js +15 -34
  15. package/lib/tokens/compound.d.ts +1 -11
  16. package/lib/tokens/compound.js +15 -36
  17. package/lib/tokens/convex.d.ts +1 -30
  18. package/lib/tokens/convex.js +15 -260
  19. package/lib/tokens/curveLP.d.ts +1 -27
  20. package/lib/tokens/curveLP.js +15 -139
  21. package/lib/tokens/decimals.d.ts +1 -2
  22. package/lib/tokens/decimals.js +15 -113
  23. package/lib/tokens/gear.d.ts +1 -14
  24. package/lib/tokens/gear.js +15 -45
  25. package/lib/tokens/index.d.ts +3 -0
  26. package/lib/tokens/index.js +19 -0
  27. package/lib/tokens/normal.d.ts +1 -9
  28. package/lib/tokens/normal.js +15 -192
  29. package/lib/tokens/quoted.d.ts +1 -3
  30. package/lib/tokens/quoted.js +15 -5
  31. package/lib/tokens/token.d.ts +1 -25
  32. package/lib/tokens/token.js +15 -303
  33. package/lib/tokens/tokenData.d.ts +1 -4
  34. package/lib/tokens/tokenData.js +16 -16
  35. package/lib/tokens/tokenType.d.ts +1 -15
  36. package/lib/tokens/tokenType.js +15 -17
  37. package/lib/tokens/yearn.d.ts +1 -26
  38. package/lib/tokens/yearn.js +15 -50
  39. package/package.json +2 -1
  40. package/lib/tokens/tokens.spec.d.ts +0 -1
  41. package/lib/tokens/tokens.spec.js +0 -151
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable max-nested-callbacks */
4
- const ethers_1 = require("ethers");
5
- const chains_1 = require("../core/chains");
6
- const types_1 = require("../types");
7
- const multicall_1 = require("../utils/multicall");
8
- const token_1 = require("./token");
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
- }
25
- const EXCEPTIONS_IN_SYMBOLS = {
26
- Mainnet: {
27
- // Our Symbol <-> On-chain Symbol
28
- [token_1.tokenDataByNetwork.Mainnet.STETH]: "stETH",
29
- },
30
- Arbitrum: {
31
- // Our Symbol <-> On-chain Symbol
32
- [token_1.tokenDataByNetwork.Arbitrum.crvUSDTWBTCWETH]: "crv3crypto",
33
- [token_1.tokenDataByNetwork.Arbitrum["50OHM_50WETH"]]: "50WETH_50OHM",
34
- [token_1.tokenDataByNetwork.Arbitrum.aDAI]: "aArbDAI",
35
- [token_1.tokenDataByNetwork.Arbitrum.aUSDC]: "aArbUSDCn",
36
- [token_1.tokenDataByNetwork.Arbitrum.aUSDT]: "aArbUSDT",
37
- [token_1.tokenDataByNetwork.Arbitrum.aWETH]: "aArbWETH",
38
- },
39
- };
40
- class TokenSuite {
41
- provider;
42
- network;
43
- calls;
44
- responses = {};
45
- constructor(network) {
46
- this.network = network;
47
- const url = process.env[`${network.toUpperCase()}_TESTS_FORK`];
48
- if (!url) {
49
- throw new Error(`${network} provder not found in env`);
50
- }
51
- this.provider = new ethers_1.ethers.providers.StaticJsonRpcProvider(url, chains_1.CHAINS[network]);
52
- // Omit NOT DEPLOYED
53
- const entries = Object.entries(token_1.tokenDataByNetwork[network]).filter(([_, addr]) => addr?.startsWith("0x"));
54
- this.calls = entries.map(([symbol, address]) => ({
55
- address,
56
- interface: NON_ERC20_SYMBOLS[address]?.interface ?? erc20,
57
- method: "symbol()",
58
- key: symbol,
59
- }));
60
- }
61
- async fetchSymbols() {
62
- // even safe multicall fails when one of addresses is an EOA and not contract address
63
- if (this.network === "Arbitrum") {
64
- // if (true) {
65
- for (const call of this.calls) {
66
- const c = types_1.IERC20Metadata__factory.connect(call.address, this.provider);
67
- try {
68
- const s = await c.symbol();
69
- this.responses[call.key] = {
70
- address: call.address,
71
- symbol: this.sanitize(s),
72
- };
73
- }
74
- catch (e) {
75
- this.responses[call.key] = {
76
- address: call.address,
77
- error: e,
78
- };
79
- }
80
- }
81
- }
82
- else {
83
- const resps = await (0, multicall_1.safeMulticall)(this.calls, this.provider);
84
- for (let i = 0; i < resps.length; i++) {
85
- const call = this.calls[i];
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;
90
- this.responses[call.key] = {
91
- address: call.address,
92
- symbol: resp.error
93
- ? undefined
94
- : this.sanitize(stringifySymbol(resp.value ?? "")),
95
- error: resp.error,
96
- };
97
- }
98
- }
99
- }
100
- /**
101
- * Given <symbol, address> token map on our sdk, asserts that symbol found on chain for this address is the same
102
- * Takes into account some exceptions
103
- * @param sdkSymbol Symbol of token in SDK
104
- */
105
- assertSymbol(sdkSymbol) {
106
- const r = this.responses[sdkSymbol];
107
- if (r.error) {
108
- throw new Error(`failed to verify ${sdkSymbol} on address ${r.address}: ${r.error}`);
109
- }
110
- const expectedSymbol = EXCEPTIONS_IN_SYMBOLS[this.network][r.address] ?? sdkSymbol;
111
- if (r.symbol !== expectedSymbol) {
112
- throw new Error(`Expected ${expectedSymbol} but found ${r.symbol} at ${r.address}`);
113
- }
114
- }
115
- assertChecksum(sdkSymbol) {
116
- const sdkAddress = token_1.tokenDataByNetwork[this.network][sdkSymbol];
117
- let err;
118
- try {
119
- const addr = ethers_1.ethers.utils.getAddress(sdkAddress);
120
- if (addr !== sdkAddress) {
121
- err = new Error(`sdk address for token ${sdkSymbol} is not checksummed: expected ${addr}, got ${sdkAddress}`);
122
- }
123
- }
124
- catch (e) {
125
- err = new Error(`sdk address ${sdkAddress} for token ${sdkSymbol} has bad checksum: ${e}`);
126
- }
127
- if (err) {
128
- throw err;
129
- }
130
- }
131
- sanitize(symbol) {
132
- return symbol.replace(/\-f$/, "").replaceAll("-", "_");
133
- }
134
- }
135
- describe("Tokens", () => {
136
- const suites = chains_1.supportedChains.map(n => new TokenSuite(n));
137
- before(async function () {
138
- this.timeout(120000);
139
- await Promise.all(suites.map(s => s.fetchSymbols()));
140
- });
141
- suites.forEach(suite => {
142
- suite.calls.forEach(call => {
143
- it(`symbol for ${call.key} on ${suite.network}`, () => {
144
- suite.assertSymbol(call.key);
145
- });
146
- it(`address checksum for ${call.key} on ${suite.network}`, () => {
147
- suite.assertChecksum(call.key);
148
- });
149
- });
150
- });
151
- });