@tomo-inc/transaction-builder-sdk 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2621 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var viem = require('viem');
5
+ var tronweb = require('tronweb');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
10
+
11
+ var __defProp = Object.defineProperty;
12
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
+
14
+ // src/constant/stage.json
15
+ var stage_default = {
16
+ dev: {
17
+ routerApiUrl: "https://wallet-test.tomo.inc/quote",
18
+ marketApiUrl: "https://gateway-dev.tomo.inc/token"
19
+ },
20
+ prod: {
21
+ routerApiUrl: "https://wallet-pro.tomo.inc/quote",
22
+ marketApiUrl: "https://wallet-pro.tomo.inc/token"
23
+ }
24
+ };
25
+
26
+ // src/api/index.ts
27
+ var QUOTE_API = "/api/v2/myDogeQuote";
28
+ var BUILD_TRANSACTION_API = "/api/v2/buildTransaction";
29
+ var createApiConfig = /* @__PURE__ */ __name((stage) => {
30
+ const routerApiUrl = stage_default[stage].routerApiUrl;
31
+ const marketApiUrl = stage_default[stage].marketApiUrl;
32
+ return {
33
+ routeApi: axios__default.default.create({
34
+ baseURL: routerApiUrl,
35
+ headers: {
36
+ "X-App-Version": "20250427"
37
+ }
38
+ }),
39
+ marketApi: axios__default.default.create({
40
+ baseURL: marketApiUrl
41
+ })
42
+ };
43
+ }, "createApiConfig");
44
+ var reinitializeApi = /* @__PURE__ */ __name((stage, apiConfig) => {
45
+ const { routeApi, marketApi } = createApiConfig(stage);
46
+ if (!apiConfig) {
47
+ throw new Error("Config was not provided");
48
+ }
49
+ [
50
+ routeApi,
51
+ marketApi
52
+ ].forEach((api) => {
53
+ api.interceptors.request.use((config) => {
54
+ Object.assign(config.headers ?? {}, {
55
+ "client-id": apiConfig.CLIENT_ID
56
+ });
57
+ return config;
58
+ }, (error) => {
59
+ if (error?.response?.status === 401) {
60
+ return Promise.reject(error);
61
+ }
62
+ });
63
+ });
64
+ return {
65
+ routeApi,
66
+ marketApi
67
+ };
68
+ }, "reinitializeApi");
69
+ var reinitializeApiMethods = /* @__PURE__ */ __name((apiConfig) => {
70
+ const { routeApi, marketApi } = apiConfig;
71
+ if (!marketApi || !routeApi) {
72
+ throw new Error("API instances are not initialized");
73
+ }
74
+ const getTokenInfo = /* @__PURE__ */ __name(async (queryParameters) => {
75
+ const res = await marketApi.get(`/v1/market/token/search`, {
76
+ params: queryParameters
77
+ });
78
+ return res.data;
79
+ }, "getTokenInfo");
80
+ const getSwapRoutesV2 = /* @__PURE__ */ __name(async (params) => {
81
+ const res = await routeApi.post(QUOTE_API, params);
82
+ const data = res?.data?.result?.data;
83
+ if (!data) {
84
+ const e = new Error("No route found");
85
+ e.cause = res?.data;
86
+ throw e;
87
+ }
88
+ return data;
89
+ }, "getSwapRoutesV2");
90
+ const getSwapRoutesTxV2 = /* @__PURE__ */ __name(async (params) => {
91
+ const res = await routeApi.post(BUILD_TRANSACTION_API, params);
92
+ const data = res?.data?.result;
93
+ if (data?.transactions[0]?.gasInfo) {
94
+ return res.data.result;
95
+ } else {
96
+ throw new Error("Transaction failed");
97
+ }
98
+ }, "getSwapRoutesTxV2");
99
+ return {
100
+ getTokenInfo,
101
+ getSwapRoutesV2,
102
+ getSwapRoutesTxV2
103
+ };
104
+ }, "reinitializeApiMethods");
105
+
106
+ // src/types/chain.ts
107
+ var IPlatformType = /* @__PURE__ */ function(IPlatformType2) {
108
+ IPlatformType2["EVM"] = "EVM";
109
+ IPlatformType2["TON"] = "TON";
110
+ IPlatformType2["TRON"] = "TRON";
111
+ IPlatformType2["BTC"] = "BTC";
112
+ IPlatformType2["DOGE"] = "DOGE";
113
+ IPlatformType2["SUI"] = "SUI";
114
+ IPlatformType2["COSMOS"] = "COSMOS";
115
+ IPlatformType2["APTOS"] = "APTOS";
116
+ IPlatformType2["SOLANA"] = "SOLANA";
117
+ return IPlatformType2;
118
+ }({});
119
+
120
+ // src/chains/const.ts
121
+ var chains = [
122
+ {
123
+ chainId: 8453,
124
+ chainIndex: 845300,
125
+ name: "BASE",
126
+ chainName: "Base",
127
+ nativeCurrencyName: "BASE_ETH",
128
+ nativeCurrencySymbol: "ETH",
129
+ nativeCurrencyDecimals: 18,
130
+ rpcUrls: [
131
+ "https://wallet-test.tomo.inc/rpc/v1/base"
132
+ ],
133
+ blockExplorerUrl: "https://basescan.org",
134
+ platformType: IPlatformType.EVM,
135
+ icon: "https://static.tomo.inc/token/base.svg",
136
+ supportSwap: true,
137
+ isListed: true,
138
+ support: true,
139
+ orderStatusSupport: true,
140
+ type: 1
141
+ },
142
+ {
143
+ chainId: 1,
144
+ chainIndex: 100,
145
+ name: "ETH",
146
+ chainName: "Ethereum",
147
+ nativeCurrencyName: "ETH",
148
+ nativeCurrencySymbol: "ETH",
149
+ nativeCurrencyDecimals: 18,
150
+ rpcUrls: [
151
+ "https://wallet-test.tomo.inc/rpc/v1/eth"
152
+ ],
153
+ blockExplorerUrl: "https://etherscan.io",
154
+ platformType: IPlatformType.EVM,
155
+ icon: "https://static.tomo.inc/token/eth_new.svg",
156
+ supportSwap: true,
157
+ isListed: true,
158
+ support: true,
159
+ orderStatusSupport: true,
160
+ type: 1
161
+ },
162
+ {
163
+ chainId: 59144,
164
+ chainIndex: 5914400,
165
+ name: "LINEA",
166
+ chainName: "Linea",
167
+ nativeCurrencyName: "LINEA_ETH",
168
+ nativeCurrencySymbol: "ETH",
169
+ nativeCurrencyDecimals: 18,
170
+ rpcUrls: [
171
+ "https://wallet-test.tomo.inc/rpc/v1/linea"
172
+ ],
173
+ blockExplorerUrl: "https://lineascan.build",
174
+ platformType: IPlatformType.EVM,
175
+ icon: "https://static.tomo.inc/token/linea.svg",
176
+ supportSwap: true,
177
+ isListed: true,
178
+ support: true,
179
+ orderStatusSupport: true,
180
+ type: 1
181
+ },
182
+ {
183
+ chainId: 10,
184
+ chainIndex: 1e3,
185
+ name: "OPTIMISM",
186
+ chainName: "Optimism",
187
+ nativeCurrencyName: "OP_ETH",
188
+ nativeCurrencySymbol: "ETH",
189
+ nativeCurrencyDecimals: 18,
190
+ rpcUrls: [
191
+ "https://wallet-test.tomo.inc/rpc/v1/optimism"
192
+ ],
193
+ blockExplorerUrl: "https://optimistic.etherscan.io",
194
+ platformType: IPlatformType.EVM,
195
+ icon: "https://static.tomo.inc/token/op.svg",
196
+ supportSwap: true,
197
+ isListed: true,
198
+ support: true,
199
+ orderStatusSupport: true,
200
+ type: 1
201
+ },
202
+ {
203
+ chainId: 42161,
204
+ chainIndex: 4216100,
205
+ name: "ARBITRUM",
206
+ chainName: "Arbitrum One",
207
+ nativeCurrencyName: "ARB_ETH",
208
+ nativeCurrencySymbol: "ETH",
209
+ nativeCurrencyDecimals: 18,
210
+ rpcUrls: [
211
+ "https://wallet-test.tomo.inc/rpc/v1/arbitrum_one"
212
+ ],
213
+ blockExplorerUrl: "https://arbiscan.io",
214
+ platformType: IPlatformType.EVM,
215
+ icon: "https://static.tomo.inc/token/arb.jpeg",
216
+ supportSwap: true,
217
+ isListed: true,
218
+ support: true,
219
+ orderStatusSupport: true,
220
+ type: 1
221
+ },
222
+ {
223
+ chainId: 56,
224
+ chainIndex: 5600,
225
+ name: "BSC",
226
+ chainName: "BNB Chain",
227
+ nativeCurrencyName: "BNB",
228
+ nativeCurrencySymbol: "BNB",
229
+ nativeCurrencyDecimals: 18,
230
+ rpcUrls: [
231
+ "https://wallet-test.tomo.inc/rpc/v1/bsc"
232
+ ],
233
+ blockExplorerUrl: "https://bscscan.com",
234
+ platformType: IPlatformType.EVM,
235
+ icon: "https://static.tomo.inc/token/bsc_new.svg",
236
+ supportSwap: true,
237
+ isListed: true,
238
+ support: true,
239
+ orderStatusSupport: true,
240
+ type: 1
241
+ },
242
+ {
243
+ chainId: 137,
244
+ chainIndex: 13700,
245
+ name: "POLYGON_POS",
246
+ chainName: "Polygon",
247
+ nativeCurrencyName: "POL",
248
+ nativeCurrencySymbol: "POL",
249
+ nativeCurrencyDecimals: 18,
250
+ rpcUrls: [
251
+ "https://wallet-test.tomo.inc/rpc/v1/polygon"
252
+ ],
253
+ blockExplorerUrl: "https://polygonscan.com",
254
+ platformType: IPlatformType.EVM,
255
+ icon: "https://static.tomo.inc/token/polygon.svg",
256
+ supportSwap: true,
257
+ isListed: true,
258
+ support: true,
259
+ orderStatusSupport: true,
260
+ type: 1
261
+ },
262
+ {
263
+ chainId: 81457,
264
+ chainIndex: 8145700,
265
+ name: "BLAST",
266
+ chainName: "Blast",
267
+ nativeCurrencyName: "BLAST_ETH",
268
+ nativeCurrencySymbol: "ETH",
269
+ nativeCurrencyDecimals: 18,
270
+ rpcUrls: [
271
+ "https://wallet-test.tomo.inc/rpc/v1/blast"
272
+ ],
273
+ blockExplorerUrl: "https://blastscan.io",
274
+ platformType: IPlatformType.EVM,
275
+ icon: "https://static.tomo.inc/token/blast.svg",
276
+ supportSwap: true,
277
+ isListed: true,
278
+ support: true,
279
+ orderStatusSupport: true,
280
+ type: 1
281
+ },
282
+ {
283
+ chainId: 534352,
284
+ chainIndex: 53435200,
285
+ name: "SCROLL",
286
+ chainName: "Scroll",
287
+ nativeCurrencyName: "SCROLL_ETH",
288
+ nativeCurrencySymbol: "ETH",
289
+ nativeCurrencyDecimals: 18,
290
+ rpcUrls: [
291
+ "https://wallet-test.tomo.inc/rpc/v1/scroll"
292
+ ],
293
+ blockExplorerUrl: "https://scrollscan.com",
294
+ platformType: IPlatformType.EVM,
295
+ icon: "https://static.tomo.inc/token/scroll.svg",
296
+ supportSwap: true,
297
+ isListed: true,
298
+ support: true,
299
+ orderStatusSupport: true,
300
+ type: 1
301
+ },
302
+ {
303
+ chainId: 43114,
304
+ chainIndex: 4311400,
305
+ name: "AVAX",
306
+ chainName: "Avalanche C",
307
+ nativeCurrencyName: "AVAX",
308
+ nativeCurrencySymbol: "AVAX",
309
+ nativeCurrencyDecimals: 18,
310
+ rpcUrls: [
311
+ "https://wallet-test.tomo.inc/rpc/v1/avalanche"
312
+ ],
313
+ blockExplorerUrl: "https://snowtrace.io",
314
+ platformType: IPlatformType.EVM,
315
+ icon: "https://static.tomo.inc/token/avalanche.svg",
316
+ supportSwap: true,
317
+ isListed: true,
318
+ support: true,
319
+ orderStatusSupport: true,
320
+ type: 1
321
+ },
322
+ {
323
+ chainId: 324,
324
+ chainIndex: 32400,
325
+ name: "ZKSYNC",
326
+ chainName: "zkSync Era",
327
+ nativeCurrencyName: "ZKSYNC_ETH",
328
+ nativeCurrencySymbol: "ETH",
329
+ nativeCurrencyDecimals: 18,
330
+ rpcUrls: [
331
+ "https://wallet-test.tomo.inc/rpc/v1/zk_sync"
332
+ ],
333
+ blockExplorerUrl: "https://mainnet.era.zksync.io",
334
+ platformType: IPlatformType.EVM,
335
+ icon: "https://static.tomo.inc/token/zksync.png",
336
+ supportSwap: false,
337
+ isListed: true,
338
+ support: true,
339
+ orderStatusSupport: true,
340
+ type: 1
341
+ },
342
+ {
343
+ chainId: 60808,
344
+ chainIndex: 6080800,
345
+ name: "BOB",
346
+ chainName: "BOB",
347
+ nativeCurrencyName: "BOB_ETH",
348
+ nativeCurrencySymbol: "ETH",
349
+ nativeCurrencyDecimals: 18,
350
+ rpcUrls: [
351
+ "https://wallet-test.tomo.inc/rpc/v1/bob"
352
+ ],
353
+ blockExplorerUrl: "https://rpc.gobob.xyz",
354
+ platformType: IPlatformType.EVM,
355
+ icon: "https://static.tomo.inc/token/bob.png",
356
+ supportSwap: false,
357
+ isListed: true,
358
+ support: true,
359
+ orderStatusSupport: true,
360
+ type: 1
361
+ },
362
+ {
363
+ chainId: 8333,
364
+ chainIndex: 833300,
365
+ name: "B3",
366
+ chainName: "B3 Mainnet",
367
+ nativeCurrencyName: "B3_ETH",
368
+ nativeCurrencySymbol: "ETH",
369
+ nativeCurrencyDecimals: 18,
370
+ rpcUrls: [
371
+ "https://wallet-test.tomo.inc/rpc/v1/b3"
372
+ ],
373
+ blockExplorerUrl: "https://mainnet-rpc.b3.fun/http",
374
+ platformType: IPlatformType.EVM,
375
+ icon: "https://static.tomo.inc/token/b3.svg",
376
+ supportSwap: false,
377
+ isListed: true,
378
+ support: true,
379
+ orderStatusSupport: true,
380
+ type: 1
381
+ },
382
+ {
383
+ chainId: 223,
384
+ chainIndex: 22300,
385
+ name: "B2",
386
+ chainName: "B\xB2 Network",
387
+ nativeCurrencyName: "B2_BTC",
388
+ nativeCurrencySymbol: "BTC",
389
+ nativeCurrencyDecimals: 18,
390
+ rpcUrls: [
391
+ "https://wallet-test.tomo.inc/rpc/v1/b2"
392
+ ],
393
+ blockExplorerUrl: "https://explorer.bsquared.network",
394
+ platformType: IPlatformType.EVM,
395
+ icon: "https://static.tomo.inc/token/b2.svg",
396
+ supportSwap: false,
397
+ isListed: true,
398
+ support: true,
399
+ orderStatusSupport: true,
400
+ type: 1
401
+ },
402
+ {
403
+ chainId: 200901,
404
+ chainIndex: 20090100,
405
+ name: "BITLAYER",
406
+ chainName: "Bitlayer",
407
+ nativeCurrencyName: "BITLAYER_BTC",
408
+ nativeCurrencySymbol: "BTC",
409
+ nativeCurrencyDecimals: 18,
410
+ rpcUrls: [
411
+ "https://wallet-test.tomo.inc/rpc/v1/bit_layer"
412
+ ],
413
+ blockExplorerUrl: "https://rpc.bitlayer.org",
414
+ platformType: IPlatformType.EVM,
415
+ icon: "https://static.tomo.inc/token/bitlayer.svg",
416
+ supportSwap: false,
417
+ isListed: true,
418
+ support: true,
419
+ orderStatusSupport: true,
420
+ type: 1
421
+ },
422
+ {
423
+ chainId: 5545,
424
+ chainIndex: 554500,
425
+ name: "DUCKCHAIN",
426
+ chainName: "DuckChain Mainnet",
427
+ nativeCurrencyName: "DUCKCHAIN_TON",
428
+ nativeCurrencySymbol: "TON",
429
+ nativeCurrencyDecimals: 18,
430
+ rpcUrls: [
431
+ "https://wallet-test.tomo.inc/rpc/v1/duck"
432
+ ],
433
+ blockExplorerUrl: "https://scan.duckchain.io",
434
+ platformType: IPlatformType.EVM,
435
+ icon: "https://static.tomo.inc/token/duckchain.svg",
436
+ supportSwap: false,
437
+ isListed: true,
438
+ support: true,
439
+ orderStatusSupport: true,
440
+ type: 1
441
+ },
442
+ {
443
+ chainId: 47763,
444
+ chainIndex: 4776300,
445
+ name: "NEOX",
446
+ chainName: "Neo X Mainnet",
447
+ nativeCurrencyName: "GAS",
448
+ nativeCurrencySymbol: "GAS",
449
+ nativeCurrencyDecimals: 18,
450
+ rpcUrls: [
451
+ "https://wallet-test.tomo.inc/rpc/v1/neox"
452
+ ],
453
+ blockExplorerUrl: "https://neotube.io/",
454
+ platformType: IPlatformType.EVM,
455
+ icon: "https://static.tomo.inc/token/neo.jpg",
456
+ supportSwap: false,
457
+ isListed: true,
458
+ support: true,
459
+ orderStatusSupport: true,
460
+ type: 1
461
+ },
462
+ {
463
+ chainId: 4200,
464
+ chainIndex: 42e4,
465
+ name: "MERLIN",
466
+ chainName: "Merlin Chain",
467
+ nativeCurrencyName: "MERLIN_BTC",
468
+ nativeCurrencySymbol: "BTC",
469
+ nativeCurrencyDecimals: 18,
470
+ rpcUrls: [
471
+ "https://wallet-test.tomo.inc/rpc/v1/merlin"
472
+ ],
473
+ blockExplorerUrl: "https://scan.merlinchain.io",
474
+ platformType: IPlatformType.EVM,
475
+ icon: "https://static.tomo.inc/token/merlin.png",
476
+ supportSwap: false,
477
+ isListed: true,
478
+ support: true,
479
+ orderStatusSupport: true,
480
+ type: 1
481
+ },
482
+ {
483
+ chainId: 1329,
484
+ chainIndex: 132900,
485
+ name: "SEI",
486
+ chainName: "Sei EVM",
487
+ nativeCurrencyName: "SEI",
488
+ nativeCurrencySymbol: "SEI",
489
+ nativeCurrencyDecimals: 18,
490
+ rpcUrls: [
491
+ "https://wallet-test.tomo.inc/rpc/v1/sei"
492
+ ],
493
+ blockExplorerUrl: "https://seitrace.com",
494
+ platformType: IPlatformType.EVM,
495
+ icon: "https://static.tomo.inc/token/sei.svg",
496
+ supportSwap: false,
497
+ isListed: true,
498
+ support: true,
499
+ orderStatusSupport: true,
500
+ type: 1
501
+ },
502
+ {
503
+ chainId: 480,
504
+ chainIndex: 48e3,
505
+ name: "WORLD_CHAIN",
506
+ chainName: "World Chain",
507
+ nativeCurrencyName: "WORLDCHAIN_ETH",
508
+ nativeCurrencySymbol: "ETH",
509
+ nativeCurrencyDecimals: 18,
510
+ rpcUrls: [
511
+ "https://wallet-test.tomo.inc/rpc/v1/world"
512
+ ],
513
+ blockExplorerUrl: "https://worldchain-mainnet.explorer.alchemy.com",
514
+ platformType: IPlatformType.EVM,
515
+ icon: "https://static.tomo.inc/token/world-chain.jpg",
516
+ supportSwap: false,
517
+ isListed: true,
518
+ support: true,
519
+ orderStatusSupport: true,
520
+ type: 1
521
+ },
522
+ {
523
+ chainId: 2649,
524
+ chainIndex: 264900,
525
+ name: "AILAYER",
526
+ chainName: "AILayer",
527
+ nativeCurrencyName: "AILAYER_BTC",
528
+ nativeCurrencySymbol: "BTC",
529
+ nativeCurrencyDecimals: 18,
530
+ rpcUrls: [
531
+ "https://wallet-test.tomo.inc/rpc/v1/ai_layer"
532
+ ],
533
+ blockExplorerUrl: "https://mainnet-explorer.ailayer.xyz",
534
+ platformType: IPlatformType.EVM,
535
+ icon: "https://static.tomo.inc/token/ailayer.svg",
536
+ supportSwap: false,
537
+ isListed: true,
538
+ support: true,
539
+ orderStatusSupport: true,
540
+ type: 1
541
+ },
542
+ {
543
+ chainId: 227,
544
+ chainIndex: 22700,
545
+ name: "PROM",
546
+ chainName: "Prom",
547
+ nativeCurrencyName: "PROM",
548
+ nativeCurrencySymbol: "PROM",
549
+ nativeCurrencyDecimals: 18,
550
+ rpcUrls: [
551
+ "https://wallet-test.tomo.inc/rpc/v1/prom_test"
552
+ ],
553
+ blockExplorerUrl: "https://promscan.io",
554
+ platformType: IPlatformType.EVM,
555
+ icon: "https://static.tomo.inc/token/prom-testnet.svg",
556
+ supportSwap: false,
557
+ isListed: true,
558
+ support: true,
559
+ orderStatusSupport: true,
560
+ type: 1
561
+ },
562
+ {
563
+ chainId: 1625,
564
+ chainIndex: 162500,
565
+ name: "GRAVITY",
566
+ chainName: "Gravity Alpha",
567
+ nativeCurrencyName: "G",
568
+ nativeCurrencySymbol: "G",
569
+ nativeCurrencyDecimals: 18,
570
+ rpcUrls: [
571
+ "https://wallet-test.tomo.inc/rpc/v1/gravity"
572
+ ],
573
+ blockExplorerUrl: "https://explorer.gravity.xyz",
574
+ platformType: IPlatformType.EVM,
575
+ icon: "https://static.tomo.inc/token/gravity.jpg",
576
+ supportSwap: false,
577
+ isListed: true,
578
+ support: true,
579
+ orderStatusSupport: true,
580
+ type: 1
581
+ },
582
+ {
583
+ chainId: 204,
584
+ chainIndex: 20400,
585
+ name: "OPBNB",
586
+ chainName: "opBNB",
587
+ nativeCurrencyName: "OP_BNB",
588
+ nativeCurrencySymbol: "BNB",
589
+ nativeCurrencyDecimals: 18,
590
+ rpcUrls: [
591
+ "https://wallet-test.tomo.inc/rpc/v1/op_bnb"
592
+ ],
593
+ blockExplorerUrl: "https://opbnb.bscscan.com",
594
+ platformType: IPlatformType.EVM,
595
+ icon: "https://static.tomo.inc/token/opbnb.svg",
596
+ supportSwap: false,
597
+ isListed: true,
598
+ support: true,
599
+ orderStatusSupport: true,
600
+ type: 1
601
+ },
602
+ {
603
+ chainId: 21e6,
604
+ chainIndex: 21e8,
605
+ name: "CORN",
606
+ chainName: "Corn",
607
+ nativeCurrencyName: "BTCN",
608
+ nativeCurrencySymbol: "BTCN",
609
+ nativeCurrencyDecimals: 18,
610
+ rpcUrls: [
611
+ "https://wallet-test.tomo.inc/rpc/v1/corn"
612
+ ],
613
+ blockExplorerUrl: "https://maizenet-explorer.usecorn.com",
614
+ platformType: IPlatformType.EVM,
615
+ icon: "https://static.tomo.inc/token/corn-logo.svg",
616
+ supportSwap: false,
617
+ isListed: true,
618
+ support: true,
619
+ orderStatusSupport: true,
620
+ type: 1
621
+ },
622
+ {
623
+ chainId: 2390,
624
+ chainIndex: 239e3,
625
+ name: "TAC_TESTNET",
626
+ chainName: "TAC Testnet",
627
+ nativeCurrencyName: "TAC(Testnet)",
628
+ nativeCurrencySymbol: "TAC",
629
+ nativeCurrencyDecimals: 18,
630
+ rpcUrls: [
631
+ "https://wallet-test.tomo.inc/rpc/v1/tac_test"
632
+ ],
633
+ blockExplorerUrl: "https://turin.explorer.tac.build",
634
+ platformType: IPlatformType.EVM,
635
+ isTestnet: true,
636
+ icon: "https://static.tomo.inc/token/tac.svg",
637
+ supportSwap: false,
638
+ isListed: true,
639
+ support: true,
640
+ orderStatusSupport: true,
641
+ type: 2
642
+ },
643
+ {
644
+ chainId: 80094,
645
+ chainIndex: 8009400,
646
+ name: "BERACHAIN_MAINNET",
647
+ chainName: "Berachain Mainnet",
648
+ nativeCurrencyName: "BERA Token",
649
+ nativeCurrencySymbol: "BERA",
650
+ nativeCurrencyDecimals: 18,
651
+ rpcUrls: [
652
+ "https://wallet-test.tomo.inc/rpc/v1/bera"
653
+ ],
654
+ blockExplorerUrl: "https://berascan.com",
655
+ platformType: IPlatformType.EVM,
656
+ icon: "https://static.tomo.inc/token/berachain.svg",
657
+ supportSwap: false,
658
+ isListed: true,
659
+ support: true,
660
+ orderStatusSupport: true,
661
+ type: 1
662
+ },
663
+ {
664
+ chainId: 1514,
665
+ chainIndex: 151400,
666
+ name: "STORY_MAINNET",
667
+ chainName: "Story Mainnet",
668
+ nativeCurrencyName: "IP",
669
+ nativeCurrencySymbol: "IP",
670
+ nativeCurrencyDecimals: 18,
671
+ rpcUrls: [
672
+ "https://wallet-test.tomo.inc/rpc/v1/story"
673
+ ],
674
+ blockExplorerUrl: "https://mainnet.storyscan.xyz",
675
+ platformType: IPlatformType.EVM,
676
+ icon: "https://static.tomo.inc/token/story.jpg",
677
+ supportSwap: false,
678
+ isListed: true,
679
+ support: true,
680
+ orderStatusSupport: true,
681
+ type: 1
682
+ },
683
+ {
684
+ chainId: 3,
685
+ chainIndex: 300,
686
+ name: "DOGECOIN",
687
+ chainName: "Dogecoin",
688
+ nativeCurrencyName: "DOGE",
689
+ nativeCurrencySymbol: "DOGE",
690
+ nativeCurrencyDecimals: 8,
691
+ platformType: IPlatformType.DOGE,
692
+ icon: "https://static.tomo.inc/token/doge.svg",
693
+ supportSwap: false,
694
+ isListed: false,
695
+ support: false,
696
+ orderStatusSupport: true,
697
+ type: 1
698
+ },
699
+ {
700
+ chainId: 501,
701
+ chainIndex: 50100,
702
+ name: "SOLANA",
703
+ chainName: "Solana",
704
+ nativeCurrencyName: "SOL",
705
+ nativeCurrencySymbol: "SOL",
706
+ nativeCurrencyDecimals: 9,
707
+ platformType: IPlatformType.SOLANA,
708
+ icon: "https://static.tomo.inc/token/sol.svg",
709
+ supportSwap: true,
710
+ isListed: true,
711
+ support: true,
712
+ orderStatusSupport: true,
713
+ type: 2
714
+ },
715
+ {
716
+ chainId: 8329,
717
+ chainIndex: 832900,
718
+ name: "LORENZO",
719
+ chainName: "Lorenzo",
720
+ nativeCurrencyName: "stBTC",
721
+ nativeCurrencySymbol: "stBTC",
722
+ nativeCurrencyDecimals: 18,
723
+ rpcUrls: [
724
+ "https://rpc.lorenzo-protocol.xyz"
725
+ ],
726
+ blockExplorerUrl: "https://scan.lorenzo-protocol.xyz",
727
+ platformType: IPlatformType.EVM,
728
+ icon: "https://static.tomo.inc/token/lorenzo.svg",
729
+ supportSwap: false,
730
+ isListed: false,
731
+ support: true,
732
+ orderStatusSupport: true,
733
+ type: 1
734
+ },
735
+ {
736
+ chainId: 1100,
737
+ chainIndex: 11e4,
738
+ name: "TON",
739
+ chainName: "TON",
740
+ nativeCurrencyName: "TON",
741
+ nativeCurrencySymbol: "TON",
742
+ nativeCurrencyDecimals: 9,
743
+ platformType: IPlatformType.TON,
744
+ icon: "https://static.tomo.inc/token/ton.svg",
745
+ supportSwap: false,
746
+ isListed: false,
747
+ support: false,
748
+ orderStatusSupport: true,
749
+ type: 1
750
+ },
751
+ {
752
+ chainId: 195,
753
+ chainIndex: 1948400,
754
+ name: "TRON",
755
+ chainName: "Tron",
756
+ nativeCurrencyName: "TRX",
757
+ nativeCurrencySymbol: "TRX",
758
+ nativeCurrencyDecimals: 6,
759
+ platformType: IPlatformType.TRON,
760
+ icon: "https://static.tomo.inc/token/tron.svg",
761
+ supportSwap: true,
762
+ isListed: true,
763
+ support: true,
764
+ orderStatusSupport: true,
765
+ type: 1
766
+ },
767
+ {
768
+ chainId: 784,
769
+ chainIndex: 78400,
770
+ name: "SUI",
771
+ chainName: "SUI",
772
+ nativeCurrencyName: "SUI",
773
+ nativeCurrencySymbol: "SUI",
774
+ nativeCurrencyDecimals: 9,
775
+ platformType: IPlatformType.SUI,
776
+ icon: "https://static.tomo.inc/token/sui.svg",
777
+ supportSwap: false,
778
+ isListed: false,
779
+ support: false,
780
+ orderStatusSupport: true,
781
+ type: 1
782
+ },
783
+ {
784
+ chainId: 4,
785
+ chainIndex: 400,
786
+ name: "COSMOS_HUB",
787
+ chainName: "Cosmos Hub",
788
+ nativeCurrencyName: "ATOM",
789
+ nativeCurrencySymbol: "ATOM",
790
+ nativeCurrencyDecimals: 6,
791
+ platformType: IPlatformType.COSMOS,
792
+ icon: "https://static.tomo.inc/token/cosmos.png",
793
+ supportSwap: false,
794
+ support: false,
795
+ orderStatusSupport: true,
796
+ isListed: false,
797
+ type: 1
798
+ },
799
+ {
800
+ chainId: 202105,
801
+ chainIndex: 20210500,
802
+ name: "DUCKCHAIN_TESTNET",
803
+ chainName: "DuckChain Testnet",
804
+ nativeCurrencyName: "DUCKCHAIN_TON(Testnet)",
805
+ nativeCurrencySymbol: "TON",
806
+ nativeCurrencyDecimals: 18,
807
+ rpcUrls: [
808
+ "https://testnet-rpc.duckchain.io"
809
+ ],
810
+ blockExplorerUrl: "https://testnet-scan.duckchain.io",
811
+ platformType: IPlatformType.EVM,
812
+ isTestnet: true,
813
+ icon: "https://static.tomo.inc/token/duckchain.svg",
814
+ supportSwap: false,
815
+ isListed: false,
816
+ support: true,
817
+ orderStatusSupport: true,
818
+ type: 2
819
+ },
820
+ {
821
+ chainId: 80084,
822
+ chainIndex: 8008400,
823
+ name: "BERACHAIN_BARTIO",
824
+ chainName: "Berachain bArtio Testnet",
825
+ nativeCurrencyName: "BERA(bartio)",
826
+ nativeCurrencySymbol: "BERA",
827
+ nativeCurrencyDecimals: 18,
828
+ rpcUrls: [
829
+ "https://bartio.rpc.berachain.com"
830
+ ],
831
+ blockExplorerUrl: "https://bartio.beratrail.io",
832
+ platformType: IPlatformType.EVM,
833
+ isTestnet: true,
834
+ icon: "https://static.tomo.inc/token/berachain.svg",
835
+ supportSwap: false,
836
+ isListed: false,
837
+ support: true,
838
+ orderStatusSupport: true,
839
+ type: 2
840
+ },
841
+ {
842
+ chainId: 3636,
843
+ chainIndex: 363600,
844
+ name: "BOTANIX_TESTNET",
845
+ chainName: "Botanix Testnet",
846
+ nativeCurrencyName: "BOTANIX_BTC(Testnet)",
847
+ nativeCurrencySymbol: "BTC",
848
+ nativeCurrencyDecimals: 18,
849
+ rpcUrls: [
850
+ "https://poa-node.botanixlabs.dev"
851
+ ],
852
+ blockExplorerUrl: "https://blockscout.botanixlabs.dev",
853
+ platformType: IPlatformType.EVM,
854
+ isTestnet: true,
855
+ icon: "https://static.tomo.inc/token/botanix-testnet.jpg",
856
+ supportSwap: false,
857
+ isListed: false,
858
+ support: true,
859
+ orderStatusSupport: true,
860
+ type: 2
861
+ },
862
+ {
863
+ chainId: 1315,
864
+ chainIndex: 131500,
865
+ name: "STORY_AENEID_TESTNET",
866
+ chainName: "Story Aeneid Testnet",
867
+ nativeCurrencyName: "IP(Testnet)",
868
+ nativeCurrencySymbol: "IP",
869
+ nativeCurrencyDecimals: 18,
870
+ rpcUrls: [
871
+ "https://aeneid.storyrpc.io"
872
+ ],
873
+ blockExplorerUrl: "https://aeneid.storyscan.xyz/",
874
+ platformType: IPlatformType.EVM,
875
+ icon: "https://static.tomo.inc/token/story.jpg",
876
+ supportSwap: false,
877
+ isListed: false,
878
+ orderStatusSupport: false,
879
+ support: false,
880
+ type: 0
881
+ },
882
+ {
883
+ chainId: 126,
884
+ chainIndex: 12600,
885
+ name: "MOVEMENT_MAINNET",
886
+ chainName: "Movement",
887
+ nativeCurrencyName: "MOVE",
888
+ nativeCurrencySymbol: "MOVE",
889
+ nativeCurrencyDecimals: 8,
890
+ rpcUrls: [
891
+ "https://mainnet.movementnetwork.xyz/v1"
892
+ ],
893
+ blockExplorerUrl: "https://explorer.movementnetwork.xyz/?network=mainnet",
894
+ platformType: IPlatformType.APTOS,
895
+ icon: "https://static.tomo.inc/token/movement.svg",
896
+ supportSwap: false,
897
+ isListed: false,
898
+ support: false,
899
+ orderStatusSupport: true,
900
+ type: 1
901
+ }
902
+ ];
903
+
904
+ // src/chains/getBridgeSupportChains.ts
905
+ var getBridgeSupportChains = /* @__PURE__ */ __name(() => {
906
+ return chains.filter((c) => c.supportSwap && c.isListed && !c.isTestnet);
907
+ }, "getBridgeSupportChains");
908
+
909
+ // src/chains/getSwapSupportChains.ts
910
+ var getSwapSupportChains = /* @__PURE__ */ __name(() => {
911
+ return chains.filter((c) => c.supportSwap && c.isListed && !c.isTestnet);
912
+ }, "getSwapSupportChains");
913
+
914
+ // src/constant/index.ts
915
+ var apiInitializedError = /* @__PURE__ */ __name(async () => {
916
+ throw new Error("API methods not initialized");
917
+ }, "apiInitializedError");
918
+
919
+ // src/constant/abis/permit2.json
920
+ var permit2_default = [
921
+ {
922
+ inputs: [
923
+ {
924
+ internalType: "uint256",
925
+ name: "deadline",
926
+ type: "uint256"
927
+ }
928
+ ],
929
+ name: "AllowanceExpired",
930
+ type: "error"
931
+ },
932
+ {
933
+ inputs: [],
934
+ name: "ExcessiveInvalidation",
935
+ type: "error"
936
+ },
937
+ {
938
+ inputs: [
939
+ {
940
+ internalType: "uint256",
941
+ name: "amount",
942
+ type: "uint256"
943
+ }
944
+ ],
945
+ name: "InsufficientAllowance",
946
+ type: "error"
947
+ },
948
+ {
949
+ inputs: [
950
+ {
951
+ internalType: "uint256",
952
+ name: "maxAmount",
953
+ type: "uint256"
954
+ }
955
+ ],
956
+ name: "InvalidAmount",
957
+ type: "error"
958
+ },
959
+ {
960
+ inputs: [],
961
+ name: "InvalidContractSignature",
962
+ type: "error"
963
+ },
964
+ {
965
+ inputs: [],
966
+ name: "InvalidNonce",
967
+ type: "error"
968
+ },
969
+ {
970
+ inputs: [],
971
+ name: "InvalidSignature",
972
+ type: "error"
973
+ },
974
+ {
975
+ inputs: [],
976
+ name: "InvalidSignatureLength",
977
+ type: "error"
978
+ },
979
+ {
980
+ inputs: [],
981
+ name: "InvalidSigner",
982
+ type: "error"
983
+ },
984
+ {
985
+ inputs: [],
986
+ name: "LengthMismatch",
987
+ type: "error"
988
+ },
989
+ {
990
+ inputs: [
991
+ {
992
+ internalType: "uint256",
993
+ name: "signatureDeadline",
994
+ type: "uint256"
995
+ }
996
+ ],
997
+ name: "SignatureExpired",
998
+ type: "error"
999
+ },
1000
+ {
1001
+ anonymous: false,
1002
+ inputs: [
1003
+ {
1004
+ indexed: true,
1005
+ internalType: "address",
1006
+ name: "owner",
1007
+ type: "address"
1008
+ },
1009
+ {
1010
+ indexed: true,
1011
+ internalType: "address",
1012
+ name: "token",
1013
+ type: "address"
1014
+ },
1015
+ {
1016
+ indexed: true,
1017
+ internalType: "address",
1018
+ name: "spender",
1019
+ type: "address"
1020
+ },
1021
+ {
1022
+ indexed: false,
1023
+ internalType: "uint160",
1024
+ name: "amount",
1025
+ type: "uint160"
1026
+ },
1027
+ {
1028
+ indexed: false,
1029
+ internalType: "uint48",
1030
+ name: "expiration",
1031
+ type: "uint48"
1032
+ }
1033
+ ],
1034
+ name: "Approval",
1035
+ type: "event"
1036
+ },
1037
+ {
1038
+ anonymous: false,
1039
+ inputs: [
1040
+ {
1041
+ indexed: true,
1042
+ internalType: "address",
1043
+ name: "owner",
1044
+ type: "address"
1045
+ },
1046
+ {
1047
+ indexed: false,
1048
+ internalType: "address",
1049
+ name: "token",
1050
+ type: "address"
1051
+ },
1052
+ {
1053
+ indexed: false,
1054
+ internalType: "address",
1055
+ name: "spender",
1056
+ type: "address"
1057
+ }
1058
+ ],
1059
+ name: "Lockdown",
1060
+ type: "event"
1061
+ },
1062
+ {
1063
+ anonymous: false,
1064
+ inputs: [
1065
+ {
1066
+ indexed: true,
1067
+ internalType: "address",
1068
+ name: "owner",
1069
+ type: "address"
1070
+ },
1071
+ {
1072
+ indexed: true,
1073
+ internalType: "address",
1074
+ name: "token",
1075
+ type: "address"
1076
+ },
1077
+ {
1078
+ indexed: true,
1079
+ internalType: "address",
1080
+ name: "spender",
1081
+ type: "address"
1082
+ },
1083
+ {
1084
+ indexed: false,
1085
+ internalType: "uint48",
1086
+ name: "newNonce",
1087
+ type: "uint48"
1088
+ },
1089
+ {
1090
+ indexed: false,
1091
+ internalType: "uint48",
1092
+ name: "oldNonce",
1093
+ type: "uint48"
1094
+ }
1095
+ ],
1096
+ name: "NonceInvalidation",
1097
+ type: "event"
1098
+ },
1099
+ {
1100
+ anonymous: false,
1101
+ inputs: [
1102
+ {
1103
+ indexed: true,
1104
+ internalType: "address",
1105
+ name: "owner",
1106
+ type: "address"
1107
+ },
1108
+ {
1109
+ indexed: true,
1110
+ internalType: "address",
1111
+ name: "token",
1112
+ type: "address"
1113
+ },
1114
+ {
1115
+ indexed: true,
1116
+ internalType: "address",
1117
+ name: "spender",
1118
+ type: "address"
1119
+ },
1120
+ {
1121
+ indexed: false,
1122
+ internalType: "uint160",
1123
+ name: "amount",
1124
+ type: "uint160"
1125
+ },
1126
+ {
1127
+ indexed: false,
1128
+ internalType: "uint48",
1129
+ name: "expiration",
1130
+ type: "uint48"
1131
+ },
1132
+ {
1133
+ indexed: false,
1134
+ internalType: "uint48",
1135
+ name: "nonce",
1136
+ type: "uint48"
1137
+ }
1138
+ ],
1139
+ name: "Permit",
1140
+ type: "event"
1141
+ },
1142
+ {
1143
+ anonymous: false,
1144
+ inputs: [
1145
+ {
1146
+ indexed: true,
1147
+ internalType: "address",
1148
+ name: "owner",
1149
+ type: "address"
1150
+ },
1151
+ {
1152
+ indexed: false,
1153
+ internalType: "uint256",
1154
+ name: "word",
1155
+ type: "uint256"
1156
+ },
1157
+ {
1158
+ indexed: false,
1159
+ internalType: "uint256",
1160
+ name: "mask",
1161
+ type: "uint256"
1162
+ }
1163
+ ],
1164
+ name: "UnorderedNonceInvalidation",
1165
+ type: "event"
1166
+ },
1167
+ {
1168
+ inputs: [],
1169
+ name: "DOMAIN_SEPARATOR",
1170
+ outputs: [
1171
+ {
1172
+ internalType: "bytes32",
1173
+ name: "",
1174
+ type: "bytes32"
1175
+ }
1176
+ ],
1177
+ stateMutability: "view",
1178
+ type: "function"
1179
+ },
1180
+ {
1181
+ inputs: [
1182
+ {
1183
+ internalType: "address",
1184
+ name: "",
1185
+ type: "address"
1186
+ },
1187
+ {
1188
+ internalType: "address",
1189
+ name: "",
1190
+ type: "address"
1191
+ },
1192
+ {
1193
+ internalType: "address",
1194
+ name: "",
1195
+ type: "address"
1196
+ }
1197
+ ],
1198
+ name: "allowance",
1199
+ outputs: [
1200
+ {
1201
+ internalType: "uint160",
1202
+ name: "amount",
1203
+ type: "uint160"
1204
+ },
1205
+ {
1206
+ internalType: "uint48",
1207
+ name: "expiration",
1208
+ type: "uint48"
1209
+ },
1210
+ {
1211
+ internalType: "uint48",
1212
+ name: "nonce",
1213
+ type: "uint48"
1214
+ }
1215
+ ],
1216
+ stateMutability: "view",
1217
+ type: "function"
1218
+ },
1219
+ {
1220
+ inputs: [
1221
+ {
1222
+ internalType: "address",
1223
+ name: "token",
1224
+ type: "address"
1225
+ },
1226
+ {
1227
+ internalType: "address",
1228
+ name: "spender",
1229
+ type: "address"
1230
+ },
1231
+ {
1232
+ internalType: "uint160",
1233
+ name: "amount",
1234
+ type: "uint160"
1235
+ },
1236
+ {
1237
+ internalType: "uint48",
1238
+ name: "expiration",
1239
+ type: "uint48"
1240
+ }
1241
+ ],
1242
+ name: "approve",
1243
+ outputs: [],
1244
+ stateMutability: "nonpayable",
1245
+ type: "function"
1246
+ },
1247
+ {
1248
+ inputs: [
1249
+ {
1250
+ internalType: "address",
1251
+ name: "token",
1252
+ type: "address"
1253
+ },
1254
+ {
1255
+ internalType: "address",
1256
+ name: "spender",
1257
+ type: "address"
1258
+ },
1259
+ {
1260
+ internalType: "uint48",
1261
+ name: "newNonce",
1262
+ type: "uint48"
1263
+ }
1264
+ ],
1265
+ name: "invalidateNonces",
1266
+ outputs: [],
1267
+ stateMutability: "nonpayable",
1268
+ type: "function"
1269
+ },
1270
+ {
1271
+ inputs: [
1272
+ {
1273
+ internalType: "uint256",
1274
+ name: "wordPos",
1275
+ type: "uint256"
1276
+ },
1277
+ {
1278
+ internalType: "uint256",
1279
+ name: "mask",
1280
+ type: "uint256"
1281
+ }
1282
+ ],
1283
+ name: "invalidateUnorderedNonces",
1284
+ outputs: [],
1285
+ stateMutability: "nonpayable",
1286
+ type: "function"
1287
+ },
1288
+ {
1289
+ inputs: [
1290
+ {
1291
+ components: [
1292
+ {
1293
+ internalType: "address",
1294
+ name: "token",
1295
+ type: "address"
1296
+ },
1297
+ {
1298
+ internalType: "address",
1299
+ name: "spender",
1300
+ type: "address"
1301
+ }
1302
+ ],
1303
+ internalType: "struct IAllowanceTransfer.TokenSpenderPair[]",
1304
+ name: "approvals",
1305
+ type: "tuple[]"
1306
+ }
1307
+ ],
1308
+ name: "lockdown",
1309
+ outputs: [],
1310
+ stateMutability: "nonpayable",
1311
+ type: "function"
1312
+ },
1313
+ {
1314
+ inputs: [
1315
+ {
1316
+ internalType: "address",
1317
+ name: "",
1318
+ type: "address"
1319
+ },
1320
+ {
1321
+ internalType: "uint256",
1322
+ name: "",
1323
+ type: "uint256"
1324
+ }
1325
+ ],
1326
+ name: "nonceBitmap",
1327
+ outputs: [
1328
+ {
1329
+ internalType: "uint256",
1330
+ name: "",
1331
+ type: "uint256"
1332
+ }
1333
+ ],
1334
+ stateMutability: "view",
1335
+ type: "function"
1336
+ },
1337
+ {
1338
+ inputs: [
1339
+ {
1340
+ internalType: "address",
1341
+ name: "owner",
1342
+ type: "address"
1343
+ },
1344
+ {
1345
+ components: [
1346
+ {
1347
+ components: [
1348
+ {
1349
+ internalType: "address",
1350
+ name: "token",
1351
+ type: "address"
1352
+ },
1353
+ {
1354
+ internalType: "uint160",
1355
+ name: "amount",
1356
+ type: "uint160"
1357
+ },
1358
+ {
1359
+ internalType: "uint48",
1360
+ name: "expiration",
1361
+ type: "uint48"
1362
+ },
1363
+ {
1364
+ internalType: "uint48",
1365
+ name: "nonce",
1366
+ type: "uint48"
1367
+ }
1368
+ ],
1369
+ internalType: "struct IAllowanceTransfer.PermitDetails[]",
1370
+ name: "details",
1371
+ type: "tuple[]"
1372
+ },
1373
+ {
1374
+ internalType: "address",
1375
+ name: "spender",
1376
+ type: "address"
1377
+ },
1378
+ {
1379
+ internalType: "uint256",
1380
+ name: "sigDeadline",
1381
+ type: "uint256"
1382
+ }
1383
+ ],
1384
+ internalType: "struct IAllowanceTransfer.PermitBatch",
1385
+ name: "permitBatch",
1386
+ type: "tuple"
1387
+ },
1388
+ {
1389
+ internalType: "bytes",
1390
+ name: "signature",
1391
+ type: "bytes"
1392
+ }
1393
+ ],
1394
+ name: "permit",
1395
+ outputs: [],
1396
+ stateMutability: "nonpayable",
1397
+ type: "function"
1398
+ },
1399
+ {
1400
+ inputs: [
1401
+ {
1402
+ internalType: "address",
1403
+ name: "owner",
1404
+ type: "address"
1405
+ },
1406
+ {
1407
+ components: [
1408
+ {
1409
+ components: [
1410
+ {
1411
+ internalType: "address",
1412
+ name: "token",
1413
+ type: "address"
1414
+ },
1415
+ {
1416
+ internalType: "uint160",
1417
+ name: "amount",
1418
+ type: "uint160"
1419
+ },
1420
+ {
1421
+ internalType: "uint48",
1422
+ name: "expiration",
1423
+ type: "uint48"
1424
+ },
1425
+ {
1426
+ internalType: "uint48",
1427
+ name: "nonce",
1428
+ type: "uint48"
1429
+ }
1430
+ ],
1431
+ internalType: "struct IAllowanceTransfer.PermitDetails",
1432
+ name: "details",
1433
+ type: "tuple"
1434
+ },
1435
+ {
1436
+ internalType: "address",
1437
+ name: "spender",
1438
+ type: "address"
1439
+ },
1440
+ {
1441
+ internalType: "uint256",
1442
+ name: "sigDeadline",
1443
+ type: "uint256"
1444
+ }
1445
+ ],
1446
+ internalType: "struct IAllowanceTransfer.PermitSingle",
1447
+ name: "permitSingle",
1448
+ type: "tuple"
1449
+ },
1450
+ {
1451
+ internalType: "bytes",
1452
+ name: "signature",
1453
+ type: "bytes"
1454
+ }
1455
+ ],
1456
+ name: "permit",
1457
+ outputs: [],
1458
+ stateMutability: "nonpayable",
1459
+ type: "function"
1460
+ },
1461
+ {
1462
+ inputs: [
1463
+ {
1464
+ components: [
1465
+ {
1466
+ components: [
1467
+ {
1468
+ internalType: "address",
1469
+ name: "token",
1470
+ type: "address"
1471
+ },
1472
+ {
1473
+ internalType: "uint256",
1474
+ name: "amount",
1475
+ type: "uint256"
1476
+ }
1477
+ ],
1478
+ internalType: "struct ISignatureTransfer.TokenPermissions",
1479
+ name: "permitted",
1480
+ type: "tuple"
1481
+ },
1482
+ {
1483
+ internalType: "uint256",
1484
+ name: "nonce",
1485
+ type: "uint256"
1486
+ },
1487
+ {
1488
+ internalType: "uint256",
1489
+ name: "deadline",
1490
+ type: "uint256"
1491
+ }
1492
+ ],
1493
+ internalType: "struct ISignatureTransfer.PermitTransferFrom",
1494
+ name: "permit",
1495
+ type: "tuple"
1496
+ },
1497
+ {
1498
+ components: [
1499
+ {
1500
+ internalType: "address",
1501
+ name: "to",
1502
+ type: "address"
1503
+ },
1504
+ {
1505
+ internalType: "uint256",
1506
+ name: "requestedAmount",
1507
+ type: "uint256"
1508
+ }
1509
+ ],
1510
+ internalType: "struct ISignatureTransfer.SignatureTransferDetails",
1511
+ name: "transferDetails",
1512
+ type: "tuple"
1513
+ },
1514
+ {
1515
+ internalType: "address",
1516
+ name: "owner",
1517
+ type: "address"
1518
+ },
1519
+ {
1520
+ internalType: "bytes",
1521
+ name: "signature",
1522
+ type: "bytes"
1523
+ }
1524
+ ],
1525
+ name: "permitTransferFrom",
1526
+ outputs: [],
1527
+ stateMutability: "nonpayable",
1528
+ type: "function"
1529
+ },
1530
+ {
1531
+ inputs: [
1532
+ {
1533
+ components: [
1534
+ {
1535
+ components: [
1536
+ {
1537
+ internalType: "address",
1538
+ name: "token",
1539
+ type: "address"
1540
+ },
1541
+ {
1542
+ internalType: "uint256",
1543
+ name: "amount",
1544
+ type: "uint256"
1545
+ }
1546
+ ],
1547
+ internalType: "struct ISignatureTransfer.TokenPermissions[]",
1548
+ name: "permitted",
1549
+ type: "tuple[]"
1550
+ },
1551
+ {
1552
+ internalType: "uint256",
1553
+ name: "nonce",
1554
+ type: "uint256"
1555
+ },
1556
+ {
1557
+ internalType: "uint256",
1558
+ name: "deadline",
1559
+ type: "uint256"
1560
+ }
1561
+ ],
1562
+ internalType: "struct ISignatureTransfer.PermitBatchTransferFrom",
1563
+ name: "permit",
1564
+ type: "tuple"
1565
+ },
1566
+ {
1567
+ components: [
1568
+ {
1569
+ internalType: "address",
1570
+ name: "to",
1571
+ type: "address"
1572
+ },
1573
+ {
1574
+ internalType: "uint256",
1575
+ name: "requestedAmount",
1576
+ type: "uint256"
1577
+ }
1578
+ ],
1579
+ internalType: "struct ISignatureTransfer.SignatureTransferDetails[]",
1580
+ name: "transferDetails",
1581
+ type: "tuple[]"
1582
+ },
1583
+ {
1584
+ internalType: "address",
1585
+ name: "owner",
1586
+ type: "address"
1587
+ },
1588
+ {
1589
+ internalType: "bytes",
1590
+ name: "signature",
1591
+ type: "bytes"
1592
+ }
1593
+ ],
1594
+ name: "permitTransferFrom",
1595
+ outputs: [],
1596
+ stateMutability: "nonpayable",
1597
+ type: "function"
1598
+ },
1599
+ {
1600
+ inputs: [
1601
+ {
1602
+ components: [
1603
+ {
1604
+ components: [
1605
+ {
1606
+ internalType: "address",
1607
+ name: "token",
1608
+ type: "address"
1609
+ },
1610
+ {
1611
+ internalType: "uint256",
1612
+ name: "amount",
1613
+ type: "uint256"
1614
+ }
1615
+ ],
1616
+ internalType: "struct ISignatureTransfer.TokenPermissions",
1617
+ name: "permitted",
1618
+ type: "tuple"
1619
+ },
1620
+ {
1621
+ internalType: "uint256",
1622
+ name: "nonce",
1623
+ type: "uint256"
1624
+ },
1625
+ {
1626
+ internalType: "uint256",
1627
+ name: "deadline",
1628
+ type: "uint256"
1629
+ }
1630
+ ],
1631
+ internalType: "struct ISignatureTransfer.PermitTransferFrom",
1632
+ name: "permit",
1633
+ type: "tuple"
1634
+ },
1635
+ {
1636
+ components: [
1637
+ {
1638
+ internalType: "address",
1639
+ name: "to",
1640
+ type: "address"
1641
+ },
1642
+ {
1643
+ internalType: "uint256",
1644
+ name: "requestedAmount",
1645
+ type: "uint256"
1646
+ }
1647
+ ],
1648
+ internalType: "struct ISignatureTransfer.SignatureTransferDetails",
1649
+ name: "transferDetails",
1650
+ type: "tuple"
1651
+ },
1652
+ {
1653
+ internalType: "address",
1654
+ name: "owner",
1655
+ type: "address"
1656
+ },
1657
+ {
1658
+ internalType: "bytes32",
1659
+ name: "witness",
1660
+ type: "bytes32"
1661
+ },
1662
+ {
1663
+ internalType: "string",
1664
+ name: "witnessTypeString",
1665
+ type: "string"
1666
+ },
1667
+ {
1668
+ internalType: "bytes",
1669
+ name: "signature",
1670
+ type: "bytes"
1671
+ }
1672
+ ],
1673
+ name: "permitWitnessTransferFrom",
1674
+ outputs: [],
1675
+ stateMutability: "nonpayable",
1676
+ type: "function"
1677
+ },
1678
+ {
1679
+ inputs: [
1680
+ {
1681
+ components: [
1682
+ {
1683
+ components: [
1684
+ {
1685
+ internalType: "address",
1686
+ name: "token",
1687
+ type: "address"
1688
+ },
1689
+ {
1690
+ internalType: "uint256",
1691
+ name: "amount",
1692
+ type: "uint256"
1693
+ }
1694
+ ],
1695
+ internalType: "struct ISignatureTransfer.TokenPermissions[]",
1696
+ name: "permitted",
1697
+ type: "tuple[]"
1698
+ },
1699
+ {
1700
+ internalType: "uint256",
1701
+ name: "nonce",
1702
+ type: "uint256"
1703
+ },
1704
+ {
1705
+ internalType: "uint256",
1706
+ name: "deadline",
1707
+ type: "uint256"
1708
+ }
1709
+ ],
1710
+ internalType: "struct ISignatureTransfer.PermitBatchTransferFrom",
1711
+ name: "permit",
1712
+ type: "tuple"
1713
+ },
1714
+ {
1715
+ components: [
1716
+ {
1717
+ internalType: "address",
1718
+ name: "to",
1719
+ type: "address"
1720
+ },
1721
+ {
1722
+ internalType: "uint256",
1723
+ name: "requestedAmount",
1724
+ type: "uint256"
1725
+ }
1726
+ ],
1727
+ internalType: "struct ISignatureTransfer.SignatureTransferDetails[]",
1728
+ name: "transferDetails",
1729
+ type: "tuple[]"
1730
+ },
1731
+ {
1732
+ internalType: "address",
1733
+ name: "owner",
1734
+ type: "address"
1735
+ },
1736
+ {
1737
+ internalType: "bytes32",
1738
+ name: "witness",
1739
+ type: "bytes32"
1740
+ },
1741
+ {
1742
+ internalType: "string",
1743
+ name: "witnessTypeString",
1744
+ type: "string"
1745
+ },
1746
+ {
1747
+ internalType: "bytes",
1748
+ name: "signature",
1749
+ type: "bytes"
1750
+ }
1751
+ ],
1752
+ name: "permitWitnessTransferFrom",
1753
+ outputs: [],
1754
+ stateMutability: "nonpayable",
1755
+ type: "function"
1756
+ },
1757
+ {
1758
+ inputs: [
1759
+ {
1760
+ components: [
1761
+ {
1762
+ internalType: "address",
1763
+ name: "from",
1764
+ type: "address"
1765
+ },
1766
+ {
1767
+ internalType: "address",
1768
+ name: "to",
1769
+ type: "address"
1770
+ },
1771
+ {
1772
+ internalType: "uint160",
1773
+ name: "amount",
1774
+ type: "uint160"
1775
+ },
1776
+ {
1777
+ internalType: "address",
1778
+ name: "token",
1779
+ type: "address"
1780
+ }
1781
+ ],
1782
+ internalType: "struct IAllowanceTransfer.AllowanceTransferDetails[]",
1783
+ name: "transferDetails",
1784
+ type: "tuple[]"
1785
+ }
1786
+ ],
1787
+ name: "transferFrom",
1788
+ outputs: [],
1789
+ stateMutability: "nonpayable",
1790
+ type: "function"
1791
+ },
1792
+ {
1793
+ inputs: [
1794
+ {
1795
+ internalType: "address",
1796
+ name: "from",
1797
+ type: "address"
1798
+ },
1799
+ {
1800
+ internalType: "address",
1801
+ name: "to",
1802
+ type: "address"
1803
+ },
1804
+ {
1805
+ internalType: "uint160",
1806
+ name: "amount",
1807
+ type: "uint160"
1808
+ },
1809
+ {
1810
+ internalType: "address",
1811
+ name: "token",
1812
+ type: "address"
1813
+ }
1814
+ ],
1815
+ name: "transferFrom",
1816
+ outputs: [],
1817
+ stateMutability: "nonpayable",
1818
+ type: "function"
1819
+ }
1820
+ ];
1821
+
1822
+ // src/constant/abi.ts
1823
+ var Permit2Abi = permit2_default;
1824
+
1825
+ // src/constant/address.ts
1826
+ var TRON_PERMIT2_ADDRESS = "TDJNTBi51CnnpCYYgi6GitoT4CJWrqim2G";
1827
+ var EVM_PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
1828
+ var OkxEvmNativeAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
1829
+ var OkxBTCNativeAddress = "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8";
1830
+ var OkxTonNativeAddress = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
1831
+ var SolanaNativeAddress = "11111111111111111111111111111111";
1832
+ var SUI_TYPE_ARG = "0x2::sui::SUI";
1833
+ var SuiNativeAddress = SUI_TYPE_ARG;
1834
+ var TronNativeAddress = "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb";
1835
+ var getOkTokenAddress = /* @__PURE__ */ __name((token, chain) => {
1836
+ if (token.address) {
1837
+ return token.address;
1838
+ }
1839
+ if (chain?.platformType === IPlatformType.TON) {
1840
+ return OkxTonNativeAddress;
1841
+ }
1842
+ if (chain?.platformType === IPlatformType.EVM) {
1843
+ return OkxEvmNativeAddress;
1844
+ }
1845
+ if (chain?.platformType === IPlatformType.BTC) {
1846
+ return OkxBTCNativeAddress;
1847
+ }
1848
+ if (chain?.platformType === IPlatformType.SOLANA) {
1849
+ return SolanaNativeAddress;
1850
+ }
1851
+ if (chain?.platformType === IPlatformType.SUI) {
1852
+ return SuiNativeAddress;
1853
+ }
1854
+ if (chain?.platformType === IPlatformType.TRON) {
1855
+ return TronNativeAddress;
1856
+ }
1857
+ return "";
1858
+ }, "getOkTokenAddress");
1859
+ var getViemChainByChainInfo = /* @__PURE__ */ __name((chain) => {
1860
+ const viemChain = /* @__PURE__ */ viem.defineChain({
1861
+ chain,
1862
+ id: chain.chainId,
1863
+ name: chain.chainName,
1864
+ nativeCurrency: {
1865
+ name: chain.nativeCurrencyName,
1866
+ symbol: chain.nativeCurrencySymbol,
1867
+ decimals: chain.nativeCurrencyDecimals
1868
+ },
1869
+ rpcUrls: {
1870
+ default: {
1871
+ http: chain.rpcUrls || []
1872
+ }
1873
+ },
1874
+ blockExplorers: {
1875
+ default: {
1876
+ name: chain.chainName + "Scan",
1877
+ url: chain.blockExplorerUrl || "",
1878
+ apiUrl: chain.blockExplorerUrl + "/api"
1879
+ }
1880
+ }
1881
+ });
1882
+ return viemChain;
1883
+ }, "getViemChainByChainInfo");
1884
+
1885
+ // src/swap/methods/chains/const.ts
1886
+ var PERMIT2_TYPES = {
1887
+ PermitDetails: [
1888
+ {
1889
+ name: "token",
1890
+ type: "address"
1891
+ },
1892
+ {
1893
+ name: "amount",
1894
+ type: "uint160"
1895
+ },
1896
+ {
1897
+ name: "expiration",
1898
+ type: "uint48"
1899
+ },
1900
+ {
1901
+ name: "nonce",
1902
+ type: "uint48"
1903
+ }
1904
+ ],
1905
+ PermitSingle: [
1906
+ {
1907
+ name: "details",
1908
+ type: "PermitDetails"
1909
+ },
1910
+ {
1911
+ name: "spender",
1912
+ type: "address"
1913
+ },
1914
+ {
1915
+ name: "sigDeadline",
1916
+ type: "uint256"
1917
+ }
1918
+ ]
1919
+ };
1920
+
1921
+ // src/swap/methods/chains/evm.ts
1922
+ var getPermitTypeData = /* @__PURE__ */ __name(async (quoteParams, quoteResult) => {
1923
+ const { sender, fromToken, amount } = quoteParams;
1924
+ const chain = quoteParams.fromToken.chain;
1925
+ const token = fromToken.address;
1926
+ const contract = quoteResult.contract;
1927
+ const viemChain = getViemChainByChainInfo(chain);
1928
+ if (!viemChain) {
1929
+ throw new Error("Chain not found");
1930
+ }
1931
+ const publicClient = viem.createPublicClient({
1932
+ chain: viemChain,
1933
+ transport: viem.http()
1934
+ });
1935
+ const permitAllowance = await publicClient.readContract({
1936
+ abi: Permit2Abi,
1937
+ address: EVM_PERMIT2_ADDRESS,
1938
+ functionName: "allowance",
1939
+ args: [
1940
+ sender,
1941
+ token,
1942
+ contract
1943
+ ]
1944
+ });
1945
+ if (!permitAllowance) {
1946
+ throw new Error("Failed to fetch Permit2 allowance data");
1947
+ }
1948
+ const sigDeadline = Math.floor(Date.now() / 1e3) + 6e3;
1949
+ const domain = {
1950
+ name: "Permit2",
1951
+ chainId: viemChain.id,
1952
+ verifyingContract: EVM_PERMIT2_ADDRESS
1953
+ };
1954
+ const message = {
1955
+ details: {
1956
+ token,
1957
+ amount,
1958
+ expiration: 0,
1959
+ nonce: Number(permitAllowance[2].toString())
1960
+ },
1961
+ spender: contract,
1962
+ sigDeadline
1963
+ };
1964
+ return {
1965
+ types: PERMIT2_TYPES,
1966
+ message,
1967
+ primaryType: "PermitSingle",
1968
+ domain
1969
+ };
1970
+ }, "getPermitTypeData");
1971
+ var getApiEVMPermit = /* @__PURE__ */ __name((signature, permitTypeData) => {
1972
+ const permit2InputEncode = viem.encodeAbiParameters(
1973
+ [
1974
+ {
1975
+ type: "tuple",
1976
+ components: [
1977
+ {
1978
+ name: "details",
1979
+ type: "tuple",
1980
+ components: [
1981
+ {
1982
+ name: "token",
1983
+ type: "address"
1984
+ },
1985
+ {
1986
+ name: "amount",
1987
+ type: "uint160"
1988
+ },
1989
+ {
1990
+ name: "expiration",
1991
+ type: "uint48"
1992
+ },
1993
+ {
1994
+ name: "nonce",
1995
+ type: "uint48"
1996
+ }
1997
+ ]
1998
+ },
1999
+ {
2000
+ name: "spender",
2001
+ type: "address"
2002
+ },
2003
+ {
2004
+ name: "sigDeadline",
2005
+ type: "uint256"
2006
+ }
2007
+ ]
2008
+ },
2009
+ {
2010
+ type: "bytes"
2011
+ }
2012
+ ],
2013
+ // @ts-ignore
2014
+ [
2015
+ permitTypeData.message,
2016
+ signature
2017
+ ]
2018
+ );
2019
+ return {
2020
+ permitSingle: permitTypeData.message,
2021
+ signature,
2022
+ permit2InputEncode
2023
+ };
2024
+ }, "getApiEVMPermit");
2025
+ var getEVMTransaction = /* @__PURE__ */ __name((params, quoteParams) => {
2026
+ const chain = quoteParams.fromToken.chain;
2027
+ if (chain.platformType !== IPlatformType.EVM) throw new Error("Chain is not EVM");
2028
+ if (params.transactions.length <= 0) throw new Error("No transactions found");
2029
+ const { value, from, to, nonce, data, gasInfo, chainId } = params.transactions[0];
2030
+ const transaction = {
2031
+ value: viem.numberToHex(BigInt(value || "0")),
2032
+ from,
2033
+ to,
2034
+ nonce: viem.numberToHex(nonce),
2035
+ data,
2036
+ gas: viem.numberToHex(BigInt(gasInfo.gasLimit)),
2037
+ gasLimit: viem.numberToHex(BigInt(gasInfo.gasLimit)),
2038
+ maxFeePerGas: viem.numberToHex(BigInt(gasInfo.baseFee) + BigInt(gasInfo.priorityFee.high)),
2039
+ maxPriorityFeePerGas: viem.numberToHex(BigInt(gasInfo.priorityFee.high)),
2040
+ chainId: viem.toHex(chainId),
2041
+ gasPrice: void 0
2042
+ };
2043
+ return transaction;
2044
+ }, "getEVMTransaction");
2045
+ var TRON_RPC = "https://orbital-dimensional-season.tron-mainnet.quiknode.pro/d14878573fe23f8f40621a303ee2eaa3c812ba1c";
2046
+ function getEip712Domain(verifyingContract) {
2047
+ return {
2048
+ name: "Permit2",
2049
+ chainId: 728126428,
2050
+ verifyingContract
2051
+ };
2052
+ }
2053
+ __name(getEip712Domain, "getEip712Domain");
2054
+ var getTronPermitSignData = /* @__PURE__ */ __name(async (quoteParams, quoteResult) => {
2055
+ const tronWeb = new tronweb.TronWeb({
2056
+ fullHost: TRON_RPC
2057
+ });
2058
+ const tronAddressToHex = /* @__PURE__ */ __name(async (tronAddress) => {
2059
+ try {
2060
+ const hexAddress = tronWeb.address.toHex(tronAddress);
2061
+ return "0x" + hexAddress.slice(2);
2062
+ } catch (error) {
2063
+ console.error("Error converting TRON address:", error);
2064
+ return null;
2065
+ }
2066
+ }, "tronAddressToHex");
2067
+ const { sender, fromToken, amount } = quoteParams;
2068
+ const token = fromToken.address;
2069
+ const contract = quoteResult.contract;
2070
+ tronWeb.setAddress(sender);
2071
+ const sigDeadline = Math.floor(Date.now() / 1e3) + 6e3;
2072
+ const permit2 = await tronWeb.contract(Permit2Abi, TRON_PERMIT2_ADDRESS);
2073
+ const tokenAddress = await tronAddressToHex(token);
2074
+ const spender = await tronAddressToHex(contract);
2075
+ const nextNonce = (await permit2.allowance(sender, tokenAddress, spender).call()).nonce;
2076
+ const permitSingle = {
2077
+ details: {
2078
+ token: tokenAddress,
2079
+ amount,
2080
+ expiration: 0,
2081
+ nonce: nextNonce
2082
+ },
2083
+ spender,
2084
+ sigDeadline
2085
+ };
2086
+ if (permit2.address) {
2087
+ const domain = getEip712Domain(permit2.address);
2088
+ const signatureHash = await tronWeb.utils._TypedDataEncoder.hash(domain, PERMIT2_TYPES, permitSingle);
2089
+ return {
2090
+ types: PERMIT2_TYPES,
2091
+ message: permitSingle,
2092
+ primaryType: "PermitSingle",
2093
+ domain,
2094
+ signatureHash
2095
+ };
2096
+ }
2097
+ throw new Error("Permit2 contract not found");
2098
+ }, "getTronPermitSignData");
2099
+ var getTronTransaction = /* @__PURE__ */ __name((params, quoteParams) => {
2100
+ const chain = quoteParams.fromToken.chain;
2101
+ if (chain.platformType !== IPlatformType.TRON) throw new Error("Chain is not Tron");
2102
+ if (params.transactions.length <= 0) throw new Error("No transactions found");
2103
+ const { data, value, from, to, rawData } = params.transactions[0];
2104
+ const transaction = {
2105
+ data,
2106
+ value,
2107
+ from,
2108
+ to,
2109
+ rawData
2110
+ };
2111
+ return transaction;
2112
+ }, "getTronTransaction");
2113
+ var getApiTRONPermit = /* @__PURE__ */ __name((signature, permitTypeData) => {
2114
+ const permit2InputEncode = viem.encodeAbiParameters(
2115
+ [
2116
+ "((address token,uint160 amount,uint48 expiration,uint48 nonce) details, address spender, uint256 sigDeadline)",
2117
+ "bytes"
2118
+ ],
2119
+ // @ts-ignore
2120
+ [
2121
+ permitTypeData.message,
2122
+ signature
2123
+ ]
2124
+ );
2125
+ return {
2126
+ permitSingle: permitTypeData.message,
2127
+ signature,
2128
+ permit2InputEncode
2129
+ };
2130
+ }, "getApiTRONPermit");
2131
+
2132
+ // src/swap/methods/chains/sol.ts
2133
+ var getSolanaTransaction = /* @__PURE__ */ __name((params, quoteParams) => {
2134
+ const chain = quoteParams.fromToken.chain;
2135
+ if (chain.platformType !== IPlatformType.SOLANA) throw new Error("Chain is not Solana");
2136
+ if (params.transactions.length <= 0) throw new Error("No transactions found");
2137
+ const { data, serializedData } = params.transactions[0];
2138
+ const transaction = {
2139
+ data: Buffer.from(serializedData || data, "base64").toString("hex")
2140
+ };
2141
+ return transaction;
2142
+ }, "getSolanaTransaction");
2143
+
2144
+ // src/swap/methods/unsign.ts
2145
+ var getSwapTransaction = /* @__PURE__ */ __name((params, quoteParams) => {
2146
+ const chain = quoteParams.fromToken.chain;
2147
+ const transaction = (() => {
2148
+ switch (chain.platformType) {
2149
+ case IPlatformType.EVM:
2150
+ return getEVMTransaction(params, quoteParams);
2151
+ case IPlatformType.SOLANA:
2152
+ return getSolanaTransaction(params, quoteParams);
2153
+ case IPlatformType.TRON:
2154
+ return getTronTransaction(params, quoteParams);
2155
+ }
2156
+ })();
2157
+ if (!transaction) throw new Error("Transaction not found");
2158
+ return transaction;
2159
+ }, "getSwapTransaction");
2160
+
2161
+ // src/swap/bridgeBuilder.ts
2162
+ var bridgeBuilder = /* @__PURE__ */ __name((builder2) => {
2163
+ return async (params, quoteParams, permitParams = void 0) => {
2164
+ const { fromToken, toToken } = quoteParams;
2165
+ if (fromToken.chain.chainId === toToken.chain.chainId) {
2166
+ throw new Error("Use getBridgeQuotes for cross-chain swaps");
2167
+ }
2168
+ const permitSignParams = (() => {
2169
+ if (permitParams) {
2170
+ switch (quoteParams.fromToken.chain.platformType) {
2171
+ case IPlatformType.EVM:
2172
+ return getApiEVMPermit(permitParams.signature, permitParams.permitTypeData);
2173
+ case IPlatformType.TRON:
2174
+ return getApiTRONPermit(permitParams.signature, permitParams.permitTypeData);
2175
+ }
2176
+ }
2177
+ })();
2178
+ const builderRes = await builder2(params, permitSignParams);
2179
+ const transaction = getSwapTransaction(builderRes, quoteParams);
2180
+ return transaction;
2181
+ };
2182
+ }, "bridgeBuilder");
2183
+
2184
+ // src/swap/getApproveBuilder.ts
2185
+ var getApproveBuilder = /* @__PURE__ */ __name((builder2) => {
2186
+ return async (params, quoteParams) => {
2187
+ const builderRes = await builder2(params);
2188
+ if (builderRes.transactions[0].type === "approve") {
2189
+ try {
2190
+ return getSwapTransaction(builderRes, quoteParams);
2191
+ } catch {
2192
+ return void 0;
2193
+ }
2194
+ }
2195
+ return void 0;
2196
+ };
2197
+ }, "getApproveBuilder");
2198
+
2199
+ // src/swap/getBridgeQuotes.ts
2200
+ var getBridgeQuotes = /* @__PURE__ */ __name((quote2) => {
2201
+ return async (params) => {
2202
+ const { fromToken, toToken } = params;
2203
+ if (fromToken.chain.chainId === toToken.chain.chainId) {
2204
+ throw new Error("Use getSwapQuotes for same-chain swaps");
2205
+ }
2206
+ return await quote2(params);
2207
+ };
2208
+ }, "getBridgeQuotes");
2209
+
2210
+ // src/swap/getSwapQuotes.ts
2211
+ var getSwapQuotes = /* @__PURE__ */ __name((quote2) => {
2212
+ return async (params) => {
2213
+ const { fromToken, toToken } = params;
2214
+ if (fromToken.chain.chainId !== toToken.chain.chainId) {
2215
+ throw new Error("Use getBridgeQuotes for cross-chain swaps");
2216
+ }
2217
+ return await quote2(params);
2218
+ };
2219
+ }, "getSwapQuotes");
2220
+
2221
+ // src/swap/methods/builder.ts
2222
+ var builder = /* @__PURE__ */ __name((apiMethods) => {
2223
+ return async (params, permitSignParams = void 0) => {
2224
+ const { quoteID } = params;
2225
+ const result = await apiMethods.getSwapRoutesTxV2({
2226
+ quoteID,
2227
+ extendedData: permitSignParams ? {
2228
+ permit2: permitSignParams
2229
+ } : void 0
2230
+ });
2231
+ return result;
2232
+ };
2233
+ }, "builder");
2234
+
2235
+ // src/api/types.ts
2236
+ var SwapV2DexName = /* @__PURE__ */ function(SwapV2DexName2) {
2237
+ SwapV2DexName2["OKX_SWAP"] = "OKXSwap";
2238
+ SwapV2DexName2["OKX0"] = "OKXCross0";
2239
+ SwapV2DexName2["OKX1"] = "OKXCross1";
2240
+ SwapV2DexName2["OKX2"] = "OKXCross2";
2241
+ SwapV2DexName2["RANGO_BASIC"] = "RangoBasic";
2242
+ SwapV2DexName2["RANGO_MAIN"] = "RangoMain";
2243
+ SwapV2DexName2["JUPITER"] = "Jupiter";
2244
+ SwapV2DexName2["ARRAKIS_BRIDGE"] = "ArrakisBridge";
2245
+ SwapV2DexName2["SUN"] = "Sun";
2246
+ SwapV2DexName2["TOMO"] = "Tomo";
2247
+ SwapV2DexName2["KODIAK"] = "Kodiak";
2248
+ SwapV2DexName2["STON"] = "Ston";
2249
+ SwapV2DexName2["ONE_INCH"] = "1Inch";
2250
+ SwapV2DexName2["NAVI"] = "Navi";
2251
+ SwapV2DexName2["DOGE_OS"] = "DogeOS";
2252
+ return SwapV2DexName2;
2253
+ }({});
2254
+
2255
+ // src/swap/methods/quote.ts
2256
+ var quote = /* @__PURE__ */ __name((apiMethods) => {
2257
+ return async (params) => {
2258
+ const { sender, recipient, fromToken, toToken, slippage, amount } = params;
2259
+ const dexs = (() => {
2260
+ if (fromToken.chain.chainId !== toToken.chain.chainId) {
2261
+ return [
2262
+ SwapV2DexName.RANGO_BASIC,
2263
+ SwapV2DexName.ARRAKIS_BRIDGE
2264
+ ];
2265
+ }
2266
+ return [
2267
+ SwapV2DexName.TOMO,
2268
+ SwapV2DexName.RANGO_BASIC
2269
+ ];
2270
+ })();
2271
+ const fromTokenInfos = await apiMethods.getTokenInfo({
2272
+ content: fromToken.address,
2273
+ chainIndex: fromToken.chain.chainIndex
2274
+ });
2275
+ const toTokenInfos = await apiMethods.getTokenInfo({
2276
+ content: toToken.address,
2277
+ chainIndex: toToken.chain.chainIndex
2278
+ });
2279
+ if (fromTokenInfos.data.length <= 0 && toTokenInfos.data.length <= 0) {
2280
+ throw new Error("Token not found");
2281
+ }
2282
+ const fromTokenInfo = fromTokenInfos.data[0];
2283
+ const toTokenInfo = toTokenInfos.data[0];
2284
+ const routesResponse = await apiMethods.getSwapRoutesV2({
2285
+ amount,
2286
+ dexs,
2287
+ dexsExclude: false,
2288
+ sender,
2289
+ recipient,
2290
+ fromToken: {
2291
+ address: getOkTokenAddress(fromTokenInfo, fromToken.chain),
2292
+ chainID: fromToken.chain.chainId.toString(),
2293
+ decimals: fromTokenInfo.decimals,
2294
+ symbol: fromTokenInfo.symbol
2295
+ },
2296
+ slippage: (slippage || 5) / 100,
2297
+ toToken: {
2298
+ address: getOkTokenAddress(toTokenInfo, toToken.chain),
2299
+ chainID: toToken.chain.chainId.toString(),
2300
+ decimals: toTokenInfo.decimals,
2301
+ symbol: toTokenInfo.symbol
2302
+ }
2303
+ });
2304
+ if (routesResponse.length < 1) throw new Error("No route found");
2305
+ return routesResponse;
2306
+ };
2307
+ }, "quote");
2308
+
2309
+ // src/swap/swapBuilder.ts
2310
+ var swapBuilder = /* @__PURE__ */ __name((builder2) => {
2311
+ return async (params, quoteParams, permitParams = void 0) => {
2312
+ const permitSignParams = (() => {
2313
+ if (permitParams) {
2314
+ switch (quoteParams.fromToken.chain.platformType) {
2315
+ case IPlatformType.EVM:
2316
+ return getApiEVMPermit(permitParams.signature, permitParams.permitTypeData);
2317
+ case IPlatformType.TRON:
2318
+ return getApiTRONPermit(permitParams.signature, permitParams.permitTypeData);
2319
+ }
2320
+ }
2321
+ })();
2322
+ const builderRes = await builder2(params, permitSignParams);
2323
+ const transaction = getSwapTransaction(builderRes, quoteParams);
2324
+ return transaction;
2325
+ };
2326
+ }, "swapBuilder");
2327
+
2328
+ // src/index.ts
2329
+ var Business = class {
2330
+ static {
2331
+ __name(this, "Business");
2332
+ }
2333
+ apiConfig = {
2334
+ routeApi: null,
2335
+ marketApi: null
2336
+ };
2337
+ apiMethods = null;
2338
+ _quoteMethod = null;
2339
+ _builderMethod = null;
2340
+ _bridgeBuilderMethod = null;
2341
+ _swapBuilderMethod = null;
2342
+ _getBridgeQuotesMethod = null;
2343
+ _getSwapQuotesMethod = null;
2344
+ _getApproveBuilderMethod = null;
2345
+ /**
2346
+ * Creates a new instance of the Business SDK
2347
+ *
2348
+ * @param options - Configuration options for the SDK
2349
+ * @param options.routerApi - Custom router API URL for transaction routing
2350
+ * @param options.marketApi - Custom market API URL for token information
2351
+ */
2352
+ constructor({ config, tomoStage }) {
2353
+ const apiConfig = reinitializeApi(tomoStage, config);
2354
+ this.apiConfig = apiConfig;
2355
+ this.apiMethods = reinitializeApiMethods(apiConfig);
2356
+ }
2357
+ getQuoteMethod() {
2358
+ if (!this._quoteMethod && this.apiMethods) {
2359
+ this._quoteMethod = quote(this.apiMethods);
2360
+ }
2361
+ return this._quoteMethod || apiInitializedError;
2362
+ }
2363
+ getBuilderMethod() {
2364
+ if (!this._builderMethod && this.apiMethods) {
2365
+ this._builderMethod = builder(this.apiMethods);
2366
+ }
2367
+ return this._builderMethod || apiInitializedError;
2368
+ }
2369
+ getBridgeBuilderMethod() {
2370
+ if (!this._bridgeBuilderMethod && this.apiMethods) {
2371
+ this._bridgeBuilderMethod = bridgeBuilder(this.getBuilderMethod());
2372
+ }
2373
+ return this._bridgeBuilderMethod || apiInitializedError;
2374
+ }
2375
+ getSwapBuilderMethod() {
2376
+ if (!this._swapBuilderMethod && this.apiMethods) {
2377
+ this._swapBuilderMethod = swapBuilder(this.getBuilderMethod());
2378
+ }
2379
+ return this._swapBuilderMethod || apiInitializedError;
2380
+ }
2381
+ getGetBridgeQuotesMethod() {
2382
+ if (!this._getBridgeQuotesMethod && this.apiMethods) {
2383
+ this._getBridgeQuotesMethod = getBridgeQuotes(this.getQuoteMethod());
2384
+ }
2385
+ return this._getBridgeQuotesMethod || apiInitializedError;
2386
+ }
2387
+ getGetSwapQuotesMethod() {
2388
+ if (!this._getSwapQuotesMethod && this.apiMethods) {
2389
+ this._getSwapQuotesMethod = getSwapQuotes(this.getQuoteMethod());
2390
+ }
2391
+ return this._getSwapQuotesMethod || apiInitializedError;
2392
+ }
2393
+ getGetApproveBuilderMethod() {
2394
+ if (!this._getApproveBuilderMethod && this.apiMethods) {
2395
+ this._getApproveBuilderMethod = getApproveBuilder(this.getBuilderMethod());
2396
+ }
2397
+ return this._getApproveBuilderMethod || apiInitializedError;
2398
+ }
2399
+ /**
2400
+ * Build a cross-chain bridge transaction based on quote result
2401
+ *
2402
+ * This method constructs a complete transaction object for cross-chain bridge operations
2403
+ * based on the provided quote and parameters. The resulting transaction can be directly
2404
+ * sent to the network after signing.
2405
+ *
2406
+ * @param quote - The quote result from getBridgeQuotes containing route and pricing information
2407
+ * @param quoteParams - The original quote parameters including sender, recipient, tokens and amount
2408
+ * @param permitSignParams - Optional permit signature parameters for token approvals (required only when TomoDEX is selected in the quote)
2409
+ * @returns Promise<Transaction> - The built transaction ready to be signed and submitted
2410
+ *
2411
+ * @throws Error - If fromToken and toToken are on the same chain (should use swapBuilder instead)
2412
+ *
2413
+ * @example
2414
+ * ```typescript
2415
+ * const quote = await business.getBridgeQuotes(quoteParams);
2416
+ * const transaction = await business.bridgeBuilder(quote[0], quoteParams);
2417
+ * ```
2418
+ */
2419
+ bridgeBuilder = /* @__PURE__ */ __name((quote2, quoteParams, permitSignParams = void 0) => {
2420
+ return this.getBridgeBuilderMethod()(quote2, quoteParams, permitSignParams);
2421
+ }, "bridgeBuilder");
2422
+ /**
2423
+ * Get cross-chain bridge quotes for token swaps between different chains
2424
+ *
2425
+ * This method fetches available routes and pricing information for cross-chain token swaps.
2426
+ * It returns multiple quotes from different bridge providers, allowing users to choose
2427
+ * the best option based on fees, speed, and other factors.
2428
+ *
2429
+ * @param params - Transaction quote parameters including sender, recipient, tokens and amount
2430
+ * @returns Promise<TransactionQuoteResult[]> - Array of quote results containing routing information and transaction details
2431
+ *
2432
+ * @throws Error - If fromToken and toToken are on the same chain (should use getSwapQuotes instead)
2433
+ *
2434
+ * @example
2435
+ * ```typescript
2436
+ * const quoteParams = {
2437
+ * sender: "0x...",
2438
+ * recipient: "0x...",
2439
+ * fromToken: {
2440
+ * address: "", // Native token
2441
+ * chain: ethereumChain
2442
+ * },
2443
+ * toToken: {
2444
+ * address: "0x...", // ERC20 token on another chain
2445
+ * chain: bscChain
2446
+ * },
2447
+ * slippage: 0.5,
2448
+ * amount: "1000000000000000000" // 1 ETH in wei
2449
+ * };
2450
+ *
2451
+ * const quotes = await business.getBridgeQuotes(quoteParams);
2452
+ * ```
2453
+ */
2454
+ getBridgeQuotes = /* @__PURE__ */ __name((params) => {
2455
+ return this.getGetBridgeQuotesMethod()(params);
2456
+ }, "getBridgeQuotes");
2457
+ /**
2458
+ * Get same-chain swap quotes for token swaps on the same chain
2459
+ *
2460
+ * This method fetches available routes and pricing information for token swaps within
2461
+ * the same blockchain network. It returns multiple quotes from different DEXes,
2462
+ * allowing users to choose the best option based on price, fees, and liquidity.
2463
+ *
2464
+ * @param params - Transaction quote parameters including sender, recipient, tokens and amount
2465
+ * @returns Promise<TransactionQuoteResult[]> - Array of quote results containing routing information and transaction details
2466
+ *
2467
+ * @throws Error - If fromToken and toToken are on different chains (should use getBridgeQuotes instead)
2468
+ *
2469
+ * @example
2470
+ * ```typescript
2471
+ * const quoteParams = {
2472
+ * sender: "0x...",
2473
+ * recipient: "0x...",
2474
+ * fromToken: {
2475
+ * address: "", // Native token (ETH)
2476
+ * chain: ethereumChain
2477
+ * },
2478
+ * toToken: {
2479
+ * address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
2480
+ * chain: ethereumChain
2481
+ * },
2482
+ * slippage: 0.5,
2483
+ * amount: "1000000000000000000" // 1 ETH in wei
2484
+ * };
2485
+ *
2486
+ * const quotes = await business.getSwapQuotes(quoteParams);
2487
+ * ```
2488
+ */
2489
+ getSwapQuotes = /* @__PURE__ */ __name((params) => {
2490
+ return this.getGetSwapQuotesMethod()(params);
2491
+ }, "getSwapQuotes");
2492
+ /**
2493
+ * Build a same-chain swap transaction based on quote result
2494
+ *
2495
+ * This method constructs a complete transaction object for same-chain swap operations
2496
+ * based on the provided quote and parameters. The resulting transaction can be directly
2497
+ * sent to the network after signing.
2498
+ *
2499
+ * @param quote - The quote result from getSwapQuotes containing route and pricing information
2500
+ * @param quoteParams - The original quote parameters including sender, recipient, tokens and amount
2501
+ * @param permitSignParams - Optional permit signature parameters for token approvals (required only when TomoDEX is selected in the quote)
2502
+ * @returns Promise<Transaction> - The built transaction ready to be signed and submitted
2503
+ *
2504
+ * @throws Error - If fromToken and toToken are on different chains (should use bridgeBuilder instead)
2505
+ *
2506
+ * @example
2507
+ * ```typescript
2508
+ * const quote = await business.getSwapQuotes(quoteParams);
2509
+ * const transaction = await business.swapBuilder(quote[0], quoteParams);
2510
+ * ```
2511
+ */
2512
+ swapBuilder = /* @__PURE__ */ __name((quote2, quoteParams, permitSignParams = void 0) => {
2513
+ return this.getSwapBuilderMethod()(quote2, quoteParams, permitSignParams);
2514
+ }, "swapBuilder");
2515
+ /**
2516
+ * Get all supported chains for swap operations
2517
+ *
2518
+ * This method returns a list of all blockchain networks that are supported
2519
+ * for swap operations. Each chain object contains information such as
2520
+ * chain ID, name, native currency, and other relevant details needed
2521
+ * for performing swaps on that network.
2522
+ *
2523
+ * @returns Chain[] - Array of supported chain objects
2524
+ *
2525
+ * @example
2526
+ * ```typescript
2527
+ * const business = new Business();
2528
+ * const supportedChains = business.getSwapSupportChains();
2529
+ * const ethereum = supportedChains.find(chain => chain.chainId === 1);
2530
+ * ```
2531
+ */
2532
+ getSwapSupportChains = getSwapSupportChains;
2533
+ /**
2534
+ * Get all supported chains for bridge operations
2535
+ *
2536
+ * This method returns a list of all blockchain networks that are supported
2537
+ * for cross-chain bridge operations. Each chain object contains information such as
2538
+ * chain ID, name, native currency, and other relevant details needed
2539
+ * for performing cross-chain transfers on that network.
2540
+ *
2541
+ * @returns Chain[] - Array of supported chain objects for bridge operations
2542
+ *
2543
+ * @example
2544
+ * ```typescript
2545
+ * const business = new Business();
2546
+ * const bridgeChains = business.getBridgeSupportChains();
2547
+ * const bsc = bridgeChains.find(chain => chain.chainId === 56);
2548
+ * ```
2549
+ */
2550
+ getBridgeSupportChains = getBridgeSupportChains;
2551
+ /**
2552
+ * Generate ERC20 token approval transaction for swap operations
2553
+ *
2554
+ * This method creates an approval transaction that allows a DEX contract to spend
2555
+ * the user's ERC20 tokens. This is required before swapping ERC20 tokens for
2556
+ * most DEXes (except those supporting permit signatures like TomoDEX).
2557
+ *
2558
+ * The method checks if an approval transaction is needed based on the quote result.
2559
+ * If needed, it returns a transaction object that can be sent to the network.
2560
+ *
2561
+ * @param quote - The quote result from getSwapQuotes or getBridgeQuotes containing route information
2562
+ * @param quoteParams - The original quote parameters including sender, recipient, tokens and amount
2563
+ * @returns Promise<Transaction | undefined> - The approval transaction if needed, otherwise undefined
2564
+ *
2565
+ * @example
2566
+ * ```typescript
2567
+ * const quotes = await business.getSwapQuotes(quoteParams);
2568
+ * const approveTx = await business.getApproveBuilder(quotes[0], quoteParams);
2569
+ * if (approveTx) {
2570
+ * // Send approval transaction
2571
+ * await sendTransaction(approveTx);
2572
+ * }
2573
+ * ```
2574
+ */
2575
+ getApproveBuilder = /* @__PURE__ */ __name((quote2, quoteParams) => {
2576
+ return this.getGetApproveBuilderMethod()(quote2, quoteParams);
2577
+ }, "getApproveBuilder");
2578
+ /**
2579
+ * EVM-specific permit signing utilities
2580
+ *
2581
+ * This namespace provides methods for handling ERC20 token approvals using
2582
+ * EIP-712 permit signatures, which allows gasless approvals for compatible tokens.
2583
+ */
2584
+ evm = {
2585
+ /**
2586
+ * Generate EIP-712 typed data for ERC20 token permit signatures
2587
+ *
2588
+ * This method creates the structured data required for signing ERC20 permit
2589
+ * transactions using EIP-712. The resulting data can be used with wallet
2590
+ * signature methods to generate permit signatures without submitting a
2591
+ * separate on-chain transaction.
2592
+ *
2593
+ * @param quoteParams - The original quote parameters including sender, recipient, tokens and amount
2594
+ * @param quote - The quote result from getSwapQuotes or getBridgeQuotes
2595
+ * @returns Promise<any> - EIP-712 typed data structure for signing
2596
+ *
2597
+ * @example
2598
+ * ```typescript
2599
+ * const permitTypeData = await business.evm.getPermitTypeData(quoteParams, quote);
2600
+ * const signature = await signTypedData(permitTypeData);
2601
+ * const unsignTx = await business.swapBuilder(quote, quoteParams, { signature, permitTypeData });
2602
+ * ```
2603
+ */
2604
+ getPermitTypeData
2605
+ };
2606
+ tron = {
2607
+ /**
2608
+ * @example
2609
+ * ```typescript
2610
+ * const permitTypeData = await business.tron.getPermitTypeData(quoteParams, quote);
2611
+ * const signature = await signTypedData(permitTypeData);
2612
+ * const unsignTx = await business.swapBuilder(quote, quoteParams, { signature, permitTypeData });
2613
+ * ```
2614
+ */
2615
+ getPermitTypeData: getTronPermitSignData,
2616
+ rpc: TRON_RPC
2617
+ };
2618
+ };
2619
+
2620
+ exports.Business = Business;
2621
+ exports.IPlatformType = IPlatformType;