@strkfarm/sdk 2.0.0-dev.9 → 2.0.0-staging.2
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/dist/index.browser.global.js +111371 -93151
- package/dist/index.browser.mjs +27815 -32690
- package/dist/index.d.ts +1095 -2011
- package/dist/index.js +27425 -32309
- package/dist/index.mjs +27590 -32452
- package/package.json +6 -5
- package/src/data/ekubo-price-fethcer.abi.json +265 -0
- package/src/data/universal-vault.abi.json +20 -135
- package/src/dataTypes/address.ts +0 -7
- package/src/dataTypes/index.ts +3 -2
- package/src/dataTypes/mynumber.ts +141 -0
- package/src/global.ts +296 -288
- package/src/index.browser.ts +6 -5
- package/src/interfaces/common.tsx +324 -184
- package/src/modules/apollo-client-config.ts +28 -0
- package/src/modules/avnu.ts +4 -17
- package/src/modules/ekubo-pricer.ts +79 -0
- package/src/modules/ekubo-quoter.ts +11 -88
- package/src/modules/erc20.ts +21 -67
- package/src/modules/harvests.ts +26 -15
- package/src/modules/index.ts +11 -13
- package/src/modules/lst-apr.ts +0 -36
- package/src/modules/pragma.ts +23 -8
- package/src/modules/pricer-from-api.ts +150 -14
- package/src/modules/pricer.ts +2 -1
- package/src/modules/pricerBase.ts +2 -1
- package/src/node/deployer.ts +36 -1
- package/src/node/pricer-redis.ts +2 -1
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/base-strategy.ts +5 -22
- package/src/strategies/ekubo-cl-vault.tsx +2904 -2175
- package/src/strategies/factory.ts +165 -0
- package/src/strategies/index.ts +10 -11
- package/src/strategies/registry.ts +268 -0
- package/src/strategies/sensei.ts +416 -292
- package/src/strategies/universal-adapters/adapter-utils.ts +1 -5
- package/src/strategies/universal-adapters/baseAdapter.ts +153 -181
- package/src/strategies/universal-adapters/common-adapter.ts +77 -98
- package/src/strategies/universal-adapters/index.ts +1 -5
- package/src/strategies/universal-adapters/vesu-adapter.ts +218 -220
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +51 -58
- package/src/strategies/universal-lst-muliplier-strategy.tsx +1952 -992
- package/src/strategies/universal-strategy.tsx +1713 -1150
- package/src/strategies/vesu-rebalance.tsx +1189 -986
- package/src/utils/health-factor-math.ts +5 -11
- package/src/utils/index.ts +8 -9
- package/src/utils/strategy-utils.ts +57 -0
- package/src/data/extended-deposit.abi.json +0 -3613
- package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
- package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
- package/src/modules/midas.ts +0 -159
- package/src/modules/token-market-data.ts +0 -202
- package/src/strategies/svk-strategy.ts +0 -247
- package/src/strategies/universal-adapters/adapter-optimizer.ts +0 -65
- package/src/strategies/universal-adapters/avnu-adapter.ts +0 -413
- package/src/strategies/universal-adapters/extended-adapter.ts +0 -972
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +0 -1306
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -370
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1379
package/src/global.ts
CHANGED
|
@@ -4,212 +4,200 @@ import { ContractAddr } from "./dataTypes";
|
|
|
4
4
|
import { logger } from "@/utils/logger";
|
|
5
5
|
|
|
6
6
|
export class FatalError extends Error {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
constructor(message: string, err?: Error) {
|
|
8
|
+
super(message);
|
|
9
|
+
logger.error(message);
|
|
10
|
+
if (err) logger.error(err.message);
|
|
11
|
+
this.name = "FatalError";
|
|
12
|
+
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const defaultTokens: TokenInfo[] = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
{
|
|
202
|
-
name: "USDC",
|
|
203
|
-
symbol: "USDC",
|
|
204
|
-
logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
|
|
205
|
-
address: ContractAddr.from(
|
|
206
|
-
"0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb"
|
|
207
|
-
),
|
|
208
|
-
decimals: 6,
|
|
209
|
-
coingeckId: undefined,
|
|
210
|
-
displayDecimals: 2,
|
|
211
|
-
priceCheckAmount: 100,
|
|
212
|
-
},
|
|
16
|
+
{
|
|
17
|
+
name: "Starknet",
|
|
18
|
+
symbol: "STRK",
|
|
19
|
+
logo: "https://assets.troves.fi/integrations/tokens/strk.svg",
|
|
20
|
+
address: ContractAddr.from(
|
|
21
|
+
"0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
|
|
22
|
+
),
|
|
23
|
+
decimals: 18,
|
|
24
|
+
coingeckId: "starknet",
|
|
25
|
+
displayDecimals: 2,
|
|
26
|
+
priceCheckAmount: 1000
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "xSTRK",
|
|
30
|
+
symbol: "xSTRK",
|
|
31
|
+
logo: "https://assets.troves.fi/integrations/tokens/xstrk.svg",
|
|
32
|
+
address: ContractAddr.from(
|
|
33
|
+
"0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
|
|
34
|
+
),
|
|
35
|
+
decimals: 18,
|
|
36
|
+
coingeckId: undefined,
|
|
37
|
+
priceCheckAmount: 1000,
|
|
38
|
+
displayDecimals: 2
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "ETH",
|
|
42
|
+
symbol: "ETH",
|
|
43
|
+
logo: "https://assets.troves.fi/integrations/tokens/eth.svg",
|
|
44
|
+
address: ContractAddr.from(
|
|
45
|
+
"0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
|
|
46
|
+
),
|
|
47
|
+
decimals: 18,
|
|
48
|
+
coingeckId: undefined,
|
|
49
|
+
priceCheckAmount: 0.1,
|
|
50
|
+
displayDecimals: 6
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "USDC",
|
|
54
|
+
symbol: "USDC",
|
|
55
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
|
|
56
|
+
address: ContractAddr.from(
|
|
57
|
+
"0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"
|
|
58
|
+
),
|
|
59
|
+
decimals: 6,
|
|
60
|
+
coingeckId: undefined,
|
|
61
|
+
displayDecimals: 2,
|
|
62
|
+
priceCheckAmount: 1000
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "USDT",
|
|
66
|
+
symbol: "USDT",
|
|
67
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdt.svg",
|
|
68
|
+
address: ContractAddr.from(
|
|
69
|
+
"0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8"
|
|
70
|
+
),
|
|
71
|
+
decimals: 6,
|
|
72
|
+
coingeckId: undefined,
|
|
73
|
+
priceCheckAmount: 1000,
|
|
74
|
+
displayDecimals: 2
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "WBTC",
|
|
78
|
+
symbol: "WBTC",
|
|
79
|
+
logo: "https://assets.troves.fi/integrations/tokens/wbtc.svg",
|
|
80
|
+
address: ContractAddr.from(
|
|
81
|
+
"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac"
|
|
82
|
+
),
|
|
83
|
+
decimals: 8,
|
|
84
|
+
coingeckId: undefined,
|
|
85
|
+
displayDecimals: 6,
|
|
86
|
+
priceCheckAmount: 0.001 // 112000 * 0.0001 = $110.2
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "tBTC",
|
|
90
|
+
symbol: "tBTC",
|
|
91
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/tbtc.svg",
|
|
92
|
+
address: ContractAddr.from(
|
|
93
|
+
"0x4daa17763b286d1e59b97c283c0b8c949994c361e426a28f743c67bdfe9a32f"
|
|
94
|
+
),
|
|
95
|
+
decimals: 18,
|
|
96
|
+
coingeckId: undefined,
|
|
97
|
+
displayDecimals: 6,
|
|
98
|
+
priceCheckAmount: 0.001 // 112000 * 0.0001 = $110.2
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "solvBTC",
|
|
102
|
+
symbol: "solvBTC",
|
|
103
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/solvbtc.svg",
|
|
104
|
+
address: ContractAddr.from(
|
|
105
|
+
"0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"
|
|
106
|
+
),
|
|
107
|
+
decimals: 18,
|
|
108
|
+
coingeckId: undefined,
|
|
109
|
+
priceProxySymbol: "WBTC",
|
|
110
|
+
displayDecimals: 6,
|
|
111
|
+
priceCheckAmount: 0.0001 // 112000 * 0.0001 = $11.2
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "LBTC",
|
|
115
|
+
symbol: "LBTC",
|
|
116
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/lbtc.svg",
|
|
117
|
+
address: ContractAddr.from(
|
|
118
|
+
"0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4"
|
|
119
|
+
),
|
|
120
|
+
decimals: 8,
|
|
121
|
+
coingeckId: undefined,
|
|
122
|
+
displayDecimals: 6,
|
|
123
|
+
priceProxySymbol: "WBTC",
|
|
124
|
+
priceCheckAmount: 0.0001 // 112000 * 0.0001 = $11.2
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "xWBTC",
|
|
128
|
+
symbol: "xWBTC",
|
|
129
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
|
|
130
|
+
address: ContractAddr.from(
|
|
131
|
+
"0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"
|
|
132
|
+
),
|
|
133
|
+
decimals: 8,
|
|
134
|
+
coingeckId: undefined,
|
|
135
|
+
displayDecimals: 6,
|
|
136
|
+
priceCheckAmount: 0.001 // 112000 * 0.0001 = $110.2
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "xsBTC",
|
|
140
|
+
symbol: "xsBTC",
|
|
141
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
|
|
142
|
+
address: ContractAddr.from(
|
|
143
|
+
"0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"
|
|
144
|
+
),
|
|
145
|
+
decimals: 18,
|
|
146
|
+
coingeckId: undefined,
|
|
147
|
+
displayDecimals: 6,
|
|
148
|
+
priceProxySymbol: "WBTC",
|
|
149
|
+
priceCheckAmount: 0.0001 // 112000 * 0.0001 = $11.2
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
// todo upgrade proxy tokens once feeds are available
|
|
153
|
+
name: "xtBTC",
|
|
154
|
+
symbol: "xtBTC",
|
|
155
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
|
|
156
|
+
address: ContractAddr.from(
|
|
157
|
+
"0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"
|
|
158
|
+
),
|
|
159
|
+
decimals: 18,
|
|
160
|
+
coingeckId: undefined,
|
|
161
|
+
displayDecimals: 6,
|
|
162
|
+
priceCheckAmount: 0.001 // 112000 * 0.0001 = $110.2
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "xLBTC",
|
|
166
|
+
symbol: "xLBTC",
|
|
167
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xlbtc.svg",
|
|
168
|
+
address: ContractAddr.from(
|
|
169
|
+
"0x07dd3c80de9fcc5545f0cb83678826819c79619ed7992cc06ff81fc67cd2efe0"
|
|
170
|
+
),
|
|
171
|
+
decimals: 8,
|
|
172
|
+
coingeckId: undefined,
|
|
173
|
+
displayDecimals: 6,
|
|
174
|
+
priceProxySymbol: "WBTC",
|
|
175
|
+
priceCheckAmount: 0.0001 // 112000 * 0.0001 = $11.2
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "mRe7BTC",
|
|
179
|
+
symbol: "mRe7BTC",
|
|
180
|
+
logo: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/3a62ecee-1e58-45d3-9862-3ce90dff1900/logo",
|
|
181
|
+
address: ContractAddr.from(
|
|
182
|
+
"0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac"
|
|
183
|
+
),
|
|
184
|
+
decimals: 18,
|
|
185
|
+
coingeckId: undefined,
|
|
186
|
+
displayDecimals: 6,
|
|
187
|
+
priceCheckAmount: 0.0001 // 112000 * 0.0001 = $11.2
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "mRe7YIELD",
|
|
191
|
+
symbol: "mRe7YIELD",
|
|
192
|
+
logo: "https://midas.app/assets/mre7-BcOOHm7i.svg",
|
|
193
|
+
address: ContractAddr.from(
|
|
194
|
+
"0x4be8945e61dc3e19ebadd1579a6bd53b262f51ba89e6f8b0c4bc9a7e3c633fc"
|
|
195
|
+
),
|
|
196
|
+
decimals: 18,
|
|
197
|
+
coingeckId: undefined,
|
|
198
|
+
displayDecimals: 2,
|
|
199
|
+
priceCheckAmount: 100
|
|
200
|
+
}
|
|
213
201
|
];
|
|
214
202
|
const tokens: TokenInfo[] = defaultTokens;
|
|
215
203
|
|
|
@@ -217,106 +205,126 @@ const tokens: TokenInfo[] = defaultTokens;
|
|
|
217
205
|
* - fatalError: Things to do when a fatal error occurs
|
|
218
206
|
*/
|
|
219
207
|
export class Global {
|
|
220
|
-
|
|
221
|
-
|
|
208
|
+
static cache: Record<
|
|
209
|
+
string,
|
|
210
|
+
{ value: any; ttl: number; timestamp: number }
|
|
211
|
+
> = {};
|
|
222
212
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
213
|
+
static fatalError(message: string, err?: Error) {
|
|
214
|
+
logger.error(message);
|
|
215
|
+
console.error(message, err);
|
|
216
|
+
if (err) console.error(err);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
229
219
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
220
|
+
static httpError(url: string, err: Error, message?: string) {
|
|
221
|
+
logger.error(`${url}: ${message}`);
|
|
222
|
+
console.error(err);
|
|
223
|
+
}
|
|
234
224
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
225
|
+
static getDefaultTokens() {
|
|
226
|
+
return tokens;
|
|
227
|
+
}
|
|
238
228
|
|
|
239
|
-
|
|
240
|
-
|
|
229
|
+
static async getTokens(): Promise<TokenInfo[]> {
|
|
230
|
+
if (tokens.length) return tokens;
|
|
241
231
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
232
|
+
// fetch from avnu API
|
|
233
|
+
const data = await axios.get(
|
|
234
|
+
"https://assets.troves.fi/integrations/tokens.json"
|
|
235
|
+
);
|
|
236
|
+
const tokensData = data.data.content;
|
|
247
237
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
238
|
+
// Array of the following is returned
|
|
239
|
+
// {
|
|
240
|
+
// "name": "USD Coin",
|
|
241
|
+
// "address": "0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
|
|
242
|
+
// "symbol": "USDC",
|
|
243
|
+
// "decimals": 6,
|
|
244
|
+
// "logoUri": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
|
|
245
|
+
// "lastDailyVolumeUsd": 2964287916.82621,
|
|
246
|
+
// "extensions": {
|
|
247
|
+
// "coingeckoId": "usd-coin"
|
|
248
|
+
// },
|
|
249
|
+
// "tags": [
|
|
250
|
+
// "AVNU",
|
|
251
|
+
// "Verified"
|
|
252
|
+
// ]
|
|
253
|
+
// }
|
|
264
254
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
255
|
+
tokensData.forEach((token: any) => {
|
|
256
|
+
// if tags do not contain Avnu and verified, ignore
|
|
257
|
+
// This would exclude meme coins for now
|
|
258
|
+
if (
|
|
259
|
+
!token.tags.includes("AVNU") ||
|
|
260
|
+
!token.tags.includes("Verified")
|
|
261
|
+
) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
271
264
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
265
|
+
tokens.push({
|
|
266
|
+
name: token.name,
|
|
267
|
+
symbol: token.symbol,
|
|
268
|
+
address: ContractAddr.from(token.address),
|
|
269
|
+
decimals: token.decimals,
|
|
270
|
+
logo: token.logoUri,
|
|
271
|
+
coingeckId: token.extensions.coingeckoId,
|
|
272
|
+
displayDecimals: 2
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
console.log(tokens);
|
|
276
|
+
return tokens;
|
|
277
|
+
}
|
|
285
278
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
279
|
+
static assert(condition: any, message: string) {
|
|
280
|
+
if (!condition) {
|
|
281
|
+
throw new FatalError(message);
|
|
282
|
+
}
|
|
289
283
|
}
|
|
290
|
-
}
|
|
291
284
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
285
|
+
static async getTokenInfoFromAddr(addr: ContractAddr) {
|
|
286
|
+
// if tokens are not loaded, load them
|
|
287
|
+
if (tokens.length == defaultTokens.length) {
|
|
288
|
+
await Global.getTokens();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const token = tokens.find((token) => addr.eq(token.address));
|
|
292
|
+
if (!token) {
|
|
293
|
+
throw new FatalError(`Token not found: ${addr.address}`);
|
|
294
|
+
}
|
|
295
|
+
return token;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
static async getTokenInfoFromName(tokenName: string) {
|
|
299
|
+
// if tokens are not loaded, load them
|
|
300
|
+
if (tokens.length == defaultTokens.length) {
|
|
301
|
+
await Global.getTokens();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const token = tokens.find(
|
|
305
|
+
(token) => token.name.toLowerCase() === tokenName.toLowerCase()
|
|
306
|
+
);
|
|
307
|
+
if (!token) {
|
|
308
|
+
throw new FatalError(`Token not found: ${tokenName}`);
|
|
309
|
+
}
|
|
310
|
+
return token;
|
|
301
311
|
}
|
|
302
|
-
return token;
|
|
303
|
-
}
|
|
304
312
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
313
|
+
static setGlobalCache(key: string, data: any, ttl: number = 60000) {
|
|
314
|
+
Global.cache[key] = {
|
|
315
|
+
value: data,
|
|
316
|
+
ttl,
|
|
317
|
+
timestamp: Date.now()
|
|
318
|
+
};
|
|
319
|
+
}
|
|
312
320
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
321
|
+
static getGlobalCache<T>(key: string): T | null {
|
|
322
|
+
const cached = Global.cache[key];
|
|
323
|
+
if (!cached) return null;
|
|
324
|
+
if (Date.now() - cached.timestamp > cached.ttl) {
|
|
325
|
+
delete Global.cache[key];
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
return cached.value;
|
|
319
329
|
}
|
|
320
|
-
return cached.value;
|
|
321
|
-
}
|
|
322
330
|
}
|
package/src/index.browser.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// contains only browser supported modules
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
2
|
+
export * from "./modules";
|
|
3
|
+
export * from "./interfaces";
|
|
4
|
+
export * from "./dataTypes";
|
|
5
|
+
export * from "./global";
|
|
6
|
+
export * from "./strategies";
|
|
7
|
+
export * from "./utils";
|