@sentio/sdk 2.60.0-rc.4 → 2.60.0-rc.5

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