@strkfarm/sdk 2.0.0-dev.42 → 2.0.0-dev.44

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/src/global.ts CHANGED
@@ -1,54 +1,52 @@
1
- import axios from "axios";
2
- import { TokenInfo } from "./interfaces";
3
- import { ContractAddr } from "./dataTypes";
4
- import { logger } from "@/utils/logger";
1
+ import axios from 'axios';
2
+ import { TokenIndexingType, TokenInfo } from './interfaces';
3
+ import { ContractAddr } from './dataTypes';
4
+ import { logger } from '@/utils/logger';
5
+
5
6
 
6
7
  export class FatalError extends Error {
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
- }
8
+ constructor(message: string, err?: Error) {
9
+ super(message);
10
+ logger.error(message);
11
+ if (err)
12
+ logger.error(err.message);
13
+ this.name = "FatalError";
14
+ }
13
15
  }
14
16
 
15
- const defaultTokens: TokenInfo[] = [
16
- {
17
- name: "Starknet",
18
- symbol: "STRK",
19
- logo: "https://assets.troves.fi/integrations/tokens/strk.svg",
20
- address: ContractAddr.from(
21
- "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
22
- ),
17
+ const defaultTokens: TokenInfo[] = [{
18
+ name: 'Starknet',
19
+ symbol: 'STRK',
20
+ logo: 'https://assets.troves.fi/integrations/tokens/strk.svg',
21
+ address: ContractAddr.from('0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d'),
23
22
  decimals: 18,
24
- coingeckId: "starknet",
23
+ coingeckId: 'starknet',
25
24
  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
- ),
25
+ priceCheckAmount: 5000,
26
+ priceMethod: 'Avnu',
27
+ indexingType: TokenIndexingType.INDEXER,
28
+ }, {
29
+ name: 'xSTRK',
30
+ symbol: 'xSTRK',
31
+ logo: 'https://assets.troves.fi/integrations/tokens/xstrk.svg',
32
+ address: ContractAddr.from('0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a'),
35
33
  decimals: 18,
36
34
  coingeckId: undefined,
37
- priceCheckAmount: 1000,
35
+ priceCheckAmount: 5000,
38
36
  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
- ),
37
+ priceMethod: 'Avnu',
38
+ indexingType: TokenIndexingType.LST_SCRIPT,
39
+ }, {
40
+ name: 'ETH',
41
+ symbol: 'ETH',
42
+ logo: 'https://assets.troves.fi/integrations/tokens/eth.svg',
43
+ address: ContractAddr.from('0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7'),
47
44
  decimals: 18,
48
45
  coingeckId: undefined,
49
46
  priceCheckAmount: 0.1,
50
47
  displayDecimals: 6,
51
- }, {
48
+ indexingType: TokenIndexingType.INDEXER,
49
+ }, {
52
50
  name: 'USDC.e',
53
51
  symbol: 'USDC.e',
54
52
  logo: 'https://assets.troves.fi/integrations/tokens/usdc.svg',
@@ -57,8 +55,9 @@ const defaultTokens: TokenInfo[] = [
57
55
  coingeckId: undefined,
58
56
  displayDecimals: 2,
59
57
  priceCheckAmount: 1000,
60
- priceProxySymbol: 'USDC'
61
- }, {
58
+ priceProxySymbol: 'USDC',
59
+ indexingType: TokenIndexingType.PEGGED,
60
+ }, {
62
61
  name: 'USDC',
63
62
  symbol: 'USDC',
64
63
  logo: 'https://assets.troves.fi/integrations/tokens/usdc.svg',
@@ -67,109 +66,94 @@ const defaultTokens: TokenInfo[] = [
67
66
  coingeckId: undefined,
68
67
  displayDecimals: 2,
69
68
  priceCheckAmount: 1000,
70
- },
71
- {
72
- name: "USDT",
73
- symbol: "USDT",
74
- logo: "https://assets.troves.fi/integrations/tokens/usdt.svg",
75
- address: ContractAddr.from(
76
- "0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8"
77
- ),
69
+ indexingType: TokenIndexingType.INDEXER,
70
+ }, {
71
+ name: 'USDT',
72
+ symbol: 'USDT',
73
+ logo: 'https://assets.troves.fi/integrations/tokens/usdt.svg',
74
+ address: ContractAddr.from('0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8'),
78
75
  decimals: 6,
79
76
  coingeckId: undefined,
80
77
  priceCheckAmount: 1000,
81
78
  displayDecimals: 2,
82
- },
83
- {
84
- name: "WBTC",
85
- symbol: "WBTC",
86
- logo: "https://assets.troves.fi/integrations/tokens/wbtc.svg",
87
- address: ContractAddr.from(
88
- "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac"
89
- ),
79
+ indexingType: TokenIndexingType.INDEXER,
80
+ }, {
81
+ name: 'WBTC',
82
+ symbol: 'WBTC',
83
+ logo: 'https://assets.troves.fi/integrations/tokens/wbtc.svg',
84
+ address: ContractAddr.from('0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac'),
90
85
  decimals: 8,
91
86
  coingeckId: undefined,
92
87
  displayDecimals: 6,
93
88
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
94
- },
95
- {
96
- name: "tBTC",
97
- symbol: "tBTC",
98
- logo: "https://assets.strkfarm.com/integrations/tokens/tbtc.svg",
99
- address: ContractAddr.from(
100
- "0x4daa17763b286d1e59b97c283c0b8c949994c361e426a28f743c67bdfe9a32f"
101
- ),
89
+ indexingType: TokenIndexingType.INDEXER,
90
+ }, {
91
+ name: 'tBTC',
92
+ symbol: 'tBTC',
93
+ logo: 'https://assets.strkfarm.com/integrations/tokens/tbtc.svg',
94
+ address: ContractAddr.from('0x4daa17763b286d1e59b97c283c0b8c949994c361e426a28f743c67bdfe9a32f'),
102
95
  decimals: 18,
103
96
  coingeckId: undefined,
104
97
  displayDecimals: 6,
105
98
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
106
- },
107
- {
108
- name: "solvBTC",
109
- symbol: "solvBTC",
110
- logo: "https://assets.strkfarm.com/integrations/tokens/solvbtc.svg",
111
- address: ContractAddr.from(
112
- "0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"
113
- ),
99
+ priceProxySymbol: 'WBTC',
100
+ indexingType: TokenIndexingType.PEGGED,
101
+ }, {
102
+ name: 'solvBTC',
103
+ symbol: 'solvBTC',
104
+ logo: 'https://assets.strkfarm.com/integrations/tokens/solvbtc.svg',
105
+ address: ContractAddr.from('0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68'),
114
106
  decimals: 18,
115
107
  coingeckId: undefined,
116
- priceProxySymbol: "WBTC",
108
+ priceProxySymbol: 'WBTC',
117
109
  displayDecimals: 6,
118
110
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
119
- },
120
- {
121
- name: "LBTC",
122
- symbol: "LBTC",
123
- logo: "https://assets.strkfarm.com/integrations/tokens/lbtc.svg",
124
- address: ContractAddr.from(
125
- "0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4"
126
- ),
111
+ indexingType: TokenIndexingType.PEGGED,
112
+ }, {
113
+ name: 'LBTC',
114
+ symbol: 'LBTC',
115
+ logo: 'https://assets.strkfarm.com/integrations/tokens/lbtc.svg',
116
+ address: ContractAddr.from('0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4'),
127
117
  decimals: 8,
128
118
  coingeckId: undefined,
129
119
  displayDecimals: 6,
130
- priceProxySymbol: "WBTC",
120
+ priceProxySymbol: 'WBTC',
131
121
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
132
- },
133
- {
134
- name: "xWBTC",
135
- symbol: "xWBTC",
136
- logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
137
- address: ContractAddr.from(
138
- "0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"
139
- ),
122
+ indexingType: TokenIndexingType.PEGGED,
123
+ }, {
124
+ name: 'xWBTC',
125
+ symbol: 'xWBTC',
126
+ logo: 'https://assets.strkfarm.com/integrations/tokens/xwbtc.svg',
127
+ address: ContractAddr.from('0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13'),
140
128
  decimals: 8,
141
129
  coingeckId: undefined,
142
130
  displayDecimals: 6,
143
- priceProxySymbol: 'WBTC',
144
131
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
145
- },
146
- {
147
- name: "xsBTC",
148
- symbol: "xsBTC",
149
- logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
150
- address: ContractAddr.from(
151
- "0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"
152
- ),
132
+ priceMethod: 'Avnu',
133
+ indexingType: TokenIndexingType.LST_SCRIPT,
134
+ }, {
135
+ name: 'xsBTC',
136
+ symbol: 'xsBTC',
137
+ logo: 'https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg',
138
+ address: ContractAddr.from('0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9'),
153
139
  decimals: 18,
154
140
  coingeckId: undefined,
155
141
  displayDecimals: 6,
156
- priceProxySymbol: "WBTC",
157
142
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
158
- },
159
- {
160
- // todo upgrade proxy tokens once feeds are available
161
- name: "xtBTC",
162
- symbol: "xtBTC",
163
- logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
164
- address: ContractAddr.from(
165
- "0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"
166
- ),
143
+ priceMethod: 'Avnu',
144
+ indexingType: TokenIndexingType.LST_SCRIPT,
145
+ }, {
146
+ name: 'xtBTC',
147
+ symbol: 'xtBTC',
148
+ logo: 'https://assets.strkfarm.com/integrations/tokens/xtbtc.svg',
149
+ address: ContractAddr.from('0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91'),
167
150
  decimals: 18,
168
151
  coingeckId: undefined,
169
152
  displayDecimals: 6,
170
153
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
171
- priceProxySymbol: 'WBTC',
172
- }, {
154
+ priceMethod: 'Avnu',
155
+ indexingType: TokenIndexingType.LST_SCRIPT,
156
+ }, {
173
157
  name: 'xLBTC',
174
158
  symbol: 'xLBTC',
175
159
  logo: 'https://assets.strkfarm.com/integrations/tokens/xlbtc.svg',
@@ -177,22 +161,21 @@ const defaultTokens: TokenInfo[] = [
177
161
  decimals: 8,
178
162
  coingeckId: undefined,
179
163
  displayDecimals: 6,
180
- priceProxySymbol: "WBTC",
181
164
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
182
- },
183
- {
184
- name: "mRe7BTC",
185
- symbol: "mRe7BTC",
186
- logo: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/3a62ecee-1e58-45d3-9862-3ce90dff1900/logo",
187
- address: ContractAddr.from(
188
- "0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac"
189
- ),
165
+ priceMethod: 'Avnu',
166
+ indexingType: TokenIndexingType.LST_SCRIPT,
167
+ }, {
168
+ name: 'mRe7BTC',
169
+ symbol: 'mRe7BTC',
170
+ logo: 'https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/3a62ecee-1e58-45d3-9862-3ce90dff1900/logo',
171
+ address: ContractAddr.from('0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac'),
190
172
  decimals: 18,
191
173
  coingeckId: undefined,
192
174
  displayDecimals: 6,
193
175
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
194
176
  dontPrice: true,
195
- }, {
177
+ indexingType: TokenIndexingType.IGNORE,
178
+ }, {
196
179
  name: 'mRe7YIELD',
197
180
  symbol: 'mRe7YIELD',
198
181
  logo: 'https://midas.app/assets/mre7-BcOOHm7i.svg',
@@ -202,9 +185,10 @@ const defaultTokens: TokenInfo[] = [
202
185
  displayDecimals: 2,
203
186
  priceCheckAmount: 100,
204
187
  dontPrice: true,
205
- }, {
206
- name: "fyWBTC",
207
- symbol: "fyWBTC",
188
+ indexingType: TokenIndexingType.IGNORE,
189
+ }, {
190
+ name: "fyeWBTC",
191
+ symbol: "fyeWBTC",
208
192
  logo: 'https://assets.strkfarm.com/integrations/tokens/wbtc.svg',
209
193
  address: ContractAddr.from('0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492'),
210
194
  decimals: 8,
@@ -212,7 +196,8 @@ const defaultTokens: TokenInfo[] = [
212
196
  displayDecimals: 6,
213
197
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
214
198
  dontPrice: true,
215
- }, {
199
+ indexingType: TokenIndexingType.IGNORE,
200
+ }, {
216
201
  name: "fyETH",
217
202
  symbol: "fyETH",
218
203
  logo: 'https://assets.strkfarm.com/integrations/tokens/eth.svg',
@@ -222,9 +207,10 @@ const defaultTokens: TokenInfo[] = [
222
207
  displayDecimals: 4,
223
208
  priceCheckAmount: 0.1,
224
209
  dontPrice: true,
225
- }, {
226
- name: "fyUSDC",
227
- symbol: "fyUSDC",
210
+ indexingType: TokenIndexingType.IGNORE,
211
+ }, {
212
+ name: "fyeUSDC",
213
+ symbol: "fyeUSDC",
228
214
  logo: 'https://assets.strkfarm.com/integrations/tokens/usdc.svg',
229
215
  address: ContractAddr.from('0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1'),
230
216
  decimals: 6,
@@ -232,7 +218,8 @@ const defaultTokens: TokenInfo[] = [
232
218
  displayDecimals: 2,
233
219
  priceCheckAmount: 100,
234
220
  dontPrice: true,
235
- }, {
221
+ indexingType: TokenIndexingType.IGNORE,
222
+ }, {
236
223
  name: 'strkBTC',
237
224
  symbol: 'strkBTC',
238
225
  logo: 'https://assets.troves.fi/integrations/tokens/strkbtc.svg',
@@ -241,8 +228,10 @@ const defaultTokens: TokenInfo[] = [
241
228
  coingeckId: undefined,
242
229
  displayDecimals: 6,
243
230
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
231
+ priceMethod: 'Avnu',
244
232
  priceProxySymbol: 'WBTC',
245
- }, {
233
+ indexingType: TokenIndexingType.PEGGED,
234
+ }, {
246
235
  name: 'xstrkBTC',
247
236
  symbol: 'xstrkBTC',
248
237
  logo: 'https://assets.troves.fi/integrations/tokens/xstrkbtc.svg',
@@ -251,129 +240,129 @@ const defaultTokens: TokenInfo[] = [
251
240
  coingeckId: undefined,
252
241
  displayDecimals: 6,
253
242
  priceCheckAmount: 0.001,
254
- priceProxySymbol: 'WBTC',
255
- },]
243
+ priceMethod: 'Avnu',
244
+ indexingType: TokenIndexingType.LST_SCRIPT,
245
+ }];
256
246
  const tokens: TokenInfo[] = defaultTokens;
257
247
 
258
248
  /** Contains globally useful functions.
259
249
  * - fatalError: Things to do when a fatal error occurs
260
250
  */
261
251
  export class Global {
262
- static cache: Record<string, { value: any; ttl: number; timestamp: number }> =
263
- {};
252
+ static cache: Record<string, {value: any, ttl: number, timestamp: number}> = {};
264
253
 
265
- static fatalError(message: string, err?: Error) {
266
- logger.error(message);
267
- console.error(message, err);
268
- if (err) console.error(err);
269
- process.exit(1);
270
- }
254
+ static fatalError(message: string, err?: Error) {
255
+ logger.error(message);
256
+ console.error(message, err);
257
+ if (err)
258
+ console.error(err);
259
+ process.exit(1);
260
+ }
271
261
 
272
- static httpError(url: string, err: Error, message?: string) {
273
- logger.error(`${url}: ${message}`);
274
- console.error(err);
275
- }
262
+ static httpError(url: string, err: Error, message?: string) {
263
+ logger.error(`${url}: ${message}`);
264
+ console.error(err);
265
+ }
276
266
 
277
- static getDefaultTokens() {
278
- return tokens;
279
- }
267
+ static getDefaultTokens() {
268
+ return tokens;
269
+ }
280
270
 
281
- static async getTokens(): Promise<TokenInfo[]> {
282
- if (tokens.length) return tokens;
271
+ static async getTokens(): Promise<TokenInfo[]> {
272
+ if (tokens.length) return tokens;
283
273
 
284
- // fetch from avnu API
285
- const data = await axios.get(
286
- "https://assets.troves.fi/integrations/tokens.json"
287
- );
288
- const tokensData = data.data.content;
274
+ // fetch from avnu API
275
+ const data = await axios.get('https://assets.troves.fi/integrations/tokens.json');
276
+ const tokensData = data.data.content;
289
277
 
290
- // Array of the following is returned
291
- // {
292
- // "name": "USD Coin",
293
- // "address": "0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
294
- // "symbol": "USDC",
295
- // "decimals": 6,
296
- // "logoUri": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
297
- // "lastDailyVolumeUsd": 2964287916.82621,
298
- // "extensions": {
299
- // "coingeckoId": "usd-coin"
300
- // },
301
- // "tags": [
302
- // "AVNU",
303
- // "Verified"
304
- // ]
305
- // }
278
+ // Array of the following is returned
279
+ // {
280
+ // "name": "USD Coin",
281
+ // "address": "0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
282
+ // "symbol": "USDC",
283
+ // "decimals": 6,
284
+ // "logoUri": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
285
+ // "lastDailyVolumeUsd": 2964287916.82621,
286
+ // "extensions": {
287
+ // "coingeckoId": "usd-coin"
288
+ // },
289
+ // "tags": [
290
+ // "AVNU",
291
+ // "Verified"
292
+ // ]
293
+ // }
306
294
 
307
- tokensData.forEach((token: any) => {
308
- // if tags do not contain Avnu and verified, ignore
309
- // This would exclude meme coins for now
310
- if (!token.tags.includes("AVNU") || !token.tags.includes("Verified")) {
311
- return;
312
- }
295
+ tokensData.forEach((token: any) => {
296
+ // if tags do not contain Avnu and verified, ignore
297
+ // This would exclude meme coins for now
298
+ if (!token.tags.includes('AVNU') || !token.tags.includes('Verified')) {
299
+ return;
300
+ }
313
301
 
314
- tokens.push({
315
- name: token.name,
316
- symbol: token.symbol,
317
- address: ContractAddr.from(token.address),
318
- decimals: token.decimals,
319
- logo: token.logoUri,
320
- coingeckId: token.extensions.coingeckoId,
321
- displayDecimals: 2,
322
- });
323
- });
324
- console.log(tokens);
325
- return tokens;
326
- }
302
+ tokens.push({
303
+ name: token.name,
304
+ symbol: token.symbol,
305
+ address: ContractAddr.from(token.address),
306
+ decimals: token.decimals,
307
+ logo: token.logoUri,
308
+ coingeckId: token.extensions.coingeckoId,
309
+ displayDecimals: 2,
310
+ indexingType: TokenIndexingType.IGNORE,
311
+ });
312
+ });
313
+ console.log(tokens);
314
+ return tokens;
315
+ }
327
316
 
328
- static assert(condition: any, message: string) {
329
- if (!condition) {
330
- throw new FatalError(message);
317
+ static assert(condition: any, message: string) {
318
+ if (!condition) {
319
+ throw new FatalError(message);
320
+ }
331
321
  }
332
- }
333
322
 
323
+ static async getTokenInfoFromAddr(addr: ContractAddr) {
324
+ // if tokens are not loaded, load them
325
+ if (tokens.length == defaultTokens.length) {
326
+ await Global.getTokens();
327
+ }
334
328
 
335
- static async getTokenInfoFromName(tokenName: string) {
336
- // if tokens are not loaded, load them
337
- if (tokens.length == defaultTokens.length) {
338
- await Global.getTokens();
329
+ const token = tokens.find((token) => addr.eq(token.address));
330
+ if (!token) {
331
+ throw new FatalError(`Token not found: ${addr.address}`);
332
+ }
333
+ return token;
339
334
  }
340
335
 
341
- const token = tokens.find(
342
- (token) => token.name.toLowerCase() === tokenName.toLowerCase()
343
- );
344
- if (!token) {
345
- throw new FatalError(`Token not found: ${tokenName}`);
346
- }
347
- return token;
348
- }
336
+ static async getTokenInfoFromName(tokenName: string) {
337
+ // if tokens are not loaded, load them
338
+ if (tokens.length == defaultTokens.length) {
339
+ await Global.getTokens();
340
+ }
349
341
 
350
- static async getTokenInfoFromAddr(addr: ContractAddr) {
351
- // if tokens are not loaded, load them
352
- if (tokens.length == defaultTokens.length) {
353
- await Global.getTokens();
342
+ const token = tokens.find(
343
+ (token) => token.name.toLowerCase() === tokenName.toLowerCase()
344
+ );
345
+ if (!token) {
346
+ throw new FatalError(`Token not found: ${tokenName}`);
347
+ }
348
+ return token;
354
349
  }
355
- const token = tokens.find((token) => addr.eq(token.address));
356
- if (!token) {
357
- throw new FatalError(`Token not found: ${addr.address}`);
358
- }
359
- return token;
360
- }
361
350
 
362
- static setGlobalCache(key: string, data: any, ttl: number = 60000) {
363
- Global.cache[key] = {
364
- value: data,
365
- ttl,
366
- timestamp: Date.now()
367
- };
368
- }
351
+ static setGlobalCache(key: string, data: any, ttl: number = 60000) {
352
+ Global.cache[key] = {
353
+ value: data,
354
+ ttl,
355
+ timestamp: Date.now()
356
+ };
357
+ }
369
358
 
370
- static getGlobalCache<T>(key: string): T | null {
371
- const cached = Global.cache[key];
372
- if (!cached) return null;
373
- if (Date.now() - cached.timestamp > cached.ttl) {
374
- delete Global.cache[key];
375
- return null;
359
+ static getGlobalCache<T>(key: string): T | null {
360
+ const cached = Global.cache[key];
361
+ if (!cached) return null;
362
+ if (Date.now() - cached.timestamp > cached.ttl) {
363
+ delete Global.cache[key];
364
+ return null;
365
+ }
366
+ return cached.value;
376
367
  }
377
- return cached.value;
378
- }
379
368
  }
@@ -25,6 +25,14 @@ export interface RiskFactor {
25
25
  reason?: string; // optional reason for the risk factor
26
26
  }
27
27
 
28
+ export type PriceMethod = 'AvnuApi' | 'Coinbase' | 'Coinmarketcap' | 'Ekubo' | 'Avnu';
29
+ export enum TokenIndexingType {
30
+ PEGGED = "pegged",
31
+ INDEXER = "indexer",
32
+ LST_SCRIPT = "lstScript",
33
+ IGNORE = "ignore",
34
+ }
35
+
28
36
  export interface TokenInfo {
29
37
  name: string;
30
38
  symbol: string;
@@ -35,7 +43,9 @@ export interface TokenInfo {
35
43
  displayDecimals: number;
36
44
  priceProxySymbol?: string; // for tokens like illiquid tokens, we use a proxy symbol to get the price
37
45
  priceCheckAmount?: number; // for tokens like BTC, doing 1BTC price check may not be ideal, esp on illiquid netwrks like sn
38
- dontPrice?: boolean; // a flag that skips pricer to check these tokens.
46
+ priceMethod?: PriceMethod; // preferred price source; tried first, then falls back to other methods
47
+ dontPrice?: boolean; // a flag that skips pricer to check these tokens.
48
+ indexingType: TokenIndexingType;
39
49
  }
40
50
 
41
51
  export enum Network {
@@ -152,7 +162,6 @@ export interface StrategyAlert {
152
162
  }
153
163
 
154
164
  export interface StrategySettings {
155
- maxTVL?: Web3Number;
156
165
  liveStatus?: StrategyLiveStatus;
157
166
  isPaused?: boolean;
158
167
  isInMaintenance?: boolean;
@@ -470,4 +479,4 @@ export const Protocols = {
470
479
  export const UnwrapLabsCurator: ICurator = {
471
480
  name: "Unwrap Labs",
472
481
  logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
473
- }
482
+ }
@@ -7,7 +7,8 @@ import { PriceInfo } from "./pricer";
7
7
  export class EkuboPricer extends PricerBase {
8
8
  EKUBO_PRICE_FETCHER_ADDRESS = '0x04946fb4ad5237d97bbb1256eba2080c4fe1de156da6a7f83e3b4823bb6d7da1';
9
9
  readonly contract: Contract;
10
- private readonly USDC_ADDRESS = '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8';
10
+ // Updating to new USDC_ADDRESS
11
+ private readonly USDC_ADDRESS = '0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb';
11
12
  private readonly USDC_DECIMALS = 6;
12
13
 
13
14
  constructor(config: IConfig, tokens: TokenInfo[]) {