@gearbox-protocol/sdk 3.0.0-vfour.337 → 3.0.0-vfour.338

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-vfour.337",
3
+ "version": "3.0.0-vfour.338",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var import_viem = require("viem");
3
- var import_vitest = require("vitest");
4
- var import_abi = require("../../abi/index.js");
5
- var import_hex = require("../utils/hex.js");
6
- var import_mappers = require("../utils/mappers.js");
7
- var import_chains = require("./chains.js");
8
- const allTokens = Object.values(import_chains.chains).map((chain) => ({
9
- address: (0, import_viem.getAddress)(chain.wellKnownToken.address),
10
- network: chain.network,
11
- symbol: chain.wellKnownToken.symbol
12
- }));
13
- async function fetchTokensMulticall(client) {
14
- const resp = await client.multicall({
15
- contracts: allTokens.map(
16
- (token) => ({
17
- address: token.address,
18
- abi: import_abi.ierc20Abi,
19
- functionName: "symbol"
20
- })
21
- ),
22
- allowFailure: true
23
- });
24
- const result = {};
25
- for (let i = 0; i < resp.length; i++) {
26
- const token = allTokens[i];
27
- const r = resp[i];
28
- result[token.address] = r.status === "success" ? r.result : void 0;
29
- }
30
- return result;
31
- }
32
- async function fetchTokensSimple(client) {
33
- const resp = await Promise.allSettled(
34
- allTokens.map(
35
- (token) => client.readContract({
36
- address: token.address,
37
- abi: import_abi.ierc20Abi,
38
- functionName: "symbol"
39
- })
40
- )
41
- );
42
- const result = {};
43
- for (let i = 0; i < resp.length; i++) {
44
- const token = allTokens[i];
45
- const r = resp[i];
46
- result[token.address] = r.status === "fulfilled" ? r.value : void 0;
47
- }
48
- return result;
49
- }
50
- async function fetchAllTokens(chain) {
51
- const client = (0, import_viem.createPublicClient)({
52
- chain,
53
- transport: (0, import_viem.fallback)(
54
- Object.values(chain.rpcUrls).flatMap((urls) => urls.http.map((u) => (0, import_viem.http)(u)))
55
- )
56
- });
57
- if (chain.contracts?.multicall3) {
58
- return fetchTokensMulticall(client);
59
- }
60
- return fetchTokensSimple(client);
61
- }
62
- (0, import_vitest.it)("should correctly identify well-known tokens on their respective chains", async () => {
63
- const allChains = Object.values(import_chains.chains);
64
- const allTokensOnAllChains = await Promise.all(
65
- allChains.map((chain) => fetchAllTokens(chain))
66
- );
67
- for (let i = 0; i < allChains.length; i++) {
68
- const {
69
- network,
70
- wellKnownToken: { address: wellKnownToken, symbol: wellKnownTokenSymbol }
71
- } = allChains[i];
72
- const tokensOnChain = allTokensOnAllChains[i];
73
- import_vitest.expect.soft(
74
- tokensOnChain[(0, import_viem.getAddress)(wellKnownToken)],
75
- `should have well-known token ${wellKnownToken} with symbol ${wellKnownTokenSymbol} on ${network}`
76
- ).toBe(wellKnownTokenSymbol);
77
- for (const [token, symbol] of import_mappers.TypedObjectUtils.entries(tokensOnChain)) {
78
- if ((0, import_hex.hexEq)(token, wellKnownToken)) {
79
- continue;
80
- }
81
- import_vitest.expect.soft(
82
- symbol,
83
- `should not have token at ${token} on ${network}, but got ${symbol}`
84
- ).toBeUndefined();
85
- }
86
- }
87
- }, 15e3);
@@ -1,86 +0,0 @@
1
- import { createPublicClient, fallback, getAddress, http } from "viem";
2
- import { expect, it } from "vitest";
3
- import { ierc20Abi } from "../../abi/index.js";
4
- import { hexEq } from "../utils/hex.js";
5
- import { TypedObjectUtils } from "../utils/mappers.js";
6
- import { chains } from "./chains.js";
7
- const allTokens = Object.values(chains).map((chain) => ({
8
- address: getAddress(chain.wellKnownToken.address),
9
- network: chain.network,
10
- symbol: chain.wellKnownToken.symbol
11
- }));
12
- async function fetchTokensMulticall(client) {
13
- const resp = await client.multicall({
14
- contracts: allTokens.map(
15
- (token) => ({
16
- address: token.address,
17
- abi: ierc20Abi,
18
- functionName: "symbol"
19
- })
20
- ),
21
- allowFailure: true
22
- });
23
- const result = {};
24
- for (let i = 0; i < resp.length; i++) {
25
- const token = allTokens[i];
26
- const r = resp[i];
27
- result[token.address] = r.status === "success" ? r.result : void 0;
28
- }
29
- return result;
30
- }
31
- async function fetchTokensSimple(client) {
32
- const resp = await Promise.allSettled(
33
- allTokens.map(
34
- (token) => client.readContract({
35
- address: token.address,
36
- abi: ierc20Abi,
37
- functionName: "symbol"
38
- })
39
- )
40
- );
41
- const result = {};
42
- for (let i = 0; i < resp.length; i++) {
43
- const token = allTokens[i];
44
- const r = resp[i];
45
- result[token.address] = r.status === "fulfilled" ? r.value : void 0;
46
- }
47
- return result;
48
- }
49
- async function fetchAllTokens(chain) {
50
- const client = createPublicClient({
51
- chain,
52
- transport: fallback(
53
- Object.values(chain.rpcUrls).flatMap((urls) => urls.http.map((u) => http(u)))
54
- )
55
- });
56
- if (chain.contracts?.multicall3) {
57
- return fetchTokensMulticall(client);
58
- }
59
- return fetchTokensSimple(client);
60
- }
61
- it("should correctly identify well-known tokens on their respective chains", async () => {
62
- const allChains = Object.values(chains);
63
- const allTokensOnAllChains = await Promise.all(
64
- allChains.map((chain) => fetchAllTokens(chain))
65
- );
66
- for (let i = 0; i < allChains.length; i++) {
67
- const {
68
- network,
69
- wellKnownToken: { address: wellKnownToken, symbol: wellKnownTokenSymbol }
70
- } = allChains[i];
71
- const tokensOnChain = allTokensOnAllChains[i];
72
- expect.soft(
73
- tokensOnChain[getAddress(wellKnownToken)],
74
- `should have well-known token ${wellKnownToken} with symbol ${wellKnownTokenSymbol} on ${network}`
75
- ).toBe(wellKnownTokenSymbol);
76
- for (const [token, symbol] of TypedObjectUtils.entries(tokensOnChain)) {
77
- if (hexEq(token, wellKnownToken)) {
78
- continue;
79
- }
80
- expect.soft(
81
- symbol,
82
- `should not have token at ${token} on ${network}, but got ${symbol}`
83
- ).toBeUndefined();
84
- }
85
- }
86
- }, 15e3);