@xswap-link/sdk 0.0.4 → 0.0.6

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