@xswap-link/sdk 0.0.4 → 0.0.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.
package/dist/index.js CHANGED
@@ -15,24 +15,1544 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
 
21
20
  // index.ts
22
21
  var xswap_sdk_exports = {};
23
22
  __export(xswap_sdk_exports, {
23
+ DEFAULT_API_URL: () => DEFAULT_API_URL,
24
+ DEFAULT_DB_ERROR: () => DEFAULT_DB_ERROR,
25
+ DEFAULT_ECOSYSTEM: () => DEFAULT_ECOSYSTEM,
26
+ DEFAULT_GAS_LIMIT_MULTIPLIER: () => DEFAULT_GAS_LIMIT_MULTIPLIER,
27
+ DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE: () => DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE,
28
+ ERC20Abi: () => ERC20Abi,
29
+ Ecosystem: () => Ecosystem,
30
+ Environment: () => Environment,
31
+ Web3Environment: () => Web3Environment,
32
+ XSwapCallType: () => XSwapCallType,
33
+ XSwapRouterAbi: () => XSwapRouterAbi,
34
+ generateApproveTxData: () => generateApproveTxData,
24
35
  getChainData: () => getChainData,
25
36
  getChains: () => getChains,
26
37
  getRoute: () => getRoute,
27
- getTokens: () => getTokens
38
+ getTokens: () => getTokens,
39
+ safeBigNumberFrom: () => safeBigNumberFrom
28
40
  });
29
41
  module.exports = __toCommonJS(xswap_sdk_exports);
30
- __reExport(xswap_sdk_exports, require("@xswap-link/common"), module.exports);
42
+
43
+ // src/models/Ecosystem.ts
44
+ var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
45
+ Ecosystem2["EVM"] = "evm";
46
+ return Ecosystem2;
47
+ })(Ecosystem || {});
48
+
49
+ // src/models/Environment.ts
50
+ var Environment = /* @__PURE__ */ ((Environment2) => {
51
+ Environment2["PROD"] = "production";
52
+ Environment2["DEV"] = "develop";
53
+ Environment2["LOCAL"] = "local";
54
+ return Environment2;
55
+ })(Environment || {});
56
+
57
+ // src/models/Web3Environment.ts
58
+ var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
59
+ Web3Environment2["DEVNET"] = "devnet";
60
+ Web3Environment2["TESTNET"] = "testnet";
61
+ Web3Environment2["MAINNET"] = "mainnet";
62
+ return Web3Environment2;
63
+ })(Web3Environment || {});
64
+
65
+ // src/models/XSwapCallType.ts
66
+ var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
67
+ XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
68
+ XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
69
+ XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
70
+ XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
71
+ return XSwapCallType2;
72
+ })(XSwapCallType || {});
73
+
74
+ // src/constants/index.ts
75
+ var DEFAULT_API_URL = "https://xswap.link/api";
76
+ var DEFAULT_DB_ERROR = "No data for provided parameters";
77
+ var DEFAULT_ECOSYSTEM = "evm" /* EVM */;
78
+ var DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE = 105;
79
+ var DEFAULT_GAS_LIMIT_MULTIPLIER = 1.2;
80
+
81
+ // src/contracts/abi/ERC20.json
82
+ var ERC20_default = [
83
+ {
84
+ constant: true,
85
+ inputs: [],
86
+ name: "name",
87
+ outputs: [
88
+ {
89
+ name: "",
90
+ type: "string"
91
+ }
92
+ ],
93
+ payable: false,
94
+ stateMutability: "view",
95
+ type: "function"
96
+ },
97
+ {
98
+ constant: false,
99
+ inputs: [
100
+ {
101
+ name: "_spender",
102
+ type: "address"
103
+ },
104
+ {
105
+ name: "_value",
106
+ type: "uint256"
107
+ }
108
+ ],
109
+ name: "approve",
110
+ outputs: [
111
+ {
112
+ name: "",
113
+ type: "bool"
114
+ }
115
+ ],
116
+ payable: false,
117
+ stateMutability: "nonpayable",
118
+ type: "function"
119
+ },
120
+ {
121
+ constant: true,
122
+ inputs: [],
123
+ name: "totalSupply",
124
+ outputs: [
125
+ {
126
+ name: "",
127
+ type: "uint256"
128
+ }
129
+ ],
130
+ payable: false,
131
+ stateMutability: "view",
132
+ type: "function"
133
+ },
134
+ {
135
+ constant: false,
136
+ inputs: [
137
+ {
138
+ name: "_from",
139
+ type: "address"
140
+ },
141
+ {
142
+ name: "_to",
143
+ type: "address"
144
+ },
145
+ {
146
+ name: "_value",
147
+ type: "uint256"
148
+ }
149
+ ],
150
+ name: "transferFrom",
151
+ outputs: [
152
+ {
153
+ name: "",
154
+ type: "bool"
155
+ }
156
+ ],
157
+ payable: false,
158
+ stateMutability: "nonpayable",
159
+ type: "function"
160
+ },
161
+ {
162
+ constant: true,
163
+ inputs: [],
164
+ name: "decimals",
165
+ outputs: [
166
+ {
167
+ name: "",
168
+ type: "uint8"
169
+ }
170
+ ],
171
+ payable: false,
172
+ stateMutability: "view",
173
+ type: "function"
174
+ },
175
+ {
176
+ constant: true,
177
+ inputs: [
178
+ {
179
+ name: "_owner",
180
+ type: "address"
181
+ }
182
+ ],
183
+ name: "balanceOf",
184
+ outputs: [
185
+ {
186
+ name: "balance",
187
+ type: "uint256"
188
+ }
189
+ ],
190
+ payable: false,
191
+ stateMutability: "view",
192
+ type: "function"
193
+ },
194
+ {
195
+ constant: true,
196
+ inputs: [],
197
+ name: "symbol",
198
+ outputs: [
199
+ {
200
+ name: "",
201
+ type: "string"
202
+ }
203
+ ],
204
+ payable: false,
205
+ stateMutability: "view",
206
+ type: "function"
207
+ },
208
+ {
209
+ constant: false,
210
+ inputs: [
211
+ {
212
+ name: "_to",
213
+ type: "address"
214
+ },
215
+ {
216
+ name: "_value",
217
+ type: "uint256"
218
+ }
219
+ ],
220
+ name: "transfer",
221
+ outputs: [
222
+ {
223
+ name: "",
224
+ type: "bool"
225
+ }
226
+ ],
227
+ payable: false,
228
+ stateMutability: "nonpayable",
229
+ type: "function"
230
+ },
231
+ {
232
+ constant: true,
233
+ inputs: [
234
+ {
235
+ name: "_owner",
236
+ type: "address"
237
+ },
238
+ {
239
+ name: "_spender",
240
+ type: "address"
241
+ }
242
+ ],
243
+ name: "allowance",
244
+ outputs: [
245
+ {
246
+ name: "",
247
+ type: "uint256"
248
+ }
249
+ ],
250
+ payable: false,
251
+ stateMutability: "view",
252
+ type: "function"
253
+ },
254
+ {
255
+ payable: true,
256
+ stateMutability: "payable",
257
+ type: "fallback"
258
+ },
259
+ {
260
+ anonymous: false,
261
+ inputs: [
262
+ {
263
+ indexed: true,
264
+ name: "owner",
265
+ type: "address"
266
+ },
267
+ {
268
+ indexed: true,
269
+ name: "spender",
270
+ type: "address"
271
+ },
272
+ {
273
+ indexed: false,
274
+ name: "value",
275
+ type: "uint256"
276
+ }
277
+ ],
278
+ name: "Approval",
279
+ type: "event"
280
+ },
281
+ {
282
+ anonymous: false,
283
+ inputs: [
284
+ {
285
+ indexed: true,
286
+ name: "from",
287
+ type: "address"
288
+ },
289
+ {
290
+ indexed: true,
291
+ name: "to",
292
+ type: "address"
293
+ },
294
+ {
295
+ indexed: false,
296
+ name: "value",
297
+ type: "uint256"
298
+ }
299
+ ],
300
+ name: "Transfer",
301
+ type: "event"
302
+ }
303
+ ];
304
+
305
+ // src/contracts/abi/XSwapRouter.json
306
+ var XSwapRouter_default = [
307
+ {
308
+ inputs: [],
309
+ stateMutability: "nonpayable",
310
+ type: "constructor"
311
+ },
312
+ {
313
+ inputs: [
314
+ {
315
+ internalType: "uint64",
316
+ name: "destinationChainSelector",
317
+ type: "uint64"
318
+ }
319
+ ],
320
+ name: "DestinationChainNotWhitelisted",
321
+ type: "error"
322
+ },
323
+ {
324
+ inputs: [],
325
+ name: "FailedToSendNative",
326
+ type: "error"
327
+ },
328
+ {
329
+ inputs: [],
330
+ name: "IncorrectArrayLength",
331
+ type: "error"
332
+ },
333
+ {
334
+ inputs: [],
335
+ name: "InvalidAddress",
336
+ type: "error"
337
+ },
338
+ {
339
+ inputs: [
340
+ {
341
+ internalType: "address",
342
+ name: "router",
343
+ type: "address"
344
+ }
345
+ ],
346
+ name: "InvalidRouter",
347
+ type: "error"
348
+ },
349
+ {
350
+ inputs: [
351
+ {
352
+ internalType: "address",
353
+ name: "messageExecutor",
354
+ type: "address"
355
+ }
356
+ ],
357
+ name: "MessageAlreadyExecuted",
358
+ type: "error"
359
+ },
360
+ {
361
+ inputs: [],
362
+ name: "MessageMustTransferOnlyOneToken",
363
+ type: "error"
364
+ },
365
+ {
366
+ inputs: [
367
+ {
368
+ internalType: "uint64",
369
+ name: "chainId",
370
+ type: "uint64"
371
+ }
372
+ ],
373
+ name: "NoXSwapRouterOnSelectedChain",
374
+ type: "error"
375
+ },
376
+ {
377
+ inputs: [
378
+ {
379
+ internalType: "uint256",
380
+ name: "currentBalance",
381
+ type: "uint256"
382
+ },
383
+ {
384
+ internalType: "uint256",
385
+ name: "calculatedFees",
386
+ type: "uint256"
387
+ }
388
+ ],
389
+ name: "NotEnoughBalance",
390
+ type: "error"
391
+ },
392
+ {
393
+ inputs: [
394
+ {
395
+ internalType: "uint64",
396
+ name: "sourceChainSelector",
397
+ type: "uint64"
398
+ },
399
+ {
400
+ internalType: "address",
401
+ name: "sender",
402
+ type: "address"
403
+ }
404
+ ],
405
+ name: "SenderNotWhitelisted",
406
+ type: "error"
407
+ },
408
+ {
409
+ inputs: [
410
+ {
411
+ internalType: "address",
412
+ name: "token",
413
+ type: "address"
414
+ }
415
+ ],
416
+ name: "TokenNotWhitelisted",
417
+ type: "error"
418
+ },
419
+ {
420
+ anonymous: false,
421
+ inputs: [
422
+ {
423
+ indexed: false,
424
+ internalType: "address",
425
+ name: "previousAdmin",
426
+ type: "address"
427
+ },
428
+ {
429
+ indexed: false,
430
+ internalType: "address",
431
+ name: "newAdmin",
432
+ type: "address"
433
+ }
434
+ ],
435
+ name: "AdminChanged",
436
+ type: "event"
437
+ },
438
+ {
439
+ anonymous: false,
440
+ inputs: [
441
+ {
442
+ indexed: true,
443
+ internalType: "address",
444
+ name: "beacon",
445
+ type: "address"
446
+ }
447
+ ],
448
+ name: "BeaconUpgraded",
449
+ type: "event"
450
+ },
451
+ {
452
+ anonymous: false,
453
+ inputs: [
454
+ {
455
+ indexed: false,
456
+ internalType: "address",
457
+ name: "token",
458
+ type: "address"
459
+ },
460
+ {
461
+ indexed: false,
462
+ internalType: "uint256",
463
+ name: "tokenAmount",
464
+ type: "uint256"
465
+ }
466
+ ],
467
+ name: "EmergencyWithdraw",
468
+ type: "event"
469
+ },
470
+ {
471
+ anonymous: false,
472
+ inputs: [
473
+ {
474
+ indexed: true,
475
+ internalType: "bytes32",
476
+ name: "messageId",
477
+ type: "bytes32"
478
+ },
479
+ {
480
+ indexed: true,
481
+ internalType: "uint64",
482
+ name: "sourceChainSelector",
483
+ type: "uint64"
484
+ },
485
+ {
486
+ indexed: true,
487
+ internalType: "address",
488
+ name: "sender",
489
+ type: "address"
490
+ },
491
+ {
492
+ indexed: false,
493
+ internalType: "bytes",
494
+ name: "data",
495
+ type: "bytes"
496
+ },
497
+ {
498
+ indexed: false,
499
+ internalType: "address",
500
+ name: "token",
501
+ type: "address"
502
+ },
503
+ {
504
+ indexed: false,
505
+ internalType: "uint256",
506
+ name: "tokenAmount",
507
+ type: "uint256"
508
+ }
509
+ ],
510
+ name: "ExecutorRunFailed",
511
+ type: "event"
512
+ },
513
+ {
514
+ anonymous: false,
515
+ inputs: [
516
+ {
517
+ indexed: false,
518
+ internalType: "address",
519
+ name: "newExecutor",
520
+ type: "address"
521
+ }
522
+ ],
523
+ name: "ExecutorUpdated",
524
+ type: "event"
525
+ },
526
+ {
527
+ anonymous: false,
528
+ inputs: [
529
+ {
530
+ indexed: true,
531
+ internalType: "bytes32",
532
+ name: "messageId",
533
+ type: "bytes32"
534
+ },
535
+ {
536
+ indexed: true,
537
+ internalType: "address",
538
+ name: "messageExecutor",
539
+ type: "address"
540
+ },
541
+ {
542
+ indexed: true,
543
+ internalType: "bytes32",
544
+ name: "executionHash",
545
+ type: "bytes32"
546
+ },
547
+ {
548
+ indexed: false,
549
+ internalType: "address",
550
+ name: "token",
551
+ type: "address"
552
+ },
553
+ {
554
+ indexed: false,
555
+ internalType: "uint256",
556
+ name: "tokenAmount",
557
+ type: "uint256"
558
+ }
559
+ ],
560
+ name: "FundsReturnedForMessageExecution",
561
+ type: "event"
562
+ },
563
+ {
564
+ anonymous: false,
565
+ inputs: [
566
+ {
567
+ indexed: false,
568
+ internalType: "uint8",
569
+ name: "version",
570
+ type: "uint8"
571
+ }
572
+ ],
573
+ name: "Initialized",
574
+ type: "event"
575
+ },
576
+ {
577
+ anonymous: false,
578
+ inputs: [
579
+ {
580
+ indexed: true,
581
+ internalType: "bytes32",
582
+ name: "messageId",
583
+ type: "bytes32"
584
+ },
585
+ {
586
+ indexed: true,
587
+ internalType: "uint64",
588
+ name: "sourceChainSelector",
589
+ type: "uint64"
590
+ },
591
+ {
592
+ indexed: true,
593
+ internalType: "address",
594
+ name: "sender",
595
+ type: "address"
596
+ },
597
+ {
598
+ indexed: false,
599
+ internalType: "bytes",
600
+ name: "data",
601
+ type: "bytes"
602
+ },
603
+ {
604
+ indexed: false,
605
+ internalType: "address",
606
+ name: "token",
607
+ type: "address"
608
+ },
609
+ {
610
+ indexed: false,
611
+ internalType: "uint256",
612
+ name: "tokenAmount",
613
+ type: "uint256"
614
+ }
615
+ ],
616
+ name: "MessageReceived",
617
+ type: "event"
618
+ },
619
+ {
620
+ anonymous: false,
621
+ inputs: [
622
+ {
623
+ indexed: true,
624
+ internalType: "bytes32",
625
+ name: "messageId",
626
+ type: "bytes32"
627
+ },
628
+ {
629
+ indexed: true,
630
+ internalType: "uint64",
631
+ name: "destinationChainSelector",
632
+ type: "uint64"
633
+ },
634
+ {
635
+ indexed: true,
636
+ internalType: "address",
637
+ name: "sender",
638
+ type: "address"
639
+ },
640
+ {
641
+ indexed: false,
642
+ internalType: "bytes",
643
+ name: "data",
644
+ type: "bytes"
645
+ },
646
+ {
647
+ indexed: false,
648
+ internalType: "address",
649
+ name: "token",
650
+ type: "address"
651
+ },
652
+ {
653
+ indexed: false,
654
+ internalType: "uint256",
655
+ name: "tokenAmount",
656
+ type: "uint256"
657
+ },
658
+ {
659
+ indexed: false,
660
+ internalType: "uint256",
661
+ name: "valueForInstantCcipRecieve",
662
+ type: "uint256"
663
+ },
664
+ {
665
+ indexed: false,
666
+ internalType: "address",
667
+ name: "transferedToken",
668
+ type: "address"
669
+ },
670
+ {
671
+ indexed: false,
672
+ internalType: "uint256",
673
+ name: "transferedTokenAmount",
674
+ type: "uint256"
675
+ }
676
+ ],
677
+ name: "MessageSent",
678
+ type: "event"
679
+ },
680
+ {
681
+ anonymous: false,
682
+ inputs: [
683
+ {
684
+ indexed: true,
685
+ internalType: "address",
686
+ name: "previousOwner",
687
+ type: "address"
688
+ },
689
+ {
690
+ indexed: true,
691
+ internalType: "address",
692
+ name: "newOwner",
693
+ type: "address"
694
+ }
695
+ ],
696
+ name: "OwnershipTransferred",
697
+ type: "event"
698
+ },
699
+ {
700
+ anonymous: false,
701
+ inputs: [
702
+ {
703
+ indexed: false,
704
+ internalType: "address",
705
+ name: "newFeeCollectorAddress",
706
+ type: "address"
707
+ }
708
+ ],
709
+ name: "SetFeeCollectorAddress",
710
+ type: "event"
711
+ },
712
+ {
713
+ anonymous: false,
714
+ inputs: [
715
+ {
716
+ indexed: false,
717
+ internalType: "address",
718
+ name: "newFeeOracleAddress",
719
+ type: "address"
720
+ }
721
+ ],
722
+ name: "SetFeeOracleAddress",
723
+ type: "event"
724
+ },
725
+ {
726
+ anonymous: false,
727
+ inputs: [
728
+ {
729
+ indexed: true,
730
+ internalType: "address",
731
+ name: "implementation",
732
+ type: "address"
733
+ }
734
+ ],
735
+ name: "Upgraded",
736
+ type: "event"
737
+ },
738
+ {
739
+ inputs: [
740
+ {
741
+ components: [
742
+ {
743
+ internalType: "bytes32",
744
+ name: "messageId",
745
+ type: "bytes32"
746
+ },
747
+ {
748
+ internalType: "uint64",
749
+ name: "sourceChainSelector",
750
+ type: "uint64"
751
+ },
752
+ {
753
+ internalType: "bytes",
754
+ name: "sender",
755
+ type: "bytes"
756
+ },
757
+ {
758
+ internalType: "bytes",
759
+ name: "data",
760
+ type: "bytes"
761
+ },
762
+ {
763
+ components: [
764
+ {
765
+ internalType: "address",
766
+ name: "token",
767
+ type: "address"
768
+ },
769
+ {
770
+ internalType: "uint256",
771
+ name: "amount",
772
+ type: "uint256"
773
+ }
774
+ ],
775
+ internalType: "struct Client.EVMTokenAmount[]",
776
+ name: "destTokenAmounts",
777
+ type: "tuple[]"
778
+ }
779
+ ],
780
+ internalType: "struct Client.Any2EVMMessage",
781
+ name: "message",
782
+ type: "tuple"
783
+ }
784
+ ],
785
+ name: "ccipReceive",
786
+ outputs: [],
787
+ stateMutability: "nonpayable",
788
+ type: "function"
789
+ },
790
+ {
791
+ inputs: [
792
+ {
793
+ internalType: "uint64",
794
+ name: "",
795
+ type: "uint64"
796
+ }
797
+ ],
798
+ name: "chainSelectorToXSwapRouterMap",
799
+ outputs: [
800
+ {
801
+ internalType: "address",
802
+ name: "",
803
+ type: "address"
804
+ }
805
+ ],
806
+ stateMutability: "view",
807
+ type: "function"
808
+ },
809
+ {
810
+ inputs: [
811
+ {
812
+ internalType: "address",
813
+ name: "_tokenToWithdraw",
814
+ type: "address"
815
+ },
816
+ {
817
+ internalType: "uint256",
818
+ name: "_amountToWithdraw",
819
+ type: "uint256"
820
+ }
821
+ ],
822
+ name: "emergencyWithdraw",
823
+ outputs: [],
824
+ stateMutability: "nonpayable",
825
+ type: "function"
826
+ },
827
+ {
828
+ inputs: [],
829
+ name: "feeCollectorAddress",
830
+ outputs: [
831
+ {
832
+ internalType: "address",
833
+ name: "",
834
+ type: "address"
835
+ }
836
+ ],
837
+ stateMutability: "view",
838
+ type: "function"
839
+ },
840
+ {
841
+ inputs: [],
842
+ name: "feeOracleAddress",
843
+ outputs: [
844
+ {
845
+ internalType: "address",
846
+ name: "",
847
+ type: "address"
848
+ }
849
+ ],
850
+ stateMutability: "view",
851
+ type: "function"
852
+ },
853
+ {
854
+ inputs: [
855
+ {
856
+ internalType: "address",
857
+ name: "_paymentToken",
858
+ type: "address"
859
+ },
860
+ {
861
+ internalType: "uint64",
862
+ name: "_destinationChainSelector",
863
+ type: "uint64"
864
+ },
865
+ {
866
+ components: [
867
+ {
868
+ internalType: "address",
869
+ name: "receiver",
870
+ type: "address"
871
+ },
872
+ {
873
+ internalType: "address",
874
+ name: "tokenOut",
875
+ type: "address"
876
+ },
877
+ {
878
+ internalType: "uint256",
879
+ name: "estimatedAmountOut",
880
+ type: "uint256"
881
+ },
882
+ {
883
+ components: [
884
+ {
885
+ internalType: "enum CallType",
886
+ name: "callType",
887
+ type: "uint8"
888
+ },
889
+ {
890
+ internalType: "address",
891
+ name: "target",
892
+ type: "address"
893
+ },
894
+ {
895
+ internalType: "uint256",
896
+ name: "value",
897
+ type: "uint256"
898
+ },
899
+ {
900
+ internalType: "bytes",
901
+ name: "callData",
902
+ type: "bytes"
903
+ },
904
+ {
905
+ internalType: "bytes",
906
+ name: "payload",
907
+ type: "bytes"
908
+ }
909
+ ],
910
+ internalType: "struct Call[]",
911
+ name: "calls",
912
+ type: "tuple[]"
913
+ }
914
+ ],
915
+ internalType: "struct SwapDataDestination",
916
+ name: "_swapDestinationData",
917
+ type: "tuple"
918
+ },
919
+ {
920
+ internalType: "address",
921
+ name: "_token",
922
+ type: "address"
923
+ },
924
+ {
925
+ internalType: "uint256",
926
+ name: "_amount",
927
+ type: "uint256"
928
+ },
929
+ {
930
+ internalType: "uint256",
931
+ name: "_gasLimit",
932
+ type: "uint256"
933
+ }
934
+ ],
935
+ name: "getFees",
936
+ outputs: [
937
+ {
938
+ components: [
939
+ {
940
+ internalType: "uint256",
941
+ name: "ccipFee",
942
+ type: "uint256"
943
+ },
944
+ {
945
+ components: [
946
+ {
947
+ internalType: "uint256",
948
+ name: "tokenFee",
949
+ type: "uint256"
950
+ },
951
+ {
952
+ internalType: "uint256",
953
+ name: "nativeFee",
954
+ type: "uint256"
955
+ }
956
+ ],
957
+ internalType: "struct XSwapFee",
958
+ name: "xSwapFee",
959
+ type: "tuple"
960
+ }
961
+ ],
962
+ internalType: "struct MessageFees",
963
+ name: "fees",
964
+ type: "tuple"
965
+ }
966
+ ],
967
+ stateMutability: "view",
968
+ type: "function"
969
+ },
970
+ {
971
+ inputs: [],
972
+ name: "getRouter",
973
+ outputs: [
974
+ {
975
+ internalType: "address",
976
+ name: "",
977
+ type: "address"
978
+ }
979
+ ],
980
+ stateMutability: "view",
981
+ type: "function"
982
+ },
983
+ {
984
+ inputs: [
985
+ {
986
+ internalType: "address",
987
+ name: "_ccipRouter",
988
+ type: "address"
989
+ },
990
+ {
991
+ internalType: "address",
992
+ name: "_feeOracle",
993
+ type: "address"
994
+ },
995
+ {
996
+ internalType: "address",
997
+ name: "_feeCollector",
998
+ type: "address"
999
+ },
1000
+ {
1001
+ internalType: "address",
1002
+ name: "_xSwapExecutor",
1003
+ type: "address"
1004
+ },
1005
+ {
1006
+ internalType: "address",
1007
+ name: "_owner",
1008
+ type: "address"
1009
+ }
1010
+ ],
1011
+ name: "initialize",
1012
+ outputs: [],
1013
+ stateMutability: "nonpayable",
1014
+ type: "function"
1015
+ },
1016
+ {
1017
+ inputs: [
1018
+ {
1019
+ components: [
1020
+ {
1021
+ internalType: "bytes32",
1022
+ name: "messageId",
1023
+ type: "bytes32"
1024
+ },
1025
+ {
1026
+ internalType: "uint64",
1027
+ name: "sourceChainSelector",
1028
+ type: "uint64"
1029
+ },
1030
+ {
1031
+ internalType: "bytes",
1032
+ name: "sender",
1033
+ type: "bytes"
1034
+ },
1035
+ {
1036
+ internalType: "bytes",
1037
+ name: "data",
1038
+ type: "bytes"
1039
+ },
1040
+ {
1041
+ components: [
1042
+ {
1043
+ internalType: "address",
1044
+ name: "token",
1045
+ type: "address"
1046
+ },
1047
+ {
1048
+ internalType: "uint256",
1049
+ name: "amount",
1050
+ type: "uint256"
1051
+ }
1052
+ ],
1053
+ internalType: "struct Client.EVMTokenAmount[]",
1054
+ name: "destTokenAmounts",
1055
+ type: "tuple[]"
1056
+ }
1057
+ ],
1058
+ internalType: "struct Client.Any2EVMMessage",
1059
+ name: "_any2EvmMessage",
1060
+ type: "tuple"
1061
+ }
1062
+ ],
1063
+ name: "instantCcipReceive",
1064
+ outputs: [],
1065
+ stateMutability: "nonpayable",
1066
+ type: "function"
1067
+ },
1068
+ {
1069
+ inputs: [
1070
+ {
1071
+ internalType: "bytes32",
1072
+ name: "",
1073
+ type: "bytes32"
1074
+ }
1075
+ ],
1076
+ name: "messageExecutionHashToExecutorMap",
1077
+ outputs: [
1078
+ {
1079
+ internalType: "address",
1080
+ name: "",
1081
+ type: "address"
1082
+ }
1083
+ ],
1084
+ stateMutability: "view",
1085
+ type: "function"
1086
+ },
1087
+ {
1088
+ inputs: [],
1089
+ name: "owner",
1090
+ outputs: [
1091
+ {
1092
+ internalType: "address",
1093
+ name: "",
1094
+ type: "address"
1095
+ }
1096
+ ],
1097
+ stateMutability: "view",
1098
+ type: "function"
1099
+ },
1100
+ {
1101
+ inputs: [],
1102
+ name: "proxiableUUID",
1103
+ outputs: [
1104
+ {
1105
+ internalType: "bytes32",
1106
+ name: "",
1107
+ type: "bytes32"
1108
+ }
1109
+ ],
1110
+ stateMutability: "view",
1111
+ type: "function"
1112
+ },
1113
+ {
1114
+ inputs: [],
1115
+ name: "renounceOwnership",
1116
+ outputs: [],
1117
+ stateMutability: "nonpayable",
1118
+ type: "function"
1119
+ },
1120
+ {
1121
+ inputs: [
1122
+ {
1123
+ internalType: "address",
1124
+ name: "_feeCollectorAddress",
1125
+ type: "address"
1126
+ }
1127
+ ],
1128
+ name: "setFeeCollectorAddress",
1129
+ outputs: [],
1130
+ stateMutability: "nonpayable",
1131
+ type: "function"
1132
+ },
1133
+ {
1134
+ inputs: [
1135
+ {
1136
+ internalType: "address",
1137
+ name: "_feeOracleAddress",
1138
+ type: "address"
1139
+ }
1140
+ ],
1141
+ name: "setFeeOracleAddress",
1142
+ outputs: [],
1143
+ stateMutability: "nonpayable",
1144
+ type: "function"
1145
+ },
1146
+ {
1147
+ inputs: [
1148
+ {
1149
+ internalType: "address",
1150
+ name: "_router",
1151
+ type: "address"
1152
+ }
1153
+ ],
1154
+ name: "setRouter",
1155
+ outputs: [],
1156
+ stateMutability: "nonpayable",
1157
+ type: "function"
1158
+ },
1159
+ {
1160
+ inputs: [
1161
+ {
1162
+ internalType: "address",
1163
+ name: "_xSwapExecutor",
1164
+ type: "address"
1165
+ }
1166
+ ],
1167
+ name: "setXSwapExecutor",
1168
+ outputs: [],
1169
+ stateMutability: "nonpayable",
1170
+ type: "function"
1171
+ },
1172
+ {
1173
+ inputs: [
1174
+ {
1175
+ internalType: "bytes4",
1176
+ name: "interfaceId",
1177
+ type: "bytes4"
1178
+ }
1179
+ ],
1180
+ name: "supportsInterface",
1181
+ outputs: [
1182
+ {
1183
+ internalType: "bool",
1184
+ name: "",
1185
+ type: "bool"
1186
+ }
1187
+ ],
1188
+ stateMutability: "pure",
1189
+ type: "function"
1190
+ },
1191
+ {
1192
+ inputs: [
1193
+ {
1194
+ internalType: "address",
1195
+ name: "_paymentToken",
1196
+ type: "address"
1197
+ },
1198
+ {
1199
+ internalType: "uint64",
1200
+ name: "_destinationChainSelector",
1201
+ type: "uint64"
1202
+ },
1203
+ {
1204
+ components: [
1205
+ {
1206
+ internalType: "address",
1207
+ name: "receiver",
1208
+ type: "address"
1209
+ },
1210
+ {
1211
+ internalType: "address",
1212
+ name: "tokenOut",
1213
+ type: "address"
1214
+ },
1215
+ {
1216
+ internalType: "uint256",
1217
+ name: "estimatedAmountOut",
1218
+ type: "uint256"
1219
+ },
1220
+ {
1221
+ components: [
1222
+ {
1223
+ internalType: "enum CallType",
1224
+ name: "callType",
1225
+ type: "uint8"
1226
+ },
1227
+ {
1228
+ internalType: "address",
1229
+ name: "target",
1230
+ type: "address"
1231
+ },
1232
+ {
1233
+ internalType: "uint256",
1234
+ name: "value",
1235
+ type: "uint256"
1236
+ },
1237
+ {
1238
+ internalType: "bytes",
1239
+ name: "callData",
1240
+ type: "bytes"
1241
+ },
1242
+ {
1243
+ internalType: "bytes",
1244
+ name: "payload",
1245
+ type: "bytes"
1246
+ }
1247
+ ],
1248
+ internalType: "struct Call[]",
1249
+ name: "calls",
1250
+ type: "tuple[]"
1251
+ }
1252
+ ],
1253
+ internalType: "struct SwapDataDestination",
1254
+ name: "_swapDestinationData",
1255
+ type: "tuple"
1256
+ },
1257
+ {
1258
+ components: [
1259
+ {
1260
+ internalType: "address",
1261
+ name: "tokenIn",
1262
+ type: "address"
1263
+ },
1264
+ {
1265
+ internalType: "uint256",
1266
+ name: "amountIn",
1267
+ type: "uint256"
1268
+ },
1269
+ {
1270
+ internalType: "address",
1271
+ name: "tokenOut",
1272
+ type: "address"
1273
+ },
1274
+ {
1275
+ internalType: "uint256",
1276
+ name: "estimatedAmountOut",
1277
+ type: "uint256"
1278
+ },
1279
+ {
1280
+ internalType: "uint256",
1281
+ name: "valueForDestinationGas",
1282
+ type: "uint256"
1283
+ },
1284
+ {
1285
+ internalType: "uint256",
1286
+ name: "valueForInstantCcipRecieve",
1287
+ type: "uint256"
1288
+ },
1289
+ {
1290
+ components: [
1291
+ {
1292
+ internalType: "enum CallType",
1293
+ name: "callType",
1294
+ type: "uint8"
1295
+ },
1296
+ {
1297
+ internalType: "address",
1298
+ name: "target",
1299
+ type: "address"
1300
+ },
1301
+ {
1302
+ internalType: "uint256",
1303
+ name: "value",
1304
+ type: "uint256"
1305
+ },
1306
+ {
1307
+ internalType: "bytes",
1308
+ name: "callData",
1309
+ type: "bytes"
1310
+ },
1311
+ {
1312
+ internalType: "bytes",
1313
+ name: "payload",
1314
+ type: "bytes"
1315
+ }
1316
+ ],
1317
+ internalType: "struct Call[]",
1318
+ name: "calls",
1319
+ type: "tuple[]"
1320
+ }
1321
+ ],
1322
+ internalType: "struct SwapDataOrigin",
1323
+ name: "_swapOriginData",
1324
+ type: "tuple"
1325
+ },
1326
+ {
1327
+ internalType: "uint256",
1328
+ name: "_gasLimit",
1329
+ type: "uint256"
1330
+ }
1331
+ ],
1332
+ name: "swapAndSendMessage",
1333
+ outputs: [
1334
+ {
1335
+ internalType: "bytes32",
1336
+ name: "messageId",
1337
+ type: "bytes32"
1338
+ }
1339
+ ],
1340
+ stateMutability: "payable",
1341
+ type: "function"
1342
+ },
1343
+ {
1344
+ inputs: [
1345
+ {
1346
+ internalType: "address",
1347
+ name: "newOwner",
1348
+ type: "address"
1349
+ }
1350
+ ],
1351
+ name: "transferOwnership",
1352
+ outputs: [],
1353
+ stateMutability: "nonpayable",
1354
+ type: "function"
1355
+ },
1356
+ {
1357
+ inputs: [
1358
+ {
1359
+ internalType: "uint64",
1360
+ name: "_chainSelector",
1361
+ type: "uint64"
1362
+ },
1363
+ {
1364
+ internalType: "address",
1365
+ name: "_xSwapRouter",
1366
+ type: "address"
1367
+ }
1368
+ ],
1369
+ name: "updateChainSelectorToXSwapRouterMap",
1370
+ outputs: [],
1371
+ stateMutability: "nonpayable",
1372
+ type: "function"
1373
+ },
1374
+ {
1375
+ inputs: [
1376
+ {
1377
+ internalType: "uint64[]",
1378
+ name: "_chainSelectors",
1379
+ type: "uint64[]"
1380
+ },
1381
+ {
1382
+ internalType: "address[]",
1383
+ name: "_xSwapRouters",
1384
+ type: "address[]"
1385
+ }
1386
+ ],
1387
+ name: "updateChainSelectorToXSwapRouterMapMany",
1388
+ outputs: [],
1389
+ stateMutability: "nonpayable",
1390
+ type: "function"
1391
+ },
1392
+ {
1393
+ inputs: [
1394
+ {
1395
+ internalType: "uint64",
1396
+ name: "_sourceChainSelector",
1397
+ type: "uint64"
1398
+ },
1399
+ {
1400
+ internalType: "address",
1401
+ name: "_sender",
1402
+ type: "address"
1403
+ },
1404
+ {
1405
+ internalType: "bool",
1406
+ name: "_isWhitelisted",
1407
+ type: "bool"
1408
+ }
1409
+ ],
1410
+ name: "updateWhitelistSender",
1411
+ outputs: [],
1412
+ stateMutability: "nonpayable",
1413
+ type: "function"
1414
+ },
1415
+ {
1416
+ inputs: [
1417
+ {
1418
+ internalType: "uint64[]",
1419
+ name: "_sourceChainSelectors",
1420
+ type: "uint64[]"
1421
+ },
1422
+ {
1423
+ internalType: "address[]",
1424
+ name: "_senders",
1425
+ type: "address[]"
1426
+ },
1427
+ {
1428
+ internalType: "bool[]",
1429
+ name: "_areWhitelisted",
1430
+ type: "bool[]"
1431
+ }
1432
+ ],
1433
+ name: "updateWhitelistSenderMany",
1434
+ outputs: [],
1435
+ stateMutability: "nonpayable",
1436
+ type: "function"
1437
+ },
1438
+ {
1439
+ inputs: [
1440
+ {
1441
+ internalType: "address",
1442
+ name: "_token",
1443
+ type: "address"
1444
+ },
1445
+ {
1446
+ internalType: "bool",
1447
+ name: "_isWhitelisted",
1448
+ type: "bool"
1449
+ }
1450
+ ],
1451
+ name: "updateWhitelistToken",
1452
+ outputs: [],
1453
+ stateMutability: "nonpayable",
1454
+ type: "function"
1455
+ },
1456
+ {
1457
+ inputs: [
1458
+ {
1459
+ internalType: "address",
1460
+ name: "newImplementation",
1461
+ type: "address"
1462
+ }
1463
+ ],
1464
+ name: "upgradeTo",
1465
+ outputs: [],
1466
+ stateMutability: "nonpayable",
1467
+ type: "function"
1468
+ },
1469
+ {
1470
+ inputs: [
1471
+ {
1472
+ internalType: "address",
1473
+ name: "newImplementation",
1474
+ type: "address"
1475
+ },
1476
+ {
1477
+ internalType: "bytes",
1478
+ name: "data",
1479
+ type: "bytes"
1480
+ }
1481
+ ],
1482
+ name: "upgradeToAndCall",
1483
+ outputs: [],
1484
+ stateMutability: "payable",
1485
+ type: "function"
1486
+ },
1487
+ {
1488
+ inputs: [
1489
+ {
1490
+ internalType: "uint64",
1491
+ name: "",
1492
+ type: "uint64"
1493
+ },
1494
+ {
1495
+ internalType: "address",
1496
+ name: "",
1497
+ type: "address"
1498
+ }
1499
+ ],
1500
+ name: "whitelistedSenders",
1501
+ outputs: [
1502
+ {
1503
+ internalType: "bool",
1504
+ name: "",
1505
+ type: "bool"
1506
+ }
1507
+ ],
1508
+ stateMutability: "view",
1509
+ type: "function"
1510
+ },
1511
+ {
1512
+ inputs: [
1513
+ {
1514
+ internalType: "address",
1515
+ name: "",
1516
+ type: "address"
1517
+ }
1518
+ ],
1519
+ name: "whitelistedTokens",
1520
+ outputs: [
1521
+ {
1522
+ internalType: "bool",
1523
+ name: "",
1524
+ type: "bool"
1525
+ }
1526
+ ],
1527
+ stateMutability: "view",
1528
+ type: "function"
1529
+ },
1530
+ {
1531
+ inputs: [],
1532
+ name: "xSwapExecutor",
1533
+ outputs: [
1534
+ {
1535
+ internalType: "address",
1536
+ name: "",
1537
+ type: "address"
1538
+ }
1539
+ ],
1540
+ stateMutability: "view",
1541
+ type: "function"
1542
+ },
1543
+ {
1544
+ stateMutability: "payable",
1545
+ type: "receive"
1546
+ }
1547
+ ];
1548
+
1549
+ // src/contracts/abi/index.ts
1550
+ var ERC20Abi = ERC20_default;
1551
+ var XSwapRouterAbi = XSwapRouter_default;
31
1552
 
32
1553
  // src/services/api.ts
33
- var import_common = require("@xswap-link/common");
34
1554
  async function _sendRequest(urlPath, options, overrides) {
35
- const apiUrl = overrides?.apiUrl || import_common.DEFAULT_API_URL;
1555
+ const apiUrl = overrides?.apiUrl || DEFAULT_API_URL;
36
1556
  const response = await fetch(`${apiUrl}${urlPath}`, {
37
1557
  ...options,
38
1558
  headers: {
@@ -87,11 +1607,43 @@ async function getTokens(chainId, address, ecosystem, overrides) {
87
1607
  overrides
88
1608
  );
89
1609
  }
1610
+
1611
+ // src/utils/bigNumbers.ts
1612
+ var import_bignumber = require("bignumber.js");
1613
+ var import_ethers = require("ethers");
1614
+ var safeBigNumberFrom = (value) => {
1615
+ import_bignumber.BigNumber.config({ DECIMAL_PLACES: 0 });
1616
+ return import_ethers.BigNumber.from(new import_bignumber.BigNumber(value).div(1).toFixed());
1617
+ };
1618
+
1619
+ // src/utils/contracts.ts
1620
+ var import_ethers2 = require("ethers");
1621
+ var erc20Interface = new import_ethers2.ethers.utils.Interface(ERC20Abi);
1622
+ var generateApproveTxData = (tokenAddress, spender, amount) => {
1623
+ const data = erc20Interface.encodeFunctionData("approve", [spender, amount]);
1624
+ return {
1625
+ to: tokenAddress,
1626
+ value: safeBigNumberFrom("0"),
1627
+ data
1628
+ };
1629
+ };
90
1630
  // Annotate the CommonJS export names for ESM import in node:
91
1631
  0 && (module.exports = {
1632
+ DEFAULT_API_URL,
1633
+ DEFAULT_DB_ERROR,
1634
+ DEFAULT_ECOSYSTEM,
1635
+ DEFAULT_GAS_LIMIT_MULTIPLIER,
1636
+ DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE,
1637
+ ERC20Abi,
1638
+ Ecosystem,
1639
+ Environment,
1640
+ Web3Environment,
1641
+ XSwapCallType,
1642
+ XSwapRouterAbi,
1643
+ generateApproveTxData,
92
1644
  getChainData,
93
1645
  getChains,
94
1646
  getRoute,
95
1647
  getTokens,
96
- ...require("@xswap-link/common")
1648
+ safeBigNumberFrom
97
1649
  });