@myx-trade/sdk 0.1.245 → 0.1.247
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +174 -195
- package/dist/index.mjs +174 -195
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1435,6 +1435,18 @@ var address_default = {
|
|
|
1435
1435
|
[59141 /* LINEA_SEPOLIA */]: LINEA_SEPOLIA,
|
|
1436
1436
|
[97 /* BSC_TESTNET */]: BSC_TEST_NET
|
|
1437
1437
|
};
|
|
1438
|
+
var executeAddressByChainId = (chainId) => {
|
|
1439
|
+
if (chainId === 421614 /* ARB_TESTNET */) {
|
|
1440
|
+
return "0x7e248ec1721639413a280d9e82e2862cae2e6e28";
|
|
1441
|
+
}
|
|
1442
|
+
if (chainId === 59141 /* LINEA_SEPOLIA */) {
|
|
1443
|
+
return "";
|
|
1444
|
+
}
|
|
1445
|
+
if (chainId === 97 /* BSC_TESTNET */) {
|
|
1446
|
+
return "";
|
|
1447
|
+
}
|
|
1448
|
+
return "";
|
|
1449
|
+
};
|
|
1438
1450
|
|
|
1439
1451
|
// src/web3/index.ts
|
|
1440
1452
|
import {
|
|
@@ -1763,7 +1775,7 @@ var RotationProvider = class extends BaseProvider {
|
|
|
1763
1775
|
// package.json
|
|
1764
1776
|
var package_default = {
|
|
1765
1777
|
name: "@myx-trade/sdk",
|
|
1766
|
-
version: "0.1.
|
|
1778
|
+
version: "0.1.247",
|
|
1767
1779
|
private: false,
|
|
1768
1780
|
publishConfig: {
|
|
1769
1781
|
access: "public"
|
|
@@ -9238,6 +9250,24 @@ var Forwarder_default = [
|
|
|
9238
9250
|
name: "InvalidInitialization",
|
|
9239
9251
|
inputs: []
|
|
9240
9252
|
},
|
|
9253
|
+
{
|
|
9254
|
+
type: "error",
|
|
9255
|
+
name: "MismatchExecuteFee",
|
|
9256
|
+
inputs: [
|
|
9257
|
+
{
|
|
9258
|
+
type: "uint256",
|
|
9259
|
+
name: "balanceBefore"
|
|
9260
|
+
},
|
|
9261
|
+
{
|
|
9262
|
+
type: "uint256",
|
|
9263
|
+
name: "balanceAfter"
|
|
9264
|
+
},
|
|
9265
|
+
{
|
|
9266
|
+
type: "uint256",
|
|
9267
|
+
name: "expected"
|
|
9268
|
+
}
|
|
9269
|
+
]
|
|
9270
|
+
},
|
|
9241
9271
|
{
|
|
9242
9272
|
type: "error",
|
|
9243
9273
|
name: "MismatchedSender",
|
|
@@ -9314,13 +9344,8 @@ var Forwarder_default = [
|
|
|
9314
9344
|
},
|
|
9315
9345
|
{
|
|
9316
9346
|
type: "error",
|
|
9317
|
-
name: "
|
|
9318
|
-
inputs: [
|
|
9319
|
-
{
|
|
9320
|
-
type: "address",
|
|
9321
|
-
name: "token"
|
|
9322
|
-
}
|
|
9323
|
-
]
|
|
9347
|
+
name: "RemoveRelayerFailed",
|
|
9348
|
+
inputs: []
|
|
9324
9349
|
},
|
|
9325
9350
|
{
|
|
9326
9351
|
type: "error",
|
|
@@ -9349,6 +9374,28 @@ var Forwarder_default = [
|
|
|
9349
9374
|
}
|
|
9350
9375
|
]
|
|
9351
9376
|
},
|
|
9377
|
+
{
|
|
9378
|
+
type: "event",
|
|
9379
|
+
anonymous: false,
|
|
9380
|
+
name: "ChargeForwardFee",
|
|
9381
|
+
inputs: [
|
|
9382
|
+
{
|
|
9383
|
+
type: "address",
|
|
9384
|
+
name: "account",
|
|
9385
|
+
indexed: false
|
|
9386
|
+
},
|
|
9387
|
+
{
|
|
9388
|
+
type: "address",
|
|
9389
|
+
name: "feeToken",
|
|
9390
|
+
indexed: false
|
|
9391
|
+
},
|
|
9392
|
+
{
|
|
9393
|
+
type: "uint256",
|
|
9394
|
+
name: "relayFee",
|
|
9395
|
+
indexed: false
|
|
9396
|
+
}
|
|
9397
|
+
]
|
|
9398
|
+
},
|
|
9352
9399
|
{
|
|
9353
9400
|
type: "event",
|
|
9354
9401
|
anonymous: false,
|
|
@@ -9455,7 +9502,7 @@ var Forwarder_default = [
|
|
|
9455
9502
|
{
|
|
9456
9503
|
type: "event",
|
|
9457
9504
|
anonymous: false,
|
|
9458
|
-
name: "
|
|
9505
|
+
name: "UpdateAcquiescentFeeToken",
|
|
9459
9506
|
inputs: [
|
|
9460
9507
|
{
|
|
9461
9508
|
type: "address",
|
|
@@ -9463,13 +9510,13 @@ var Forwarder_default = [
|
|
|
9463
9510
|
indexed: false
|
|
9464
9511
|
},
|
|
9465
9512
|
{
|
|
9466
|
-
type: "
|
|
9467
|
-
name: "
|
|
9513
|
+
type: "address",
|
|
9514
|
+
name: "oldRelayGas",
|
|
9468
9515
|
indexed: false
|
|
9469
9516
|
},
|
|
9470
9517
|
{
|
|
9471
|
-
type: "
|
|
9472
|
-
name: "
|
|
9518
|
+
type: "address",
|
|
9519
|
+
name: "newRelayGas",
|
|
9473
9520
|
indexed: false
|
|
9474
9521
|
}
|
|
9475
9522
|
]
|
|
@@ -9477,7 +9524,7 @@ var Forwarder_default = [
|
|
|
9477
9524
|
{
|
|
9478
9525
|
type: "event",
|
|
9479
9526
|
anonymous: false,
|
|
9480
|
-
name: "
|
|
9527
|
+
name: "UpdateEquilibriumGas",
|
|
9481
9528
|
inputs: [
|
|
9482
9529
|
{
|
|
9483
9530
|
type: "address",
|
|
@@ -9486,22 +9533,34 @@ var Forwarder_default = [
|
|
|
9486
9533
|
},
|
|
9487
9534
|
{
|
|
9488
9535
|
type: "uint256",
|
|
9489
|
-
name: "
|
|
9536
|
+
name: "oldRelayGas",
|
|
9490
9537
|
indexed: false
|
|
9491
9538
|
},
|
|
9492
9539
|
{
|
|
9493
9540
|
type: "uint256",
|
|
9494
|
-
name: "
|
|
9541
|
+
name: "newRelayGas",
|
|
9542
|
+
indexed: false
|
|
9543
|
+
}
|
|
9544
|
+
]
|
|
9545
|
+
},
|
|
9546
|
+
{
|
|
9547
|
+
type: "event",
|
|
9548
|
+
anonymous: false,
|
|
9549
|
+
name: "UpdateMaxRelayFee",
|
|
9550
|
+
inputs: [
|
|
9551
|
+
{
|
|
9552
|
+
type: "address",
|
|
9553
|
+
name: "sender",
|
|
9495
9554
|
indexed: false
|
|
9496
9555
|
},
|
|
9497
9556
|
{
|
|
9498
9557
|
type: "uint256",
|
|
9499
|
-
name: "
|
|
9558
|
+
name: "oldMaxRelayFee",
|
|
9500
9559
|
indexed: false
|
|
9501
9560
|
},
|
|
9502
9561
|
{
|
|
9503
9562
|
type: "uint256",
|
|
9504
|
-
name: "
|
|
9563
|
+
name: "newMaxRelayFee",
|
|
9505
9564
|
indexed: false
|
|
9506
9565
|
}
|
|
9507
9566
|
]
|
|
@@ -9564,6 +9623,10 @@ var Forwarder_default = [
|
|
|
9564
9623
|
stateMutability: "payable",
|
|
9565
9624
|
payable: true,
|
|
9566
9625
|
inputs: [
|
|
9626
|
+
{
|
|
9627
|
+
type: "address",
|
|
9628
|
+
name: "forwardFeeToken"
|
|
9629
|
+
},
|
|
9567
9630
|
{
|
|
9568
9631
|
type: "tuple[]",
|
|
9569
9632
|
name: "bundleParams",
|
|
@@ -9639,6 +9702,19 @@ var Forwarder_default = [
|
|
|
9639
9702
|
}
|
|
9640
9703
|
]
|
|
9641
9704
|
},
|
|
9705
|
+
{
|
|
9706
|
+
type: "function",
|
|
9707
|
+
name: "equilibriumGas",
|
|
9708
|
+
constant: true,
|
|
9709
|
+
stateMutability: "view",
|
|
9710
|
+
payable: false,
|
|
9711
|
+
inputs: [],
|
|
9712
|
+
outputs: [
|
|
9713
|
+
{
|
|
9714
|
+
type: "uint256"
|
|
9715
|
+
}
|
|
9716
|
+
]
|
|
9717
|
+
},
|
|
9642
9718
|
{
|
|
9643
9719
|
type: "function",
|
|
9644
9720
|
name: "execute",
|
|
@@ -9679,6 +9755,10 @@ var Forwarder_default = [
|
|
|
9679
9755
|
name: "signature"
|
|
9680
9756
|
}
|
|
9681
9757
|
]
|
|
9758
|
+
},
|
|
9759
|
+
{
|
|
9760
|
+
type: "address",
|
|
9761
|
+
name: "masterAccount"
|
|
9682
9762
|
}
|
|
9683
9763
|
],
|
|
9684
9764
|
outputs: []
|
|
@@ -9724,6 +9804,10 @@ var Forwarder_default = [
|
|
|
9724
9804
|
}
|
|
9725
9805
|
]
|
|
9726
9806
|
},
|
|
9807
|
+
{
|
|
9808
|
+
type: "address",
|
|
9809
|
+
name: "masterAccount"
|
|
9810
|
+
},
|
|
9727
9811
|
{
|
|
9728
9812
|
type: "address",
|
|
9729
9813
|
name: "refundReceiver"
|
|
@@ -9738,6 +9822,10 @@ var Forwarder_default = [
|
|
|
9738
9822
|
stateMutability: "payable",
|
|
9739
9823
|
payable: true,
|
|
9740
9824
|
inputs: [
|
|
9825
|
+
{
|
|
9826
|
+
type: "address",
|
|
9827
|
+
name: "forwardFeeToken"
|
|
9828
|
+
},
|
|
9741
9829
|
{
|
|
9742
9830
|
type: "tuple",
|
|
9743
9831
|
name: "params",
|
|
@@ -9777,16 +9865,11 @@ var Forwarder_default = [
|
|
|
9777
9865
|
},
|
|
9778
9866
|
{
|
|
9779
9867
|
type: "function",
|
|
9780
|
-
name: "
|
|
9781
|
-
constant:
|
|
9782
|
-
stateMutability: "view",
|
|
9868
|
+
name: "exitForwardMode",
|
|
9869
|
+
constant: false,
|
|
9783
9870
|
payable: false,
|
|
9784
9871
|
inputs: [],
|
|
9785
|
-
outputs: [
|
|
9786
|
-
{
|
|
9787
|
-
type: "address"
|
|
9788
|
-
}
|
|
9789
|
-
]
|
|
9872
|
+
outputs: []
|
|
9790
9873
|
},
|
|
9791
9874
|
{
|
|
9792
9875
|
type: "function",
|
|
@@ -9834,7 +9917,7 @@ var Forwarder_default = [
|
|
|
9834
9917
|
},
|
|
9835
9918
|
{
|
|
9836
9919
|
type: "function",
|
|
9837
|
-
name: "
|
|
9920
|
+
name: "getDesignatedToken",
|
|
9838
9921
|
constant: true,
|
|
9839
9922
|
stateMutability: "view",
|
|
9840
9923
|
payable: false,
|
|
@@ -9847,71 +9930,58 @@ var Forwarder_default = [
|
|
|
9847
9930
|
},
|
|
9848
9931
|
{
|
|
9849
9932
|
type: "function",
|
|
9850
|
-
name: "
|
|
9933
|
+
name: "getEquilibriumGas",
|
|
9851
9934
|
constant: true,
|
|
9852
9935
|
stateMutability: "view",
|
|
9853
9936
|
payable: false,
|
|
9854
9937
|
inputs: [],
|
|
9855
9938
|
outputs: [
|
|
9856
9939
|
{
|
|
9857
|
-
type: "
|
|
9940
|
+
type: "uint256"
|
|
9858
9941
|
}
|
|
9859
9942
|
]
|
|
9860
9943
|
},
|
|
9861
9944
|
{
|
|
9862
9945
|
type: "function",
|
|
9863
|
-
name: "
|
|
9946
|
+
name: "getImplementation",
|
|
9864
9947
|
constant: true,
|
|
9865
9948
|
stateMutability: "view",
|
|
9866
9949
|
payable: false,
|
|
9867
9950
|
inputs: [],
|
|
9868
9951
|
outputs: [
|
|
9869
9952
|
{
|
|
9870
|
-
type: "
|
|
9953
|
+
type: "address"
|
|
9871
9954
|
}
|
|
9872
9955
|
]
|
|
9873
9956
|
},
|
|
9874
9957
|
{
|
|
9875
9958
|
type: "function",
|
|
9876
|
-
name: "
|
|
9959
|
+
name: "getUserRelayers",
|
|
9877
9960
|
constant: true,
|
|
9878
9961
|
stateMutability: "view",
|
|
9879
9962
|
payable: false,
|
|
9880
|
-
inputs: [
|
|
9881
|
-
outputs: [
|
|
9963
|
+
inputs: [
|
|
9882
9964
|
{
|
|
9883
|
-
type: "
|
|
9965
|
+
type: "address",
|
|
9966
|
+
name: "account"
|
|
9884
9967
|
}
|
|
9885
|
-
]
|
|
9886
|
-
},
|
|
9887
|
-
{
|
|
9888
|
-
type: "function",
|
|
9889
|
-
name: "getRelayGas",
|
|
9890
|
-
constant: true,
|
|
9891
|
-
stateMutability: "view",
|
|
9892
|
-
payable: false,
|
|
9893
|
-
inputs: [],
|
|
9968
|
+
],
|
|
9894
9969
|
outputs: [
|
|
9895
9970
|
{
|
|
9896
|
-
type: "
|
|
9971
|
+
type: "address[]"
|
|
9897
9972
|
}
|
|
9898
9973
|
]
|
|
9899
9974
|
},
|
|
9900
9975
|
{
|
|
9901
9976
|
type: "function",
|
|
9902
|
-
name: "
|
|
9977
|
+
name: "inForwardMode",
|
|
9903
9978
|
constant: true,
|
|
9904
9979
|
stateMutability: "view",
|
|
9905
9980
|
payable: false,
|
|
9906
|
-
inputs: [
|
|
9907
|
-
{
|
|
9908
|
-
type: "address",
|
|
9909
|
-
name: "account"
|
|
9910
|
-
}
|
|
9911
|
-
],
|
|
9981
|
+
inputs: [],
|
|
9912
9982
|
outputs: [
|
|
9913
9983
|
{
|
|
9914
|
-
type: "
|
|
9984
|
+
type: "bool"
|
|
9915
9985
|
}
|
|
9916
9986
|
]
|
|
9917
9987
|
},
|
|
@@ -9925,35 +9995,23 @@ var Forwarder_default = [
|
|
|
9925
9995
|
type: "address",
|
|
9926
9996
|
name: "addressManager"
|
|
9927
9997
|
},
|
|
9928
|
-
{
|
|
9929
|
-
type: "address",
|
|
9930
|
-
name: "_feeToken"
|
|
9931
|
-
},
|
|
9932
9998
|
{
|
|
9933
9999
|
type: "uint256",
|
|
9934
|
-
name: "
|
|
9935
|
-
},
|
|
9936
|
-
{
|
|
9937
|
-
type: "uint256",
|
|
9938
|
-
name: "_relayGas"
|
|
9939
|
-
},
|
|
9940
|
-
{
|
|
9941
|
-
type: "uint256",
|
|
9942
|
-
name: "_maxRelayFee"
|
|
10000
|
+
name: "_equilibriumGas"
|
|
9943
10001
|
}
|
|
9944
10002
|
],
|
|
9945
10003
|
outputs: []
|
|
9946
10004
|
},
|
|
9947
10005
|
{
|
|
9948
10006
|
type: "function",
|
|
9949
|
-
name: "
|
|
10007
|
+
name: "isAllowedTargets",
|
|
9950
10008
|
constant: true,
|
|
9951
10009
|
stateMutability: "view",
|
|
9952
10010
|
payable: false,
|
|
9953
10011
|
inputs: [
|
|
9954
10012
|
{
|
|
9955
10013
|
type: "address",
|
|
9956
|
-
name: "
|
|
10014
|
+
name: "contractAddr"
|
|
9957
10015
|
}
|
|
9958
10016
|
],
|
|
9959
10017
|
outputs: [
|
|
@@ -9964,18 +10022,14 @@ var Forwarder_default = [
|
|
|
9964
10022
|
},
|
|
9965
10023
|
{
|
|
9966
10024
|
type: "function",
|
|
9967
|
-
name: "
|
|
10025
|
+
name: "isTrustedForwarder",
|
|
9968
10026
|
constant: true,
|
|
9969
10027
|
stateMutability: "view",
|
|
9970
10028
|
payable: false,
|
|
9971
10029
|
inputs: [
|
|
9972
10030
|
{
|
|
9973
10031
|
type: "address",
|
|
9974
|
-
name: "
|
|
9975
|
-
},
|
|
9976
|
-
{
|
|
9977
|
-
type: "address",
|
|
9978
|
-
name: "relayer"
|
|
10032
|
+
name: "forwarder"
|
|
9979
10033
|
}
|
|
9980
10034
|
],
|
|
9981
10035
|
outputs: [
|
|
@@ -9986,14 +10040,23 @@ var Forwarder_default = [
|
|
|
9986
10040
|
},
|
|
9987
10041
|
{
|
|
9988
10042
|
type: "function",
|
|
9989
|
-
name: "
|
|
10043
|
+
name: "isUserRelayerEnabled",
|
|
9990
10044
|
constant: true,
|
|
9991
10045
|
stateMutability: "view",
|
|
9992
10046
|
payable: false,
|
|
9993
|
-
inputs: [
|
|
10047
|
+
inputs: [
|
|
10048
|
+
{
|
|
10049
|
+
type: "address",
|
|
10050
|
+
name: "account"
|
|
10051
|
+
},
|
|
10052
|
+
{
|
|
10053
|
+
type: "address",
|
|
10054
|
+
name: "relayer"
|
|
10055
|
+
}
|
|
10056
|
+
],
|
|
9994
10057
|
outputs: [
|
|
9995
10058
|
{
|
|
9996
|
-
type: "
|
|
10059
|
+
type: "bool"
|
|
9997
10060
|
}
|
|
9998
10061
|
]
|
|
9999
10062
|
},
|
|
@@ -10102,32 +10165,6 @@ var Forwarder_default = [
|
|
|
10102
10165
|
}
|
|
10103
10166
|
]
|
|
10104
10167
|
},
|
|
10105
|
-
{
|
|
10106
|
-
type: "function",
|
|
10107
|
-
name: "relayFee",
|
|
10108
|
-
constant: true,
|
|
10109
|
-
stateMutability: "view",
|
|
10110
|
-
payable: false,
|
|
10111
|
-
inputs: [],
|
|
10112
|
-
outputs: [
|
|
10113
|
-
{
|
|
10114
|
-
type: "uint256"
|
|
10115
|
-
}
|
|
10116
|
-
]
|
|
10117
|
-
},
|
|
10118
|
-
{
|
|
10119
|
-
type: "function",
|
|
10120
|
-
name: "relayGas",
|
|
10121
|
-
constant: true,
|
|
10122
|
-
stateMutability: "view",
|
|
10123
|
-
payable: false,
|
|
10124
|
-
inputs: [],
|
|
10125
|
-
outputs: [
|
|
10126
|
-
{
|
|
10127
|
-
type: "uint256"
|
|
10128
|
-
}
|
|
10129
|
-
]
|
|
10130
|
-
},
|
|
10131
10168
|
{
|
|
10132
10169
|
type: "function",
|
|
10133
10170
|
name: "removeAllowedTarget",
|
|
@@ -10156,30 +10193,13 @@ var Forwarder_default = [
|
|
|
10156
10193
|
},
|
|
10157
10194
|
{
|
|
10158
10195
|
type: "function",
|
|
10159
|
-
name: "
|
|
10196
|
+
name: "updateEquilibriumGas",
|
|
10160
10197
|
constant: false,
|
|
10161
10198
|
payable: false,
|
|
10162
10199
|
inputs: [
|
|
10163
10200
|
{
|
|
10164
10201
|
type: "uint256",
|
|
10165
|
-
name: "
|
|
10166
|
-
}
|
|
10167
|
-
],
|
|
10168
|
-
outputs: []
|
|
10169
|
-
},
|
|
10170
|
-
{
|
|
10171
|
-
type: "function",
|
|
10172
|
-
name: "updateRelayInfo",
|
|
10173
|
-
constant: false,
|
|
10174
|
-
payable: false,
|
|
10175
|
-
inputs: [
|
|
10176
|
-
{
|
|
10177
|
-
type: "uint256",
|
|
10178
|
-
name: "_relayFee"
|
|
10179
|
-
},
|
|
10180
|
-
{
|
|
10181
|
-
type: "uint256",
|
|
10182
|
-
name: "_relayGas"
|
|
10202
|
+
name: "_equilibriumGas"
|
|
10183
10203
|
}
|
|
10184
10204
|
],
|
|
10185
10205
|
outputs: []
|
|
@@ -13077,10 +13097,10 @@ var Position = class {
|
|
|
13077
13097
|
}
|
|
13078
13098
|
const updateParams = {
|
|
13079
13099
|
poolId,
|
|
13100
|
+
oracleType: poolOracleType,
|
|
13080
13101
|
referencePrice: ethers5.parseUnits(priceData?.price ?? "0", 30),
|
|
13081
13102
|
oracleUpdateData: priceData?.vaa ?? "0",
|
|
13082
|
-
publishTime: priceData.publishTime
|
|
13083
|
-
oracleType: poolOracleType
|
|
13103
|
+
publishTime: priceData.publishTime
|
|
13084
13104
|
};
|
|
13085
13105
|
let needsApproval = false;
|
|
13086
13106
|
if (Number(adjustAmount) > 0) {
|
|
@@ -19063,9 +19083,14 @@ var Utils = class {
|
|
|
19063
19083
|
}
|
|
19064
19084
|
}
|
|
19065
19085
|
async checkSeamlessGas(userAddress, chainId) {
|
|
19066
|
-
const forwarderContract = await getForwarderContract(chainId);
|
|
19067
|
-
const relayFee = await forwarderContract.getRelayFee();
|
|
19068
19086
|
const provider = await getJSONProvider(chainId);
|
|
19087
|
+
const marketManagerContract = new ethers7.Contract(
|
|
19088
|
+
getContractAddressByChainId(chainId).MARKET_MANAGER,
|
|
19089
|
+
MarketManager_default,
|
|
19090
|
+
provider
|
|
19091
|
+
);
|
|
19092
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
19093
|
+
const relayFee = await marketManagerContract.getRelayFee(forwardFeeToken);
|
|
19069
19094
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
19070
19095
|
const erc20Contract = new ethers7.Contract(
|
|
19071
19096
|
contractAddress.ERC20,
|
|
@@ -19936,29 +19961,6 @@ var Account = class {
|
|
|
19936
19961
|
}
|
|
19937
19962
|
async getAvailableMarginBalance({ poolId, chainId, address }) {
|
|
19938
19963
|
try {
|
|
19939
|
-
const poolListRes = await this.client.api.getPoolList();
|
|
19940
|
-
if (poolListRes.code !== 9200) {
|
|
19941
|
-
throw new MyxSDKError(
|
|
19942
|
-
"REQUEST_FAILED" /* RequestFailed */,
|
|
19943
|
-
"Failed to get pool list"
|
|
19944
|
-
);
|
|
19945
|
-
}
|
|
19946
|
-
const poolList = poolListRes.data;
|
|
19947
|
-
const pool = poolList?.find((pool2) => pool2.poolId === poolId);
|
|
19948
|
-
const orderRes = await this.client.order.getOrders(address);
|
|
19949
|
-
if (orderRes.code !== 0) {
|
|
19950
|
-
throw new MyxSDKError(
|
|
19951
|
-
"REQUEST_FAILED" /* RequestFailed */,
|
|
19952
|
-
"Failed to get orders"
|
|
19953
|
-
);
|
|
19954
|
-
}
|
|
19955
|
-
const orders = orderRes.data;
|
|
19956
|
-
const openOrders = orders?.filter((order) => order.poolId === poolId);
|
|
19957
|
-
const used = openOrders?.reduce((acc, order) => {
|
|
19958
|
-
const prev = BigInt(ethers8.parseUnits(acc, pool?.quoteDecimals ?? 6));
|
|
19959
|
-
const curr = BigInt(ethers8.parseUnits(order.collateralAmount ?? "0", pool?.quoteDecimals ?? 6)) + prev;
|
|
19960
|
-
return curr.toString();
|
|
19961
|
-
}, "0");
|
|
19962
19964
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
19963
19965
|
if (marginAccountBalanceRes.code !== 0) {
|
|
19964
19966
|
throw new MyxSDKError(
|
|
@@ -19967,15 +19969,10 @@ var Account = class {
|
|
|
19967
19969
|
);
|
|
19968
19970
|
}
|
|
19969
19971
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
19970
|
-
const usedMargin = BigInt(used ?? "0");
|
|
19971
19972
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
19972
19973
|
const freeAmount = BigInt(marginAccountBalance?.freeMargin ?? 0);
|
|
19973
19974
|
const accountMargin = freeAmount + quoteProfit;
|
|
19974
|
-
|
|
19975
|
-
return BigInt(0);
|
|
19976
|
-
}
|
|
19977
|
-
const availableAccountMarginBalance = accountMargin - usedMargin;
|
|
19978
|
-
return availableAccountMarginBalance;
|
|
19975
|
+
return accountMargin;
|
|
19979
19976
|
} catch (error) {
|
|
19980
19977
|
throw new MyxSDKError(
|
|
19981
19978
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -20137,8 +20134,6 @@ var Account = class {
|
|
|
20137
20134
|
};
|
|
20138
20135
|
}
|
|
20139
20136
|
}
|
|
20140
|
-
async getCurrentEpoch() {
|
|
20141
|
-
}
|
|
20142
20137
|
async getAccountVipInfo(chainId, address) {
|
|
20143
20138
|
const config = this.configManager.getConfig();
|
|
20144
20139
|
const provider = await getJSONProvider(chainId);
|
|
@@ -20689,8 +20684,6 @@ var Seamless = class {
|
|
|
20689
20684
|
}
|
|
20690
20685
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
20691
20686
|
const masterAddress = await config.signer.getAddress();
|
|
20692
|
-
const forwarderContract = await getForwarderContract(chainId);
|
|
20693
|
-
const forwarderAddress = forwarderContract.target;
|
|
20694
20687
|
const erc20Contract = new ethers9.Contract(
|
|
20695
20688
|
contractAddress.ERC20,
|
|
20696
20689
|
ERC20Token_default,
|
|
@@ -20698,49 +20691,28 @@ var Seamless = class {
|
|
|
20698
20691
|
);
|
|
20699
20692
|
try {
|
|
20700
20693
|
const nonces = await erc20Contract.nonces(masterAddress);
|
|
20701
|
-
const
|
|
20694
|
+
const tradingRouterSignPermit = await signPermit(
|
|
20702
20695
|
config.signer,
|
|
20703
|
-
// 使用 signer 而不是 provider
|
|
20704
20696
|
erc20Contract,
|
|
20705
20697
|
masterAddress,
|
|
20706
|
-
|
|
20698
|
+
contractAddress.TRADING_ROUTER,
|
|
20707
20699
|
ethers9.MaxUint256.toString(),
|
|
20708
20700
|
nonces.toString(),
|
|
20709
20701
|
deadline.toString()
|
|
20710
20702
|
);
|
|
20711
|
-
const
|
|
20712
|
-
|
|
20713
|
-
// 使用 signer 而不是 provider
|
|
20714
|
-
erc20Contract,
|
|
20715
|
-
masterAddress,
|
|
20716
|
-
contractAddress.Account,
|
|
20717
|
-
ethers9.MaxUint256.toString(),
|
|
20718
|
-
(nonces + BigInt(1)).toString(),
|
|
20719
|
-
deadline.toString()
|
|
20720
|
-
);
|
|
20721
|
-
const forwarderPermitParams = {
|
|
20722
|
-
token: erc20Contract.target,
|
|
20703
|
+
const tradingRouterPermitParams = {
|
|
20704
|
+
token: contractAddress.ERC20,
|
|
20723
20705
|
owner: masterAddress,
|
|
20724
|
-
spender:
|
|
20725
|
-
value: ethers9.MaxUint256,
|
|
20726
|
-
deadline,
|
|
20727
|
-
v:
|
|
20728
|
-
r:
|
|
20729
|
-
s:
|
|
20706
|
+
spender: contractAddress.TRADING_ROUTER,
|
|
20707
|
+
value: ethers9.MaxUint256.toString(),
|
|
20708
|
+
deadline: deadline.toString(),
|
|
20709
|
+
v: tradingRouterSignPermit.v,
|
|
20710
|
+
r: tradingRouterSignPermit.r,
|
|
20711
|
+
s: tradingRouterSignPermit.s
|
|
20730
20712
|
};
|
|
20731
|
-
|
|
20732
|
-
token: erc20Contract.target,
|
|
20733
|
-
owner: masterAddress,
|
|
20734
|
-
spender: contractAddress.Account,
|
|
20735
|
-
value: ethers9.MaxUint256,
|
|
20736
|
-
deadline,
|
|
20737
|
-
v: accountSignPermit.v,
|
|
20738
|
-
r: accountSignPermit.r,
|
|
20739
|
-
s: accountSignPermit.s
|
|
20740
|
-
};
|
|
20741
|
-
return [forwarderPermitParams, accountPermitParams];
|
|
20713
|
+
return [tradingRouterPermitParams];
|
|
20742
20714
|
} catch (error) {
|
|
20743
|
-
|
|
20715
|
+
console.log("error-->", error);
|
|
20744
20716
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
|
|
20745
20717
|
}
|
|
20746
20718
|
}
|
|
@@ -20771,17 +20743,24 @@ var Seamless = class {
|
|
|
20771
20743
|
deadline,
|
|
20772
20744
|
data
|
|
20773
20745
|
});
|
|
20774
|
-
const
|
|
20746
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
20747
|
+
const txRs = await this.api.forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature, forwardFeeToken }, chainId);
|
|
20775
20748
|
return txRs;
|
|
20776
20749
|
}
|
|
20777
20750
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
|
20778
20751
|
const config = this.configManager.getConfig();
|
|
20779
20752
|
const masterAddress = await config.signer?.getAddress() ?? "";
|
|
20753
|
+
const provider = await getSignerProvider(chainId);
|
|
20780
20754
|
if (approve2) {
|
|
20781
20755
|
const balanceRes = await this.account.getWalletQuoteTokenBalance(chainId, masterAddress);
|
|
20782
20756
|
const balance = balanceRes.data;
|
|
20783
|
-
const
|
|
20784
|
-
|
|
20757
|
+
const marketManagerContract = new ethers9.Contract(
|
|
20758
|
+
getContractAddressByChainId(chainId).MARKET_MANAGER,
|
|
20759
|
+
MarketManager_default,
|
|
20760
|
+
provider
|
|
20761
|
+
);
|
|
20762
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
20763
|
+
const pledgeFee = await marketManagerContract.getForwardFeeByToken(forwardFeeToken);
|
|
20785
20764
|
const gasFee = BigInt(pledgeFee) * BigInt(FORWARD_PLEDGE_FEE_RADIO);
|
|
20786
20765
|
if (gasFee > 0 && gasFee > BigInt(balance)) {
|
|
20787
20766
|
throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient balance");
|