@myx-trade/sdk 0.1.245 → 0.1.246
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 +437 -71
- package/dist/index.mjs +437 -71
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -732,6 +732,7 @@ type ForwarderTxParams = {
|
|
|
732
732
|
data: string;
|
|
733
733
|
deadline: number;
|
|
734
734
|
signature: string;
|
|
735
|
+
forwardFeeToken: string;
|
|
735
736
|
};
|
|
736
737
|
type FetchForwarderGetParams = {
|
|
737
738
|
requestId: string;
|
|
@@ -1653,7 +1654,6 @@ declare class Account {
|
|
|
1653
1654
|
message: string;
|
|
1654
1655
|
data?: undefined;
|
|
1655
1656
|
}>;
|
|
1656
|
-
getCurrentEpoch(): Promise<void>;
|
|
1657
1657
|
getAccountVipInfo(chainId: number, address: string): Promise<{
|
|
1658
1658
|
code: number;
|
|
1659
1659
|
data: any;
|
|
@@ -1698,11 +1698,11 @@ declare class Seamless {
|
|
|
1698
1698
|
constructor(configManager: ConfigManager, logger: Logger, utils: Utils, account: Account, api: Api);
|
|
1699
1699
|
onCheckRelayer(account: string, relayer: string, chainId: number): Promise<boolean>;
|
|
1700
1700
|
getUSDPermitParams(deadline: number, chainId: number): Promise<{
|
|
1701
|
-
token: string
|
|
1701
|
+
token: string;
|
|
1702
1702
|
owner: string;
|
|
1703
1703
|
spender: string;
|
|
1704
|
-
value:
|
|
1705
|
-
deadline:
|
|
1704
|
+
value: string;
|
|
1705
|
+
deadline: string;
|
|
1706
1706
|
v: number;
|
|
1707
1707
|
r: string;
|
|
1708
1708
|
s: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -732,6 +732,7 @@ type ForwarderTxParams = {
|
|
|
732
732
|
data: string;
|
|
733
733
|
deadline: number;
|
|
734
734
|
signature: string;
|
|
735
|
+
forwardFeeToken: string;
|
|
735
736
|
};
|
|
736
737
|
type FetchForwarderGetParams = {
|
|
737
738
|
requestId: string;
|
|
@@ -1653,7 +1654,6 @@ declare class Account {
|
|
|
1653
1654
|
message: string;
|
|
1654
1655
|
data?: undefined;
|
|
1655
1656
|
}>;
|
|
1656
|
-
getCurrentEpoch(): Promise<void>;
|
|
1657
1657
|
getAccountVipInfo(chainId: number, address: string): Promise<{
|
|
1658
1658
|
code: number;
|
|
1659
1659
|
data: any;
|
|
@@ -1698,11 +1698,11 @@ declare class Seamless {
|
|
|
1698
1698
|
constructor(configManager: ConfigManager, logger: Logger, utils: Utils, account: Account, api: Api);
|
|
1699
1699
|
onCheckRelayer(account: string, relayer: string, chainId: number): Promise<boolean>;
|
|
1700
1700
|
getUSDPermitParams(deadline: number, chainId: number): Promise<{
|
|
1701
|
-
token: string
|
|
1701
|
+
token: string;
|
|
1702
1702
|
owner: string;
|
|
1703
1703
|
spender: string;
|
|
1704
|
-
value:
|
|
1705
|
-
deadline:
|
|
1704
|
+
value: string;
|
|
1705
|
+
deadline: string;
|
|
1706
1706
|
v: number;
|
|
1707
1707
|
r: string;
|
|
1708
1708
|
s: string;
|
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.246",
|
|
1843
1855
|
private: false,
|
|
1844
1856
|
publishConfig: {
|
|
1845
1857
|
access: "public"
|
|
@@ -13153,10 +13165,10 @@ var Position = class {
|
|
|
13153
13165
|
}
|
|
13154
13166
|
const updateParams = {
|
|
13155
13167
|
poolId,
|
|
13168
|
+
oracleType: poolOracleType,
|
|
13156
13169
|
referencePrice: import_ethers23.ethers.parseUnits(priceData?.price ?? "0", 30),
|
|
13157
13170
|
oracleUpdateData: priceData?.vaa ?? "0",
|
|
13158
|
-
publishTime: priceData.publishTime
|
|
13159
|
-
oracleType: poolOracleType
|
|
13171
|
+
publishTime: priceData.publishTime
|
|
13160
13172
|
};
|
|
13161
13173
|
let needsApproval = false;
|
|
13162
13174
|
if (Number(adjustAmount) > 0) {
|
|
@@ -20012,29 +20024,6 @@ var Account = class {
|
|
|
20012
20024
|
}
|
|
20013
20025
|
async getAvailableMarginBalance({ poolId, chainId, address }) {
|
|
20014
20026
|
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
20027
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
20039
20028
|
if (marginAccountBalanceRes.code !== 0) {
|
|
20040
20029
|
throw new MyxSDKError(
|
|
@@ -20043,15 +20032,10 @@ var Account = class {
|
|
|
20043
20032
|
);
|
|
20044
20033
|
}
|
|
20045
20034
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
20046
|
-
const usedMargin = BigInt(used ?? "0");
|
|
20047
20035
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
20048
20036
|
const freeAmount = BigInt(marginAccountBalance?.freeMargin ?? 0);
|
|
20049
20037
|
const accountMargin = freeAmount + quoteProfit;
|
|
20050
|
-
|
|
20051
|
-
return BigInt(0);
|
|
20052
|
-
}
|
|
20053
|
-
const availableAccountMarginBalance = accountMargin - usedMargin;
|
|
20054
|
-
return availableAccountMarginBalance;
|
|
20038
|
+
return accountMargin;
|
|
20055
20039
|
} catch (error) {
|
|
20056
20040
|
throw new MyxSDKError(
|
|
20057
20041
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -20213,8 +20197,6 @@ var Account = class {
|
|
|
20213
20197
|
};
|
|
20214
20198
|
}
|
|
20215
20199
|
}
|
|
20216
|
-
async getCurrentEpoch() {
|
|
20217
|
-
}
|
|
20218
20200
|
async getAccountVipInfo(chainId, address) {
|
|
20219
20201
|
const config = this.configManager.getConfig();
|
|
20220
20202
|
const provider = await getJSONProvider(chainId);
|
|
@@ -20678,6 +20660,408 @@ var getEIP712Domain = async (contract) => {
|
|
|
20678
20660
|
|
|
20679
20661
|
// src/manager/seamless/index.ts
|
|
20680
20662
|
var import_bytes = require("@ethersproject/bytes");
|
|
20663
|
+
|
|
20664
|
+
// src/abi/TradingRouter.json
|
|
20665
|
+
var TradingRouter_default = [
|
|
20666
|
+
{
|
|
20667
|
+
type: "error",
|
|
20668
|
+
name: "AddressEmptyCode",
|
|
20669
|
+
inputs: [
|
|
20670
|
+
{
|
|
20671
|
+
type: "address",
|
|
20672
|
+
name: "target"
|
|
20673
|
+
}
|
|
20674
|
+
]
|
|
20675
|
+
},
|
|
20676
|
+
{
|
|
20677
|
+
type: "error",
|
|
20678
|
+
name: "DesignatedTokenMismatch",
|
|
20679
|
+
inputs: [
|
|
20680
|
+
{
|
|
20681
|
+
type: "address",
|
|
20682
|
+
name: "collectToken"
|
|
20683
|
+
},
|
|
20684
|
+
{
|
|
20685
|
+
type: "address",
|
|
20686
|
+
name: "designatedToken"
|
|
20687
|
+
}
|
|
20688
|
+
]
|
|
20689
|
+
},
|
|
20690
|
+
{
|
|
20691
|
+
type: "error",
|
|
20692
|
+
name: "ERC1967InvalidImplementation",
|
|
20693
|
+
inputs: [
|
|
20694
|
+
{
|
|
20695
|
+
type: "address",
|
|
20696
|
+
name: "implementation"
|
|
20697
|
+
}
|
|
20698
|
+
]
|
|
20699
|
+
},
|
|
20700
|
+
{
|
|
20701
|
+
type: "error",
|
|
20702
|
+
name: "ERC1967NonPayable",
|
|
20703
|
+
inputs: []
|
|
20704
|
+
},
|
|
20705
|
+
{
|
|
20706
|
+
type: "error",
|
|
20707
|
+
name: "FailedCall",
|
|
20708
|
+
inputs: []
|
|
20709
|
+
},
|
|
20710
|
+
{
|
|
20711
|
+
type: "error",
|
|
20712
|
+
name: "InvalidInitialization",
|
|
20713
|
+
inputs: []
|
|
20714
|
+
},
|
|
20715
|
+
{
|
|
20716
|
+
type: "error",
|
|
20717
|
+
name: "NotActiveBroker",
|
|
20718
|
+
inputs: [
|
|
20719
|
+
{
|
|
20720
|
+
type: "address",
|
|
20721
|
+
name: "broker"
|
|
20722
|
+
}
|
|
20723
|
+
]
|
|
20724
|
+
},
|
|
20725
|
+
{
|
|
20726
|
+
type: "error",
|
|
20727
|
+
name: "NotAddressManager",
|
|
20728
|
+
inputs: []
|
|
20729
|
+
},
|
|
20730
|
+
{
|
|
20731
|
+
type: "error",
|
|
20732
|
+
name: "NotDependencyManager",
|
|
20733
|
+
inputs: []
|
|
20734
|
+
},
|
|
20735
|
+
{
|
|
20736
|
+
type: "error",
|
|
20737
|
+
name: "NotForwardAllowedTarget",
|
|
20738
|
+
inputs: [
|
|
20739
|
+
{
|
|
20740
|
+
type: "address",
|
|
20741
|
+
name: "from"
|
|
20742
|
+
}
|
|
20743
|
+
]
|
|
20744
|
+
},
|
|
20745
|
+
{
|
|
20746
|
+
type: "error",
|
|
20747
|
+
name: "NotInitializing",
|
|
20748
|
+
inputs: []
|
|
20749
|
+
},
|
|
20750
|
+
{
|
|
20751
|
+
type: "error",
|
|
20752
|
+
name: "NotProxyAdmin",
|
|
20753
|
+
inputs: []
|
|
20754
|
+
},
|
|
20755
|
+
{
|
|
20756
|
+
type: "error",
|
|
20757
|
+
name: "PermissionDenied",
|
|
20758
|
+
inputs: [
|
|
20759
|
+
{
|
|
20760
|
+
type: "address",
|
|
20761
|
+
name: "caller"
|
|
20762
|
+
},
|
|
20763
|
+
{
|
|
20764
|
+
type: "address",
|
|
20765
|
+
name: "target"
|
|
20766
|
+
}
|
|
20767
|
+
]
|
|
20768
|
+
},
|
|
20769
|
+
{
|
|
20770
|
+
type: "error",
|
|
20771
|
+
name: "ReentrancyGuardReentrantCall",
|
|
20772
|
+
inputs: []
|
|
20773
|
+
},
|
|
20774
|
+
{
|
|
20775
|
+
type: "error",
|
|
20776
|
+
name: "SafeERC20FailedOperation",
|
|
20777
|
+
inputs: [
|
|
20778
|
+
{
|
|
20779
|
+
type: "address",
|
|
20780
|
+
name: "token"
|
|
20781
|
+
}
|
|
20782
|
+
]
|
|
20783
|
+
},
|
|
20784
|
+
{
|
|
20785
|
+
type: "error",
|
|
20786
|
+
name: "UUPSUnauthorizedCallContext",
|
|
20787
|
+
inputs: []
|
|
20788
|
+
},
|
|
20789
|
+
{
|
|
20790
|
+
type: "error",
|
|
20791
|
+
name: "UUPSUnsupportedProxiableUUID",
|
|
20792
|
+
inputs: [
|
|
20793
|
+
{
|
|
20794
|
+
type: "bytes32",
|
|
20795
|
+
name: "slot"
|
|
20796
|
+
}
|
|
20797
|
+
]
|
|
20798
|
+
},
|
|
20799
|
+
{
|
|
20800
|
+
type: "event",
|
|
20801
|
+
anonymous: false,
|
|
20802
|
+
name: "Initialized",
|
|
20803
|
+
inputs: [
|
|
20804
|
+
{
|
|
20805
|
+
type: "uint64",
|
|
20806
|
+
name: "version",
|
|
20807
|
+
indexed: false
|
|
20808
|
+
}
|
|
20809
|
+
]
|
|
20810
|
+
},
|
|
20811
|
+
{
|
|
20812
|
+
type: "event",
|
|
20813
|
+
anonymous: false,
|
|
20814
|
+
name: "Upgraded",
|
|
20815
|
+
inputs: [
|
|
20816
|
+
{
|
|
20817
|
+
type: "address",
|
|
20818
|
+
name: "implementation",
|
|
20819
|
+
indexed: true
|
|
20820
|
+
}
|
|
20821
|
+
]
|
|
20822
|
+
},
|
|
20823
|
+
{
|
|
20824
|
+
type: "function",
|
|
20825
|
+
name: "UPGRADE_INTERFACE_VERSION",
|
|
20826
|
+
constant: true,
|
|
20827
|
+
stateMutability: "view",
|
|
20828
|
+
payable: false,
|
|
20829
|
+
inputs: [],
|
|
20830
|
+
outputs: [
|
|
20831
|
+
{
|
|
20832
|
+
type: "string"
|
|
20833
|
+
}
|
|
20834
|
+
]
|
|
20835
|
+
},
|
|
20836
|
+
{
|
|
20837
|
+
type: "function",
|
|
20838
|
+
name: "__ERC2771ContextUpgradeable_init",
|
|
20839
|
+
constant: false,
|
|
20840
|
+
payable: false,
|
|
20841
|
+
inputs: [
|
|
20842
|
+
{
|
|
20843
|
+
type: "address",
|
|
20844
|
+
name: "trustedForwarder_"
|
|
20845
|
+
}
|
|
20846
|
+
],
|
|
20847
|
+
outputs: []
|
|
20848
|
+
},
|
|
20849
|
+
{
|
|
20850
|
+
type: "function",
|
|
20851
|
+
name: "collectExecutionFee",
|
|
20852
|
+
constant: false,
|
|
20853
|
+
payable: false,
|
|
20854
|
+
inputs: [
|
|
20855
|
+
{
|
|
20856
|
+
type: "uint8",
|
|
20857
|
+
name: "source"
|
|
20858
|
+
},
|
|
20859
|
+
{
|
|
20860
|
+
type: "bytes",
|
|
20861
|
+
name: "data"
|
|
20862
|
+
}
|
|
20863
|
+
],
|
|
20864
|
+
outputs: []
|
|
20865
|
+
},
|
|
20866
|
+
{
|
|
20867
|
+
type: "function",
|
|
20868
|
+
name: "collectForwardFeeIfNecessary",
|
|
20869
|
+
constant: false,
|
|
20870
|
+
payable: false,
|
|
20871
|
+
inputs: [
|
|
20872
|
+
{
|
|
20873
|
+
type: "uint8",
|
|
20874
|
+
name: "source"
|
|
20875
|
+
},
|
|
20876
|
+
{
|
|
20877
|
+
type: "bytes",
|
|
20878
|
+
name: "data"
|
|
20879
|
+
}
|
|
20880
|
+
],
|
|
20881
|
+
outputs: []
|
|
20882
|
+
},
|
|
20883
|
+
{
|
|
20884
|
+
type: "function",
|
|
20885
|
+
name: "depositFor",
|
|
20886
|
+
constant: false,
|
|
20887
|
+
payable: false,
|
|
20888
|
+
inputs: [
|
|
20889
|
+
{
|
|
20890
|
+
type: "address",
|
|
20891
|
+
name: "user"
|
|
20892
|
+
},
|
|
20893
|
+
{
|
|
20894
|
+
type: "address",
|
|
20895
|
+
name: "token"
|
|
20896
|
+
},
|
|
20897
|
+
{
|
|
20898
|
+
type: "uint256",
|
|
20899
|
+
name: "amount"
|
|
20900
|
+
}
|
|
20901
|
+
],
|
|
20902
|
+
outputs: []
|
|
20903
|
+
},
|
|
20904
|
+
{
|
|
20905
|
+
type: "function",
|
|
20906
|
+
name: "depositToAccount",
|
|
20907
|
+
constant: false,
|
|
20908
|
+
payable: false,
|
|
20909
|
+
inputs: [
|
|
20910
|
+
{
|
|
20911
|
+
type: "address",
|
|
20912
|
+
name: "recipient"
|
|
20913
|
+
},
|
|
20914
|
+
{
|
|
20915
|
+
type: "address",
|
|
20916
|
+
name: "token"
|
|
20917
|
+
},
|
|
20918
|
+
{
|
|
20919
|
+
type: "uint256",
|
|
20920
|
+
name: "amount"
|
|
20921
|
+
}
|
|
20922
|
+
],
|
|
20923
|
+
outputs: []
|
|
20924
|
+
},
|
|
20925
|
+
{
|
|
20926
|
+
type: "function",
|
|
20927
|
+
name: "getAddressManager",
|
|
20928
|
+
constant: true,
|
|
20929
|
+
stateMutability: "view",
|
|
20930
|
+
payable: false,
|
|
20931
|
+
inputs: [],
|
|
20932
|
+
outputs: [
|
|
20933
|
+
{
|
|
20934
|
+
type: "address"
|
|
20935
|
+
}
|
|
20936
|
+
]
|
|
20937
|
+
},
|
|
20938
|
+
{
|
|
20939
|
+
type: "function",
|
|
20940
|
+
name: "getDependencyAddress",
|
|
20941
|
+
constant: true,
|
|
20942
|
+
stateMutability: "view",
|
|
20943
|
+
payable: false,
|
|
20944
|
+
inputs: [
|
|
20945
|
+
{
|
|
20946
|
+
type: "bytes32",
|
|
20947
|
+
name: "identifier"
|
|
20948
|
+
}
|
|
20949
|
+
],
|
|
20950
|
+
outputs: [
|
|
20951
|
+
{
|
|
20952
|
+
type: "address"
|
|
20953
|
+
}
|
|
20954
|
+
]
|
|
20955
|
+
},
|
|
20956
|
+
{
|
|
20957
|
+
type: "function",
|
|
20958
|
+
name: "getImplementation",
|
|
20959
|
+
constant: true,
|
|
20960
|
+
stateMutability: "view",
|
|
20961
|
+
payable: false,
|
|
20962
|
+
inputs: [],
|
|
20963
|
+
outputs: [
|
|
20964
|
+
{
|
|
20965
|
+
type: "address"
|
|
20966
|
+
}
|
|
20967
|
+
]
|
|
20968
|
+
},
|
|
20969
|
+
{
|
|
20970
|
+
type: "function",
|
|
20971
|
+
name: "initialize",
|
|
20972
|
+
constant: false,
|
|
20973
|
+
payable: false,
|
|
20974
|
+
inputs: [
|
|
20975
|
+
{
|
|
20976
|
+
type: "address",
|
|
20977
|
+
name: "addressManager"
|
|
20978
|
+
}
|
|
20979
|
+
],
|
|
20980
|
+
outputs: []
|
|
20981
|
+
},
|
|
20982
|
+
{
|
|
20983
|
+
type: "function",
|
|
20984
|
+
name: "isTrustedForwarder",
|
|
20985
|
+
constant: true,
|
|
20986
|
+
stateMutability: "view",
|
|
20987
|
+
payable: false,
|
|
20988
|
+
inputs: [
|
|
20989
|
+
{
|
|
20990
|
+
type: "address",
|
|
20991
|
+
name: "forwarder"
|
|
20992
|
+
}
|
|
20993
|
+
],
|
|
20994
|
+
outputs: [
|
|
20995
|
+
{
|
|
20996
|
+
type: "bool"
|
|
20997
|
+
}
|
|
20998
|
+
]
|
|
20999
|
+
},
|
|
21000
|
+
{
|
|
21001
|
+
type: "function",
|
|
21002
|
+
name: "proxiableUUID",
|
|
21003
|
+
constant: true,
|
|
21004
|
+
stateMutability: "view",
|
|
21005
|
+
payable: false,
|
|
21006
|
+
inputs: [],
|
|
21007
|
+
outputs: [
|
|
21008
|
+
{
|
|
21009
|
+
type: "bytes32"
|
|
21010
|
+
}
|
|
21011
|
+
]
|
|
21012
|
+
},
|
|
21013
|
+
{
|
|
21014
|
+
type: "function",
|
|
21015
|
+
name: "trustedForwarder",
|
|
21016
|
+
constant: true,
|
|
21017
|
+
stateMutability: "view",
|
|
21018
|
+
payable: false,
|
|
21019
|
+
inputs: [],
|
|
21020
|
+
outputs: [
|
|
21021
|
+
{
|
|
21022
|
+
type: "address"
|
|
21023
|
+
}
|
|
21024
|
+
]
|
|
21025
|
+
},
|
|
21026
|
+
{
|
|
21027
|
+
type: "function",
|
|
21028
|
+
name: "upgradeTo",
|
|
21029
|
+
constant: false,
|
|
21030
|
+
stateMutability: "payable",
|
|
21031
|
+
payable: true,
|
|
21032
|
+
inputs: [
|
|
21033
|
+
{
|
|
21034
|
+
type: "address",
|
|
21035
|
+
name: "newImplementation"
|
|
21036
|
+
},
|
|
21037
|
+
{
|
|
21038
|
+
type: "bytes",
|
|
21039
|
+
name: "data"
|
|
21040
|
+
}
|
|
21041
|
+
],
|
|
21042
|
+
outputs: []
|
|
21043
|
+
},
|
|
21044
|
+
{
|
|
21045
|
+
type: "function",
|
|
21046
|
+
name: "upgradeToAndCall",
|
|
21047
|
+
constant: false,
|
|
21048
|
+
stateMutability: "payable",
|
|
21049
|
+
payable: true,
|
|
21050
|
+
inputs: [
|
|
21051
|
+
{
|
|
21052
|
+
type: "address",
|
|
21053
|
+
name: "newImplementation"
|
|
21054
|
+
},
|
|
21055
|
+
{
|
|
21056
|
+
type: "bytes",
|
|
21057
|
+
name: "data"
|
|
21058
|
+
}
|
|
21059
|
+
],
|
|
21060
|
+
outputs: []
|
|
21061
|
+
}
|
|
21062
|
+
];
|
|
21063
|
+
|
|
21064
|
+
// src/manager/seamless/index.ts
|
|
20681
21065
|
var contractTypes = {
|
|
20682
21066
|
ForwardRequest: [
|
|
20683
21067
|
{ name: "from", type: "address" },
|
|
@@ -20765,8 +21149,11 @@ var Seamless = class {
|
|
|
20765
21149
|
}
|
|
20766
21150
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
20767
21151
|
const masterAddress = await config.signer.getAddress();
|
|
20768
|
-
const
|
|
20769
|
-
|
|
21152
|
+
const tradingRouterContract = new import_ethers27.ethers.Contract(
|
|
21153
|
+
contractAddress.TRADING_ROUTER,
|
|
21154
|
+
TradingRouter_default,
|
|
21155
|
+
config.signer
|
|
21156
|
+
);
|
|
20770
21157
|
const erc20Contract = new import_ethers27.ethers.Contract(
|
|
20771
21158
|
contractAddress.ERC20,
|
|
20772
21159
|
ERC20Token_default,
|
|
@@ -20774,49 +21161,27 @@ var Seamless = class {
|
|
|
20774
21161
|
);
|
|
20775
21162
|
try {
|
|
20776
21163
|
const nonces = await erc20Contract.nonces(masterAddress);
|
|
20777
|
-
const
|
|
21164
|
+
const tradingRouterSignPermit = await signPermit(
|
|
20778
21165
|
config.signer,
|
|
20779
|
-
|
|
20780
|
-
erc20Contract,
|
|
21166
|
+
tradingRouterContract,
|
|
20781
21167
|
masterAddress,
|
|
20782
|
-
|
|
21168
|
+
contractAddress.TRADING_ROUTER,
|
|
20783
21169
|
import_ethers27.ethers.MaxUint256.toString(),
|
|
20784
21170
|
nonces.toString(),
|
|
20785
21171
|
deadline.toString()
|
|
20786
21172
|
);
|
|
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,
|
|
20799
|
-
owner: masterAddress,
|
|
20800
|
-
spender: forwarderAddress,
|
|
20801
|
-
value: import_ethers27.ethers.MaxUint256,
|
|
20802
|
-
deadline,
|
|
20803
|
-
v: forwarderSignPermit.v,
|
|
20804
|
-
r: forwarderSignPermit.r,
|
|
20805
|
-
s: forwarderSignPermit.s
|
|
20806
|
-
};
|
|
20807
|
-
const accountPermitParams = {
|
|
20808
|
-
token: erc20Contract.target,
|
|
21173
|
+
const tradingRouterPermitParams = {
|
|
21174
|
+
token: contractAddress.ERC20,
|
|
20809
21175
|
owner: masterAddress,
|
|
20810
|
-
spender: contractAddress.
|
|
20811
|
-
value: import_ethers27.ethers.MaxUint256,
|
|
20812
|
-
deadline,
|
|
20813
|
-
v:
|
|
20814
|
-
r:
|
|
20815
|
-
s:
|
|
21176
|
+
spender: contractAddress.TRADING_ROUTER,
|
|
21177
|
+
value: import_ethers27.ethers.MaxUint256.toString(),
|
|
21178
|
+
deadline: deadline.toString(),
|
|
21179
|
+
v: tradingRouterSignPermit.v,
|
|
21180
|
+
r: tradingRouterSignPermit.r,
|
|
21181
|
+
s: tradingRouterSignPermit.s
|
|
20816
21182
|
};
|
|
20817
|
-
return [
|
|
21183
|
+
return [tradingRouterPermitParams];
|
|
20818
21184
|
} catch (error) {
|
|
20819
|
-
this.logger.error("error-->", error);
|
|
20820
21185
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
|
|
20821
21186
|
}
|
|
20822
21187
|
}
|
|
@@ -20847,7 +21212,8 @@ var Seamless = class {
|
|
|
20847
21212
|
deadline,
|
|
20848
21213
|
data
|
|
20849
21214
|
});
|
|
20850
|
-
const
|
|
21215
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
21216
|
+
const txRs = await this.api.forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature, forwardFeeToken }, chainId);
|
|
20851
21217
|
return txRs;
|
|
20852
21218
|
}
|
|
20853
21219
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
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.246",
|
|
1767
1779
|
private: false,
|
|
1768
1780
|
publishConfig: {
|
|
1769
1781
|
access: "public"
|
|
@@ -13077,10 +13089,10 @@ var Position = class {
|
|
|
13077
13089
|
}
|
|
13078
13090
|
const updateParams = {
|
|
13079
13091
|
poolId,
|
|
13092
|
+
oracleType: poolOracleType,
|
|
13080
13093
|
referencePrice: ethers5.parseUnits(priceData?.price ?? "0", 30),
|
|
13081
13094
|
oracleUpdateData: priceData?.vaa ?? "0",
|
|
13082
|
-
publishTime: priceData.publishTime
|
|
13083
|
-
oracleType: poolOracleType
|
|
13095
|
+
publishTime: priceData.publishTime
|
|
13084
13096
|
};
|
|
13085
13097
|
let needsApproval = false;
|
|
13086
13098
|
if (Number(adjustAmount) > 0) {
|
|
@@ -19936,29 +19948,6 @@ var Account = class {
|
|
|
19936
19948
|
}
|
|
19937
19949
|
async getAvailableMarginBalance({ poolId, chainId, address }) {
|
|
19938
19950
|
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
19951
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
19963
19952
|
if (marginAccountBalanceRes.code !== 0) {
|
|
19964
19953
|
throw new MyxSDKError(
|
|
@@ -19967,15 +19956,10 @@ var Account = class {
|
|
|
19967
19956
|
);
|
|
19968
19957
|
}
|
|
19969
19958
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
19970
|
-
const usedMargin = BigInt(used ?? "0");
|
|
19971
19959
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
19972
19960
|
const freeAmount = BigInt(marginAccountBalance?.freeMargin ?? 0);
|
|
19973
19961
|
const accountMargin = freeAmount + quoteProfit;
|
|
19974
|
-
|
|
19975
|
-
return BigInt(0);
|
|
19976
|
-
}
|
|
19977
|
-
const availableAccountMarginBalance = accountMargin - usedMargin;
|
|
19978
|
-
return availableAccountMarginBalance;
|
|
19962
|
+
return accountMargin;
|
|
19979
19963
|
} catch (error) {
|
|
19980
19964
|
throw new MyxSDKError(
|
|
19981
19965
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -20137,8 +20121,6 @@ var Account = class {
|
|
|
20137
20121
|
};
|
|
20138
20122
|
}
|
|
20139
20123
|
}
|
|
20140
|
-
async getCurrentEpoch() {
|
|
20141
|
-
}
|
|
20142
20124
|
async getAccountVipInfo(chainId, address) {
|
|
20143
20125
|
const config = this.configManager.getConfig();
|
|
20144
20126
|
const provider = await getJSONProvider(chainId);
|
|
@@ -20602,6 +20584,408 @@ var getEIP712Domain = async (contract) => {
|
|
|
20602
20584
|
|
|
20603
20585
|
// src/manager/seamless/index.ts
|
|
20604
20586
|
import { splitSignature } from "@ethersproject/bytes";
|
|
20587
|
+
|
|
20588
|
+
// src/abi/TradingRouter.json
|
|
20589
|
+
var TradingRouter_default = [
|
|
20590
|
+
{
|
|
20591
|
+
type: "error",
|
|
20592
|
+
name: "AddressEmptyCode",
|
|
20593
|
+
inputs: [
|
|
20594
|
+
{
|
|
20595
|
+
type: "address",
|
|
20596
|
+
name: "target"
|
|
20597
|
+
}
|
|
20598
|
+
]
|
|
20599
|
+
},
|
|
20600
|
+
{
|
|
20601
|
+
type: "error",
|
|
20602
|
+
name: "DesignatedTokenMismatch",
|
|
20603
|
+
inputs: [
|
|
20604
|
+
{
|
|
20605
|
+
type: "address",
|
|
20606
|
+
name: "collectToken"
|
|
20607
|
+
},
|
|
20608
|
+
{
|
|
20609
|
+
type: "address",
|
|
20610
|
+
name: "designatedToken"
|
|
20611
|
+
}
|
|
20612
|
+
]
|
|
20613
|
+
},
|
|
20614
|
+
{
|
|
20615
|
+
type: "error",
|
|
20616
|
+
name: "ERC1967InvalidImplementation",
|
|
20617
|
+
inputs: [
|
|
20618
|
+
{
|
|
20619
|
+
type: "address",
|
|
20620
|
+
name: "implementation"
|
|
20621
|
+
}
|
|
20622
|
+
]
|
|
20623
|
+
},
|
|
20624
|
+
{
|
|
20625
|
+
type: "error",
|
|
20626
|
+
name: "ERC1967NonPayable",
|
|
20627
|
+
inputs: []
|
|
20628
|
+
},
|
|
20629
|
+
{
|
|
20630
|
+
type: "error",
|
|
20631
|
+
name: "FailedCall",
|
|
20632
|
+
inputs: []
|
|
20633
|
+
},
|
|
20634
|
+
{
|
|
20635
|
+
type: "error",
|
|
20636
|
+
name: "InvalidInitialization",
|
|
20637
|
+
inputs: []
|
|
20638
|
+
},
|
|
20639
|
+
{
|
|
20640
|
+
type: "error",
|
|
20641
|
+
name: "NotActiveBroker",
|
|
20642
|
+
inputs: [
|
|
20643
|
+
{
|
|
20644
|
+
type: "address",
|
|
20645
|
+
name: "broker"
|
|
20646
|
+
}
|
|
20647
|
+
]
|
|
20648
|
+
},
|
|
20649
|
+
{
|
|
20650
|
+
type: "error",
|
|
20651
|
+
name: "NotAddressManager",
|
|
20652
|
+
inputs: []
|
|
20653
|
+
},
|
|
20654
|
+
{
|
|
20655
|
+
type: "error",
|
|
20656
|
+
name: "NotDependencyManager",
|
|
20657
|
+
inputs: []
|
|
20658
|
+
},
|
|
20659
|
+
{
|
|
20660
|
+
type: "error",
|
|
20661
|
+
name: "NotForwardAllowedTarget",
|
|
20662
|
+
inputs: [
|
|
20663
|
+
{
|
|
20664
|
+
type: "address",
|
|
20665
|
+
name: "from"
|
|
20666
|
+
}
|
|
20667
|
+
]
|
|
20668
|
+
},
|
|
20669
|
+
{
|
|
20670
|
+
type: "error",
|
|
20671
|
+
name: "NotInitializing",
|
|
20672
|
+
inputs: []
|
|
20673
|
+
},
|
|
20674
|
+
{
|
|
20675
|
+
type: "error",
|
|
20676
|
+
name: "NotProxyAdmin",
|
|
20677
|
+
inputs: []
|
|
20678
|
+
},
|
|
20679
|
+
{
|
|
20680
|
+
type: "error",
|
|
20681
|
+
name: "PermissionDenied",
|
|
20682
|
+
inputs: [
|
|
20683
|
+
{
|
|
20684
|
+
type: "address",
|
|
20685
|
+
name: "caller"
|
|
20686
|
+
},
|
|
20687
|
+
{
|
|
20688
|
+
type: "address",
|
|
20689
|
+
name: "target"
|
|
20690
|
+
}
|
|
20691
|
+
]
|
|
20692
|
+
},
|
|
20693
|
+
{
|
|
20694
|
+
type: "error",
|
|
20695
|
+
name: "ReentrancyGuardReentrantCall",
|
|
20696
|
+
inputs: []
|
|
20697
|
+
},
|
|
20698
|
+
{
|
|
20699
|
+
type: "error",
|
|
20700
|
+
name: "SafeERC20FailedOperation",
|
|
20701
|
+
inputs: [
|
|
20702
|
+
{
|
|
20703
|
+
type: "address",
|
|
20704
|
+
name: "token"
|
|
20705
|
+
}
|
|
20706
|
+
]
|
|
20707
|
+
},
|
|
20708
|
+
{
|
|
20709
|
+
type: "error",
|
|
20710
|
+
name: "UUPSUnauthorizedCallContext",
|
|
20711
|
+
inputs: []
|
|
20712
|
+
},
|
|
20713
|
+
{
|
|
20714
|
+
type: "error",
|
|
20715
|
+
name: "UUPSUnsupportedProxiableUUID",
|
|
20716
|
+
inputs: [
|
|
20717
|
+
{
|
|
20718
|
+
type: "bytes32",
|
|
20719
|
+
name: "slot"
|
|
20720
|
+
}
|
|
20721
|
+
]
|
|
20722
|
+
},
|
|
20723
|
+
{
|
|
20724
|
+
type: "event",
|
|
20725
|
+
anonymous: false,
|
|
20726
|
+
name: "Initialized",
|
|
20727
|
+
inputs: [
|
|
20728
|
+
{
|
|
20729
|
+
type: "uint64",
|
|
20730
|
+
name: "version",
|
|
20731
|
+
indexed: false
|
|
20732
|
+
}
|
|
20733
|
+
]
|
|
20734
|
+
},
|
|
20735
|
+
{
|
|
20736
|
+
type: "event",
|
|
20737
|
+
anonymous: false,
|
|
20738
|
+
name: "Upgraded",
|
|
20739
|
+
inputs: [
|
|
20740
|
+
{
|
|
20741
|
+
type: "address",
|
|
20742
|
+
name: "implementation",
|
|
20743
|
+
indexed: true
|
|
20744
|
+
}
|
|
20745
|
+
]
|
|
20746
|
+
},
|
|
20747
|
+
{
|
|
20748
|
+
type: "function",
|
|
20749
|
+
name: "UPGRADE_INTERFACE_VERSION",
|
|
20750
|
+
constant: true,
|
|
20751
|
+
stateMutability: "view",
|
|
20752
|
+
payable: false,
|
|
20753
|
+
inputs: [],
|
|
20754
|
+
outputs: [
|
|
20755
|
+
{
|
|
20756
|
+
type: "string"
|
|
20757
|
+
}
|
|
20758
|
+
]
|
|
20759
|
+
},
|
|
20760
|
+
{
|
|
20761
|
+
type: "function",
|
|
20762
|
+
name: "__ERC2771ContextUpgradeable_init",
|
|
20763
|
+
constant: false,
|
|
20764
|
+
payable: false,
|
|
20765
|
+
inputs: [
|
|
20766
|
+
{
|
|
20767
|
+
type: "address",
|
|
20768
|
+
name: "trustedForwarder_"
|
|
20769
|
+
}
|
|
20770
|
+
],
|
|
20771
|
+
outputs: []
|
|
20772
|
+
},
|
|
20773
|
+
{
|
|
20774
|
+
type: "function",
|
|
20775
|
+
name: "collectExecutionFee",
|
|
20776
|
+
constant: false,
|
|
20777
|
+
payable: false,
|
|
20778
|
+
inputs: [
|
|
20779
|
+
{
|
|
20780
|
+
type: "uint8",
|
|
20781
|
+
name: "source"
|
|
20782
|
+
},
|
|
20783
|
+
{
|
|
20784
|
+
type: "bytes",
|
|
20785
|
+
name: "data"
|
|
20786
|
+
}
|
|
20787
|
+
],
|
|
20788
|
+
outputs: []
|
|
20789
|
+
},
|
|
20790
|
+
{
|
|
20791
|
+
type: "function",
|
|
20792
|
+
name: "collectForwardFeeIfNecessary",
|
|
20793
|
+
constant: false,
|
|
20794
|
+
payable: false,
|
|
20795
|
+
inputs: [
|
|
20796
|
+
{
|
|
20797
|
+
type: "uint8",
|
|
20798
|
+
name: "source"
|
|
20799
|
+
},
|
|
20800
|
+
{
|
|
20801
|
+
type: "bytes",
|
|
20802
|
+
name: "data"
|
|
20803
|
+
}
|
|
20804
|
+
],
|
|
20805
|
+
outputs: []
|
|
20806
|
+
},
|
|
20807
|
+
{
|
|
20808
|
+
type: "function",
|
|
20809
|
+
name: "depositFor",
|
|
20810
|
+
constant: false,
|
|
20811
|
+
payable: false,
|
|
20812
|
+
inputs: [
|
|
20813
|
+
{
|
|
20814
|
+
type: "address",
|
|
20815
|
+
name: "user"
|
|
20816
|
+
},
|
|
20817
|
+
{
|
|
20818
|
+
type: "address",
|
|
20819
|
+
name: "token"
|
|
20820
|
+
},
|
|
20821
|
+
{
|
|
20822
|
+
type: "uint256",
|
|
20823
|
+
name: "amount"
|
|
20824
|
+
}
|
|
20825
|
+
],
|
|
20826
|
+
outputs: []
|
|
20827
|
+
},
|
|
20828
|
+
{
|
|
20829
|
+
type: "function",
|
|
20830
|
+
name: "depositToAccount",
|
|
20831
|
+
constant: false,
|
|
20832
|
+
payable: false,
|
|
20833
|
+
inputs: [
|
|
20834
|
+
{
|
|
20835
|
+
type: "address",
|
|
20836
|
+
name: "recipient"
|
|
20837
|
+
},
|
|
20838
|
+
{
|
|
20839
|
+
type: "address",
|
|
20840
|
+
name: "token"
|
|
20841
|
+
},
|
|
20842
|
+
{
|
|
20843
|
+
type: "uint256",
|
|
20844
|
+
name: "amount"
|
|
20845
|
+
}
|
|
20846
|
+
],
|
|
20847
|
+
outputs: []
|
|
20848
|
+
},
|
|
20849
|
+
{
|
|
20850
|
+
type: "function",
|
|
20851
|
+
name: "getAddressManager",
|
|
20852
|
+
constant: true,
|
|
20853
|
+
stateMutability: "view",
|
|
20854
|
+
payable: false,
|
|
20855
|
+
inputs: [],
|
|
20856
|
+
outputs: [
|
|
20857
|
+
{
|
|
20858
|
+
type: "address"
|
|
20859
|
+
}
|
|
20860
|
+
]
|
|
20861
|
+
},
|
|
20862
|
+
{
|
|
20863
|
+
type: "function",
|
|
20864
|
+
name: "getDependencyAddress",
|
|
20865
|
+
constant: true,
|
|
20866
|
+
stateMutability: "view",
|
|
20867
|
+
payable: false,
|
|
20868
|
+
inputs: [
|
|
20869
|
+
{
|
|
20870
|
+
type: "bytes32",
|
|
20871
|
+
name: "identifier"
|
|
20872
|
+
}
|
|
20873
|
+
],
|
|
20874
|
+
outputs: [
|
|
20875
|
+
{
|
|
20876
|
+
type: "address"
|
|
20877
|
+
}
|
|
20878
|
+
]
|
|
20879
|
+
},
|
|
20880
|
+
{
|
|
20881
|
+
type: "function",
|
|
20882
|
+
name: "getImplementation",
|
|
20883
|
+
constant: true,
|
|
20884
|
+
stateMutability: "view",
|
|
20885
|
+
payable: false,
|
|
20886
|
+
inputs: [],
|
|
20887
|
+
outputs: [
|
|
20888
|
+
{
|
|
20889
|
+
type: "address"
|
|
20890
|
+
}
|
|
20891
|
+
]
|
|
20892
|
+
},
|
|
20893
|
+
{
|
|
20894
|
+
type: "function",
|
|
20895
|
+
name: "initialize",
|
|
20896
|
+
constant: false,
|
|
20897
|
+
payable: false,
|
|
20898
|
+
inputs: [
|
|
20899
|
+
{
|
|
20900
|
+
type: "address",
|
|
20901
|
+
name: "addressManager"
|
|
20902
|
+
}
|
|
20903
|
+
],
|
|
20904
|
+
outputs: []
|
|
20905
|
+
},
|
|
20906
|
+
{
|
|
20907
|
+
type: "function",
|
|
20908
|
+
name: "isTrustedForwarder",
|
|
20909
|
+
constant: true,
|
|
20910
|
+
stateMutability: "view",
|
|
20911
|
+
payable: false,
|
|
20912
|
+
inputs: [
|
|
20913
|
+
{
|
|
20914
|
+
type: "address",
|
|
20915
|
+
name: "forwarder"
|
|
20916
|
+
}
|
|
20917
|
+
],
|
|
20918
|
+
outputs: [
|
|
20919
|
+
{
|
|
20920
|
+
type: "bool"
|
|
20921
|
+
}
|
|
20922
|
+
]
|
|
20923
|
+
},
|
|
20924
|
+
{
|
|
20925
|
+
type: "function",
|
|
20926
|
+
name: "proxiableUUID",
|
|
20927
|
+
constant: true,
|
|
20928
|
+
stateMutability: "view",
|
|
20929
|
+
payable: false,
|
|
20930
|
+
inputs: [],
|
|
20931
|
+
outputs: [
|
|
20932
|
+
{
|
|
20933
|
+
type: "bytes32"
|
|
20934
|
+
}
|
|
20935
|
+
]
|
|
20936
|
+
},
|
|
20937
|
+
{
|
|
20938
|
+
type: "function",
|
|
20939
|
+
name: "trustedForwarder",
|
|
20940
|
+
constant: true,
|
|
20941
|
+
stateMutability: "view",
|
|
20942
|
+
payable: false,
|
|
20943
|
+
inputs: [],
|
|
20944
|
+
outputs: [
|
|
20945
|
+
{
|
|
20946
|
+
type: "address"
|
|
20947
|
+
}
|
|
20948
|
+
]
|
|
20949
|
+
},
|
|
20950
|
+
{
|
|
20951
|
+
type: "function",
|
|
20952
|
+
name: "upgradeTo",
|
|
20953
|
+
constant: false,
|
|
20954
|
+
stateMutability: "payable",
|
|
20955
|
+
payable: true,
|
|
20956
|
+
inputs: [
|
|
20957
|
+
{
|
|
20958
|
+
type: "address",
|
|
20959
|
+
name: "newImplementation"
|
|
20960
|
+
},
|
|
20961
|
+
{
|
|
20962
|
+
type: "bytes",
|
|
20963
|
+
name: "data"
|
|
20964
|
+
}
|
|
20965
|
+
],
|
|
20966
|
+
outputs: []
|
|
20967
|
+
},
|
|
20968
|
+
{
|
|
20969
|
+
type: "function",
|
|
20970
|
+
name: "upgradeToAndCall",
|
|
20971
|
+
constant: false,
|
|
20972
|
+
stateMutability: "payable",
|
|
20973
|
+
payable: true,
|
|
20974
|
+
inputs: [
|
|
20975
|
+
{
|
|
20976
|
+
type: "address",
|
|
20977
|
+
name: "newImplementation"
|
|
20978
|
+
},
|
|
20979
|
+
{
|
|
20980
|
+
type: "bytes",
|
|
20981
|
+
name: "data"
|
|
20982
|
+
}
|
|
20983
|
+
],
|
|
20984
|
+
outputs: []
|
|
20985
|
+
}
|
|
20986
|
+
];
|
|
20987
|
+
|
|
20988
|
+
// src/manager/seamless/index.ts
|
|
20605
20989
|
var contractTypes = {
|
|
20606
20990
|
ForwardRequest: [
|
|
20607
20991
|
{ name: "from", type: "address" },
|
|
@@ -20689,8 +21073,11 @@ var Seamless = class {
|
|
|
20689
21073
|
}
|
|
20690
21074
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
20691
21075
|
const masterAddress = await config.signer.getAddress();
|
|
20692
|
-
const
|
|
20693
|
-
|
|
21076
|
+
const tradingRouterContract = new ethers9.Contract(
|
|
21077
|
+
contractAddress.TRADING_ROUTER,
|
|
21078
|
+
TradingRouter_default,
|
|
21079
|
+
config.signer
|
|
21080
|
+
);
|
|
20694
21081
|
const erc20Contract = new ethers9.Contract(
|
|
20695
21082
|
contractAddress.ERC20,
|
|
20696
21083
|
ERC20Token_default,
|
|
@@ -20698,49 +21085,27 @@ var Seamless = class {
|
|
|
20698
21085
|
);
|
|
20699
21086
|
try {
|
|
20700
21087
|
const nonces = await erc20Contract.nonces(masterAddress);
|
|
20701
|
-
const
|
|
21088
|
+
const tradingRouterSignPermit = await signPermit(
|
|
20702
21089
|
config.signer,
|
|
20703
|
-
|
|
20704
|
-
erc20Contract,
|
|
21090
|
+
tradingRouterContract,
|
|
20705
21091
|
masterAddress,
|
|
20706
|
-
|
|
21092
|
+
contractAddress.TRADING_ROUTER,
|
|
20707
21093
|
ethers9.MaxUint256.toString(),
|
|
20708
21094
|
nonces.toString(),
|
|
20709
21095
|
deadline.toString()
|
|
20710
21096
|
);
|
|
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,
|
|
20723
|
-
owner: masterAddress,
|
|
20724
|
-
spender: forwarderAddress,
|
|
20725
|
-
value: ethers9.MaxUint256,
|
|
20726
|
-
deadline,
|
|
20727
|
-
v: forwarderSignPermit.v,
|
|
20728
|
-
r: forwarderSignPermit.r,
|
|
20729
|
-
s: forwarderSignPermit.s
|
|
20730
|
-
};
|
|
20731
|
-
const accountPermitParams = {
|
|
20732
|
-
token: erc20Contract.target,
|
|
21097
|
+
const tradingRouterPermitParams = {
|
|
21098
|
+
token: contractAddress.ERC20,
|
|
20733
21099
|
owner: masterAddress,
|
|
20734
|
-
spender: contractAddress.
|
|
20735
|
-
value: ethers9.MaxUint256,
|
|
20736
|
-
deadline,
|
|
20737
|
-
v:
|
|
20738
|
-
r:
|
|
20739
|
-
s:
|
|
21100
|
+
spender: contractAddress.TRADING_ROUTER,
|
|
21101
|
+
value: ethers9.MaxUint256.toString(),
|
|
21102
|
+
deadline: deadline.toString(),
|
|
21103
|
+
v: tradingRouterSignPermit.v,
|
|
21104
|
+
r: tradingRouterSignPermit.r,
|
|
21105
|
+
s: tradingRouterSignPermit.s
|
|
20740
21106
|
};
|
|
20741
|
-
return [
|
|
21107
|
+
return [tradingRouterPermitParams];
|
|
20742
21108
|
} catch (error) {
|
|
20743
|
-
this.logger.error("error-->", error);
|
|
20744
21109
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
|
|
20745
21110
|
}
|
|
20746
21111
|
}
|
|
@@ -20771,7 +21136,8 @@ var Seamless = class {
|
|
|
20771
21136
|
deadline,
|
|
20772
21137
|
data
|
|
20773
21138
|
});
|
|
20774
|
-
const
|
|
21139
|
+
const forwardFeeToken = executeAddressByChainId(chainId);
|
|
21140
|
+
const txRs = await this.api.forwarderTxApi({ from, to, value, gas, nonce, data, deadline, signature, forwardFeeToken }, chainId);
|
|
20775
21141
|
return txRs;
|
|
20776
21142
|
}
|
|
20777
21143
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|