@sentio/sdk 2.15.0-rc.2 → 2.15.0-rc.4

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 (52) hide show
  1. package/lib/aptos/context.d.ts +7 -8
  2. package/lib/aptos/context.js +10 -7
  3. package/lib/aptos/context.js.map +1 -1
  4. package/lib/aptos/ext/aptos-dex.d.ts +11 -19
  5. package/lib/aptos/ext/aptos-dex.js +13 -172
  6. package/lib/aptos/ext/aptos-dex.js.map +1 -1
  7. package/lib/aptos/ext/coin.d.ts +2 -10
  8. package/lib/aptos/ext/coin.js +0 -3
  9. package/lib/aptos/ext/coin.js.map +1 -1
  10. package/lib/move/abstract-move-coder.d.ts +1 -1
  11. package/lib/move/abstract-move-coder.js.map +1 -1
  12. package/lib/move/ext/coin-list.d.ts +8 -0
  13. package/lib/move/ext/coin-list.js +2 -0
  14. package/lib/move/ext/coin-list.js.map +1 -0
  15. package/lib/move/ext/index.d.ts +2 -0
  16. package/lib/move/ext/index.js +3 -0
  17. package/lib/move/ext/index.js.map +1 -0
  18. package/lib/move/ext/move-dex.d.ts +34 -0
  19. package/lib/move/ext/move-dex.js +180 -0
  20. package/lib/move/ext/move-dex.js.map +1 -0
  21. package/lib/move/index.d.ts +1 -0
  22. package/lib/move/index.js +1 -0
  23. package/lib/move/index.js.map +1 -1
  24. package/lib/move/move-context.d.ts +14 -0
  25. package/lib/move/move-context.js +12 -0
  26. package/lib/move/move-context.js.map +1 -0
  27. package/lib/sui/context.d.ts +9 -8
  28. package/lib/sui/context.js +11 -6
  29. package/lib/sui/context.js.map +1 -1
  30. package/lib/sui/ext/coin.d.ts +14 -0
  31. package/lib/sui/ext/coin.js +508 -0
  32. package/lib/sui/ext/coin.js.map +1 -0
  33. package/lib/sui/ext/move-dex.d.ts +18 -0
  34. package/lib/sui/ext/move-dex.js +21 -0
  35. package/lib/sui/ext/move-dex.js.map +1 -0
  36. package/lib/sui/sui-plugin.d.ts +2 -1
  37. package/lib/sui/sui-plugin.js +4 -0
  38. package/lib/sui/sui-plugin.js.map +1 -1
  39. package/package.json +3 -3
  40. package/src/aptos/context.ts +13 -8
  41. package/src/aptos/ext/aptos-dex.ts +34 -224
  42. package/src/aptos/ext/coin.ts +2 -11
  43. package/src/move/abstract-move-coder.ts +1 -1
  44. package/src/move/ext/coin-list.ts +9 -0
  45. package/src/move/ext/index.ts +2 -0
  46. package/src/move/ext/move-dex.ts +255 -0
  47. package/src/move/index.ts +1 -0
  48. package/src/move/move-context.ts +18 -0
  49. package/src/sui/context.ts +26 -8
  50. package/src/sui/ext/coin.ts +537 -0
  51. package/src/sui/ext/move-dex.ts +41 -0
  52. package/src/sui/sui-plugin.ts +5 -0
@@ -0,0 +1,537 @@
1
+ import { SimpleCoinInfo } from '../../move/ext/index.js'
2
+ import fetch from 'node-fetch'
3
+ import { SPLITTER } from '../../move/index.js'
4
+ import { getPriceByType } from '../../utils/index.js'
5
+ import { SuiChainId } from '../../core/chain.js'
6
+ import { validateAndNormalizeAddress } from '../utils.js'
7
+
8
+ const WHITELISTED_COINS = new Map<string, SimpleCoinInfo>()
9
+
10
+ export async function initCoinList() {
11
+ let list = DEFAULT_LIST.coinlist
12
+ try {
13
+ const resp = await fetch('https://raw.githubusercontent.com/solflare-wallet/sui-coinlist/master/sui-coinlist.json')
14
+ list = ((await resp.json()) as any).coinlist
15
+ } catch (e) {
16
+ console.warn("Can't not fetch newest coin list, use default list")
17
+ }
18
+
19
+ setCoinList(list)
20
+ }
21
+
22
+ export interface SuiCoinInfo {
23
+ network: string
24
+ address: string
25
+ symbol: string
26
+ name: string
27
+ decimals: number
28
+ }
29
+
30
+ function setCoinList(list: SuiCoinInfo[]) {
31
+ for (const info of list) {
32
+ if (info.address.startsWith('0x2::coin::Coin')) {
33
+ continue
34
+ }
35
+ if (info.network !== 'mainnet') {
36
+ continue
37
+ }
38
+ let bridge = 'native'
39
+ if (info.name.includes('Celer')) {
40
+ bridge = 'Celer'
41
+ }
42
+ if (info.name.includes('LayerZero')) {
43
+ bridge = 'LayerZero'
44
+ }
45
+ if (info.name.includes('Wormhole')) {
46
+ bridge = 'Wormhole'
47
+ }
48
+ WHITELISTED_COINS.set(info.address, {
49
+ token_type: {
50
+ type: info.address,
51
+ account_address: info.address.split('::')[0],
52
+ },
53
+ symbol: info.symbol,
54
+ decimals: info.decimals,
55
+ bridge,
56
+ })
57
+ }
58
+ }
59
+
60
+ export function whitelistCoins() {
61
+ return WHITELISTED_COINS
62
+ }
63
+
64
+ export function whiteListed(coin: string): boolean {
65
+ const [addr, module, type] = coin.split(SPLITTER)
66
+ const normalized = [validateAndNormalizeAddress(addr), module, type].join(SPLITTER)
67
+ return WHITELISTED_COINS.has(normalized)
68
+ }
69
+
70
+ export function getCoinInfo(type: string): SimpleCoinInfo {
71
+ const r = WHITELISTED_COINS.get(type)
72
+ if (!r) {
73
+ const parts = type.split('::')
74
+ // TDDO retrive from network
75
+ return {
76
+ token_type: { type: type, account_address: parts[0] },
77
+ symbol: parts[2],
78
+ decimals: 8,
79
+ bridge: 'native',
80
+ }
81
+ }
82
+ return r
83
+ }
84
+
85
+ export async function getPrice(coinType: string, timestamp: number): Promise<number> {
86
+ if (!whiteListed(coinType)) {
87
+ return 0.0
88
+ }
89
+ const date = new Date(timestamp / 1000)
90
+ try {
91
+ return (await getPriceByType(SuiChainId.SUI_MAINNET, coinType, date)) || 0
92
+ } catch (error) {
93
+ console.log(JSON.stringify(error))
94
+ throw error
95
+ }
96
+ }
97
+
98
+ export async function calculateValueInUsd(n: bigint, coinInfo: SimpleCoinInfo, timestamp: number) {
99
+ const price = await getPrice(coinInfo.token_type.type, timestamp)
100
+ const amount = n.scaleDown(coinInfo.decimals)
101
+ return amount.multipliedBy(price)
102
+ }
103
+
104
+ const DEFAULT_LIST = {
105
+ name: 'Sui Coin List',
106
+ timestamp: '2022-12-01T13:34:30.145Z',
107
+ logoURI: 'https://s2.coinmarketcap.com/static/img/coins/128x128/20947.png',
108
+ coinlist: [
109
+ {
110
+ network: 'mainnet',
111
+ address: '0x2::coin::Coin<0x2::sui::SUI>',
112
+ symbol: 'SUI',
113
+ name: 'Sui Coin',
114
+ decimals: 9,
115
+ logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',
116
+ tags: [],
117
+ extensions: {
118
+ coingeckoId: 'sui',
119
+ },
120
+ },
121
+ {
122
+ network: 'testnet',
123
+ address: '0x2::coin::Coin<0x2::sui::SUI>',
124
+ symbol: 'SUI',
125
+ name: 'Sui Coin',
126
+ decimals: 9,
127
+ logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',
128
+ tags: [],
129
+ extensions: {
130
+ coingeckoId: 'sui',
131
+ },
132
+ },
133
+ {
134
+ network: 'devnet',
135
+ address: '0x2::coin::Coin<0x2::sui::SUI>',
136
+ symbol: 'SUI',
137
+ name: 'Sui Coin',
138
+ decimals: 9,
139
+ logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',
140
+ tags: [],
141
+ extensions: {
142
+ coingeckoId: 'sui',
143
+ },
144
+ },
145
+ {
146
+ network: 'mainnet',
147
+ address: '0x2::sui::SUI',
148
+ symbol: 'SUI',
149
+ name: 'Sui Coin',
150
+ decimals: 9,
151
+ logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',
152
+ tags: [],
153
+ extensions: {
154
+ coingeckoId: 'sui',
155
+ },
156
+ },
157
+ {
158
+ network: 'testnet',
159
+ address: '0x2::sui::SUI',
160
+ symbol: 'SUI',
161
+ name: 'Sui Coin',
162
+ decimals: 9,
163
+ logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',
164
+ tags: [],
165
+ extensions: {
166
+ coingeckoId: 'sui',
167
+ },
168
+ },
169
+ {
170
+ network: 'devnet',
171
+ address: '0x2::sui::SUI',
172
+ symbol: 'SUI',
173
+ name: 'Sui Coin',
174
+ decimals: 9,
175
+ logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',
176
+ tags: [],
177
+ extensions: {
178
+ coingeckoId: 'sui',
179
+ },
180
+ },
181
+ {
182
+ network: 'testnet',
183
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',
184
+ symbol: 'TEST',
185
+ name: 'Test Token',
186
+ logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',
187
+ tags: [],
188
+ decimals: 8,
189
+ extensions: {},
190
+ },
191
+ {
192
+ network: 'testnet',
193
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',
194
+ symbol: 'USDT',
195
+ name: 'Tether',
196
+ logoURI:
197
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',
198
+ tags: [],
199
+ decimals: 8,
200
+ extensions: {
201
+ coingeckoId: 'tether',
202
+ },
203
+ },
204
+ {
205
+ network: 'testnet',
206
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',
207
+ symbol: 'USDC',
208
+ name: 'USD Coin',
209
+ logoURI:
210
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',
211
+ decimals: 8,
212
+ tags: [],
213
+ extensions: {
214
+ coingeckoId: 'usd-coin',
215
+ },
216
+ },
217
+ {
218
+ network: 'testnet',
219
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',
220
+ symbol: 'SOL',
221
+ name: 'Solana',
222
+ logoURI:
223
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',
224
+ decimals: 8,
225
+ extensions: {
226
+ coingeckoId: 'solana',
227
+ },
228
+ },
229
+ {
230
+ network: 'testnet',
231
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',
232
+ symbol: 'BTC',
233
+ name: 'Bitcoin',
234
+ logoURI:
235
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',
236
+ decimals: 8,
237
+ tags: [],
238
+ extensions: {
239
+ coingeckoId: 'bitcoin',
240
+ },
241
+ },
242
+ {
243
+ network: 'testnet',
244
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',
245
+ symbol: 'DAI',
246
+ name: 'DAI',
247
+ logoURI:
248
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',
249
+ decimals: 8,
250
+ tags: [],
251
+ extensions: {
252
+ coingeckoId: 'dai',
253
+ },
254
+ },
255
+ {
256
+ network: 'testnet',
257
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',
258
+ symbol: 'BNB',
259
+ name: 'BNB',
260
+ logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',
261
+ decimals: 8,
262
+ tags: [],
263
+ extensions: {
264
+ coingeckoId: 'binancecoin',
265
+ },
266
+ },
267
+ {
268
+ network: 'testnet',
269
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',
270
+ symbol: 'ETH',
271
+ name: 'Ethereum',
272
+ logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
273
+ decimals: 8,
274
+ tags: [],
275
+ extensions: {
276
+ coingeckoId: 'ethereum',
277
+ },
278
+ },
279
+ {
280
+ network: 'testnet',
281
+ address: '0x31b14985adb91360ed90a5786cb0956c83e7f275a8ae6123f38adab9d2b792b1::usdc::USDC',
282
+ symbol: 'USDC',
283
+ name: 'USD Coin',
284
+ logoURI:
285
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',
286
+ decimals: 8,
287
+ tags: [],
288
+ extensions: {
289
+ coingeckoId: 'usd-coin',
290
+ },
291
+ },
292
+ {
293
+ network: 'devnet',
294
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',
295
+ symbol: 'TEST',
296
+ name: 'Test Token',
297
+ logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',
298
+ tags: [],
299
+ decimals: 8,
300
+ extensions: {},
301
+ },
302
+ {
303
+ network: 'devnet',
304
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',
305
+ symbol: 'USDT',
306
+ name: 'Tether',
307
+ logoURI:
308
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',
309
+ tags: [],
310
+ decimals: 8,
311
+ extensions: {
312
+ coingeckoId: 'tether',
313
+ },
314
+ },
315
+ {
316
+ network: 'devnet',
317
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',
318
+ symbol: 'USDC',
319
+ name: 'USD Coin',
320
+ logoURI:
321
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',
322
+ decimals: 8,
323
+ tags: [],
324
+ extensions: {
325
+ coingeckoId: 'usd-coin',
326
+ },
327
+ },
328
+ {
329
+ network: 'devnet',
330
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',
331
+ symbol: 'SOL',
332
+ name: 'Solana',
333
+ logoURI:
334
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',
335
+ decimals: 8,
336
+ extensions: {
337
+ coingeckoId: 'solana',
338
+ },
339
+ },
340
+ {
341
+ network: 'devnet',
342
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',
343
+ symbol: 'BTC',
344
+ name: 'Bitcoin',
345
+ logoURI:
346
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',
347
+ decimals: 8,
348
+ tags: [],
349
+ extensions: {
350
+ coingeckoId: 'bitcoin',
351
+ },
352
+ },
353
+ {
354
+ network: 'devnet',
355
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',
356
+ symbol: 'DAI',
357
+ name: 'DAI',
358
+ logoURI:
359
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',
360
+ decimals: 8,
361
+ tags: [],
362
+ extensions: {
363
+ coingeckoId: 'dai',
364
+ },
365
+ },
366
+ {
367
+ network: 'devnet',
368
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',
369
+ symbol: 'BNB',
370
+ name: 'BNB',
371
+ logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',
372
+ decimals: 8,
373
+ tags: [],
374
+ extensions: {
375
+ coingeckoId: 'binancecoin',
376
+ },
377
+ },
378
+ {
379
+ network: 'devnet',
380
+ address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',
381
+ symbol: 'ETH',
382
+ name: 'Ethereum',
383
+ logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
384
+ decimals: 8,
385
+ tags: [],
386
+ extensions: {
387
+ coingeckoId: 'ethereum',
388
+ },
389
+ },
390
+ {
391
+ network: 'mainnet',
392
+ address: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN',
393
+ symbol: 'wETH',
394
+ name: 'Wrapped Ethereum (Wormhole)',
395
+ decimals: 8,
396
+ logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
397
+ tags: [],
398
+ extensions: {
399
+ coingeckoId: 'ethereum',
400
+ },
401
+ },
402
+ {
403
+ network: 'mainnet',
404
+ address: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',
405
+ symbol: 'wUSDT',
406
+ name: 'Tether (Wormhole)',
407
+ decimals: 6,
408
+ logoURI:
409
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',
410
+ tags: [],
411
+ extensions: {
412
+ coingeckoId: 'tether',
413
+ },
414
+ },
415
+ {
416
+ network: 'mainnet',
417
+ address: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',
418
+ symbol: 'wUSDC',
419
+ name: 'USD Coin (Wormhole)',
420
+ decimals: 6,
421
+ logoURI:
422
+ 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',
423
+ tags: [],
424
+ extensions: {
425
+ coingeckoId: 'usd-coin',
426
+ },
427
+ },
428
+ {
429
+ network: 'mainnet',
430
+ address: '0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f::coin::COIN',
431
+ symbol: 'wCELO',
432
+ name: 'Celo (Wormhole)',
433
+ decimals: 8,
434
+ logoURI: 'https://assets.coingecko.com/coins/images/11090/large/InjXBNx9_400x400.jpg',
435
+ tags: [],
436
+ extensions: {
437
+ coingeckoId: 'celo',
438
+ },
439
+ },
440
+ {
441
+ network: 'mainnet',
442
+ address: '0xdbe380b13a6d0f5cdedd58de8f04625263f113b3f9db32b3e1983f49e2841676::coin::COIN',
443
+ symbol: 'wMATIC',
444
+ name: 'Wrapped Matic (Wormhole)',
445
+ decimals: 8,
446
+ logoURI: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',
447
+ tags: [],
448
+ extensions: {
449
+ coingeckoId: 'matic-network',
450
+ },
451
+ },
452
+ {
453
+ network: 'mainnet',
454
+ address: '0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN',
455
+ symbol: 'wBNB',
456
+ name: 'Wrapped BNB (Wormhole)',
457
+ decimals: 8,
458
+ logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',
459
+ tags: [],
460
+ extensions: {
461
+ coingeckoId: 'binancecoin',
462
+ },
463
+ },
464
+ {
465
+ network: 'mainnet',
466
+ address: '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',
467
+ symbol: 'wBTC',
468
+ name: 'Wrapped Bitcoin (Wormhole)',
469
+ decimals: 8,
470
+ logoURI: 'https://assets.coingecko.com/coins/images/1/large/bitcoin.png',
471
+ tags: [],
472
+ extensions: {
473
+ coingeckoId: 'bitcoin',
474
+ },
475
+ },
476
+ {
477
+ network: 'mainnet',
478
+ address: '0x1e8b532cca6569cab9f9b9ebc73f8c13885012ade714729aa3b450e0339ac766::coin::COIN',
479
+ symbol: 'wAVAX',
480
+ name: 'Wrapped AVAX (Wormhole)',
481
+ decimals: 8,
482
+ logoURI: 'https://assets.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png',
483
+ tags: [],
484
+ extensions: {
485
+ coingeckoId: 'avalanche-2',
486
+ },
487
+ },
488
+ {
489
+ network: 'mainnet',
490
+ address: '0x6081300950a4f1e2081580e919c210436a1bed49080502834950d31ee55a2396::coin::COIN',
491
+ symbol: 'wFTM',
492
+ name: 'Wrapped Fantom (Wormhole)',
493
+ decimals: 8,
494
+ logoURI: 'https://assets.coingecko.com/coins/images/4001/large/Fantom_round.png',
495
+ tags: [],
496
+ extensions: {
497
+ coingeckoId: 'fantom',
498
+ },
499
+ },
500
+ {
501
+ network: 'mainnet',
502
+ address: '0x66f87084e49c38f76502d17f87d17f943f183bb94117561eb573e075fdc5ff75::coin::COIN',
503
+ symbol: 'wGLMR',
504
+ name: 'Wrapped GLMR (Wormhole)',
505
+ decimals: 8,
506
+ logoURI: 'https://assets.coingecko.com/coins/images/22459/large/glmr.png',
507
+ tags: [],
508
+ extensions: {
509
+ coingeckoId: 'moonbeam',
510
+ },
511
+ },
512
+ {
513
+ network: 'mainnet',
514
+ address: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN',
515
+ symbol: 'wSOL',
516
+ name: 'Wrapped Solana (Wormhole)',
517
+ decimals: 8,
518
+ logoURI: 'https://assets.coingecko.com/coins/images/4128/large/solana.png',
519
+ tags: [],
520
+ extensions: {
521
+ coingeckoId: 'solana',
522
+ },
523
+ },
524
+ {
525
+ network: 'mainnet',
526
+ address: '0xb231fcda8bbddb31f2ef02e6161444aec64a514e2c89279584ac9806ce9cf037::coin::COIN',
527
+ symbol: 'wUSDCsol',
528
+ name: 'USD Coin Solana (Wormhole)',
529
+ decimals: 6,
530
+ logoURI: 'https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png',
531
+ tags: [],
532
+ extensions: {
533
+ coingeckoId: 'usd-coin',
534
+ },
535
+ },
536
+ ],
537
+ }
@@ -0,0 +1,41 @@
1
+ import { BigDecimal } from '@sentio/bigdecimal'
2
+ import { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js'
3
+ import { MoveCoinList, MoveDex, MovePoolAdaptor, SimpleCoinInfo } from '../../move/ext/index.js'
4
+ import { SuiMoveObject, SuiMovePackage } from '@mysten/sui.js'
5
+ import { SuiNetwork } from '../network.js'
6
+ import { SuiContext, SuiObjectsContext } from '../context.js'
7
+
8
+ export type PoolAdaptor<T> = MovePoolAdaptor<SuiMoveObject, T>
9
+
10
+ export class CoinList implements MoveCoinList {
11
+ calculateValueInUsd(amount: bigint, coinInfo: SimpleCoinInfo, timestamp: number): Promise<BigDecimal> {
12
+ return calculateValueInUsd(amount, coinInfo, timestamp)
13
+ }
14
+
15
+ getCoinInfo(type: string): SimpleCoinInfo {
16
+ return getCoinInfo(type)
17
+ }
18
+
19
+ whiteListed(type: string): boolean {
20
+ return whiteListed(type)
21
+ }
22
+
23
+ whitelistCoins(): Map<string, SimpleCoinInfo> {
24
+ return whitelistCoins()
25
+ }
26
+ }
27
+
28
+ export const SuiCoinList = new CoinList()
29
+
30
+ export class SuiDex<T> extends MoveDex<
31
+ SuiNetwork,
32
+ SuiMovePackage,
33
+ SuiMoveObject,
34
+ Event,
35
+ SuiContext,
36
+ SuiObjectsContext,
37
+ T
38
+ > {
39
+ coinList = SuiCoinList
40
+ declare poolAdaptor: PoolAdaptor<T>
41
+ }
@@ -11,12 +11,14 @@ import {
11
11
  MoveEventHandlerConfig,
12
12
  ProcessConfigResponse,
13
13
  ProcessResult,
14
+ StartRequest,
14
15
  } from '@sentio/protos'
15
16
 
16
17
  import { ServerError, Status } from 'nice-grpc'
17
18
 
18
19
  import { SuiAccountProcessorState, SuiProcessorState } from './sui-processor.js'
19
20
  import { validateAndNormalizeAddress } from './utils.js'
21
+ import { initCoinList } from './ext/coin.js'
20
22
 
21
23
  interface Handlers {
22
24
  suiEventHandlers: ((event: Data_SuiEvent) => Promise<ProcessResult>)[]
@@ -31,6 +33,9 @@ export class SuiPlugin extends Plugin {
31
33
  suiEventHandlers: [],
32
34
  suiObjectHandlers: [],
33
35
  }
36
+ async start(start: StartRequest): Promise<void> {
37
+ await initCoinList()
38
+ }
34
39
 
35
40
  async configure(config: ProcessConfigResponse) {
36
41
  const handlers: Handlers = {