@chainflip/sdk 0.1.0

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/swap.js ADDED
@@ -0,0 +1,2229 @@
1
+ 'use strict';
2
+
3
+ var ethers = require('ethers');
4
+ var utilCrypto = require('@polkadot/util-crypto');
5
+ var zod = require('zod');
6
+ var util = require('@polkadot/util');
7
+ var axios = require('axios');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var ethers__namespace = /*#__PURE__*/_interopNamespace(ethers);
30
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
31
+
32
+ var __defProp = Object.defineProperty;
33
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
34
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
35
+ var __publicField = (obj, key, value) => {
36
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
+ return value;
38
+ };
39
+
40
+ // ../shared/src/enums.ts
41
+ var arrayToMap = /* @__PURE__ */ __name((array) => Object.fromEntries(array.map((key) => [
42
+ key,
43
+ key
44
+ ])), "arrayToMap");
45
+ var Chains = arrayToMap([
46
+ "Bitcoin",
47
+ "Ethereum",
48
+ "Polkadot"
49
+ ]);
50
+ var Assets = arrayToMap([
51
+ "FLIP",
52
+ "USDC",
53
+ "DOT",
54
+ "ETH",
55
+ "BTC"
56
+ ]);
57
+ var ChainflipNetworks = arrayToMap([
58
+ "sisyphos",
59
+ "perseverance",
60
+ "mainnet",
61
+ "partnernet"
62
+ ]);
63
+ var isTestnet = /* @__PURE__ */ __name((network) => network !== ChainflipNetworks.mainnet, "isTestnet");
64
+ var assetChains = {
65
+ [Assets.ETH]: Chains.Ethereum,
66
+ [Assets.FLIP]: Chains.Ethereum,
67
+ [Assets.USDC]: Chains.Ethereum,
68
+ [Assets.BTC]: Chains.Bitcoin,
69
+ [Assets.DOT]: Chains.Polkadot
70
+ };
71
+ var assetDecimals = {
72
+ [Assets.DOT]: 10,
73
+ [Assets.ETH]: 18,
74
+ [Assets.FLIP]: 18,
75
+ [Assets.USDC]: 6,
76
+ [Assets.BTC]: 8
77
+ };
78
+ var assetContractIds = {
79
+ // 0 is reservered for particular cross chain messaging scenarios where we want to pass
80
+ // through a message without making a swap.
81
+ [Assets.ETH]: 1,
82
+ [Assets.FLIP]: 2,
83
+ [Assets.USDC]: 3,
84
+ [Assets.DOT]: 4,
85
+ [Assets.BTC]: 5
86
+ };
87
+ var chainAssets = {
88
+ [Chains.Ethereum]: [
89
+ Assets.ETH,
90
+ Assets.USDC,
91
+ Assets.FLIP
92
+ ],
93
+ [Chains.Bitcoin]: [
94
+ Assets.BTC
95
+ ],
96
+ [Chains.Polkadot]: [
97
+ Assets.DOT
98
+ ]
99
+ };
100
+ var chainContractIds = {
101
+ [Chains.Ethereum]: 1,
102
+ [Chains.Polkadot]: 2,
103
+ [Chains.Bitcoin]: 3
104
+ };
105
+
106
+ // ../shared/src/guards.ts
107
+ var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
108
+ function assert(condition, message) {
109
+ if (condition)
110
+ return;
111
+ const error = new Error(message);
112
+ if (error.stack) {
113
+ error.stack = error.stack.replace(/\n.+/, "\n");
114
+ }
115
+ throw error;
116
+ }
117
+ __name(assert, "assert");
118
+ var isTokenSwap = /* @__PURE__ */ __name((params) => "srcAsset" in params, "isTokenSwap");
119
+ var isTokenCall = /* @__PURE__ */ __name((params) => "srcAsset" in params, "isTokenCall");
120
+ var _abi = [
121
+ {
122
+ inputs: [
123
+ {
124
+ internalType: "address",
125
+ name: "owner",
126
+ type: "address"
127
+ },
128
+ {
129
+ internalType: "address",
130
+ name: "spender",
131
+ type: "address"
132
+ }
133
+ ],
134
+ name: "allowance",
135
+ outputs: [
136
+ {
137
+ internalType: "uint256",
138
+ name: "",
139
+ type: "uint256"
140
+ }
141
+ ],
142
+ stateMutability: "view",
143
+ type: "function"
144
+ },
145
+ {
146
+ inputs: [
147
+ {
148
+ internalType: "address",
149
+ name: "spender",
150
+ type: "address"
151
+ },
152
+ {
153
+ internalType: "uint256",
154
+ name: "amount",
155
+ type: "uint256"
156
+ }
157
+ ],
158
+ name: "approve",
159
+ outputs: [
160
+ {
161
+ internalType: "bool",
162
+ name: "",
163
+ type: "bool"
164
+ }
165
+ ],
166
+ stateMutability: "nonpayable",
167
+ type: "function"
168
+ },
169
+ {
170
+ inputs: [
171
+ {
172
+ internalType: "address",
173
+ name: "account",
174
+ type: "address"
175
+ }
176
+ ],
177
+ name: "balanceOf",
178
+ outputs: [
179
+ {
180
+ internalType: "uint256",
181
+ name: "",
182
+ type: "uint256"
183
+ }
184
+ ],
185
+ stateMutability: "view",
186
+ type: "function"
187
+ }
188
+ ];
189
+ var ERC20__factory = class {
190
+ static createInterface() {
191
+ return new ethers.utils.Interface(_abi);
192
+ }
193
+ static connect(address, signerOrProvider) {
194
+ return new ethers.Contract(address, _abi, signerOrProvider);
195
+ }
196
+ };
197
+ __name(ERC20__factory, "ERC20__factory");
198
+ __publicField(ERC20__factory, "abi", _abi);
199
+ var _abi2 = [
200
+ {
201
+ inputs: [
202
+ {
203
+ internalType: "contract IKeyManager",
204
+ name: "keyManager",
205
+ type: "address"
206
+ }
207
+ ],
208
+ stateMutability: "nonpayable",
209
+ type: "constructor"
210
+ },
211
+ {
212
+ anonymous: false,
213
+ inputs: [
214
+ {
215
+ indexed: false,
216
+ internalType: "bytes32",
217
+ name: "swapID",
218
+ type: "bytes32"
219
+ },
220
+ {
221
+ indexed: false,
222
+ internalType: "uint256",
223
+ name: "amount",
224
+ type: "uint256"
225
+ }
226
+ ],
227
+ name: "AddGasNative",
228
+ type: "event"
229
+ },
230
+ {
231
+ anonymous: false,
232
+ inputs: [
233
+ {
234
+ indexed: false,
235
+ internalType: "bytes32",
236
+ name: "swapID",
237
+ type: "bytes32"
238
+ },
239
+ {
240
+ indexed: false,
241
+ internalType: "uint256",
242
+ name: "amount",
243
+ type: "uint256"
244
+ },
245
+ {
246
+ indexed: false,
247
+ internalType: "address",
248
+ name: "token",
249
+ type: "address"
250
+ }
251
+ ],
252
+ name: "AddGasToken",
253
+ type: "event"
254
+ },
255
+ {
256
+ anonymous: false,
257
+ inputs: [
258
+ {
259
+ indexed: false,
260
+ internalType: "bool",
261
+ name: "communityGuardDisabled",
262
+ type: "bool"
263
+ }
264
+ ],
265
+ name: "CommunityGuardDisabled",
266
+ type: "event"
267
+ },
268
+ {
269
+ anonymous: false,
270
+ inputs: [
271
+ {
272
+ indexed: true,
273
+ internalType: "address payable",
274
+ name: "multicallAddress",
275
+ type: "address"
276
+ },
277
+ {
278
+ indexed: false,
279
+ internalType: "uint256",
280
+ name: "amount",
281
+ type: "uint256"
282
+ },
283
+ {
284
+ indexed: true,
285
+ internalType: "address",
286
+ name: "token",
287
+ type: "address"
288
+ },
289
+ {
290
+ indexed: false,
291
+ internalType: "bytes",
292
+ name: "reason",
293
+ type: "bytes"
294
+ }
295
+ ],
296
+ name: "ExecuteActionsFailed",
297
+ type: "event"
298
+ },
299
+ {
300
+ anonymous: false,
301
+ inputs: [
302
+ {
303
+ indexed: false,
304
+ internalType: "bool",
305
+ name: "suspended",
306
+ type: "bool"
307
+ }
308
+ ],
309
+ name: "Suspended",
310
+ type: "event"
311
+ },
312
+ {
313
+ anonymous: false,
314
+ inputs: [
315
+ {
316
+ indexed: false,
317
+ internalType: "uint32",
318
+ name: "dstChain",
319
+ type: "uint32"
320
+ },
321
+ {
322
+ indexed: false,
323
+ internalType: "bytes",
324
+ name: "dstAddress",
325
+ type: "bytes"
326
+ },
327
+ {
328
+ indexed: false,
329
+ internalType: "uint32",
330
+ name: "dstToken",
331
+ type: "uint32"
332
+ },
333
+ {
334
+ indexed: false,
335
+ internalType: "uint256",
336
+ name: "amount",
337
+ type: "uint256"
338
+ },
339
+ {
340
+ indexed: true,
341
+ internalType: "address",
342
+ name: "sender",
343
+ type: "address"
344
+ },
345
+ {
346
+ indexed: false,
347
+ internalType: "bytes",
348
+ name: "cfParameters",
349
+ type: "bytes"
350
+ }
351
+ ],
352
+ name: "SwapNative",
353
+ type: "event"
354
+ },
355
+ {
356
+ anonymous: false,
357
+ inputs: [
358
+ {
359
+ indexed: false,
360
+ internalType: "uint32",
361
+ name: "dstChain",
362
+ type: "uint32"
363
+ },
364
+ {
365
+ indexed: false,
366
+ internalType: "bytes",
367
+ name: "dstAddress",
368
+ type: "bytes"
369
+ },
370
+ {
371
+ indexed: false,
372
+ internalType: "uint32",
373
+ name: "dstToken",
374
+ type: "uint32"
375
+ },
376
+ {
377
+ indexed: false,
378
+ internalType: "address",
379
+ name: "srcToken",
380
+ type: "address"
381
+ },
382
+ {
383
+ indexed: false,
384
+ internalType: "uint256",
385
+ name: "amount",
386
+ type: "uint256"
387
+ },
388
+ {
389
+ indexed: true,
390
+ internalType: "address",
391
+ name: "sender",
392
+ type: "address"
393
+ },
394
+ {
395
+ indexed: false,
396
+ internalType: "bytes",
397
+ name: "cfParameters",
398
+ type: "bytes"
399
+ }
400
+ ],
401
+ name: "SwapToken",
402
+ type: "event"
403
+ },
404
+ {
405
+ anonymous: false,
406
+ inputs: [
407
+ {
408
+ indexed: true,
409
+ internalType: "address payable",
410
+ name: "recipient",
411
+ type: "address"
412
+ },
413
+ {
414
+ indexed: false,
415
+ internalType: "uint256",
416
+ name: "amount",
417
+ type: "uint256"
418
+ }
419
+ ],
420
+ name: "TransferNativeFailed",
421
+ type: "event"
422
+ },
423
+ {
424
+ anonymous: false,
425
+ inputs: [
426
+ {
427
+ indexed: true,
428
+ internalType: "address payable",
429
+ name: "recipient",
430
+ type: "address"
431
+ },
432
+ {
433
+ indexed: false,
434
+ internalType: "uint256",
435
+ name: "amount",
436
+ type: "uint256"
437
+ },
438
+ {
439
+ indexed: true,
440
+ internalType: "address",
441
+ name: "token",
442
+ type: "address"
443
+ },
444
+ {
445
+ indexed: false,
446
+ internalType: "bytes",
447
+ name: "reason",
448
+ type: "bytes"
449
+ }
450
+ ],
451
+ name: "TransferTokenFailed",
452
+ type: "event"
453
+ },
454
+ {
455
+ anonymous: false,
456
+ inputs: [
457
+ {
458
+ indexed: false,
459
+ internalType: "address",
460
+ name: "keyManager",
461
+ type: "address"
462
+ }
463
+ ],
464
+ name: "UpdatedKeyManager",
465
+ type: "event"
466
+ },
467
+ {
468
+ anonymous: false,
469
+ inputs: [
470
+ {
471
+ indexed: false,
472
+ internalType: "uint32",
473
+ name: "dstChain",
474
+ type: "uint32"
475
+ },
476
+ {
477
+ indexed: false,
478
+ internalType: "bytes",
479
+ name: "dstAddress",
480
+ type: "bytes"
481
+ },
482
+ {
483
+ indexed: false,
484
+ internalType: "uint32",
485
+ name: "dstToken",
486
+ type: "uint32"
487
+ },
488
+ {
489
+ indexed: false,
490
+ internalType: "uint256",
491
+ name: "amount",
492
+ type: "uint256"
493
+ },
494
+ {
495
+ indexed: true,
496
+ internalType: "address",
497
+ name: "sender",
498
+ type: "address"
499
+ },
500
+ {
501
+ indexed: false,
502
+ internalType: "bytes",
503
+ name: "message",
504
+ type: "bytes"
505
+ },
506
+ {
507
+ indexed: false,
508
+ internalType: "uint256",
509
+ name: "gasAmount",
510
+ type: "uint256"
511
+ },
512
+ {
513
+ indexed: false,
514
+ internalType: "bytes",
515
+ name: "cfParameters",
516
+ type: "bytes"
517
+ }
518
+ ],
519
+ name: "XCallNative",
520
+ type: "event"
521
+ },
522
+ {
523
+ anonymous: false,
524
+ inputs: [
525
+ {
526
+ indexed: false,
527
+ internalType: "uint32",
528
+ name: "dstChain",
529
+ type: "uint32"
530
+ },
531
+ {
532
+ indexed: false,
533
+ internalType: "bytes",
534
+ name: "dstAddress",
535
+ type: "bytes"
536
+ },
537
+ {
538
+ indexed: false,
539
+ internalType: "uint32",
540
+ name: "dstToken",
541
+ type: "uint32"
542
+ },
543
+ {
544
+ indexed: false,
545
+ internalType: "address",
546
+ name: "srcToken",
547
+ type: "address"
548
+ },
549
+ {
550
+ indexed: false,
551
+ internalType: "uint256",
552
+ name: "amount",
553
+ type: "uint256"
554
+ },
555
+ {
556
+ indexed: true,
557
+ internalType: "address",
558
+ name: "sender",
559
+ type: "address"
560
+ },
561
+ {
562
+ indexed: false,
563
+ internalType: "bytes",
564
+ name: "message",
565
+ type: "bytes"
566
+ },
567
+ {
568
+ indexed: false,
569
+ internalType: "uint256",
570
+ name: "gasAmount",
571
+ type: "uint256"
572
+ },
573
+ {
574
+ indexed: false,
575
+ internalType: "bytes",
576
+ name: "cfParameters",
577
+ type: "bytes"
578
+ }
579
+ ],
580
+ name: "XCallToken",
581
+ type: "event"
582
+ },
583
+ {
584
+ inputs: [
585
+ {
586
+ internalType: "bytes32",
587
+ name: "swapID",
588
+ type: "bytes32"
589
+ }
590
+ ],
591
+ name: "addGasNative",
592
+ outputs: [],
593
+ stateMutability: "payable",
594
+ type: "function"
595
+ },
596
+ {
597
+ inputs: [
598
+ {
599
+ internalType: "bytes32",
600
+ name: "swapID",
601
+ type: "bytes32"
602
+ },
603
+ {
604
+ internalType: "uint256",
605
+ name: "amount",
606
+ type: "uint256"
607
+ },
608
+ {
609
+ internalType: "contract IERC20",
610
+ name: "token",
611
+ type: "address"
612
+ }
613
+ ],
614
+ name: "addGasToken",
615
+ outputs: [],
616
+ stateMutability: "nonpayable",
617
+ type: "function"
618
+ },
619
+ {
620
+ inputs: [
621
+ {
622
+ components: [
623
+ {
624
+ internalType: "uint256",
625
+ name: "sig",
626
+ type: "uint256"
627
+ },
628
+ {
629
+ internalType: "uint256",
630
+ name: "nonce",
631
+ type: "uint256"
632
+ },
633
+ {
634
+ internalType: "address",
635
+ name: "kTimesGAddress",
636
+ type: "address"
637
+ }
638
+ ],
639
+ internalType: "struct IShared.SigData",
640
+ name: "sigData",
641
+ type: "tuple"
642
+ },
643
+ {
644
+ components: [
645
+ {
646
+ internalType: "bytes32",
647
+ name: "swapID",
648
+ type: "bytes32"
649
+ },
650
+ {
651
+ internalType: "address",
652
+ name: "token",
653
+ type: "address"
654
+ }
655
+ ],
656
+ internalType: "struct IShared.DeployFetchParams[]",
657
+ name: "deployFetchParamsArray",
658
+ type: "tuple[]"
659
+ },
660
+ {
661
+ components: [
662
+ {
663
+ internalType: "address payable",
664
+ name: "fetchContract",
665
+ type: "address"
666
+ },
667
+ {
668
+ internalType: "address",
669
+ name: "token",
670
+ type: "address"
671
+ }
672
+ ],
673
+ internalType: "struct IShared.FetchParams[]",
674
+ name: "fetchParamsArray",
675
+ type: "tuple[]"
676
+ },
677
+ {
678
+ components: [
679
+ {
680
+ internalType: "address",
681
+ name: "token",
682
+ type: "address"
683
+ },
684
+ {
685
+ internalType: "address payable",
686
+ name: "recipient",
687
+ type: "address"
688
+ },
689
+ {
690
+ internalType: "uint256",
691
+ name: "amount",
692
+ type: "uint256"
693
+ }
694
+ ],
695
+ internalType: "struct IShared.TransferParams[]",
696
+ name: "transferParamsArray",
697
+ type: "tuple[]"
698
+ }
699
+ ],
700
+ name: "allBatch",
701
+ outputs: [],
702
+ stateMutability: "nonpayable",
703
+ type: "function"
704
+ },
705
+ {
706
+ inputs: [
707
+ {
708
+ components: [
709
+ {
710
+ internalType: "uint256",
711
+ name: "sig",
712
+ type: "uint256"
713
+ },
714
+ {
715
+ internalType: "uint256",
716
+ name: "nonce",
717
+ type: "uint256"
718
+ },
719
+ {
720
+ internalType: "address",
721
+ name: "kTimesGAddress",
722
+ type: "address"
723
+ }
724
+ ],
725
+ internalType: "struct IShared.SigData",
726
+ name: "sigData",
727
+ type: "tuple"
728
+ },
729
+ {
730
+ components: [
731
+ {
732
+ internalType: "bytes32",
733
+ name: "swapID",
734
+ type: "bytes32"
735
+ },
736
+ {
737
+ internalType: "address",
738
+ name: "token",
739
+ type: "address"
740
+ }
741
+ ],
742
+ internalType: "struct IShared.DeployFetchParams[]",
743
+ name: "deployFetchParamsArray",
744
+ type: "tuple[]"
745
+ }
746
+ ],
747
+ name: "deployAndFetchBatch",
748
+ outputs: [],
749
+ stateMutability: "nonpayable",
750
+ type: "function"
751
+ },
752
+ {
753
+ inputs: [],
754
+ name: "disableCommunityGuard",
755
+ outputs: [],
756
+ stateMutability: "nonpayable",
757
+ type: "function"
758
+ },
759
+ {
760
+ inputs: [],
761
+ name: "enableCommunityGuard",
762
+ outputs: [],
763
+ stateMutability: "nonpayable",
764
+ type: "function"
765
+ },
766
+ {
767
+ inputs: [
768
+ {
769
+ components: [
770
+ {
771
+ internalType: "uint256",
772
+ name: "sig",
773
+ type: "uint256"
774
+ },
775
+ {
776
+ internalType: "uint256",
777
+ name: "nonce",
778
+ type: "uint256"
779
+ },
780
+ {
781
+ internalType: "address",
782
+ name: "kTimesGAddress",
783
+ type: "address"
784
+ }
785
+ ],
786
+ internalType: "struct IShared.SigData",
787
+ name: "sigData",
788
+ type: "tuple"
789
+ },
790
+ {
791
+ components: [
792
+ {
793
+ internalType: "address",
794
+ name: "token",
795
+ type: "address"
796
+ },
797
+ {
798
+ internalType: "address payable",
799
+ name: "recipient",
800
+ type: "address"
801
+ },
802
+ {
803
+ internalType: "uint256",
804
+ name: "amount",
805
+ type: "uint256"
806
+ }
807
+ ],
808
+ internalType: "struct IShared.TransferParams",
809
+ name: "transferParams",
810
+ type: "tuple"
811
+ },
812
+ {
813
+ components: [
814
+ {
815
+ internalType: "enum IMulticall.CallType",
816
+ name: "callType",
817
+ type: "uint8"
818
+ },
819
+ {
820
+ internalType: "address",
821
+ name: "target",
822
+ type: "address"
823
+ },
824
+ {
825
+ internalType: "uint256",
826
+ name: "value",
827
+ type: "uint256"
828
+ },
829
+ {
830
+ internalType: "bytes",
831
+ name: "callData",
832
+ type: "bytes"
833
+ },
834
+ {
835
+ internalType: "bytes",
836
+ name: "payload",
837
+ type: "bytes"
838
+ }
839
+ ],
840
+ internalType: "struct IMulticall.Call[]",
841
+ name: "calls",
842
+ type: "tuple[]"
843
+ },
844
+ {
845
+ internalType: "uint256",
846
+ name: "gasMulticall",
847
+ type: "uint256"
848
+ }
849
+ ],
850
+ name: "executeActions",
851
+ outputs: [],
852
+ stateMutability: "nonpayable",
853
+ type: "function"
854
+ },
855
+ {
856
+ inputs: [
857
+ {
858
+ components: [
859
+ {
860
+ internalType: "uint256",
861
+ name: "sig",
862
+ type: "uint256"
863
+ },
864
+ {
865
+ internalType: "uint256",
866
+ name: "nonce",
867
+ type: "uint256"
868
+ },
869
+ {
870
+ internalType: "address",
871
+ name: "kTimesGAddress",
872
+ type: "address"
873
+ }
874
+ ],
875
+ internalType: "struct IShared.SigData",
876
+ name: "sigData",
877
+ type: "tuple"
878
+ },
879
+ {
880
+ internalType: "address",
881
+ name: "recipient",
882
+ type: "address"
883
+ },
884
+ {
885
+ internalType: "uint32",
886
+ name: "srcChain",
887
+ type: "uint32"
888
+ },
889
+ {
890
+ internalType: "bytes",
891
+ name: "srcAddress",
892
+ type: "bytes"
893
+ },
894
+ {
895
+ internalType: "bytes",
896
+ name: "message",
897
+ type: "bytes"
898
+ }
899
+ ],
900
+ name: "executexCall",
901
+ outputs: [],
902
+ stateMutability: "nonpayable",
903
+ type: "function"
904
+ },
905
+ {
906
+ inputs: [
907
+ {
908
+ components: [
909
+ {
910
+ internalType: "uint256",
911
+ name: "sig",
912
+ type: "uint256"
913
+ },
914
+ {
915
+ internalType: "uint256",
916
+ name: "nonce",
917
+ type: "uint256"
918
+ },
919
+ {
920
+ internalType: "address",
921
+ name: "kTimesGAddress",
922
+ type: "address"
923
+ }
924
+ ],
925
+ internalType: "struct IShared.SigData",
926
+ name: "sigData",
927
+ type: "tuple"
928
+ },
929
+ {
930
+ components: [
931
+ {
932
+ internalType: "address",
933
+ name: "token",
934
+ type: "address"
935
+ },
936
+ {
937
+ internalType: "address payable",
938
+ name: "recipient",
939
+ type: "address"
940
+ },
941
+ {
942
+ internalType: "uint256",
943
+ name: "amount",
944
+ type: "uint256"
945
+ }
946
+ ],
947
+ internalType: "struct IShared.TransferParams",
948
+ name: "transferParams",
949
+ type: "tuple"
950
+ },
951
+ {
952
+ internalType: "uint32",
953
+ name: "srcChain",
954
+ type: "uint32"
955
+ },
956
+ {
957
+ internalType: "bytes",
958
+ name: "srcAddress",
959
+ type: "bytes"
960
+ },
961
+ {
962
+ internalType: "bytes",
963
+ name: "message",
964
+ type: "bytes"
965
+ }
966
+ ],
967
+ name: "executexSwapAndCall",
968
+ outputs: [],
969
+ stateMutability: "nonpayable",
970
+ type: "function"
971
+ },
972
+ {
973
+ inputs: [
974
+ {
975
+ components: [
976
+ {
977
+ internalType: "uint256",
978
+ name: "sig",
979
+ type: "uint256"
980
+ },
981
+ {
982
+ internalType: "uint256",
983
+ name: "nonce",
984
+ type: "uint256"
985
+ },
986
+ {
987
+ internalType: "address",
988
+ name: "kTimesGAddress",
989
+ type: "address"
990
+ }
991
+ ],
992
+ internalType: "struct IShared.SigData",
993
+ name: "sigData",
994
+ type: "tuple"
995
+ },
996
+ {
997
+ components: [
998
+ {
999
+ internalType: "address payable",
1000
+ name: "fetchContract",
1001
+ type: "address"
1002
+ },
1003
+ {
1004
+ internalType: "address",
1005
+ name: "token",
1006
+ type: "address"
1007
+ }
1008
+ ],
1009
+ internalType: "struct IShared.FetchParams[]",
1010
+ name: "fetchParamsArray",
1011
+ type: "tuple[]"
1012
+ }
1013
+ ],
1014
+ name: "fetchBatch",
1015
+ outputs: [],
1016
+ stateMutability: "nonpayable",
1017
+ type: "function"
1018
+ },
1019
+ {
1020
+ inputs: [],
1021
+ name: "getCommunityGuardDisabled",
1022
+ outputs: [
1023
+ {
1024
+ internalType: "bool",
1025
+ name: "",
1026
+ type: "bool"
1027
+ }
1028
+ ],
1029
+ stateMutability: "view",
1030
+ type: "function"
1031
+ },
1032
+ {
1033
+ inputs: [],
1034
+ name: "getCommunityKey",
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: "getGovernor",
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: "getKeyManager",
1061
+ outputs: [
1062
+ {
1063
+ internalType: "contract IKeyManager",
1064
+ name: "",
1065
+ type: "address"
1066
+ }
1067
+ ],
1068
+ stateMutability: "view",
1069
+ type: "function"
1070
+ },
1071
+ {
1072
+ inputs: [],
1073
+ name: "getSuspendedState",
1074
+ outputs: [
1075
+ {
1076
+ internalType: "bool",
1077
+ name: "",
1078
+ type: "bool"
1079
+ }
1080
+ ],
1081
+ stateMutability: "view",
1082
+ type: "function"
1083
+ },
1084
+ {
1085
+ inputs: [
1086
+ {
1087
+ internalType: "address[]",
1088
+ name: "tokens",
1089
+ type: "address[]"
1090
+ }
1091
+ ],
1092
+ name: "govWithdraw",
1093
+ outputs: [],
1094
+ stateMutability: "nonpayable",
1095
+ type: "function"
1096
+ },
1097
+ {
1098
+ inputs: [],
1099
+ name: "resume",
1100
+ outputs: [],
1101
+ stateMutability: "nonpayable",
1102
+ type: "function"
1103
+ },
1104
+ {
1105
+ inputs: [],
1106
+ name: "suspend",
1107
+ outputs: [],
1108
+ stateMutability: "nonpayable",
1109
+ type: "function"
1110
+ },
1111
+ {
1112
+ inputs: [
1113
+ {
1114
+ components: [
1115
+ {
1116
+ internalType: "uint256",
1117
+ name: "sig",
1118
+ type: "uint256"
1119
+ },
1120
+ {
1121
+ internalType: "uint256",
1122
+ name: "nonce",
1123
+ type: "uint256"
1124
+ },
1125
+ {
1126
+ internalType: "address",
1127
+ name: "kTimesGAddress",
1128
+ type: "address"
1129
+ }
1130
+ ],
1131
+ internalType: "struct IShared.SigData",
1132
+ name: "sigData",
1133
+ type: "tuple"
1134
+ },
1135
+ {
1136
+ components: [
1137
+ {
1138
+ internalType: "address",
1139
+ name: "token",
1140
+ type: "address"
1141
+ },
1142
+ {
1143
+ internalType: "address payable",
1144
+ name: "recipient",
1145
+ type: "address"
1146
+ },
1147
+ {
1148
+ internalType: "uint256",
1149
+ name: "amount",
1150
+ type: "uint256"
1151
+ }
1152
+ ],
1153
+ internalType: "struct IShared.TransferParams",
1154
+ name: "transferParams",
1155
+ type: "tuple"
1156
+ }
1157
+ ],
1158
+ name: "transfer",
1159
+ outputs: [],
1160
+ stateMutability: "nonpayable",
1161
+ type: "function"
1162
+ },
1163
+ {
1164
+ inputs: [
1165
+ {
1166
+ components: [
1167
+ {
1168
+ internalType: "uint256",
1169
+ name: "sig",
1170
+ type: "uint256"
1171
+ },
1172
+ {
1173
+ internalType: "uint256",
1174
+ name: "nonce",
1175
+ type: "uint256"
1176
+ },
1177
+ {
1178
+ internalType: "address",
1179
+ name: "kTimesGAddress",
1180
+ type: "address"
1181
+ }
1182
+ ],
1183
+ internalType: "struct IShared.SigData",
1184
+ name: "sigData",
1185
+ type: "tuple"
1186
+ },
1187
+ {
1188
+ components: [
1189
+ {
1190
+ internalType: "address",
1191
+ name: "token",
1192
+ type: "address"
1193
+ },
1194
+ {
1195
+ internalType: "address payable",
1196
+ name: "recipient",
1197
+ type: "address"
1198
+ },
1199
+ {
1200
+ internalType: "uint256",
1201
+ name: "amount",
1202
+ type: "uint256"
1203
+ }
1204
+ ],
1205
+ internalType: "struct IShared.TransferParams[]",
1206
+ name: "transferParamsArray",
1207
+ type: "tuple[]"
1208
+ }
1209
+ ],
1210
+ name: "transferBatch",
1211
+ outputs: [],
1212
+ stateMutability: "nonpayable",
1213
+ type: "function"
1214
+ },
1215
+ {
1216
+ inputs: [
1217
+ {
1218
+ components: [
1219
+ {
1220
+ internalType: "uint256",
1221
+ name: "sig",
1222
+ type: "uint256"
1223
+ },
1224
+ {
1225
+ internalType: "uint256",
1226
+ name: "nonce",
1227
+ type: "uint256"
1228
+ },
1229
+ {
1230
+ internalType: "address",
1231
+ name: "kTimesGAddress",
1232
+ type: "address"
1233
+ }
1234
+ ],
1235
+ internalType: "struct IShared.SigData",
1236
+ name: "sigData",
1237
+ type: "tuple"
1238
+ },
1239
+ {
1240
+ internalType: "contract IKeyManager",
1241
+ name: "keyManager",
1242
+ type: "address"
1243
+ },
1244
+ {
1245
+ internalType: "bool",
1246
+ name: "omitChecks",
1247
+ type: "bool"
1248
+ }
1249
+ ],
1250
+ name: "updateKeyManager",
1251
+ outputs: [],
1252
+ stateMutability: "nonpayable",
1253
+ type: "function"
1254
+ },
1255
+ {
1256
+ inputs: [
1257
+ {
1258
+ internalType: "uint32",
1259
+ name: "dstChain",
1260
+ type: "uint32"
1261
+ },
1262
+ {
1263
+ internalType: "bytes",
1264
+ name: "dstAddress",
1265
+ type: "bytes"
1266
+ },
1267
+ {
1268
+ internalType: "uint32",
1269
+ name: "dstToken",
1270
+ type: "uint32"
1271
+ },
1272
+ {
1273
+ internalType: "bytes",
1274
+ name: "message",
1275
+ type: "bytes"
1276
+ },
1277
+ {
1278
+ internalType: "uint256",
1279
+ name: "gasAmount",
1280
+ type: "uint256"
1281
+ },
1282
+ {
1283
+ internalType: "bytes",
1284
+ name: "cfParameters",
1285
+ type: "bytes"
1286
+ }
1287
+ ],
1288
+ name: "xCallNative",
1289
+ outputs: [],
1290
+ stateMutability: "payable",
1291
+ type: "function"
1292
+ },
1293
+ {
1294
+ inputs: [
1295
+ {
1296
+ internalType: "uint32",
1297
+ name: "dstChain",
1298
+ type: "uint32"
1299
+ },
1300
+ {
1301
+ internalType: "bytes",
1302
+ name: "dstAddress",
1303
+ type: "bytes"
1304
+ },
1305
+ {
1306
+ internalType: "uint32",
1307
+ name: "dstToken",
1308
+ type: "uint32"
1309
+ },
1310
+ {
1311
+ internalType: "bytes",
1312
+ name: "message",
1313
+ type: "bytes"
1314
+ },
1315
+ {
1316
+ internalType: "uint256",
1317
+ name: "gasAmount",
1318
+ type: "uint256"
1319
+ },
1320
+ {
1321
+ internalType: "contract IERC20",
1322
+ name: "srcToken",
1323
+ type: "address"
1324
+ },
1325
+ {
1326
+ internalType: "uint256",
1327
+ name: "amount",
1328
+ type: "uint256"
1329
+ },
1330
+ {
1331
+ internalType: "bytes",
1332
+ name: "cfParameters",
1333
+ type: "bytes"
1334
+ }
1335
+ ],
1336
+ name: "xCallToken",
1337
+ outputs: [],
1338
+ stateMutability: "nonpayable",
1339
+ type: "function"
1340
+ },
1341
+ {
1342
+ inputs: [
1343
+ {
1344
+ internalType: "uint32",
1345
+ name: "dstChain",
1346
+ type: "uint32"
1347
+ },
1348
+ {
1349
+ internalType: "bytes",
1350
+ name: "dstAddress",
1351
+ type: "bytes"
1352
+ },
1353
+ {
1354
+ internalType: "uint32",
1355
+ name: "dstToken",
1356
+ type: "uint32"
1357
+ },
1358
+ {
1359
+ internalType: "bytes",
1360
+ name: "cfParameters",
1361
+ type: "bytes"
1362
+ }
1363
+ ],
1364
+ name: "xSwapNative",
1365
+ outputs: [],
1366
+ stateMutability: "payable",
1367
+ type: "function"
1368
+ },
1369
+ {
1370
+ inputs: [
1371
+ {
1372
+ internalType: "uint32",
1373
+ name: "dstChain",
1374
+ type: "uint32"
1375
+ },
1376
+ {
1377
+ internalType: "bytes",
1378
+ name: "dstAddress",
1379
+ type: "bytes"
1380
+ },
1381
+ {
1382
+ internalType: "uint32",
1383
+ name: "dstToken",
1384
+ type: "uint32"
1385
+ },
1386
+ {
1387
+ internalType: "contract IERC20",
1388
+ name: "srcToken",
1389
+ type: "address"
1390
+ },
1391
+ {
1392
+ internalType: "uint256",
1393
+ name: "amount",
1394
+ type: "uint256"
1395
+ },
1396
+ {
1397
+ internalType: "bytes",
1398
+ name: "cfParameters",
1399
+ type: "bytes"
1400
+ }
1401
+ ],
1402
+ name: "xSwapToken",
1403
+ outputs: [],
1404
+ stateMutability: "nonpayable",
1405
+ type: "function"
1406
+ },
1407
+ {
1408
+ stateMutability: "payable",
1409
+ type: "receive"
1410
+ }
1411
+ ];
1412
+ var Vault__factory = class {
1413
+ static createInterface() {
1414
+ return new ethers.utils.Interface(_abi2);
1415
+ }
1416
+ static connect(address, signerOrProvider) {
1417
+ return new ethers.Contract(address, _abi2, signerOrProvider);
1418
+ }
1419
+ };
1420
+ __name(Vault__factory, "Vault__factory");
1421
+ __publicField(Vault__factory, "abi", _abi2);
1422
+
1423
+ // ../shared/src/consts.ts
1424
+ var ADDRESSES = {
1425
+ [ChainflipNetworks.sisyphos]: {
1426
+ FLIP_CONTRACT_ADDRESS: "0x2FD78122663A07672e9ac63486573A99EB00125d",
1427
+ VAULT_CONTRACT_ADDRESS: "0xd498606dcb9F440CD9F06B397C40fd3327FC2550",
1428
+ STATE_CHAIN_MANAGER_CONTRACT_ADDRESS: "0xCCF267Bc5B709F1A1738122f3b76Cd01F0d9f947"
1429
+ },
1430
+ [ChainflipNetworks.partnernet]: {
1431
+ FLIP_CONTRACT_ADDRESS: "0x7D18Ed38e962FA25f39109f4aC8FbC4C75a0475C",
1432
+ VAULT_CONTRACT_ADDRESS: "0xE781866455c5EF1f791975512f7E27814Dc200E1",
1433
+ STATE_CHAIN_MANAGER_CONTRACT_ADDRESS: "0x5aC721F46b88E8671c1B62A501CD78b7C8b07a62"
1434
+ },
1435
+ [ChainflipNetworks.perseverance]: {
1436
+ FLIP_CONTRACT_ADDRESS: "0x1194C91d47Fc1b65bE18db38380B5344682b67db",
1437
+ VAULT_CONTRACT_ADDRESS: "0xF1B061aCCDAa4B7c029128b49aBc047F89D5CB8d",
1438
+ STATE_CHAIN_MANAGER_CONTRACT_ADDRESS: "0xC960C4eEe4ADf40d24374D85094f3219cf2DD8EB"
1439
+ }
1440
+ };
1441
+ var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
1442
+
1443
+ // ../shared/src/contracts.ts
1444
+ var getTokenContractAddress = /* @__PURE__ */ __name((asset, network) => {
1445
+ assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
1446
+ if (asset === Assets.FLIP)
1447
+ return ADDRESSES[network].FLIP_CONTRACT_ADDRESS;
1448
+ assert(asset === Assets.USDC, "Only FLIP and USDC are supported for now");
1449
+ return GOERLI_USDC_CONTRACT_ADDRESS;
1450
+ }, "getTokenContractAddress");
1451
+ var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20Address, signer) => {
1452
+ const erc202 = ERC20__factory.connect(erc20Address, signer);
1453
+ const signerAddress = await signer.getAddress();
1454
+ const allowance = await erc202.allowance(signerAddress, spenderAddress);
1455
+ return {
1456
+ allowance,
1457
+ isAllowable: allowance.gte(amount),
1458
+ erc20: erc202
1459
+ };
1460
+ }, "checkAllowance");
1461
+ var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc202, allowance, nonce) => {
1462
+ const amountBigNumber = ethers.BigNumber.from(amount);
1463
+ const allowanceBigNumber = ethers.BigNumber.from(allowance);
1464
+ if (allowanceBigNumber.gte(amountBigNumber))
1465
+ return null;
1466
+ const requiredAmount = amountBigNumber.sub(allowanceBigNumber);
1467
+ const tx = await erc202.approve(spenderAddress, requiredAmount, {
1468
+ nonce
1469
+ });
1470
+ return tx.wait(1);
1471
+ }, "approve");
1472
+ var getVaultManagerContractAddress = /* @__PURE__ */ __name((network) => {
1473
+ assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
1474
+ return ADDRESSES[network].VAULT_CONTRACT_ADDRESS;
1475
+ }, "getVaultManagerContractAddress");
1476
+
1477
+ // ../shared/src/validation/segwitAddr.ts
1478
+ var CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
1479
+ var GENERATOR = [
1480
+ 996825010,
1481
+ 642813549,
1482
+ 513874426,
1483
+ 1027748829,
1484
+ 705979059
1485
+ ];
1486
+ var Encoding;
1487
+ (function(Encoding2) {
1488
+ Encoding2["Bech32"] = "bech32";
1489
+ Encoding2["Bech32m"] = "bech32m";
1490
+ })(Encoding || (Encoding = {}));
1491
+ var bech32 = {
1492
+ getEncodingConst(enc) {
1493
+ if (enc === Encoding.Bech32)
1494
+ return 1;
1495
+ if (enc === Encoding.Bech32m)
1496
+ return 734539939;
1497
+ return null;
1498
+ },
1499
+ polymod(values) {
1500
+ let chk = 1;
1501
+ for (let p = 0; p < values.length; p += 1) {
1502
+ const top = chk >> 25;
1503
+ chk = (chk & 33554431) << 5 ^ values[p];
1504
+ for (let i = 0; i < 5; i += 1) {
1505
+ if (top >> i & 1) {
1506
+ chk ^= GENERATOR[i];
1507
+ }
1508
+ }
1509
+ }
1510
+ return chk;
1511
+ },
1512
+ hrpExpand(hrp) {
1513
+ const ret = [];
1514
+ let p;
1515
+ for (p = 0; p < hrp.length; p += 1) {
1516
+ ret.push(hrp.charCodeAt(p) >> 5);
1517
+ }
1518
+ ret.push(0);
1519
+ for (p = 0; p < hrp.length; p += 1) {
1520
+ ret.push(hrp.charCodeAt(p) & 31);
1521
+ }
1522
+ return ret;
1523
+ },
1524
+ verifyChecksum(hrp, data, enc) {
1525
+ return this.polymod(this.hrpExpand(hrp).concat(data)) === this.getEncodingConst(enc);
1526
+ },
1527
+ createChecksum(hrp, data, enc) {
1528
+ const values = this.hrpExpand(hrp).concat(data).concat([
1529
+ 0,
1530
+ 0,
1531
+ 0,
1532
+ 0,
1533
+ 0,
1534
+ 0
1535
+ ]);
1536
+ const mod = this.polymod(values) ^ this.getEncodingConst(enc);
1537
+ const ret = [];
1538
+ for (let p = 0; p < 6; p += 1) {
1539
+ ret.push(mod >> 5 * (5 - p) & 31);
1540
+ }
1541
+ return ret;
1542
+ },
1543
+ encode(hrp, data, enc) {
1544
+ const combined = data.concat(this.createChecksum(hrp, data, enc));
1545
+ let ret = `${hrp}1`;
1546
+ for (let p = 0; p < combined.length; p += 1) {
1547
+ ret += CHARSET.charAt(combined[p]);
1548
+ }
1549
+ return ret;
1550
+ },
1551
+ decode(bechString, enc) {
1552
+ let p;
1553
+ let hasLower = false;
1554
+ let hasUpper = false;
1555
+ for (p = 0; p < bechString.length; p += 1) {
1556
+ if (bechString.charCodeAt(p) < 33 || bechString.charCodeAt(p) > 126) {
1557
+ return null;
1558
+ }
1559
+ if (bechString.charCodeAt(p) >= 97 && bechString.charCodeAt(p) <= 122) {
1560
+ hasLower = true;
1561
+ }
1562
+ if (bechString.charCodeAt(p) >= 65 && bechString.charCodeAt(p) <= 90) {
1563
+ hasUpper = true;
1564
+ }
1565
+ }
1566
+ if (hasLower && hasUpper)
1567
+ return null;
1568
+ const lowercase = bechString.toLowerCase();
1569
+ const pos = lowercase.lastIndexOf("1");
1570
+ if (pos < 1 || pos + 7 > lowercase.length || lowercase.length > 90) {
1571
+ return null;
1572
+ }
1573
+ const hrp = lowercase.substring(0, pos);
1574
+ const data = [];
1575
+ for (p = pos + 1; p < lowercase.length; p += 1) {
1576
+ const d = CHARSET.indexOf(lowercase.charAt(p));
1577
+ if (d === -1)
1578
+ return null;
1579
+ data.push(d);
1580
+ }
1581
+ if (!this.verifyChecksum(hrp, data, enc)) {
1582
+ return null;
1583
+ }
1584
+ return {
1585
+ hrp,
1586
+ data: data.slice(0, data.length - 6)
1587
+ };
1588
+ }
1589
+ };
1590
+ var segwitAddress = {
1591
+ convertbits(data, frombits, tobits, pad) {
1592
+ let acc = 0;
1593
+ let bits = 0;
1594
+ const ret = [];
1595
+ const maxv = (1 << tobits) - 1;
1596
+ for (let p = 0; p < data.length; p += 1) {
1597
+ const value = data[p];
1598
+ if (value < 0 || value >> frombits !== 0) {
1599
+ return null;
1600
+ }
1601
+ acc = acc << frombits | value;
1602
+ bits += frombits;
1603
+ while (bits >= tobits) {
1604
+ bits -= tobits;
1605
+ ret.push(acc >> bits & maxv);
1606
+ }
1607
+ }
1608
+ if (pad) {
1609
+ if (bits > 0) {
1610
+ ret.push(acc << tobits - bits & maxv);
1611
+ }
1612
+ } else if (bits >= frombits || acc << tobits - bits & maxv) {
1613
+ return null;
1614
+ }
1615
+ return ret;
1616
+ },
1617
+ decode(hrp, addr) {
1618
+ let bech32m = false;
1619
+ let dec = bech32.decode(addr, Encoding.Bech32);
1620
+ if (dec === null) {
1621
+ dec = bech32.decode(addr, Encoding.Bech32m);
1622
+ bech32m = true;
1623
+ }
1624
+ if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) {
1625
+ return null;
1626
+ }
1627
+ const res = this.convertbits(dec.data.slice(1), 5, 8, false);
1628
+ if (res === null || res.length < 2 || res.length > 40) {
1629
+ return null;
1630
+ }
1631
+ if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) {
1632
+ return null;
1633
+ }
1634
+ if (dec.data[0] === 0 && bech32m) {
1635
+ return null;
1636
+ }
1637
+ if (dec.data[0] !== 0 && !bech32m) {
1638
+ return null;
1639
+ }
1640
+ return {
1641
+ version: dec.data[0],
1642
+ program: res
1643
+ };
1644
+ },
1645
+ encode(hrp, version, program) {
1646
+ let enc = Encoding.Bech32;
1647
+ if (version > 0) {
1648
+ enc = Encoding.Bech32m;
1649
+ }
1650
+ const ret = bech32.encode(
1651
+ hrp,
1652
+ // @ts-expect-error can be null
1653
+ [
1654
+ version
1655
+ ].concat(this.convertbits(program, 8, 5, true)),
1656
+ enc
1657
+ );
1658
+ if (this.decode(hrp, ret) === null) {
1659
+ return null;
1660
+ }
1661
+ return ret;
1662
+ }
1663
+ };
1664
+ var isValidSegwitAddress = /* @__PURE__ */ __name((address) => {
1665
+ const hrp = /^(bc|tb|bcrt)1/.exec(address)?.[1];
1666
+ if (!hrp)
1667
+ return false;
1668
+ return segwitAddress.decode(hrp, address) !== null;
1669
+ }, "isValidSegwitAddress");
1670
+
1671
+ // ../shared/src/validation/addressValidation.ts
1672
+ var assertArraylikeEqual = /* @__PURE__ */ __name((a, b) => {
1673
+ assert(a.length === b.length, "arraylike lengths must be equal");
1674
+ for (let i = 0; i < a.length; i += 1) {
1675
+ assert(a[i] === b[i], "arraylike elements must be equal");
1676
+ }
1677
+ }, "assertArraylikeEqual");
1678
+ var validateP2PKHOrP2SHAddress = /* @__PURE__ */ __name((address, network) => {
1679
+ try {
1680
+ const decoded = ethers__namespace.utils.base58.decode(address);
1681
+ assert(decoded.length === 25, "decoded address must be 25 bytes long");
1682
+ if (network === "mainnet") {
1683
+ assert(decoded[0] === 0 || decoded[0] === 5, "decoded address must start with 0x00 or 0x05");
1684
+ } else {
1685
+ assert(decoded[0] === 111 || decoded[0] === 196, "decoded address must start with 0x6f or 0xc4");
1686
+ }
1687
+ const checksum = decoded.slice(-4);
1688
+ const doubleHash = ethers__namespace.utils.arrayify(ethers__namespace.utils.sha256(ethers__namespace.utils.sha256(decoded.slice(0, 21))));
1689
+ assertArraylikeEqual(checksum, doubleHash.slice(0, 4));
1690
+ return true;
1691
+ } catch (error) {
1692
+ return false;
1693
+ }
1694
+ }, "validateP2PKHOrP2SHAddress");
1695
+ var validateSegwitAddress = /* @__PURE__ */ __name((address, network) => {
1696
+ try {
1697
+ assert(
1698
+ // On mainnet, the address must start with "bc1"
1699
+ network === "mainnet" && address.startsWith("bc1") || // on testnet it must start with "tb1"
1700
+ network === "testnet" && address.startsWith("tb1") || // on regtest it must start with "bcrt1"
1701
+ network === "regtest" && address.startsWith("bcrt1"),
1702
+ "address must start with bc1, tb1 or bcrt1"
1703
+ );
1704
+ return isValidSegwitAddress(address);
1705
+ } catch {
1706
+ return false;
1707
+ }
1708
+ }, "validateSegwitAddress");
1709
+ var validateBitcoinAddress = /* @__PURE__ */ __name((address, network) => validateP2PKHOrP2SHAddress(address, network) || validateSegwitAddress(address, network), "validateBitcoinAddress");
1710
+ var validateBitcoinMainnetAddress = /* @__PURE__ */ __name((address) => validateBitcoinAddress(address, "mainnet"), "validateBitcoinMainnetAddress");
1711
+ var validateBitcoinTestnetAddress = /* @__PURE__ */ __name((address) => validateBitcoinAddress(address, "testnet"), "validateBitcoinTestnetAddress");
1712
+ var validateBitcoinRegtestAddress = /* @__PURE__ */ __name((address) => validateBitcoinAddress(address, "regtest"), "validateBitcoinRegtestAddress");
1713
+
1714
+ // ../shared/src/parsers.ts
1715
+ var errorMap = /* @__PURE__ */ __name((issue, context) => ({
1716
+ message: `received: ${JSON.stringify(context.data)}`
1717
+ }), "errorMap");
1718
+ var string = zod.z.string({
1719
+ errorMap
1720
+ });
1721
+ zod.z.number({
1722
+ errorMap
1723
+ });
1724
+ var numericString = string.regex(/^[0-9]+$/);
1725
+ var hexString = zod.z.custom((val) => typeof val === "string" && /^0x[0-9a-f]+$/i.test(val));
1726
+ numericString.transform((arg) => ethers__namespace.BigNumber.from(arg).toHexString()).refine((arg) => arg.startsWith("0x"));
1727
+ string.regex(/^[0-9a-f]+$/);
1728
+ var btcAddress = zod.z.union([
1729
+ string.regex(/^(1|3|bc1)/).refine(validateBitcoinMainnetAddress),
1730
+ string.regex(/^(m|n|2|tb1)/).refine(validateBitcoinTestnetAddress),
1731
+ string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress)
1732
+ ]);
1733
+ var dotAddress = zod.z.union([
1734
+ string,
1735
+ hexString
1736
+ ]).transform((arg) => {
1737
+ try {
1738
+ if (arg.startsWith("0x")) {
1739
+ return utilCrypto.encodeAddress(util.hexToU8a(arg));
1740
+ }
1741
+ utilCrypto.decodeAddress(arg);
1742
+ return arg;
1743
+ } catch {
1744
+ return null;
1745
+ }
1746
+ }).refine(isString);
1747
+ var ethereumAddress = hexString.refine((address) => ethers__namespace.utils.isAddress(address));
1748
+ numericString.transform((arg) => BigInt(arg));
1749
+ var u128 = zod.z.union([
1750
+ numericString,
1751
+ hexString
1752
+ ]).transform((arg) => BigInt(arg));
1753
+ zod.z.union([
1754
+ u128,
1755
+ zod.z.number().transform((n) => BigInt(n))
1756
+ ]);
1757
+ zod.z.object({
1758
+ __kind: zod.z.enum([
1759
+ "Usdc",
1760
+ "Flip",
1761
+ "Dot",
1762
+ "Eth",
1763
+ "Btc"
1764
+ ])
1765
+ }).transform(({ __kind }) => __kind.toUpperCase());
1766
+ zod.z.nativeEnum(Chains);
1767
+ zod.z.nativeEnum(Assets);
1768
+ var chainflipNetwork = zod.z.nativeEnum(ChainflipNetworks);
1769
+
1770
+ // ../shared/src/vault/schemas.ts
1771
+ var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
1772
+ ...arr
1773
+ ].map((v) => v.toString(16).padStart(2, "0")).join("")}`, "bytesToHex");
1774
+ var utf8ToHex = /* @__PURE__ */ __name((str) => `0x${Buffer.from(str).toString("hex")}`, "utf8ToHex");
1775
+ var base = zod.z.object({
1776
+ amount: zod.z.union([
1777
+ numericString,
1778
+ hexString,
1779
+ zod.z.bigint()
1780
+ ])
1781
+ });
1782
+ var ethereumBase = base.extend({
1783
+ destChain: zod.z.literal(Chains.Ethereum),
1784
+ destAddress: ethereumAddress
1785
+ });
1786
+ var polkadotBase = base.extend({
1787
+ destChain: zod.z.literal(Chains.Polkadot),
1788
+ destAddress: dotAddress.transform((addr) => bytesToHex(utilCrypto.decodeAddress(addr)))
1789
+ });
1790
+ var bitcoinBase = base.extend({
1791
+ destChain: zod.z.literal(Chains.Bitcoin),
1792
+ destAddress: btcAddress.transform(utf8ToHex)
1793
+ });
1794
+ var erc20 = zod.z.union([
1795
+ zod.z.literal(Assets.FLIP),
1796
+ zod.z.literal(Assets.USDC)
1797
+ ]);
1798
+ var ethereumNative = ethereumBase.extend({
1799
+ destAsset: erc20
1800
+ }).strict();
1801
+ var polkadotNative = polkadotBase.extend({
1802
+ destAsset: zod.z.literal(Assets.DOT)
1803
+ }).strict();
1804
+ var bitcoinNative = bitcoinBase.extend({
1805
+ destAsset: zod.z.literal(Assets.BTC)
1806
+ }).strict();
1807
+ var nativeSwapParamsSchema = zod.z.union([
1808
+ ethereumNative,
1809
+ polkadotNative,
1810
+ bitcoinNative
1811
+ ]);
1812
+ var tokenSwapParamsSchema = zod.z.union([
1813
+ ethereumBase.extend({
1814
+ srcAsset: zod.z.literal(Assets.FLIP),
1815
+ destAsset: zod.z.union([
1816
+ zod.z.literal(Assets.USDC),
1817
+ zod.z.literal(Assets.ETH)
1818
+ ])
1819
+ }),
1820
+ ethereumBase.extend({
1821
+ srcAsset: zod.z.literal(Assets.USDC),
1822
+ destAsset: zod.z.union([
1823
+ zod.z.literal(Assets.FLIP),
1824
+ zod.z.literal(Assets.ETH)
1825
+ ])
1826
+ }),
1827
+ polkadotNative.extend({
1828
+ srcAsset: erc20
1829
+ }),
1830
+ bitcoinNative.extend({
1831
+ srcAsset: erc20
1832
+ })
1833
+ ]);
1834
+ var executeSwapParamsSchema = zod.z.union([
1835
+ nativeSwapParamsSchema,
1836
+ tokenSwapParamsSchema
1837
+ ]);
1838
+ var nativeCallParamsSchema = ethereumBase.extend({
1839
+ destAsset: erc20,
1840
+ message: zod.z.string(),
1841
+ gasAmount: numericString
1842
+ }).strict();
1843
+ var tokenCallParamsSchema = zod.z.union([
1844
+ ethereumBase.extend({
1845
+ srcAsset: zod.z.literal(Assets.FLIP),
1846
+ destAsset: zod.z.union([
1847
+ zod.z.literal(Assets.USDC),
1848
+ zod.z.literal(Assets.ETH)
1849
+ ]),
1850
+ message: hexString,
1851
+ gasAmount: numericString
1852
+ }),
1853
+ ethereumBase.extend({
1854
+ srcAsset: zod.z.literal(Assets.USDC),
1855
+ destAsset: zod.z.union([
1856
+ zod.z.literal(Assets.FLIP),
1857
+ zod.z.literal(Assets.ETH)
1858
+ ]),
1859
+ message: hexString,
1860
+ gasAmount: numericString
1861
+ })
1862
+ ]);
1863
+ var executeCallParamsSchema = zod.z.union([
1864
+ nativeCallParamsSchema,
1865
+ tokenCallParamsSchema
1866
+ ]);
1867
+ var executeOptionsSchema = zod.z.intersection(zod.z.object({
1868
+ signer: zod.z.instanceof(ethers.Signer),
1869
+ nonce: zod.z.union([
1870
+ zod.z.number(),
1871
+ zod.z.bigint(),
1872
+ zod.z.string()
1873
+ ]).optional()
1874
+ }), zod.z.union([
1875
+ zod.z.object({
1876
+ network: chainflipNetwork
1877
+ }),
1878
+ zod.z.object({
1879
+ network: zod.z.literal("localnet"),
1880
+ vaultContractAddress: zod.z.string(),
1881
+ srcTokenContractAddress: zod.z.string().optional()
1882
+ })
1883
+ ]));
1884
+
1885
+ // ../shared/src/vault/executeSwap.ts
1886
+ var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, { nonce, ...opts }) => {
1887
+ const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
1888
+ const vault = Vault__factory.connect(vaultContractAddress, opts.signer);
1889
+ const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], [], {
1890
+ value: amount,
1891
+ nonce
1892
+ });
1893
+ return transaction.wait(1);
1894
+ }, "swapNative");
1895
+ var swapToken = /* @__PURE__ */ __name(async (params, opts) => {
1896
+ const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
1897
+ const erc20Address = opts.network === "localnet" ? opts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, opts.network);
1898
+ assert(erc20Address !== void 0, "Missing ERC20 contract address");
1899
+ const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, opts.signer);
1900
+ assert(isAllowable, "Swap amount exceeds allowance");
1901
+ const vault = Vault__factory.connect(vaultContractAddress, opts.signer);
1902
+ const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, [], {
1903
+ nonce: opts.nonce
1904
+ });
1905
+ return transaction.wait(1);
1906
+ }, "swapToken");
1907
+ var executeSwap = /* @__PURE__ */ __name(async (params, options) => {
1908
+ const parsedParams = executeSwapParamsSchema.parse(params);
1909
+ const opts = executeOptionsSchema.parse(options);
1910
+ return isTokenSwap(parsedParams) ? swapToken(parsedParams, opts) : swapNative(parsedParams, opts);
1911
+ }, "executeSwap");
1912
+ var executeSwap_default = executeSwap;
1913
+
1914
+ // ../shared/src/vault/executeCall.ts
1915
+ var callNative = /* @__PURE__ */ __name(async (params, { nonce, ...opts }) => {
1916
+ const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
1917
+ const vault = Vault__factory.connect(vaultContractAddress, opts.signer);
1918
+ const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasAmount, [], {
1919
+ value: params.amount,
1920
+ nonce
1921
+ });
1922
+ return transaction.wait(1);
1923
+ }, "callNative");
1924
+ var callToken = /* @__PURE__ */ __name(async (params, { signer, ...opts }) => {
1925
+ const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
1926
+ const erc20Address = opts.network === "localnet" ? opts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, opts.network);
1927
+ assert(erc20Address !== void 0, "Missing ERC20 contract address");
1928
+ const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, signer);
1929
+ assert(isAllowable, "Swap amount exceeds allowance");
1930
+ const vault = Vault__factory.connect(vaultContractAddress, signer);
1931
+ const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasAmount, erc20Address, params.amount, [], {
1932
+ nonce: opts.nonce
1933
+ });
1934
+ return transaction.wait(1);
1935
+ }, "callToken");
1936
+ var executeCall = /* @__PURE__ */ __name(async (params, options) => {
1937
+ const parsedParams = executeCallParamsSchema.parse(params);
1938
+ const opts = executeOptionsSchema.parse(options);
1939
+ return isTokenCall(parsedParams) ? callToken(parsedParams, opts) : callNative(parsedParams, opts);
1940
+ }, "executeCall");
1941
+ var executeCall_default = executeCall;
1942
+
1943
+ // ../shared/src/vault/approval.ts
1944
+ var checkVaultAllowance = /* @__PURE__ */ __name((params, opts) => {
1945
+ const erc20Address = opts.network === "localnet" ? opts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, opts.network);
1946
+ assert(erc20Address !== void 0, "Missing ERC20 contract address");
1947
+ const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
1948
+ return checkAllowance(params.amount, vaultContractAddress, erc20Address, opts.signer);
1949
+ }, "checkVaultAllowance");
1950
+ var approveVault = /* @__PURE__ */ __name(async (params, opts) => {
1951
+ const { isAllowable, erc20: erc202, allowance } = await checkVaultAllowance(params, opts);
1952
+ if (isAllowable)
1953
+ return null;
1954
+ const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
1955
+ return approve(params.amount, vaultContractAddress, erc202, allowance, opts.nonce);
1956
+ }, "approveVault");
1957
+
1958
+ // src/swap/consts.ts
1959
+ var BACKEND_SERVICE_URLS = {
1960
+ [ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
1961
+ [ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/",
1962
+ [ChainflipNetworks.partnernet]: "https://chainflip-swap-partnernet.chainflip.io/"
1963
+ };
1964
+
1965
+ // src/swap/mocks.ts
1966
+ var ethereum = {
1967
+ id: Chains.Ethereum,
1968
+ name: "Ethereum",
1969
+ isMainnet: true
1970
+ };
1971
+ var polkadot = {
1972
+ id: Chains.Polkadot,
1973
+ name: "Polkadot",
1974
+ isMainnet: true
1975
+ };
1976
+ var bitcoin = {
1977
+ id: Chains.Bitcoin,
1978
+ name: "Bitcoin",
1979
+ isMainnet: true
1980
+ };
1981
+ var ethereumAssets = [
1982
+ {
1983
+ id: Assets.ETH,
1984
+ chain: Chains.Ethereum,
1985
+ contractAddress: "0xeth",
1986
+ decimals: assetDecimals[Assets.ETH],
1987
+ name: "ether",
1988
+ symbol: "ETH",
1989
+ isMainnet: true
1990
+ },
1991
+ {
1992
+ id: Assets.USDC,
1993
+ chain: Chains.Ethereum,
1994
+ contractAddress: "0xusdc",
1995
+ decimals: assetDecimals[Assets.USDC],
1996
+ name: "usdc",
1997
+ symbol: "USDC",
1998
+ isMainnet: true
1999
+ },
2000
+ {
2001
+ id: Assets.FLIP,
2002
+ chain: Chains.Ethereum,
2003
+ contractAddress: "0xflip",
2004
+ decimals: assetDecimals[Assets.FLIP],
2005
+ name: "flip",
2006
+ symbol: "FLIP",
2007
+ isMainnet: true
2008
+ }
2009
+ ];
2010
+ var dot$ = {
2011
+ id: Assets.DOT,
2012
+ chain: Chains.Polkadot,
2013
+ contractAddress: "0xdot",
2014
+ decimals: assetDecimals[Assets.DOT],
2015
+ name: "dot",
2016
+ symbol: "DOT",
2017
+ isMainnet: true
2018
+ };
2019
+ var btc$ = {
2020
+ id: Assets.BTC,
2021
+ chain: Chains.Bitcoin,
2022
+ contractAddress: "0xbitcoin",
2023
+ decimals: assetDecimals[Assets.BTC],
2024
+ name: "bitcoin",
2025
+ symbol: "BTC",
2026
+ isMainnet: true
2027
+ };
2028
+ var testnetChains = /* @__PURE__ */ __name((chains) => chains.map((chain) => ({
2029
+ ...chain,
2030
+ isMainnet: false
2031
+ })), "testnetChains");
2032
+ var testnetAssets = /* @__PURE__ */ __name((assets) => assets.map((asset) => ({
2033
+ ...asset,
2034
+ isMainnet: false
2035
+ })), "testnetAssets");
2036
+
2037
+ // src/swap/services/ApiService.ts
2038
+ var getChains = /* @__PURE__ */ __name(async (network) => {
2039
+ if (isTestnet(network)) {
2040
+ return testnetChains([
2041
+ ethereum,
2042
+ polkadot,
2043
+ bitcoin
2044
+ ]);
2045
+ }
2046
+ return [
2047
+ ethereum,
2048
+ polkadot,
2049
+ bitcoin
2050
+ ];
2051
+ }, "getChains");
2052
+ var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, network) => {
2053
+ if (isTestnet(network)) {
2054
+ if (sourceChain === Chains.Ethereum)
2055
+ return testnetChains([
2056
+ polkadot,
2057
+ bitcoin
2058
+ ]);
2059
+ if (sourceChain === Chains.Polkadot)
2060
+ return testnetChains([
2061
+ ethereum,
2062
+ bitcoin
2063
+ ]);
2064
+ if (sourceChain === Chains.Bitcoin)
2065
+ return testnetChains([
2066
+ ethereum,
2067
+ polkadot
2068
+ ]);
2069
+ throw new Error("received testnet flag but mainnet chain");
2070
+ }
2071
+ if (sourceChain === Chains.Ethereum)
2072
+ return [
2073
+ bitcoin,
2074
+ polkadot
2075
+ ];
2076
+ if (sourceChain === Chains.Polkadot)
2077
+ return [
2078
+ ethereum,
2079
+ bitcoin
2080
+ ];
2081
+ if (sourceChain === Chains.Bitcoin)
2082
+ return [
2083
+ ethereum,
2084
+ polkadot
2085
+ ];
2086
+ throw new Error("received unknown chain");
2087
+ }, "getPossibleDestinationChains");
2088
+ var getAssets = /* @__PURE__ */ __name(async (chain, network) => {
2089
+ if (isTestnet(network)) {
2090
+ if (chain === Chains.Ethereum)
2091
+ return testnetAssets(ethereumAssets);
2092
+ if (chain === Chains.Polkadot)
2093
+ return testnetAssets([
2094
+ dot$
2095
+ ]);
2096
+ if (chain === Chains.Bitcoin)
2097
+ return testnetAssets([
2098
+ btc$
2099
+ ]);
2100
+ throw new Error("received testnet flag but mainnet chain");
2101
+ }
2102
+ if (chain === Chains.Ethereum)
2103
+ return ethereumAssets;
2104
+ if (chain === Chains.Polkadot)
2105
+ return [
2106
+ dot$
2107
+ ];
2108
+ if (chain === Chains.Bitcoin)
2109
+ return [
2110
+ btc$
2111
+ ];
2112
+ throw new Error("received unknown chain");
2113
+ }, "getAssets");
2114
+ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
2115
+ const params = {
2116
+ amount: quoteRequest.amount,
2117
+ srcAsset: quoteRequest.srcAsset,
2118
+ destAsset: quoteRequest.destAsset
2119
+ };
2120
+ const queryParams = new URLSearchParams(params);
2121
+ const url = new URL(`/quote?${queryParams.toString()}`, baseUrl).toString();
2122
+ const { data } = await axios__default.default.get(url, {
2123
+ signal
2124
+ });
2125
+ return {
2126
+ ...quoteRequest,
2127
+ quote: data
2128
+ };
2129
+ }, "getQuote");
2130
+ var requestDepositAddress = /* @__PURE__ */ __name(async (baseUrl, depositAddressRequest, { signal }) => {
2131
+ const body = {
2132
+ destAddress: depositAddressRequest.destAddress,
2133
+ srcAsset: depositAddressRequest.srcAsset,
2134
+ destAsset: depositAddressRequest.destAsset,
2135
+ srcChain: depositAddressRequest.srcChain,
2136
+ destChain: depositAddressRequest.destChain,
2137
+ amount: depositAddressRequest.amount,
2138
+ ccmMetadata: depositAddressRequest.ccmMetadata
2139
+ };
2140
+ const url = new URL("/swaps", baseUrl).toString();
2141
+ const { data } = await axios__default.default.post(url, body, {
2142
+ signal
2143
+ });
2144
+ return {
2145
+ ...depositAddressRequest,
2146
+ depositChannelId: data.id,
2147
+ depositAddress: data.depositAddress
2148
+ };
2149
+ }, "requestDepositAddress");
2150
+ var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
2151
+ const url = new URL(`/swaps/${id}`, baseUrl).toString();
2152
+ const { data } = await axios__default.default.get(url, {
2153
+ signal
2154
+ });
2155
+ return data;
2156
+ }, "getStatus");
2157
+ var ApiService_default = {
2158
+ getChains,
2159
+ getPossibleDestinationChains,
2160
+ getQuote,
2161
+ getAssets,
2162
+ getStatus,
2163
+ requestDepositAddress
2164
+ };
2165
+
2166
+ // src/swap/sdk.ts
2167
+ var SwapSDK = class {
2168
+ constructor(options = {}) {
2169
+ this.network = options.network ?? ChainflipNetworks.partnernet;
2170
+ this.baseUrl = options.backendUrl ?? BACKEND_SERVICE_URLS[this.network];
2171
+ this.signer = options.signer;
2172
+ }
2173
+ getChains(sourceChain) {
2174
+ if (sourceChain !== void 0) {
2175
+ return ApiService_default.getPossibleDestinationChains(sourceChain, this.network);
2176
+ }
2177
+ return ApiService_default.getChains(this.network);
2178
+ }
2179
+ getAssets(chain) {
2180
+ return ApiService_default.getAssets(chain, this.network);
2181
+ }
2182
+ getQuote(quoteRequest, options = {}) {
2183
+ return ApiService_default.getQuote(this.baseUrl, quoteRequest, options);
2184
+ }
2185
+ requestDepositAddress(depositAddressRequest, options = {}) {
2186
+ return ApiService_default.requestDepositAddress(this.baseUrl, depositAddressRequest, options);
2187
+ }
2188
+ getStatus(swapStatusRequest, options = {}) {
2189
+ return ApiService_default.getStatus(this.baseUrl, swapStatusRequest, options);
2190
+ }
2191
+ async executeSwap(params) {
2192
+ assert(this.signer, "No signer provided");
2193
+ const receipt = await executeSwap_default(params, {
2194
+ network: this.network,
2195
+ signer: this.signer
2196
+ });
2197
+ return receipt.transactionHash;
2198
+ }
2199
+ async executeCall(params) {
2200
+ assert(this.signer, "No signer provided");
2201
+ const receipt = await executeCall_default(params, {
2202
+ network: this.network,
2203
+ signer: this.signer
2204
+ });
2205
+ return receipt.transactionHash;
2206
+ }
2207
+ async approveVault(params, options = {}) {
2208
+ if (!("srcAsset" in params))
2209
+ return null;
2210
+ assert(this.signer, "No signer provided");
2211
+ const receipt = await approveVault(params, {
2212
+ signer: this.signer,
2213
+ network: this.network,
2214
+ ...options
2215
+ });
2216
+ return receipt && receipt.transactionHash;
2217
+ }
2218
+ };
2219
+ __name(SwapSDK, "SwapSDK");
2220
+
2221
+ exports.Assets = Assets;
2222
+ exports.ChainflipNetworks = ChainflipNetworks;
2223
+ exports.Chains = Chains;
2224
+ exports.SwapSDK = SwapSDK;
2225
+ exports.assetChains = assetChains;
2226
+ exports.assetContractIds = assetContractIds;
2227
+ exports.assetDecimals = assetDecimals;
2228
+ exports.chainAssets = chainAssets;
2229
+ exports.chainContractIds = chainContractIds;