@sentio/sdk 2.15.0-rc.1 → 2.15.0-rc.3

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