@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.js
CHANGED
|
@@ -1517,6 +1517,18 @@ var address_default = {
|
|
|
1517
1517
|
[59141 /* LINEA_SEPOLIA */]: LINEA_SEPOLIA,
|
|
1518
1518
|
[97 /* BSC_TESTNET */]: BSC_TEST_NET
|
|
1519
1519
|
};
|
|
1520
|
+
var executeAddressByChainId = (chainId) => {
|
|
1521
|
+
if (chainId === 421614 /* ARB_TESTNET */) {
|
|
1522
|
+
return "0x7e248ec1721639413a280d9e82e2862cae2e6e28";
|
|
1523
|
+
}
|
|
1524
|
+
if (chainId === 59141 /* LINEA_SEPOLIA */) {
|
|
1525
|
+
return "";
|
|
1526
|
+
}
|
|
1527
|
+
if (chainId === 97 /* BSC_TESTNET */) {
|
|
1528
|
+
return "";
|
|
1529
|
+
}
|
|
1530
|
+
return "";
|
|
1531
|
+
};
|
|
1520
1532
|
|
|
1521
1533
|
// src/web3/index.ts
|
|
1522
1534
|
var import_ethers2 = require("ethers");
|
|
@@ -1839,7 +1851,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
|
|
|
1839
1851
|
// package.json
|
|
1840
1852
|
var package_default = {
|
|
1841
1853
|
name: "@myx-trade/sdk",
|
|
1842
|
-
version: "0.1.
|
|
1854
|
+
version: "0.1.247",
|
|
1843
1855
|
private: false,
|
|
1844
1856
|
publishConfig: {
|
|
1845
1857
|
access: "public"
|
|
@@ -9314,6 +9326,24 @@ var Forwarder_default = [
|
|
|
9314
9326
|
name: "InvalidInitialization",
|
|
9315
9327
|
inputs: []
|
|
9316
9328
|
},
|
|
9329
|
+
{
|
|
9330
|
+
type: "error",
|
|
9331
|
+
name: "MismatchExecuteFee",
|
|
9332
|
+
inputs: [
|
|
9333
|
+
{
|
|
9334
|
+
type: "uint256",
|
|
9335
|
+
name: "balanceBefore"
|
|
9336
|
+
},
|
|
9337
|
+
{
|
|
9338
|
+
type: "uint256",
|
|
9339
|
+
name: "balanceAfter"
|
|
9340
|
+
},
|
|
9341
|
+
{
|
|
9342
|
+
type: "uint256",
|
|
9343
|
+
name: "expected"
|
|
9344
|
+
}
|
|
9345
|
+
]
|
|
9346
|
+
},
|
|
9317
9347
|
{
|
|
9318
9348
|
type: "error",
|
|
9319
9349
|
name: "MismatchedSender",
|
|
@@ -9390,13 +9420,8 @@ var Forwarder_default = [
|
|
|
9390
9420
|
},
|
|
9391
9421
|
{
|
|
9392
9422
|
type: "error",
|
|
9393
|
-
name: "
|
|
9394
|
-
inputs: [
|
|
9395
|
-
{
|
|
9396
|
-
type: "address",
|
|
9397
|
-
name: "token"
|
|
9398
|
-
}
|
|
9399
|
-
]
|
|
9423
|
+
name: "RemoveRelayerFailed",
|
|
9424
|
+
inputs: []
|
|
9400
9425
|
},
|
|
9401
9426
|
{
|
|
9402
9427
|
type: "error",
|
|
@@ -9425,6 +9450,28 @@ var Forwarder_default = [
|
|
|
9425
9450
|
}
|
|
9426
9451
|
]
|
|
9427
9452
|
},
|
|
9453
|
+
{
|
|
9454
|
+
type: "event",
|
|
9455
|
+
anonymous: false,
|
|
9456
|
+
name: "ChargeForwardFee",
|
|
9457
|
+
inputs: [
|
|
9458
|
+
{
|
|
9459
|
+
type: "address",
|
|
9460
|
+
name: "account",
|
|
9461
|
+
indexed: false
|
|
9462
|
+
},
|
|
9463
|
+
{
|
|
9464
|
+
type: "address",
|
|
9465
|
+
name: "feeToken",
|
|
9466
|
+
indexed: false
|
|
9467
|
+
},
|
|
9468
|
+
{
|
|
9469
|
+
type: "uint256",
|
|
9470
|
+
name: "relayFee",
|
|
9471
|
+
indexed: false
|
|
9472
|
+
}
|
|
9473
|
+
]
|
|
9474
|
+
},
|
|
9428
9475
|
{
|
|
9429
9476
|
type: "event",
|
|
9430
9477
|
anonymous: false,
|
|
@@ -9531,7 +9578,7 @@ var Forwarder_default = [
|
|
|
9531
9578
|
{
|
|
9532
9579
|
type: "event",
|
|
9533
9580
|
anonymous: false,
|
|
9534
|
-
name: "
|
|
9581
|
+
name: "UpdateAcquiescentFeeToken",
|
|
9535
9582
|
inputs: [
|
|
9536
9583
|
{
|
|
9537
9584
|
type: "address",
|
|
@@ -9539,13 +9586,13 @@ var Forwarder_default = [
|
|
|
9539
9586
|
indexed: false
|
|
9540
9587
|
},
|
|
9541
9588
|
{
|
|
9542
|
-
type: "
|
|
9543
|
-
name: "
|
|
9589
|
+
type: "address",
|
|
9590
|
+
name: "oldRelayGas",
|
|
9544
9591
|
indexed: false
|
|
9545
9592
|
},
|
|
9546
9593
|
{
|
|
9547
|
-
type: "
|
|
9548
|
-
name: "
|
|
9594
|
+
type: "address",
|
|
9595
|
+
name: "newRelayGas",
|
|
9549
9596
|
indexed: false
|
|
9550
9597
|
}
|
|
9551
9598
|
]
|
|
@@ -9553,7 +9600,7 @@ var Forwarder_default = [
|
|
|
9553
9600
|
{
|
|
9554
9601
|
type: "event",
|
|
9555
9602
|
anonymous: false,
|
|
9556
|
-
name: "
|
|
9603
|
+
name: "UpdateEquilibriumGas",
|
|
9557
9604
|
inputs: [
|
|
9558
9605
|
{
|
|
9559
9606
|
type: "address",
|
|
@@ -9562,22 +9609,34 @@ var Forwarder_default = [
|
|
|
9562
9609
|
},
|
|
9563
9610
|
{
|
|
9564
9611
|
type: "uint256",
|
|
9565
|
-
name: "
|
|
9612
|
+
name: "oldRelayGas",
|
|
9566
9613
|
indexed: false
|
|
9567
9614
|
},
|
|
9568
9615
|
{
|
|
9569
9616
|
type: "uint256",
|
|
9570
|
-
name: "
|
|
9617
|
+
name: "newRelayGas",
|
|
9618
|
+
indexed: false
|
|
9619
|
+
}
|
|
9620
|
+
]
|
|
9621
|
+
},
|
|
9622
|
+
{
|
|
9623
|
+
type: "event",
|
|
9624
|
+
anonymous: false,
|
|
9625
|
+
name: "UpdateMaxRelayFee",
|
|
9626
|
+
inputs: [
|
|
9627
|
+
{
|
|
9628
|
+
type: "address",
|
|
9629
|
+
name: "sender",
|
|
9571
9630
|
indexed: false
|
|
9572
9631
|
},
|
|
9573
9632
|
{
|
|
9574
9633
|
type: "uint256",
|
|
9575
|
-
name: "
|
|
9634
|
+
name: "oldMaxRelayFee",
|
|
9576
9635
|
indexed: false
|
|
9577
9636
|
},
|
|
9578
9637
|
{
|
|
9579
9638
|
type: "uint256",
|
|
9580
|
-
name: "
|
|
9639
|
+
name: "newMaxRelayFee",
|
|
9581
9640
|
indexed: false
|
|
9582
9641
|
}
|
|
9583
9642
|
]
|
|
@@ -9640,6 +9699,10 @@ var Forwarder_default = [
|
|
|
9640
9699
|
stateMutability: "payable",
|
|
9641
9700
|
payable: true,
|
|
9642
9701
|
inputs: [
|
|
9702
|
+
{
|
|
9703
|
+
type: "address",
|
|
9704
|
+
name: "forwardFeeToken"
|
|
9705
|
+
},
|
|
9643
9706
|
{
|
|
9644
9707
|
type: "tuple[]",
|
|
9645
9708
|
name: "bundleParams",
|
|
@@ -9715,6 +9778,19 @@ var Forwarder_default = [
|
|
|
9715
9778
|
}
|
|
9716
9779
|
]
|
|
9717
9780
|
},
|
|
9781
|
+
{
|
|
9782
|
+
type: "function",
|
|
9783
|
+
name: "equilibriumGas",
|
|
9784
|
+
constant: true,
|
|
9785
|
+
stateMutability: "view",
|
|
9786
|
+
payable: false,
|
|
9787
|
+
inputs: [],
|
|
9788
|
+
outputs: [
|
|
9789
|
+
{
|
|
9790
|
+
type: "uint256"
|
|
9791
|
+
}
|
|
9792
|
+
]
|
|
9793
|
+
},
|
|
9718
9794
|
{
|
|
9719
9795
|
type: "function",
|
|
9720
9796
|
name: "execute",
|
|
@@ -9755,6 +9831,10 @@ var Forwarder_default = [
|
|
|
9755
9831
|
name: "signature"
|
|
9756
9832
|
}
|
|
9757
9833
|
]
|
|
9834
|
+
},
|
|
9835
|
+
{
|
|
9836
|
+
type: "address",
|
|
9837
|
+
name: "masterAccount"
|
|
9758
9838
|
}
|
|
9759
9839
|
],
|
|
9760
9840
|
outputs: []
|
|
@@ -9800,6 +9880,10 @@ var Forwarder_default = [
|
|
|
9800
9880
|
}
|
|
9801
9881
|
]
|
|
9802
9882
|
},
|
|
9883
|
+
{
|
|
9884
|
+
type: "address",
|
|
9885
|
+
name: "masterAccount"
|
|
9886
|
+
},
|
|
9803
9887
|
{
|
|
9804
9888
|
type: "address",
|
|
9805
9889
|
name: "refundReceiver"
|
|
@@ -9814,6 +9898,10 @@ var Forwarder_default = [
|
|
|
9814
9898
|
stateMutability: "payable",
|
|
9815
9899
|
payable: true,
|
|
9816
9900
|
inputs: [
|
|
9901
|
+
{
|
|
9902
|
+
type: "address",
|
|
9903
|
+
name: "forwardFeeToken"
|
|
9904
|
+
},
|
|
9817
9905
|
{
|
|
9818
9906
|
type: "tuple",
|
|
9819
9907
|
name: "params",
|
|
@@ -9853,16 +9941,11 @@ var Forwarder_default = [
|
|
|
9853
9941
|
},
|
|
9854
9942
|
{
|
|
9855
9943
|
type: "function",
|
|
9856
|
-
name: "
|
|
9857
|
-
constant:
|
|
9858
|
-
stateMutability: "view",
|
|
9944
|
+
name: "exitForwardMode",
|
|
9945
|
+
constant: false,
|
|
9859
9946
|
payable: false,
|
|
9860
9947
|
inputs: [],
|
|
9861
|
-
outputs: [
|
|
9862
|
-
{
|
|
9863
|
-
type: "address"
|
|
9864
|
-
}
|
|
9865
|
-
]
|
|
9948
|
+
outputs: []
|
|
9866
9949
|
},
|
|
9867
9950
|
{
|
|
9868
9951
|
type: "function",
|
|
@@ -9910,7 +9993,7 @@ var Forwarder_default = [
|
|
|
9910
9993
|
},
|
|
9911
9994
|
{
|
|
9912
9995
|
type: "function",
|
|
9913
|
-
name: "
|
|
9996
|
+
name: "getDesignatedToken",
|
|
9914
9997
|
constant: true,
|
|
9915
9998
|
stateMutability: "view",
|
|
9916
9999
|
payable: false,
|
|
@@ -9923,71 +10006,58 @@ var Forwarder_default = [
|
|
|
9923
10006
|
},
|
|
9924
10007
|
{
|
|
9925
10008
|
type: "function",
|
|
9926
|
-
name: "
|
|
10009
|
+
name: "getEquilibriumGas",
|
|
9927
10010
|
constant: true,
|
|
9928
10011
|
stateMutability: "view",
|
|
9929
10012
|
payable: false,
|
|
9930
10013
|
inputs: [],
|
|
9931
10014
|
outputs: [
|
|
9932
10015
|
{
|
|
9933
|
-
type: "
|
|
10016
|
+
type: "uint256"
|
|
9934
10017
|
}
|
|
9935
10018
|
]
|
|
9936
10019
|
},
|
|
9937
10020
|
{
|
|
9938
10021
|
type: "function",
|
|
9939
|
-
name: "
|
|
10022
|
+
name: "getImplementation",
|
|
9940
10023
|
constant: true,
|
|
9941
10024
|
stateMutability: "view",
|
|
9942
10025
|
payable: false,
|
|
9943
10026
|
inputs: [],
|
|
9944
10027
|
outputs: [
|
|
9945
10028
|
{
|
|
9946
|
-
type: "
|
|
10029
|
+
type: "address"
|
|
9947
10030
|
}
|
|
9948
10031
|
]
|
|
9949
10032
|
},
|
|
9950
10033
|
{
|
|
9951
10034
|
type: "function",
|
|
9952
|
-
name: "
|
|
10035
|
+
name: "getUserRelayers",
|
|
9953
10036
|
constant: true,
|
|
9954
10037
|
stateMutability: "view",
|
|
9955
10038
|
payable: false,
|
|
9956
|
-
inputs: [
|
|
9957
|
-
outputs: [
|
|
10039
|
+
inputs: [
|
|
9958
10040
|
{
|
|
9959
|
-
type: "
|
|
10041
|
+
type: "address",
|
|
10042
|
+
name: "account"
|
|
9960
10043
|
}
|
|
9961
|
-
]
|
|
9962
|
-
},
|
|
9963
|
-
{
|
|
9964
|
-
type: "function",
|
|
9965
|
-
name: "getRelayGas",
|
|
9966
|
-
constant: true,
|
|
9967
|
-
stateMutability: "view",
|
|
9968
|
-
payable: false,
|
|
9969
|
-
inputs: [],
|
|
10044
|
+
],
|
|
9970
10045
|
outputs: [
|
|
9971
10046
|
{
|
|
9972
|
-
type: "
|
|
10047
|
+
type: "address[]"
|
|
9973
10048
|
}
|
|
9974
10049
|
]
|
|
9975
10050
|
},
|
|
9976
10051
|
{
|
|
9977
10052
|
type: "function",
|
|
9978
|
-
name: "
|
|
10053
|
+
name: "inForwardMode",
|
|
9979
10054
|
constant: true,
|
|
9980
10055
|
stateMutability: "view",
|
|
9981
10056
|
payable: false,
|
|
9982
|
-
inputs: [
|
|
9983
|
-
{
|
|
9984
|
-
type: "address",
|
|
9985
|
-
name: "account"
|
|
9986
|
-
}
|
|
9987
|
-
],
|
|
10057
|
+
inputs: [],
|
|
9988
10058
|
outputs: [
|
|
9989
10059
|
{
|
|
9990
|
-
type: "
|
|
10060
|
+
type: "bool"
|
|
9991
10061
|
}
|
|
9992
10062
|
]
|
|
9993
10063
|
},
|
|
@@ -10001,35 +10071,23 @@ var Forwarder_default = [
|
|
|
10001
10071
|
type: "address",
|
|
10002
10072
|
name: "addressManager"
|
|
10003
10073
|
},
|
|
10004
|
-
{
|
|
10005
|
-
type: "address",
|
|
10006
|
-
name: "_feeToken"
|
|
10007
|
-
},
|
|
10008
10074
|
{
|
|
10009
10075
|
type: "uint256",
|
|
10010
|
-
name: "
|
|
10011
|
-
},
|
|
10012
|
-
{
|
|
10013
|
-
type: "uint256",
|
|
10014
|
-
name: "_relayGas"
|
|
10015
|
-
},
|
|
10016
|
-
{
|
|
10017
|
-
type: "uint256",
|
|
10018
|
-
name: "_maxRelayFee"
|
|
10076
|
+
name: "_equilibriumGas"
|
|
10019
10077
|
}
|
|
10020
10078
|
],
|
|
10021
10079
|
outputs: []
|
|
10022
10080
|
},
|
|
10023
10081
|
{
|
|
10024
10082
|
type: "function",
|
|
10025
|
-
name: "
|
|
10083
|
+
name: "isAllowedTargets",
|
|
10026
10084
|
constant: true,
|
|
10027
10085
|
stateMutability: "view",
|
|
10028
10086
|
payable: false,
|
|
10029
10087
|
inputs: [
|
|
10030
10088
|
{
|
|
10031
10089
|
type: "address",
|
|
10032
|
-
name: "
|
|
10090
|
+
name: "contractAddr"
|
|
10033
10091
|
}
|
|
10034
10092
|
],
|
|
10035
10093
|
outputs: [
|
|
@@ -10040,18 +10098,14 @@ var Forwarder_default = [
|
|
|
10040
10098
|
},
|
|
10041
10099
|
{
|
|
10042
10100
|
type: "function",
|
|
10043
|
-
name: "
|
|
10101
|
+
name: "isTrustedForwarder",
|
|
10044
10102
|
constant: true,
|
|
10045
10103
|
stateMutability: "view",
|
|
10046
10104
|
payable: false,
|
|
10047
10105
|
inputs: [
|
|
10048
10106
|
{
|
|
10049
10107
|
type: "address",
|
|
10050
|
-
name: "
|
|
10051
|
-
},
|
|
10052
|
-
{
|
|
10053
|
-
type: "address",
|
|
10054
|
-
name: "relayer"
|
|
10108
|
+
name: "forwarder"
|
|
10055
10109
|
}
|
|
10056
10110
|
],
|
|
10057
10111
|
outputs: [
|
|
@@ -10062,14 +10116,23 @@ var Forwarder_default = [
|
|
|
10062
10116
|
},
|
|
10063
10117
|
{
|
|
10064
10118
|
type: "function",
|
|
10065
|
-
name: "
|
|
10119
|
+
name: "isUserRelayerEnabled",
|
|
10066
10120
|
constant: true,
|
|
10067
10121
|
stateMutability: "view",
|
|
10068
10122
|
payable: false,
|
|
10069
|
-
inputs: [
|
|
10123
|
+
inputs: [
|
|
10124
|
+
{
|
|
10125
|
+
type: "address",
|
|
10126
|
+
name: "account"
|
|
10127
|
+
},
|
|
10128
|
+
{
|
|
10129
|
+
type: "address",
|
|
10130
|
+
name: "relayer"
|
|
10131
|
+
}
|
|
10132
|
+
],
|
|
10070
10133
|
outputs: [
|
|
10071
10134
|
{
|
|
10072
|
-
type: "
|
|
10135
|
+
type: "bool"
|
|
10073
10136
|
}
|
|
10074
10137
|
]
|
|
10075
10138
|
},
|
|
@@ -10178,32 +10241,6 @@ var Forwarder_default = [
|
|
|
10178
10241
|
}
|
|
10179
10242
|
]
|
|
10180
10243
|
},
|
|
10181
|
-
{
|
|
10182
|
-
type: "function",
|
|
10183
|
-
name: "relayFee",
|
|
10184
|
-
constant: true,
|
|
10185
|
-
stateMutability: "view",
|
|
10186
|
-
payable: false,
|
|
10187
|
-
inputs: [],
|
|
10188
|
-
outputs: [
|
|
10189
|
-
{
|
|
10190
|
-
type: "uint256"
|
|
10191
|
-
}
|
|
10192
|
-
]
|
|
10193
|
-
},
|
|
10194
|
-
{
|
|
10195
|
-
type: "function",
|
|
10196
|
-
name: "relayGas",
|
|
10197
|
-
constant: true,
|
|
10198
|
-
stateMutability: "view",
|
|
10199
|
-
payable: false,
|
|
10200
|
-
inputs: [],
|
|
10201
|
-
outputs: [
|
|
10202
|
-
{
|
|
10203
|
-
type: "uint256"
|
|
10204
|
-
}
|
|
10205
|
-
]
|
|
10206
|
-
},
|
|
10207
10244
|
{
|
|
10208
10245
|
type: "function",
|
|
10209
10246
|
name: "removeAllowedTarget",
|
|
@@ -10232,30 +10269,13 @@ var Forwarder_default = [
|
|
|
10232
10269
|
},
|
|
10233
10270
|
{
|
|
10234
10271
|
type: "function",
|
|
10235
|
-
name: "
|
|
10272
|
+
name: "updateEquilibriumGas",
|
|
10236
10273
|
constant: false,
|
|
10237
10274
|
payable: false,
|
|
10238
10275
|
inputs: [
|
|
10239
10276
|
{
|
|
10240
10277
|
type: "uint256",
|
|
10241
|
-
name: "
|
|
10242
|
-
}
|
|
10243
|
-
],
|
|
10244
|
-
outputs: []
|
|
10245
|
-
},
|
|
10246
|
-
{
|
|
10247
|
-
type: "function",
|
|
10248
|
-
name: "updateRelayInfo",
|
|
10249
|
-
constant: false,
|
|
10250
|
-
payable: false,
|
|
10251
|
-
inputs: [
|
|
10252
|
-
{
|
|
10253
|
-
type: "uint256",
|
|
10254
|
-
name: "_relayFee"
|
|
10255
|
-
},
|
|
10256
|
-
{
|
|
10257
|
-
type: "uint256",
|
|
10258
|
-
name: "_relayGas"
|
|
10278
|
+
name: "_equilibriumGas"
|
|
10259
10279
|
}
|
|
10260
10280
|
],
|
|
10261
10281
|
outputs: []
|
|
@@ -13153,10 +13173,10 @@ var Position = class {
|
|
|
13153
13173
|
}
|
|
13154
13174
|
const updateParams = {
|
|
13155
13175
|
poolId,
|
|
13176
|
+
oracleType: poolOracleType,
|
|
13156
13177
|
referencePrice: import_ethers23.ethers.parseUnits(priceData?.price ?? "0", 30),
|
|
13157
13178
|
oracleUpdateData: priceData?.vaa ?? "0",
|
|
13158
|
-
publishTime: priceData.publishTime
|
|
13159
|
-
oracleType: poolOracleType
|
|
13179
|
+
publishTime: priceData.publishTime
|
|
13160
13180
|
};
|
|
13161
13181
|
let needsApproval = false;
|
|
13162
13182
|
if (Number(adjustAmount) > 0) {
|
|
@@ -19139,9 +19159,14 @@ var Utils = class {
|
|
|
19139
19159
|
}
|
|
19140
19160
|
}
|
|
19141
19161
|
async checkSeamlessGas(userAddress, chainId) {
|
|
19142
|
-
const forwarderContract = await getForwarderContract(chainId);
|
|
19143
|
-
const relayFee = await forwarderContract.getRelayFee();
|
|
19144
19162
|
const provider = await getJSONProvider(chainId);
|
|
19163
|
+
const marketManagerContract = new import_ethers25.ethers.Contract(
|
|
19164
|
+
getContractAddressByChainId(chainId).MARKET_MANAGER,
|
|
19165
|
+
MarketManager_default,
|
|
19166
|
+
provider
|
|
19167
|
+
);
|
|
19168
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
19169
|
+
const relayFee = await marketManagerContract.getRelayFee(forwardFeeToken);
|
|
19145
19170
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
19146
19171
|
const erc20Contract = new import_ethers25.ethers.Contract(
|
|
19147
19172
|
contractAddress.ERC20,
|
|
@@ -20012,29 +20037,6 @@ var Account = class {
|
|
|
20012
20037
|
}
|
|
20013
20038
|
async getAvailableMarginBalance({ poolId, chainId, address }) {
|
|
20014
20039
|
try {
|
|
20015
|
-
const poolListRes = await this.client.api.getPoolList();
|
|
20016
|
-
if (poolListRes.code !== 9200) {
|
|
20017
|
-
throw new MyxSDKError(
|
|
20018
|
-
"REQUEST_FAILED" /* RequestFailed */,
|
|
20019
|
-
"Failed to get pool list"
|
|
20020
|
-
);
|
|
20021
|
-
}
|
|
20022
|
-
const poolList = poolListRes.data;
|
|
20023
|
-
const pool = poolList?.find((pool2) => pool2.poolId === poolId);
|
|
20024
|
-
const orderRes = await this.client.order.getOrders(address);
|
|
20025
|
-
if (orderRes.code !== 0) {
|
|
20026
|
-
throw new MyxSDKError(
|
|
20027
|
-
"REQUEST_FAILED" /* RequestFailed */,
|
|
20028
|
-
"Failed to get orders"
|
|
20029
|
-
);
|
|
20030
|
-
}
|
|
20031
|
-
const orders = orderRes.data;
|
|
20032
|
-
const openOrders = orders?.filter((order) => order.poolId === poolId);
|
|
20033
|
-
const used = openOrders?.reduce((acc, order) => {
|
|
20034
|
-
const prev = BigInt(import_ethers26.ethers.parseUnits(acc, pool?.quoteDecimals ?? 6));
|
|
20035
|
-
const curr = BigInt(import_ethers26.ethers.parseUnits(order.collateralAmount ?? "0", pool?.quoteDecimals ?? 6)) + prev;
|
|
20036
|
-
return curr.toString();
|
|
20037
|
-
}, "0");
|
|
20038
20040
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
20039
20041
|
if (marginAccountBalanceRes.code !== 0) {
|
|
20040
20042
|
throw new MyxSDKError(
|
|
@@ -20043,15 +20045,10 @@ var Account = class {
|
|
|
20043
20045
|
);
|
|
20044
20046
|
}
|
|
20045
20047
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
20046
|
-
const usedMargin = BigInt(used ?? "0");
|
|
20047
20048
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
20048
20049
|
const freeAmount = BigInt(marginAccountBalance?.freeMargin ?? 0);
|
|
20049
20050
|
const accountMargin = freeAmount + quoteProfit;
|
|
20050
|
-
|
|
20051
|
-
return BigInt(0);
|
|
20052
|
-
}
|
|
20053
|
-
const availableAccountMarginBalance = accountMargin - usedMargin;
|
|
20054
|
-
return availableAccountMarginBalance;
|
|
20051
|
+
return accountMargin;
|
|
20055
20052
|
} catch (error) {
|
|
20056
20053
|
throw new MyxSDKError(
|
|
20057
20054
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -20213,8 +20210,6 @@ var Account = class {
|
|
|
20213
20210
|
};
|
|
20214
20211
|
}
|
|
20215
20212
|
}
|
|
20216
|
-
async getCurrentEpoch() {
|
|
20217
|
-
}
|
|
20218
20213
|
async getAccountVipInfo(chainId, address) {
|
|
20219
20214
|
const config = this.configManager.getConfig();
|
|
20220
20215
|
const provider = await getJSONProvider(chainId);
|
|
@@ -20765,8 +20760,6 @@ var Seamless = class {
|
|
|
20765
20760
|
}
|
|
20766
20761
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
20767
20762
|
const masterAddress = await config.signer.getAddress();
|
|
20768
|
-
const forwarderContract = await getForwarderContract(chainId);
|
|
20769
|
-
const forwarderAddress = forwarderContract.target;
|
|
20770
20763
|
const erc20Contract = new import_ethers27.ethers.Contract(
|
|
20771
20764
|
contractAddress.ERC20,
|
|
20772
20765
|
ERC20Token_default,
|
|
@@ -20774,49 +20767,28 @@ var Seamless = class {
|
|
|
20774
20767
|
);
|
|
20775
20768
|
try {
|
|
20776
20769
|
const nonces = await erc20Contract.nonces(masterAddress);
|
|
20777
|
-
const
|
|
20770
|
+
const tradingRouterSignPermit = await signPermit(
|
|
20778
20771
|
config.signer,
|
|
20779
|
-
// 使用 signer 而不是 provider
|
|
20780
20772
|
erc20Contract,
|
|
20781
20773
|
masterAddress,
|
|
20782
|
-
|
|
20774
|
+
contractAddress.TRADING_ROUTER,
|
|
20783
20775
|
import_ethers27.ethers.MaxUint256.toString(),
|
|
20784
20776
|
nonces.toString(),
|
|
20785
20777
|
deadline.toString()
|
|
20786
20778
|
);
|
|
20787
|
-
const
|
|
20788
|
-
|
|
20789
|
-
// 使用 signer 而不是 provider
|
|
20790
|
-
erc20Contract,
|
|
20791
|
-
masterAddress,
|
|
20792
|
-
contractAddress.Account,
|
|
20793
|
-
import_ethers27.ethers.MaxUint256.toString(),
|
|
20794
|
-
(nonces + BigInt(1)).toString(),
|
|
20795
|
-
deadline.toString()
|
|
20796
|
-
);
|
|
20797
|
-
const forwarderPermitParams = {
|
|
20798
|
-
token: erc20Contract.target,
|
|
20779
|
+
const tradingRouterPermitParams = {
|
|
20780
|
+
token: contractAddress.ERC20,
|
|
20799
20781
|
owner: masterAddress,
|
|
20800
|
-
spender:
|
|
20801
|
-
value: import_ethers27.ethers.MaxUint256,
|
|
20802
|
-
deadline,
|
|
20803
|
-
v:
|
|
20804
|
-
r:
|
|
20805
|
-
s:
|
|
20782
|
+
spender: contractAddress.TRADING_ROUTER,
|
|
20783
|
+
value: import_ethers27.ethers.MaxUint256.toString(),
|
|
20784
|
+
deadline: deadline.toString(),
|
|
20785
|
+
v: tradingRouterSignPermit.v,
|
|
20786
|
+
r: tradingRouterSignPermit.r,
|
|
20787
|
+
s: tradingRouterSignPermit.s
|
|
20806
20788
|
};
|
|
20807
|
-
|
|
20808
|
-
token: erc20Contract.target,
|
|
20809
|
-
owner: masterAddress,
|
|
20810
|
-
spender: contractAddress.Account,
|
|
20811
|
-
value: import_ethers27.ethers.MaxUint256,
|
|
20812
|
-
deadline,
|
|
20813
|
-
v: accountSignPermit.v,
|
|
20814
|
-
r: accountSignPermit.r,
|
|
20815
|
-
s: accountSignPermit.s
|
|
20816
|
-
};
|
|
20817
|
-
return [forwarderPermitParams, accountPermitParams];
|
|
20789
|
+
return [tradingRouterPermitParams];
|
|
20818
20790
|
} catch (error) {
|
|
20819
|
-
|
|
20791
|
+
console.log("error-->", error);
|
|
20820
20792
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
|
|
20821
20793
|
}
|
|
20822
20794
|
}
|
|
@@ -20847,17 +20819,24 @@ var Seamless = class {
|
|
|
20847
20819
|
deadline,
|
|
20848
20820
|
data
|
|
20849
20821
|
});
|
|
20850
|
-
const
|
|
20822
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
20823
|
+
const txRs = await this.api.forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature, forwardFeeToken }, chainId);
|
|
20851
20824
|
return txRs;
|
|
20852
20825
|
}
|
|
20853
20826
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
|
20854
20827
|
const config = this.configManager.getConfig();
|
|
20855
20828
|
const masterAddress = await config.signer?.getAddress() ?? "";
|
|
20829
|
+
const provider = await getSignerProvider(chainId);
|
|
20856
20830
|
if (approve2) {
|
|
20857
20831
|
const balanceRes = await this.account.getWalletQuoteTokenBalance(chainId, masterAddress);
|
|
20858
20832
|
const balance = balanceRes.data;
|
|
20859
|
-
const
|
|
20860
|
-
|
|
20833
|
+
const marketManagerContract = new import_ethers27.ethers.Contract(
|
|
20834
|
+
getContractAddressByChainId(chainId).MARKET_MANAGER,
|
|
20835
|
+
MarketManager_default,
|
|
20836
|
+
provider
|
|
20837
|
+
);
|
|
20838
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
20839
|
+
const pledgeFee = await marketManagerContract.getForwardFeeByToken(forwardFeeToken);
|
|
20861
20840
|
const gasFee = BigInt(pledgeFee) * BigInt(FORWARD_PLEDGE_FEE_RADIO);
|
|
20862
20841
|
if (gasFee > 0 && gasFee > BigInt(balance)) {
|
|
20863
20842
|
throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient balance");
|