@reyaxyz/sdk 0.64.1 → 0.66.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/README.md +1 -1
- package/dist/abis/Periphery.json +90 -236
- package/dist/services/lp/bridgeAndDepositPassivePool.js +1 -1
- package/dist/services/lp/bridgeAndDepositPassivePool.js.map +1 -1
- package/dist/services/lp/encode.js +5 -11
- package/dist/services/lp/encode.js.map +1 -1
- package/dist/services/lp/transferFromMAToPool.js +5 -3
- package/dist/services/lp/transferFromMAToPool.js.map +1 -1
- package/dist/services/lp/withdrawPassivePoolAndBridge.js +3 -5
- package/dist/services/lp/withdrawPassivePoolAndBridge.js.map +1 -1
- package/dist/services/margin-accounts/bridgeAndDepositExistingMA.js +1 -1
- package/dist/services/margin-accounts/bridgeAndDepositExistingMA.js.map +1 -1
- package/dist/services/margin-accounts/bridgeAndDepositNewMA.js +1 -1
- package/dist/services/margin-accounts/bridgeAndDepositNewMA.js.map +1 -1
- package/dist/services/margin-accounts/encode.js +18 -27
- package/dist/services/margin-accounts/encode.js.map +1 -1
- package/dist/services/margin-accounts/transferMarginBetweenAccounts.js +1 -1
- package/dist/services/margin-accounts/transferMarginBetweenAccounts.js.map +1 -1
- package/dist/services/margin-accounts/withdrawMAAndBridge.js +6 -11
- package/dist/services/margin-accounts/withdrawMAAndBridge.js.map +1 -1
- package/dist/services/orders/encode.js +2 -1
- package/dist/services/orders/encode.js.map +1 -1
- package/dist/services/sign.js +5 -3
- package/dist/services/sign.js.map +1 -1
- package/dist/types/services/lp/bridgeAndDepositPassivePool.d.ts.map +1 -1
- package/dist/types/services/lp/encode.d.ts +2 -2
- package/dist/types/services/lp/encode.d.ts.map +1 -1
- package/dist/types/services/lp/transferFromMAToPool.d.ts.map +1 -1
- package/dist/types/services/lp/withdrawPassivePoolAndBridge.d.ts.map +1 -1
- package/dist/types/services/margin-accounts/bridgeAndDepositExistingMA.d.ts.map +1 -1
- package/dist/types/services/margin-accounts/bridgeAndDepositNewMA.d.ts.map +1 -1
- package/dist/types/services/margin-accounts/encode.d.ts +3 -3
- package/dist/types/services/margin-accounts/encode.d.ts.map +1 -1
- package/dist/types/services/margin-accounts/withdrawMAAndBridge.d.ts.map +1 -1
- package/dist/types/services/orders/encode.d.ts.map +1 -1
- package/dist/types/services/sign.d.ts +2 -2
- package/dist/types/services/sign.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/abis/Periphery.json +90 -236
- package/src/services/lp/bridgeAndDepositPassivePool.ts +0 -3
- package/src/services/lp/encode.ts +5 -15
- package/src/services/lp/transferFromMAToPool.ts +8 -1
- package/src/services/lp/withdrawPassivePoolAndBridge.ts +4 -7
- package/src/services/margin-accounts/bridgeAndDepositExistingMA.ts +0 -3
- package/src/services/margin-accounts/bridgeAndDepositNewMA.ts +0 -3
- package/src/services/margin-accounts/encode.ts +18 -33
- package/src/services/margin-accounts/transferMarginBetweenAccounts.ts +1 -1
- package/src/services/margin-accounts/withdrawMAAndBridge.ts +12 -16
- package/src/services/orders/encode.ts +2 -0
- package/src/services/sign.ts +10 -2
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
package/dist/abis/Periphery.json
CHANGED
|
@@ -202,6 +202,10 @@
|
|
|
202
202
|
"name": "ZeroAddress",
|
|
203
203
|
"inputs": []
|
|
204
204
|
},
|
|
205
|
+
{
|
|
206
|
+
"type": "receive",
|
|
207
|
+
"stateMutability": "payable"
|
|
208
|
+
},
|
|
205
209
|
{
|
|
206
210
|
"type": "function",
|
|
207
211
|
"name": "getGlobalConfiguration",
|
|
@@ -232,6 +236,30 @@
|
|
|
232
236
|
],
|
|
233
237
|
"stateMutability": "pure"
|
|
234
238
|
},
|
|
239
|
+
{
|
|
240
|
+
"type": "function",
|
|
241
|
+
"name": "getTokenChainConnector",
|
|
242
|
+
"inputs": [
|
|
243
|
+
{
|
|
244
|
+
"name": "token",
|
|
245
|
+
"type": "address",
|
|
246
|
+
"internalType": "address"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"name": "chainId",
|
|
250
|
+
"type": "uint256",
|
|
251
|
+
"internalType": "uint256"
|
|
252
|
+
}
|
|
253
|
+
],
|
|
254
|
+
"outputs": [
|
|
255
|
+
{
|
|
256
|
+
"name": "connector",
|
|
257
|
+
"type": "address",
|
|
258
|
+
"internalType": "address"
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
"stateMutability": "view"
|
|
262
|
+
},
|
|
235
263
|
{
|
|
236
264
|
"type": "function",
|
|
237
265
|
"name": "getTokenController",
|
|
@@ -365,6 +393,29 @@
|
|
|
365
393
|
"outputs": [],
|
|
366
394
|
"stateMutability": "nonpayable"
|
|
367
395
|
},
|
|
396
|
+
{
|
|
397
|
+
"type": "function",
|
|
398
|
+
"name": "setTokenChainConnector",
|
|
399
|
+
"inputs": [
|
|
400
|
+
{
|
|
401
|
+
"name": "token",
|
|
402
|
+
"type": "address",
|
|
403
|
+
"internalType": "address"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"name": "chainId",
|
|
407
|
+
"type": "uint256",
|
|
408
|
+
"internalType": "uint256"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"name": "connector",
|
|
412
|
+
"type": "address",
|
|
413
|
+
"internalType": "address"
|
|
414
|
+
}
|
|
415
|
+
],
|
|
416
|
+
"outputs": [],
|
|
417
|
+
"stateMutability": "nonpayable"
|
|
418
|
+
},
|
|
368
419
|
{
|
|
369
420
|
"type": "function",
|
|
370
421
|
"name": "setTokenController",
|
|
@@ -424,6 +475,22 @@
|
|
|
424
475
|
"outputs": [],
|
|
425
476
|
"stateMutability": "nonpayable"
|
|
426
477
|
},
|
|
478
|
+
{
|
|
479
|
+
"type": "error",
|
|
480
|
+
"name": "ConnectorNotRegistered",
|
|
481
|
+
"inputs": [
|
|
482
|
+
{
|
|
483
|
+
"name": "token",
|
|
484
|
+
"type": "address",
|
|
485
|
+
"internalType": "address"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"name": "chainId",
|
|
489
|
+
"type": "uint256",
|
|
490
|
+
"internalType": "uint256"
|
|
491
|
+
}
|
|
492
|
+
]
|
|
493
|
+
},
|
|
427
494
|
{
|
|
428
495
|
"type": "error",
|
|
429
496
|
"name": "ControllerNotRegistered",
|
|
@@ -490,11 +557,6 @@
|
|
|
490
557
|
"name": "token",
|
|
491
558
|
"type": "address",
|
|
492
559
|
"internalType": "address"
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
"name": "tokenAmount",
|
|
496
|
-
"type": "uint256",
|
|
497
|
-
"internalType": "uint256"
|
|
498
560
|
}
|
|
499
561
|
]
|
|
500
562
|
}
|
|
@@ -520,11 +582,6 @@
|
|
|
520
582
|
"name": "token",
|
|
521
583
|
"type": "address",
|
|
522
584
|
"internalType": "address"
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
"name": "tokenAmount",
|
|
526
|
-
"type": "uint256",
|
|
527
|
-
"internalType": "uint256"
|
|
528
585
|
}
|
|
529
586
|
]
|
|
530
587
|
}
|
|
@@ -557,11 +614,6 @@
|
|
|
557
614
|
"type": "address",
|
|
558
615
|
"internalType": "address"
|
|
559
616
|
},
|
|
560
|
-
{
|
|
561
|
-
"name": "amount",
|
|
562
|
-
"type": "uint256",
|
|
563
|
-
"internalType": "uint256"
|
|
564
|
-
},
|
|
565
617
|
{
|
|
566
618
|
"name": "minShares",
|
|
567
619
|
"type": "uint256",
|
|
@@ -575,26 +627,15 @@
|
|
|
575
627
|
},
|
|
576
628
|
{
|
|
577
629
|
"type": "error",
|
|
578
|
-
"name": "
|
|
630
|
+
"name": "CallerIsNotExecutionHelper",
|
|
579
631
|
"inputs": [
|
|
580
632
|
{
|
|
581
|
-
"name": "
|
|
582
|
-
"type": "
|
|
583
|
-
"internalType": "
|
|
633
|
+
"name": "caller",
|
|
634
|
+
"type": "address",
|
|
635
|
+
"internalType": "address"
|
|
584
636
|
},
|
|
585
637
|
{
|
|
586
|
-
"name": "
|
|
587
|
-
"type": "uint256",
|
|
588
|
-
"internalType": "uint256"
|
|
589
|
-
}
|
|
590
|
-
]
|
|
591
|
-
},
|
|
592
|
-
{
|
|
593
|
-
"type": "error",
|
|
594
|
-
"name": "CheckSelfCall",
|
|
595
|
-
"inputs": [
|
|
596
|
-
{
|
|
597
|
-
"name": "caller",
|
|
638
|
+
"name": "token",
|
|
598
639
|
"type": "address",
|
|
599
640
|
"internalType": "address"
|
|
600
641
|
}
|
|
@@ -643,199 +684,6 @@
|
|
|
643
684
|
}
|
|
644
685
|
]
|
|
645
686
|
},
|
|
646
|
-
{
|
|
647
|
-
"type": "function",
|
|
648
|
-
"name": "depositExistingMA",
|
|
649
|
-
"inputs": [
|
|
650
|
-
{
|
|
651
|
-
"name": "inputs",
|
|
652
|
-
"type": "tuple",
|
|
653
|
-
"internalType": "struct DepositExistingMAInputs",
|
|
654
|
-
"components": [
|
|
655
|
-
{
|
|
656
|
-
"name": "accountId",
|
|
657
|
-
"type": "uint128",
|
|
658
|
-
"internalType": "uint128"
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
"name": "token",
|
|
662
|
-
"type": "address",
|
|
663
|
-
"internalType": "address"
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
"name": "tokenAmount",
|
|
667
|
-
"type": "uint256",
|
|
668
|
-
"internalType": "uint256"
|
|
669
|
-
}
|
|
670
|
-
]
|
|
671
|
-
},
|
|
672
|
-
{
|
|
673
|
-
"name": "fallbackData",
|
|
674
|
-
"type": "tuple",
|
|
675
|
-
"internalType": "struct FallbackData",
|
|
676
|
-
"components": [
|
|
677
|
-
{
|
|
678
|
-
"name": "socketMsgGasLimit",
|
|
679
|
-
"type": "uint256",
|
|
680
|
-
"internalType": "uint256"
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
"name": "socketPayloadSize",
|
|
684
|
-
"type": "uint256",
|
|
685
|
-
"internalType": "uint256"
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
"name": "socketConnector",
|
|
689
|
-
"type": "address",
|
|
690
|
-
"internalType": "address"
|
|
691
|
-
}
|
|
692
|
-
]
|
|
693
|
-
}
|
|
694
|
-
],
|
|
695
|
-
"outputs": [],
|
|
696
|
-
"stateMutability": "nonpayable"
|
|
697
|
-
},
|
|
698
|
-
{
|
|
699
|
-
"type": "function",
|
|
700
|
-
"name": "depositNewMA",
|
|
701
|
-
"inputs": [
|
|
702
|
-
{
|
|
703
|
-
"name": "inputs",
|
|
704
|
-
"type": "tuple",
|
|
705
|
-
"internalType": "struct DepositNewMAInputs",
|
|
706
|
-
"components": [
|
|
707
|
-
{
|
|
708
|
-
"name": "accountOwner",
|
|
709
|
-
"type": "address",
|
|
710
|
-
"internalType": "address"
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
"name": "token",
|
|
714
|
-
"type": "address",
|
|
715
|
-
"internalType": "address"
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
"name": "tokenAmount",
|
|
719
|
-
"type": "uint256",
|
|
720
|
-
"internalType": "uint256"
|
|
721
|
-
}
|
|
722
|
-
]
|
|
723
|
-
},
|
|
724
|
-
{
|
|
725
|
-
"name": "fallbackData",
|
|
726
|
-
"type": "tuple",
|
|
727
|
-
"internalType": "struct FallbackData",
|
|
728
|
-
"components": [
|
|
729
|
-
{
|
|
730
|
-
"name": "socketMsgGasLimit",
|
|
731
|
-
"type": "uint256",
|
|
732
|
-
"internalType": "uint256"
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
"name": "socketPayloadSize",
|
|
736
|
-
"type": "uint256",
|
|
737
|
-
"internalType": "uint256"
|
|
738
|
-
},
|
|
739
|
-
{
|
|
740
|
-
"name": "socketConnector",
|
|
741
|
-
"type": "address",
|
|
742
|
-
"internalType": "address"
|
|
743
|
-
}
|
|
744
|
-
]
|
|
745
|
-
}
|
|
746
|
-
],
|
|
747
|
-
"outputs": [],
|
|
748
|
-
"stateMutability": "nonpayable"
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
"type": "function",
|
|
752
|
-
"name": "depositPassivePool",
|
|
753
|
-
"inputs": [
|
|
754
|
-
{
|
|
755
|
-
"name": "inputs",
|
|
756
|
-
"type": "tuple",
|
|
757
|
-
"internalType": "struct DepositPassivePoolInputs",
|
|
758
|
-
"components": [
|
|
759
|
-
{
|
|
760
|
-
"name": "poolId",
|
|
761
|
-
"type": "uint128",
|
|
762
|
-
"internalType": "uint128"
|
|
763
|
-
},
|
|
764
|
-
{
|
|
765
|
-
"name": "owner",
|
|
766
|
-
"type": "address",
|
|
767
|
-
"internalType": "address"
|
|
768
|
-
},
|
|
769
|
-
{
|
|
770
|
-
"name": "amount",
|
|
771
|
-
"type": "uint256",
|
|
772
|
-
"internalType": "uint256"
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
"name": "minShares",
|
|
776
|
-
"type": "uint256",
|
|
777
|
-
"internalType": "uint256"
|
|
778
|
-
}
|
|
779
|
-
]
|
|
780
|
-
},
|
|
781
|
-
{
|
|
782
|
-
"name": "fallbackData",
|
|
783
|
-
"type": "tuple",
|
|
784
|
-
"internalType": "struct FallbackData",
|
|
785
|
-
"components": [
|
|
786
|
-
{
|
|
787
|
-
"name": "socketMsgGasLimit",
|
|
788
|
-
"type": "uint256",
|
|
789
|
-
"internalType": "uint256"
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
"name": "socketPayloadSize",
|
|
793
|
-
"type": "uint256",
|
|
794
|
-
"internalType": "uint256"
|
|
795
|
-
},
|
|
796
|
-
{
|
|
797
|
-
"name": "socketConnector",
|
|
798
|
-
"type": "address",
|
|
799
|
-
"internalType": "address"
|
|
800
|
-
}
|
|
801
|
-
]
|
|
802
|
-
}
|
|
803
|
-
],
|
|
804
|
-
"outputs": [],
|
|
805
|
-
"stateMutability": "nonpayable"
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
"type": "error",
|
|
809
|
-
"name": "CallerIsNotExecutionHelper",
|
|
810
|
-
"inputs": [
|
|
811
|
-
{
|
|
812
|
-
"name": "caller",
|
|
813
|
-
"type": "address",
|
|
814
|
-
"internalType": "address"
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
"name": "token",
|
|
818
|
-
"type": "address",
|
|
819
|
-
"internalType": "address"
|
|
820
|
-
}
|
|
821
|
-
]
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
"type": "error",
|
|
825
|
-
"name": "NotEnoughFees",
|
|
826
|
-
"inputs": [
|
|
827
|
-
{
|
|
828
|
-
"name": "tokenAmount",
|
|
829
|
-
"type": "uint256",
|
|
830
|
-
"internalType": "uint256"
|
|
831
|
-
},
|
|
832
|
-
{
|
|
833
|
-
"name": "tokenFees",
|
|
834
|
-
"type": "uint256",
|
|
835
|
-
"internalType": "uint256"
|
|
836
|
-
}
|
|
837
|
-
]
|
|
838
|
-
},
|
|
839
687
|
{
|
|
840
688
|
"type": "function",
|
|
841
689
|
"name": "executeMatchOrders",
|
|
@@ -1175,15 +1023,10 @@
|
|
|
1175
1023
|
"internalType": "uint256"
|
|
1176
1024
|
},
|
|
1177
1025
|
{
|
|
1178
|
-
"name": "
|
|
1026
|
+
"name": "chainId",
|
|
1179
1027
|
"type": "uint256",
|
|
1180
1028
|
"internalType": "uint256"
|
|
1181
1029
|
},
|
|
1182
|
-
{
|
|
1183
|
-
"name": "socketConnector",
|
|
1184
|
-
"type": "address",
|
|
1185
|
-
"internalType": "address"
|
|
1186
|
-
},
|
|
1187
1030
|
{
|
|
1188
1031
|
"name": "receiver",
|
|
1189
1032
|
"type": "address",
|
|
@@ -1257,15 +1100,10 @@
|
|
|
1257
1100
|
"internalType": "uint256"
|
|
1258
1101
|
},
|
|
1259
1102
|
{
|
|
1260
|
-
"name": "
|
|
1103
|
+
"name": "chainId",
|
|
1261
1104
|
"type": "uint256",
|
|
1262
1105
|
"internalType": "uint256"
|
|
1263
1106
|
},
|
|
1264
|
-
{
|
|
1265
|
-
"name": "socketConnector",
|
|
1266
|
-
"type": "address",
|
|
1267
|
-
"internalType": "address"
|
|
1268
|
-
},
|
|
1269
1107
|
{
|
|
1270
1108
|
"name": "receiver",
|
|
1271
1109
|
"type": "address",
|
|
@@ -1277,6 +1115,22 @@
|
|
|
1277
1115
|
"outputs": [],
|
|
1278
1116
|
"stateMutability": "nonpayable"
|
|
1279
1117
|
},
|
|
1118
|
+
{
|
|
1119
|
+
"type": "error",
|
|
1120
|
+
"name": "NotEnoughFees",
|
|
1121
|
+
"inputs": [
|
|
1122
|
+
{
|
|
1123
|
+
"name": "tokenAmount",
|
|
1124
|
+
"type": "uint256",
|
|
1125
|
+
"internalType": "uint256"
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
"name": "tokenFees",
|
|
1129
|
+
"type": "uint256",
|
|
1130
|
+
"internalType": "uint256"
|
|
1131
|
+
}
|
|
1132
|
+
]
|
|
1133
|
+
},
|
|
1280
1134
|
{
|
|
1281
1135
|
"type": "function",
|
|
1282
1136
|
"name": "onERC721Received",
|
|
@@ -60,7 +60,7 @@ var bridgeAndDepositPassivePool = function (params) { return __awaiter(void 0, v
|
|
|
60
60
|
peripheryAddress = (0, contractAddresses_1.getAddress)((0, common_1.getReyaNetworkFromMoneyInOutChainId)(moneyInOutChainId), contractAddresses_1.ContractType.PERIPHERY_PROXY);
|
|
61
61
|
_a = (0, encode_1.encodeBridgeAndDepositPassivePool)(peripheryAddress, BigInt('10000000'), socketConnectors.deposit, '0x', (0, common_1.getSocketDepositFeesAsBigInt)({
|
|
62
62
|
moneyInOutChainId: moneyInOutChainId,
|
|
63
|
-
}), params.pool.id, params.ownerAddress, amount, BigInt(0)
|
|
63
|
+
}), params.pool.id, params.ownerAddress, amount, BigInt(0)), data = _a.calldata, value = _a.value;
|
|
64
64
|
return [4 /*yield*/, (0, executeTransaction_1.executeTransaction)(params.signer, data, value, moneyInOutChainId, (0, common_1.getSocketVault)({
|
|
65
65
|
moneyInOutChainId: moneyInOutChainId,
|
|
66
66
|
tokenName: tokenInfo.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeAndDepositPassivePool.js","sourceRoot":"/","sources":["services/lp/bridgeAndDepositPassivePool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAQyB;AACzB,uCAAyD;AACzD,mEAAyE;AACzE,4DAA2D;AAC3D,mCAA6D;AAQtD,IAAM,2BAA2B,GAAG,UACzC,MAAyC;;;;;oBAEzB,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,iBAAiB,GAAsB,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAEhE,SAAS,GAAG,IAAA,mCAA0B,EAAC,iBAAiB,CAAC,CAAC;gBAE1D,MAAM,GAAG,IAAA,cAAK,EAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAElD,gBAAgB,GAAG,IAAA,4BAAmB,EAAC;oBAC3C,iBAAiB,EAAE,iBAAiB;oBACpC,SAAS,EAAE,SAAS,CAAC,IAAI;iBAC1B,CAAC,CAAC;gBAEG,gBAAgB,GAAG,IAAA,8BAAU,EACjC,IAAA,4CAAmC,EAAC,iBAAiB,CAAC,EACtD,gCAAY,CAAC,eAAe,CAC7B,CAAC;gBAEI,KAA4B,IAAA,0CAAiC,EACjE,gBAAgB,EAChB,MAAM,CAAC,UAAU,CAAC,EAClB,gBAAgB,CAAC,OAAO,EACxB,IAAI,EACJ,IAAA,qCAA4B,EAAC;oBAC3B,iBAAiB,EAAE,iBAAiB;iBACrC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ACnB,MAAM,EACN,MAAM,CAAC,CAAC,CAAC,CACV,EAZiB,IAAI,cAAA,EAAE,KAAK,WAAA,CAY3B;gBAEa,qBAAM,IAAA,uCAAkB,EACrC,MAAM,CAAC,MAAM,EACb,IAAI,EACJ,KAAK,EACL,iBAAiB,EACjB,IAAA,uBAAc,EAAC;wBACb,iBAAiB,EAAE,iBAAiB;wBACpC,SAAS,EAAE,SAAS,CAAC,IAAI;qBAC1B,CAAC,CACH,EAAA;;gBATK,MAAM,GAAG,SASd;gBAED,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,IAAI;qBACtC,EAAC;;;KACH,CAAC;AAhDW,QAAA,2BAA2B,+BAgDtC;AAEK,IAAM,0CAA0C,GAAG,UACxD,MAAwD;;;;;gBAElD,gBAAgB,GAAG,IAAA,kCAAyB,GAAE,CAAC;gBACrD,qBAAM,gBAAgB,CAAC,sBAAsB,CAAC;wBAC5C,aAAa,EAAE,MAAM,CAAC,YAAY;wBAClC,IAAI,EAAE,MAAM,CAAC,UAAU;qBACxB,CAAC,EAAA;;gBAHF,SAGE,CAAC;gBAEI,qBAAM,IAAA,mCAA2B,EAAC,MAAM,CAAC,EAAA;oBAAhD,sBAAO,SAAyC,EAAC;;;KAClD,CAAC;AAVW,QAAA,0CAA0C,8CAUrD","sourcesContent":["import {\n getSocketDepositFeesAsBigInt,\n getSocketVault,\n scale,\n MoneyInOutChainId,\n getSocketConnectors,\n getReyaNetworkFromMoneyInOutChainId,\n getRUSDUnderlyingTokenInfo,\n} from '@reyaxyz/common';\nimport { getAlphaTermsModuleClient } from '../../config';\nimport { ContractType, getAddress } from '../../utils/contractAddresses';\nimport { executeTransaction } from '../executeTransaction';\nimport { encodeBridgeAndDepositPassivePool } from './encode';\nimport {\n BridgeAndDepositPassivePoolParams,\n BridgeAndDepositPassivePoolResult,\n BridgeAndDepositPassivePoolUnderAlphaTermsParams,\n BridgeAndDepositPassivePoolUnderAlphaTermsResult,\n} from './types';\n\nexport const bridgeAndDepositPassivePool = async (\n params: BridgeAndDepositPassivePoolParams,\n): Promise<BridgeAndDepositPassivePoolResult> => {\n const network = await params.signer.provider?.getNetwork();\n const moneyInOutChainId: MoneyInOutChainId = Number(network?.chainId);\n\n const tokenInfo = getRUSDUnderlyingTokenInfo(moneyInOutChainId);\n\n const amount = scale(tokenInfo.decimals)(params.amount);\n\n const socketConnectors = getSocketConnectors({\n moneyInOutChainId: moneyInOutChainId,\n tokenName: tokenInfo.name,\n });\n\n const peripheryAddress = getAddress(\n getReyaNetworkFromMoneyInOutChainId(moneyInOutChainId),\n ContractType.PERIPHERY_PROXY,\n );\n\n const { calldata: data, value } = encodeBridgeAndDepositPassivePool(\n peripheryAddress,\n BigInt('10000000'),\n socketConnectors.deposit,\n '0x',\n getSocketDepositFeesAsBigInt({\n moneyInOutChainId: moneyInOutChainId,\n }),\n params.pool.id,\n params.ownerAddress,\n amount,\n BigInt(0),\n );\n\n const result = await executeTransaction(\n params.signer,\n data,\n value,\n moneyInOutChainId,\n getSocketVault({\n moneyInOutChainId: moneyInOutChainId,\n tokenName: tokenInfo.name,\n }),\n );\n\n return {\n transactionHash: result?.hash || null,\n };\n};\n\nexport const bridgeAndDepositPassivePoolUnderAlphaTerms = async (\n params: BridgeAndDepositPassivePoolUnderAlphaTermsParams,\n): Promise<BridgeAndDepositPassivePoolUnderAlphaTermsResult> => {\n const alphaTermsModule = getAlphaTermsModuleClient();\n await alphaTermsModule.registerAlphaSignature({\n walletAddress: params.ownerAddress,\n link: params.signedLink,\n });\n\n return await bridgeAndDepositPassivePool(params);\n};\n"]}
|
|
@@ -36,7 +36,7 @@ var encodeTransferFromMAToPool = function (accountId, amount, sig, poolId, minSh
|
|
|
36
36
|
return { calldata: calldata, value: BigInt(0).toString(10) };
|
|
37
37
|
};
|
|
38
38
|
exports.encodeTransferFromMAToPool = encodeTransferFromMAToPool;
|
|
39
|
-
var encodeWithdrawPassivePoolAndBridge = function (owner, poolId, sharesAmount, minOut, sig, socketMsgGasLimit,
|
|
39
|
+
var encodeWithdrawPassivePoolAndBridge = function (owner, poolId, sharesAmount, minOut, sig, socketMsgGasLimit, chainId, receiver) {
|
|
40
40
|
var functionSignature = 'withdrawPassivePool';
|
|
41
41
|
var parameters = [
|
|
42
42
|
{
|
|
@@ -46,8 +46,7 @@ var encodeWithdrawPassivePoolAndBridge = function (owner, poolId, sharesAmount,
|
|
|
46
46
|
minOut: minOut,
|
|
47
47
|
sig: sig,
|
|
48
48
|
socketMsgGasLimit: socketMsgGasLimit,
|
|
49
|
-
|
|
50
|
-
socketConnector: socketConnector,
|
|
49
|
+
chainId: chainId,
|
|
51
50
|
receiver: receiver,
|
|
52
51
|
},
|
|
53
52
|
];
|
|
@@ -56,15 +55,10 @@ var encodeWithdrawPassivePoolAndBridge = function (owner, poolId, sharesAmount,
|
|
|
56
55
|
return { calldata: calldata, value: BigInt(0).toString(10) };
|
|
57
56
|
};
|
|
58
57
|
exports.encodeWithdrawPassivePoolAndBridge = encodeWithdrawPassivePoolAndBridge;
|
|
59
|
-
var encodeBridgeAndDepositPassivePool = function (receiver, socketMsgGasLimit, socketConnector, socketBridgeOptions, socketFees, poolId, owner, amount, minShares
|
|
58
|
+
var encodeBridgeAndDepositPassivePool = function (receiver, socketMsgGasLimit, socketConnector, socketBridgeOptions, socketFees, poolId, owner, amount, minShares) {
|
|
60
59
|
var PERIPHERY_INTERFACE = new ethers_1.Interface(Periphery_json_1.abi);
|
|
61
|
-
var inputs = { poolId: poolId, owner: owner,
|
|
62
|
-
var
|
|
63
|
-
socketMsgGasLimit: fallbackSocketMsgGasLimit,
|
|
64
|
-
socketConnector: fallbackSocketConnector,
|
|
65
|
-
socketPayloadSize: fallbackSocketPayloadSize,
|
|
66
|
-
};
|
|
67
|
-
var peripheryCalldata = PERIPHERY_INTERFACE.encodeFunctionData('depositPassivePool((uint128,address,uint256,uint256),(uint256,uint256,address))', [inputs, fallbackData]);
|
|
60
|
+
var inputs = { poolId: poolId, owner: owner, minShares: minShares };
|
|
61
|
+
var peripheryCalldata = PERIPHERY_INTERFACE.encodeFunctionData('depositPassivePool((uint128,address,uint256))', [inputs]);
|
|
68
62
|
var functionSignature = 'bridge';
|
|
69
63
|
var parameters = [
|
|
70
64
|
receiver,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode.js","sourceRoot":"/","sources":["services/lp/encode.ts"],"names":[],"mappings":";;;AACA,iCAAmC;AAEnC,4DAAgE;AAChE,iFAA4F;AAE5F,mBAAmB;AACnB,IAAM,mBAAmB,GAAG;IAC1B,2GAA2G;CAC5G,CAAC;AAEF,mBAAmB;AACnB,IAAM,kBAAkB,GAAG;IACzB,kGAAkG;CACnG,CAAC;AACK,IAAM,0BAA0B,GAAG,UACxC,MAAc,EACd,YAAoB,EACpB,MAAc,EACd,SAAiB;IAEjB,IAAM,iBAAiB,GAAG,cAAc,CAAC;IACzC,IAAM,UAAU,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC7D,IAAM,SAAS,GAAG,IAAI,kBAAS,CAAC,mBAAmB,CAAC,CAAC;IACrD,IAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAC7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/D,CAAC,CAAC;AAXW,QAAA,0BAA0B,8BAWrC;AAEK,IAAM,yBAAyB,GAAG,UACvC,MAAc,EACd,YAAoB,EACpB,MAAc;IAEd,IAAM,iBAAiB,GAAG,iBAAiB,CAAC;IAC5C,IAAM,UAAU,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAClD,IAAM,SAAS,GAAG,IAAI,kBAAS,CAAC,kBAAkB,CAAC,CAAC;IAC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AAiB;IAEjB,IAAM,mBAAmB,GAAG,IAAI,kBAAS,CAAC,oBAAY,CAAC,CAAC;IACxD,IAAM,MAAM,GAAG,EAAE,MAAM,QAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IAC5C,IAAM,iBAAiB,GAAG,mBAAmB,CAAC,kBAAkB,CAC9D,+CAA+C,EAC/C,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,IAAM,iBAAiB,GAAG,QAAQ,CAAC;IACnC,IAAM,UAAU,GAAG;QACjB,QAAQ;QACR,MAAM;QACN,iBAAiB;QACjB,eAAe;QACf,iBAAiB;QACjB,mBAAmB;KACpB,CAAC;IACF,IAAM,SAAS,GAAG,IAAI,kBAAS,CAAC,2BAA0B,CAAC,CAAC;IAC5D,IAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAC7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAChE,CAAC,CAAC;AA9BW,QAAA,iCAAiC,qCA8B5C","sourcesContent":["import { MethodParameters } from '../../utils/action';\nimport { Interface } from 'ethers';\nimport { EIP712Signature } from '../sign';\nimport { abi as peripheryAbi } from '../../abis/Periphery.json';\nimport { abi as Socket_VaultWithPayloadAbi } from '../../abis/socket/VaultWithPayload.json';\n\n// @todo Update ABI\nconst provideLiquidityAbi = [\n 'function addLiquidity(uint128 poolId, address owner, uint256 amount, uint256 minShares) returns (uint256)',\n];\n\n// @todo Update ABI\nconst removeLiquidityabi = [\n 'function removeLiquidity(uint128 poolId, uint256 sharesAmount, uint256 minOut) returns (uint256)',\n];\nexport const encodeProvideLiquidityCall = (\n poolId: number,\n accountOwner: string,\n amount: bigint,\n minShares: number,\n): MethodParameters => {\n const functionSignature = 'addLiquidity';\n const parameters = [poolId, accountOwner, amount, minShares];\n const INTERFACE = new Interface(provideLiquidityAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return { calldata: calldata, value: BigInt(0).toString(10) };\n};\n\nexport const encodeRemoveLiquidityCall = (\n poolId: number,\n sharesAmount: bigint,\n minOut: number,\n): MethodParameters => {\n const functionSignature = 'removeLiquidity';\n const parameters = [poolId, sharesAmount, minOut];\n const INTERFACE = new Interface(removeLiquidityabi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return { calldata: calldata, value: BigInt(0).toString(10) };\n};\n\nexport const encodeTransferFromMAToPool = (\n accountId: number,\n amount: bigint,\n sig: EIP712Signature,\n poolId: number,\n minShares: bigint,\n receiver: string,\n): MethodParameters => {\n const functionSignature = 'transferFromMAToPool';\n const parameters = [{ accountId, amount, sig, poolId, minShares, receiver }];\n const INTERFACE = new Interface(peripheryAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return { calldata: calldata, value: BigInt(0).toString(10) };\n};\n\nexport const encodeWithdrawPassivePoolAndBridge = (\n owner: string,\n poolId: number,\n sharesAmount: bigint,\n minOut: bigint,\n sig: EIP712Signature,\n socketMsgGasLimit: bigint,\n chainId: number,\n receiver: string,\n): MethodParameters => {\n const functionSignature = 'withdrawPassivePool';\n const parameters = [\n {\n owner,\n poolId,\n sharesAmount,\n minOut,\n sig,\n socketMsgGasLimit,\n chainId,\n receiver,\n },\n ];\n const INTERFACE = new Interface(peripheryAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return { calldata: calldata, value: BigInt(0).toString(10) };\n};\n\nexport const encodeBridgeAndDepositPassivePool = (\n receiver: string,\n socketMsgGasLimit: bigint,\n socketConnector: string,\n socketBridgeOptions: string,\n socketFees: bigint,\n poolId: number,\n owner: string,\n amount: bigint,\n minShares: bigint,\n): MethodParameters => {\n const PERIPHERY_INTERFACE = new Interface(peripheryAbi);\n const inputs = { poolId, owner, minShares };\n const peripheryCalldata = PERIPHERY_INTERFACE.encodeFunctionData(\n 'depositPassivePool((uint128,address,uint256))',\n [inputs],\n );\n\n const functionSignature = 'bridge';\n const parameters = [\n receiver,\n amount,\n socketMsgGasLimit,\n socketConnector,\n peripheryCalldata,\n socketBridgeOptions,\n ];\n const INTERFACE = new Interface(Socket_VaultWithPayloadAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return { calldata: calldata, value: socketFees.toString(10) };\n};\n"]}
|
|
@@ -45,8 +45,9 @@ var encode_1 = require("./encode");
|
|
|
45
45
|
var consts_1 = require("../../utils/consts");
|
|
46
46
|
var action_1 = require("../../utils/action");
|
|
47
47
|
var encode_2 = require("../encode");
|
|
48
|
+
var ethers_1 = require("ethers");
|
|
48
49
|
var transferFromMAToPool = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var network, reyaChainId, tokenInfo, amount, multiAction, eip712Signature, _a, data, value, result;
|
|
50
|
+
var network, reyaChainId, tokenInfo, amount, minShares, multiAction, eip712Signature, _a, data, value, result;
|
|
50
51
|
var _b;
|
|
51
52
|
return __generator(this, function (_c) {
|
|
52
53
|
switch (_c.label) {
|
|
@@ -56,12 +57,13 @@ var transferFromMAToPool = function (params) { return __awaiter(void 0, void 0,
|
|
|
56
57
|
reyaChainId = Number(network === null || network === void 0 ? void 0 : network.chainId);
|
|
57
58
|
tokenInfo = (0, common_1.getTokenInfoByAddress)(params.pool.tokenAddress);
|
|
58
59
|
amount = (0, common_1.scale)(tokenInfo.decimals)(params.amount);
|
|
60
|
+
minShares = BigInt(0);
|
|
59
61
|
multiAction = new action_1.MultiAction();
|
|
60
62
|
(0, encode_2.encodeSingleWithdraw)(params.pool.tokenAddress, amount, multiAction);
|
|
61
|
-
return [4 /*yield*/, (0, sign_1.signCoreCommands)(params.signer, reyaChainId, (0, contractAddresses_1.getAddress)(reyaChainId, contractAddresses_1.ContractType.PERIPHERY_PROXY), params.marginAccountId, multiAction.commands, params.owner.coreSigNonce + 1, (0, common_1.getCurrentTimestampInSeconds)() + consts_1.BRIDGE_DEADLINE_IN_SECONDS)];
|
|
63
|
+
return [4 /*yield*/, (0, sign_1.signCoreCommands)(params.signer, reyaChainId, (0, contractAddresses_1.getAddress)(reyaChainId, contractAddresses_1.ContractType.PERIPHERY_PROXY), params.marginAccountId, multiAction.commands, params.owner.coreSigNonce + 1, (0, common_1.getCurrentTimestampInSeconds)() + consts_1.BRIDGE_DEADLINE_IN_SECONDS, ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['uint128', 'address', 'uint256'], [params.pool.id, params.owner.address, minShares]))];
|
|
62
64
|
case 2:
|
|
63
65
|
eip712Signature = _c.sent();
|
|
64
|
-
_a = (0, encode_1.encodeTransferFromMAToPool)(params.marginAccountId, amount, eip712Signature, params.pool.id,
|
|
66
|
+
_a = (0, encode_1.encodeTransferFromMAToPool)(params.marginAccountId, amount, eip712Signature, params.pool.id, minShares, params.owner.address), data = _a.calldata, value = _a.value;
|
|
65
67
|
return [4 /*yield*/, (0, executeTransaction_1.executeTransaction)(params.signer, data, value, reyaChainId, contractAddresses_1.ContractType.PERIPHERY_PROXY)];
|
|
66
68
|
case 3:
|
|
67
69
|
result = _c.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferFromMAToPool.js","sourceRoot":"/","sources":["services/lp/transferFromMAToPool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AACzB,mEAAyE;AACzE,4DAA2D;AAC3D,gCAA2C;AAC3C,mCAAsD;AAKtD,6CAAgE;AAChE,6CAAiD;AACjD,oCAAiD;
|
|
1
|
+
{"version":3,"file":"transferFromMAToPool.js","sourceRoot":"/","sources":["services/lp/transferFromMAToPool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AACzB,mEAAyE;AACzE,4DAA2D;AAC3D,gCAA2C;AAC3C,mCAAsD;AAKtD,6CAAgE;AAChE,6CAAiD;AACjD,oCAA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f,MAAM,CAAC,IAAI,CAAC,EAAE,EACd,SAAS,EACT,MAAM,CAAC,KAAK,CAAC,OAAO,CACrB,EAPiB,IAAI,cAAA,EAAE,KAAK,WAAA,CAO3B;gBAEa,qBAAM,IAAA,uCAAkB,EACrC,MAAM,CAAC,MAAM,EACb,IAAI,EACJ,KAAK,EACL,WAAW,EACX,gCAAY,CAAC,eAAe,CAC7B,EAAA;;gBANK,MAAM,GAAG,SAMd;gBAED,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,IAAI;qBACtC,EAAC;;;KACH,CAAC;AAhDW,QAAA,oBAAoB,wBAgD/B","sourcesContent":["import {\n getCurrentTimestampInSeconds,\n scale,\n ReyaChainId,\n getTokenInfoByAddress,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '../../utils/contractAddresses';\nimport { executeTransaction } from '../executeTransaction';\nimport { signCoreCommands } from '../sign';\nimport { encodeTransferFromMAToPool } from './encode';\nimport {\n TransferFromMAToPoolParams,\n TransferFromMAToPoolResult,\n} from './types';\nimport { BRIDGE_DEADLINE_IN_SECONDS } from '../../utils/consts';\nimport { MultiAction } from '../../utils/action';\nimport { encodeSingleWithdraw } from '../encode';\nimport { ethers } from 'ethers';\n\nexport const transferFromMAToPool = async (\n params: TransferFromMAToPoolParams,\n): Promise<TransferFromMAToPoolResult> => {\n const network = await params.signer.provider?.getNetwork();\n const reyaChainId: ReyaChainId = Number(network?.chainId);\n\n const tokenInfo = getTokenInfoByAddress(params.pool.tokenAddress);\n const amount = scale(tokenInfo.decimals)(params.amount);\n\n const minShares = BigInt(0);\n\n // transfer from MA to pool involves a core withdrawal\n const multiAction = new MultiAction();\n encodeSingleWithdraw(params.pool.tokenAddress, amount, multiAction);\n const eip712Signature = await signCoreCommands(\n params.signer,\n reyaChainId,\n getAddress(reyaChainId, ContractType.PERIPHERY_PROXY),\n params.marginAccountId,\n multiAction.commands,\n params.owner.coreSigNonce + 1,\n getCurrentTimestampInSeconds() + BRIDGE_DEADLINE_IN_SECONDS,\n ethers.AbiCoder.defaultAbiCoder().encode(\n ['uint128', 'address', 'uint256'],\n [params.pool.id, params.owner.address, minShares],\n ),\n );\n\n const { calldata: data, value } = encodeTransferFromMAToPool(\n params.marginAccountId,\n amount,\n eip712Signature,\n params.pool.id,\n minShares,\n params.owner.address,\n );\n\n const result = await executeTransaction(\n params.signer,\n data,\n value,\n reyaChainId,\n ContractType.PERIPHERY_PROXY,\n );\n\n return {\n transactionHash: result?.hash || null,\n };\n};\n"]}
|
|
@@ -58,14 +58,12 @@ var withdrawPassivePoolAndBridge = function (params) { return __awaiter(void 0,
|
|
|
58
58
|
else {
|
|
59
59
|
sharesAmount = (0, common_1.scale)(30)(params.amount * params.sharePrice);
|
|
60
60
|
}
|
|
61
|
-
return [4 /*yield*/, (0, sign_1.signPoolRemoveLiquidity)(params.signer, reyaChainId, (0, contractAddresses_1.getAddress)(reyaChainId, contractAddresses_1.ContractType.PERIPHERY_PROXY), params.owner.address, params.pool.id, sharesAmount, BigInt(0), params.owner.poolSigNonce + 1, (0, common_1.getCurrentTimestampInSeconds)() + consts_1.BRIDGE_DEADLINE_IN_SECONDS)
|
|
61
|
+
return [4 /*yield*/, (0, sign_1.signPoolRemoveLiquidity)(params.signer, reyaChainId, (0, contractAddresses_1.getAddress)(reyaChainId, contractAddresses_1.ContractType.PERIPHERY_PROXY), params.owner.address, params.pool.id, sharesAmount, BigInt(0), params.owner.poolSigNonce + 1, (0, common_1.getCurrentTimestampInSeconds)() + consts_1.BRIDGE_DEADLINE_IN_SECONDS, BigInt('10000000'), //todo
|
|
62
|
+
params.moneyInOutChainId, params.owner.address)];
|
|
62
63
|
case 2:
|
|
63
64
|
eip712Signature = _c.sent();
|
|
64
65
|
_a = (0, encode_1.encodeWithdrawPassivePoolAndBridge)(params.owner.address, params.pool.id, sharesAmount, BigInt(0), eip712Signature, BigInt('10000000'), //todo
|
|
65
|
-
|
|
66
|
-
moneyInOutChainId: params.moneyInOutChainId,
|
|
67
|
-
tokenName: (0, common_1.getRUSDUnderlyingTokenInfo)(params.moneyInOutChainId).name,
|
|
68
|
-
}).withdraw, params.owner.address), data = _a.calldata, value = _a.value;
|
|
66
|
+
params.moneyInOutChainId, params.owner.address), data = _a.calldata, value = _a.value;
|
|
69
67
|
return [4 /*yield*/, (0, executeTransaction_1.executeTransaction)(params.signer, data, value, reyaChainId, contractAddresses_1.ContractType.PERIPHERY_PROXY)];
|
|
70
68
|
case 3:
|
|
71
69
|
result = _c.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawPassivePoolAndBridge.js","sourceRoot":"/","sources":["services/lp/withdrawPassivePoolAndBridge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAyE;AACzE,4DAA2D;AAC3D,gCAAkD;AAKlD,mCAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"withdrawPassivePoolAndBridge.js","sourceRoot":"/","sources":["services/lp/withdrawPassivePoolAndBridge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAyE;AACzE,4DAA2D;AAC3D,gCAAkD;AAKlD,mCAA8D;AAC9D,0CAIyB;AACzB,6CAAgE;AAEzD,IAAM,4BAA4B,GAAG,UAC1C,MAA0C;;;;;oBAE1B,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,WAAW,GAAgB,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAG1D,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;oBACvB,YAAY,GAAG,IAAA,cAAK,EAAC,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAChD,CAAC;qBAAM,C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ress } from '../../utils/contractAddresses';\nimport { executeTransaction } from '../executeTransaction';\nimport { signPoolRemoveLiquidity } from '../sign';\nimport {\n WithdrawPassivePoolAndBridgeParams,\n WithdrawPassivePoolAndBridgeResult,\n} from './types';\nimport { encodeWithdrawPassivePoolAndBridge } from './encode';\nimport {\n ReyaChainId,\n getCurrentTimestampInSeconds,\n scale,\n} from '@reyaxyz/common';\nimport { BRIDGE_DEADLINE_IN_SECONDS } from '../../utils/consts';\n\nexport const withdrawPassivePoolAndBridge = async (\n params: WithdrawPassivePoolAndBridgeParams,\n): Promise<WithdrawPassivePoolAndBridgeResult> => {\n const network = await params.signer.provider?.getNetwork();\n const reyaChainId: ReyaChainId = Number(network?.chainId);\n\n let sharesAmount;\n if (params.withdrawMax) {\n sharesAmount = scale(30)(params.sharesAmount);\n } else {\n sharesAmount = scale(30)(params.amount * params.sharePrice);\n }\n\n const eip712Signature = await signPoolRemoveLiquidity(\n params.signer,\n reyaChainId,\n getAddress(reyaChainId, ContractType.PERIPHERY_PROXY),\n params.owner.address,\n params.pool.id,\n sharesAmount,\n BigInt(0),\n params.owner.poolSigNonce + 1,\n getCurrentTimestampInSeconds() + BRIDGE_DEADLINE_IN_SECONDS,\n BigInt('10000000'), //todo\n params.moneyInOutChainId,\n params.owner.address,\n );\n\n const { calldata: data, value } = encodeWithdrawPassivePoolAndBridge(\n params.owner.address,\n params.pool.id,\n sharesAmount,\n BigInt(0),\n eip712Signature,\n BigInt('10000000'), //todo\n params.moneyInOutChainId,\n params.owner.address,\n );\n\n const result = await executeTransaction(\n params.signer,\n data,\n value,\n reyaChainId,\n ContractType.PERIPHERY_PROXY,\n );\n\n return {\n transactionHash: result?.hash || null,\n };\n};\n"]}
|
|
@@ -67,7 +67,7 @@ var bridgeAndDepositExistingMA = function (params) { return __awaiter(void 0, vo
|
|
|
67
67
|
});
|
|
68
68
|
_a = (0, encode_1.encodeBridgeAndDepositExistingMA)(peripheryAddress, BigInt('10000000'), socketConnectors.deposit, '0x', (0, common_1.getSocketDepositFeesAsBigInt)({
|
|
69
69
|
moneyInOutChainId: moneyInOutChainId,
|
|
70
|
-
}), params.marginAccountId, reyaPeripheryTokenInfo.address, (0, common_1.scale)(reyaPeripheryTokenInfo.decimals)(params.amount), (0, common_1.scale)(moneyInOutTokenInfo.decimals)(params.amount)
|
|
70
|
+
}), params.marginAccountId, reyaPeripheryTokenInfo.address, (0, common_1.scale)(reyaPeripheryTokenInfo.decimals)(params.amount), (0, common_1.scale)(moneyInOutTokenInfo.decimals)(params.amount)), data = _a.calldata, value = _a.value;
|
|
71
71
|
return [4 /*yield*/, (0, executeTransaction_1.executeTransaction)(params.signer, data, value, moneyInOutChainId, (0, common_1.getSocketVault)({
|
|
72
72
|
moneyInOutChainId: moneyInOutChainId,
|
|
73
73
|
tokenName: moneyInOutTokenInfo.name,
|