@myx-trade/sdk 0.1.128 → 0.1.129
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 +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +45 -35
- package/dist/index.mjs +45 -35
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1320,15 +1320,17 @@ declare class SubScription {
|
|
|
1320
1320
|
declare class Utils {
|
|
1321
1321
|
private configManager;
|
|
1322
1322
|
private logger;
|
|
1323
|
-
|
|
1323
|
+
private client;
|
|
1324
|
+
constructor(configManager: ConfigManager, logger: Logger, client: MyxClient);
|
|
1324
1325
|
getOrderIdFromTransaction(receipt: any): string | null;
|
|
1325
1326
|
private getApproveQuoteAmount;
|
|
1326
1327
|
needsApproval(chainId: number, quoteAddress: string, requiredAmount: string, spenderAddress?: string): Promise<boolean>;
|
|
1327
|
-
approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, signer }: {
|
|
1328
|
+
approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, account, signer }: {
|
|
1328
1329
|
chainId: number;
|
|
1329
1330
|
quoteAddress: string;
|
|
1330
1331
|
amount?: string;
|
|
1331
1332
|
spenderAddress?: string;
|
|
1333
|
+
account?: string;
|
|
1332
1334
|
signer?: ethers$1.Signer;
|
|
1333
1335
|
}): Promise<{
|
|
1334
1336
|
code: number;
|
|
@@ -1472,10 +1474,11 @@ declare class Account {
|
|
|
1472
1474
|
message: string;
|
|
1473
1475
|
data?: undefined;
|
|
1474
1476
|
}>;
|
|
1475
|
-
deposit({ amount, tokenAddress, chainId }: {
|
|
1477
|
+
deposit({ amount, tokenAddress, chainId, account }: {
|
|
1476
1478
|
amount: string;
|
|
1477
1479
|
tokenAddress: string;
|
|
1478
1480
|
chainId: number;
|
|
1481
|
+
account: string;
|
|
1479
1482
|
}): Promise<{
|
|
1480
1483
|
code: number;
|
|
1481
1484
|
message: string;
|
|
@@ -1569,9 +1572,10 @@ declare class Seamless {
|
|
|
1569
1572
|
open: boolean;
|
|
1570
1573
|
};
|
|
1571
1574
|
}>;
|
|
1572
|
-
createSeamless({ password, chainId }: {
|
|
1575
|
+
createSeamless({ password, chainId, account }: {
|
|
1573
1576
|
password: string;
|
|
1574
1577
|
chainId: number;
|
|
1578
|
+
account: string;
|
|
1575
1579
|
}): Promise<{
|
|
1576
1580
|
code: number;
|
|
1577
1581
|
data: {
|
|
@@ -1607,13 +1611,14 @@ declare class Position {
|
|
|
1607
1611
|
code: number;
|
|
1608
1612
|
data: PositionHistoryItem[];
|
|
1609
1613
|
}>;
|
|
1610
|
-
adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, chainId }: {
|
|
1614
|
+
adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, chainId, account }: {
|
|
1611
1615
|
poolId: string;
|
|
1612
1616
|
positionId: string;
|
|
1613
1617
|
adjustAmount: string;
|
|
1614
1618
|
quoteToken: string;
|
|
1615
1619
|
poolOracleType: OracleType;
|
|
1616
1620
|
chainId: number;
|
|
1621
|
+
account: string;
|
|
1617
1622
|
}): Promise<{
|
|
1618
1623
|
code: number;
|
|
1619
1624
|
message: string;
|
|
@@ -1774,7 +1779,7 @@ declare class Order {
|
|
|
1774
1779
|
code: number;
|
|
1775
1780
|
message: any;
|
|
1776
1781
|
}>;
|
|
1777
|
-
updateOrderTpSl(params: UpdateOrderParams, quoteAddress: string, chainId: number): Promise<{
|
|
1782
|
+
updateOrderTpSl(params: UpdateOrderParams, quoteAddress: string, chainId: number, account: string): Promise<{
|
|
1778
1783
|
code: number;
|
|
1779
1784
|
data: ethers$1.ContractTransactionReceipt | null;
|
|
1780
1785
|
message: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1320,15 +1320,17 @@ declare class SubScription {
|
|
|
1320
1320
|
declare class Utils {
|
|
1321
1321
|
private configManager;
|
|
1322
1322
|
private logger;
|
|
1323
|
-
|
|
1323
|
+
private client;
|
|
1324
|
+
constructor(configManager: ConfigManager, logger: Logger, client: MyxClient);
|
|
1324
1325
|
getOrderIdFromTransaction(receipt: any): string | null;
|
|
1325
1326
|
private getApproveQuoteAmount;
|
|
1326
1327
|
needsApproval(chainId: number, quoteAddress: string, requiredAmount: string, spenderAddress?: string): Promise<boolean>;
|
|
1327
|
-
approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, signer }: {
|
|
1328
|
+
approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, account, signer }: {
|
|
1328
1329
|
chainId: number;
|
|
1329
1330
|
quoteAddress: string;
|
|
1330
1331
|
amount?: string;
|
|
1331
1332
|
spenderAddress?: string;
|
|
1333
|
+
account?: string;
|
|
1332
1334
|
signer?: ethers$1.Signer;
|
|
1333
1335
|
}): Promise<{
|
|
1334
1336
|
code: number;
|
|
@@ -1472,10 +1474,11 @@ declare class Account {
|
|
|
1472
1474
|
message: string;
|
|
1473
1475
|
data?: undefined;
|
|
1474
1476
|
}>;
|
|
1475
|
-
deposit({ amount, tokenAddress, chainId }: {
|
|
1477
|
+
deposit({ amount, tokenAddress, chainId, account }: {
|
|
1476
1478
|
amount: string;
|
|
1477
1479
|
tokenAddress: string;
|
|
1478
1480
|
chainId: number;
|
|
1481
|
+
account: string;
|
|
1479
1482
|
}): Promise<{
|
|
1480
1483
|
code: number;
|
|
1481
1484
|
message: string;
|
|
@@ -1569,9 +1572,10 @@ declare class Seamless {
|
|
|
1569
1572
|
open: boolean;
|
|
1570
1573
|
};
|
|
1571
1574
|
}>;
|
|
1572
|
-
createSeamless({ password, chainId }: {
|
|
1575
|
+
createSeamless({ password, chainId, account }: {
|
|
1573
1576
|
password: string;
|
|
1574
1577
|
chainId: number;
|
|
1578
|
+
account: string;
|
|
1575
1579
|
}): Promise<{
|
|
1576
1580
|
code: number;
|
|
1577
1581
|
data: {
|
|
@@ -1607,13 +1611,14 @@ declare class Position {
|
|
|
1607
1611
|
code: number;
|
|
1608
1612
|
data: PositionHistoryItem[];
|
|
1609
1613
|
}>;
|
|
1610
|
-
adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, chainId }: {
|
|
1614
|
+
adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, chainId, account }: {
|
|
1611
1615
|
poolId: string;
|
|
1612
1616
|
positionId: string;
|
|
1613
1617
|
adjustAmount: string;
|
|
1614
1618
|
quoteToken: string;
|
|
1615
1619
|
poolOracleType: OracleType;
|
|
1616
1620
|
chainId: number;
|
|
1621
|
+
account: string;
|
|
1617
1622
|
}): Promise<{
|
|
1618
1623
|
code: number;
|
|
1619
1624
|
message: string;
|
|
@@ -1774,7 +1779,7 @@ declare class Order {
|
|
|
1774
1779
|
code: number;
|
|
1775
1780
|
message: any;
|
|
1776
1781
|
}>;
|
|
1777
|
-
updateOrderTpSl(params: UpdateOrderParams, quoteAddress: string, chainId: number): Promise<{
|
|
1782
|
+
updateOrderTpSl(params: UpdateOrderParams, quoteAddress: string, chainId: number, account: string): Promise<{
|
|
1778
1783
|
code: number;
|
|
1779
1784
|
data: ethers$1.ContractTransactionReceipt | null;
|
|
1780
1785
|
message: string;
|
package/dist/index.js
CHANGED
|
@@ -1822,7 +1822,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
|
|
|
1822
1822
|
// package.json
|
|
1823
1823
|
var package_default = {
|
|
1824
1824
|
name: "@myx-trade/sdk",
|
|
1825
|
-
version: "0.1.
|
|
1825
|
+
version: "0.1.129",
|
|
1826
1826
|
private: false,
|
|
1827
1827
|
publishConfig: {
|
|
1828
1828
|
access: "public"
|
|
@@ -14079,7 +14079,8 @@ var Position = class {
|
|
|
14079
14079
|
adjustAmount,
|
|
14080
14080
|
quoteToken,
|
|
14081
14081
|
poolOracleType,
|
|
14082
|
-
chainId
|
|
14082
|
+
chainId,
|
|
14083
|
+
account
|
|
14083
14084
|
}) {
|
|
14084
14085
|
const config = this.configManager.getConfig();
|
|
14085
14086
|
this.logger.debug("adjustCollateral params-->", {
|
|
@@ -14122,7 +14123,8 @@ var Position = class {
|
|
|
14122
14123
|
chainId,
|
|
14123
14124
|
quoteAddress: quoteToken,
|
|
14124
14125
|
amount: import_ethers23.ethers.MaxUint256.toString(),
|
|
14125
|
-
signer: seamlessWallet
|
|
14126
|
+
signer: seamlessWallet,
|
|
14127
|
+
account
|
|
14126
14128
|
});
|
|
14127
14129
|
if (approvalResult.code !== 0) {
|
|
14128
14130
|
throw new Error(approvalResult.message);
|
|
@@ -14174,7 +14176,8 @@ var Position = class {
|
|
|
14174
14176
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14175
14177
|
chainId,
|
|
14176
14178
|
quoteAddress: quoteToken,
|
|
14177
|
-
amount: import_ethers23.ethers.MaxUint256.toString()
|
|
14179
|
+
amount: import_ethers23.ethers.MaxUint256.toString(),
|
|
14180
|
+
account
|
|
14178
14181
|
});
|
|
14179
14182
|
if (approvalResult.code !== 0) {
|
|
14180
14183
|
throw new Error(approvalResult.message);
|
|
@@ -14333,7 +14336,8 @@ var Order = class {
|
|
|
14333
14336
|
chainId: params.chainId,
|
|
14334
14337
|
quoteAddress: params.executionFeeToken,
|
|
14335
14338
|
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14336
|
-
signer: seamlessWallet
|
|
14339
|
+
signer: seamlessWallet,
|
|
14340
|
+
account: params.address
|
|
14337
14341
|
});
|
|
14338
14342
|
this.logger.info("approvalResult-->", approvalResult);
|
|
14339
14343
|
if (approvalResult.code !== 0) {
|
|
@@ -14395,7 +14399,8 @@ var Order = class {
|
|
|
14395
14399
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14396
14400
|
chainId: params.chainId,
|
|
14397
14401
|
quoteAddress: params.executionFeeToken,
|
|
14398
|
-
amount: import_ethers24.ethers.MaxUint256.toString()
|
|
14402
|
+
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14403
|
+
account: params.address
|
|
14399
14404
|
});
|
|
14400
14405
|
if (approvalResult.code !== 0) {
|
|
14401
14406
|
throw new Error(approvalResult.message);
|
|
@@ -14521,7 +14526,8 @@ var Order = class {
|
|
|
14521
14526
|
chainId,
|
|
14522
14527
|
quoteAddress: params[0].executionFeeToken,
|
|
14523
14528
|
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14524
|
-
signer: seamlessWallet
|
|
14529
|
+
signer: seamlessWallet,
|
|
14530
|
+
account: params[0].address
|
|
14525
14531
|
});
|
|
14526
14532
|
if (approvalResult.code !== 0) {
|
|
14527
14533
|
throw new Error(approvalResult.message);
|
|
@@ -14564,7 +14570,8 @@ var Order = class {
|
|
|
14564
14570
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14565
14571
|
chainId,
|
|
14566
14572
|
quoteAddress: params[0].executionFeeToken,
|
|
14567
|
-
amount: import_ethers24.ethers.MaxUint256.toString()
|
|
14573
|
+
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14574
|
+
account: params[0].address
|
|
14568
14575
|
});
|
|
14569
14576
|
if (approvalResult.code !== 0) {
|
|
14570
14577
|
throw new Error(approvalResult.message);
|
|
@@ -14648,7 +14655,8 @@ var Order = class {
|
|
|
14648
14655
|
chainId: params.chainId,
|
|
14649
14656
|
quoteAddress: params.executionFeeToken,
|
|
14650
14657
|
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14651
|
-
signer: seamlessWallet
|
|
14658
|
+
signer: seamlessWallet,
|
|
14659
|
+
account: params.address
|
|
14652
14660
|
});
|
|
14653
14661
|
if (approvalResult.code !== 0) {
|
|
14654
14662
|
throw new Error(approvalResult.message);
|
|
@@ -14703,7 +14711,8 @@ var Order = class {
|
|
|
14703
14711
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14704
14712
|
chainId: params.chainId,
|
|
14705
14713
|
quoteAddress: params.executionFeeToken,
|
|
14706
|
-
amount: import_ethers24.ethers.MaxUint256.toString()
|
|
14714
|
+
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14715
|
+
account: params.address
|
|
14707
14716
|
});
|
|
14708
14717
|
if (approvalResult.code !== 0) {
|
|
14709
14718
|
throw new Error(approvalResult.message);
|
|
@@ -14844,7 +14853,8 @@ var Order = class {
|
|
|
14844
14853
|
chainId: params.chainId,
|
|
14845
14854
|
quoteAddress: params.executionFeeToken,
|
|
14846
14855
|
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14847
|
-
signer: seamlessWallet2
|
|
14856
|
+
signer: seamlessWallet2,
|
|
14857
|
+
account: params.address
|
|
14848
14858
|
});
|
|
14849
14859
|
if (approvalResult.code !== 0) {
|
|
14850
14860
|
throw new Error(approvalResult.message);
|
|
@@ -14896,7 +14906,8 @@ var Order = class {
|
|
|
14896
14906
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14897
14907
|
chainId: params.chainId,
|
|
14898
14908
|
quoteAddress: params.executionFeeToken,
|
|
14899
|
-
amount: import_ethers24.ethers.MaxUint256.toString()
|
|
14909
|
+
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14910
|
+
account: params.address
|
|
14900
14911
|
});
|
|
14901
14912
|
if (approvalResult.code !== 0) {
|
|
14902
14913
|
throw new Error(approvalResult.message);
|
|
@@ -14983,7 +14994,8 @@ var Order = class {
|
|
|
14983
14994
|
chainId: params.chainId,
|
|
14984
14995
|
quoteAddress: params.executionFeeToken,
|
|
14985
14996
|
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
14986
|
-
signer: seamlessWallet
|
|
14997
|
+
signer: seamlessWallet,
|
|
14998
|
+
account: params.address
|
|
14987
14999
|
});
|
|
14988
15000
|
if (approvalResult.code !== 0) {
|
|
14989
15001
|
throw new Error(approvalResult.message);
|
|
@@ -15035,7 +15047,8 @@ var Order = class {
|
|
|
15035
15047
|
const approvalResult = await this.utils.approveAuthorization({
|
|
15036
15048
|
chainId: params.chainId,
|
|
15037
15049
|
quoteAddress: params.executionFeeToken,
|
|
15038
|
-
amount: import_ethers24.ethers.MaxUint256.toString()
|
|
15050
|
+
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
15051
|
+
account: params.address
|
|
15039
15052
|
});
|
|
15040
15053
|
if (approvalResult.code !== 0) {
|
|
15041
15054
|
throw new Error(approvalResult.message);
|
|
@@ -15205,7 +15218,7 @@ var Order = class {
|
|
|
15205
15218
|
};
|
|
15206
15219
|
}
|
|
15207
15220
|
}
|
|
15208
|
-
async updateOrderTpSl(params, quoteAddress, chainId) {
|
|
15221
|
+
async updateOrderTpSl(params, quoteAddress, chainId, account) {
|
|
15209
15222
|
const config = this.configManager.getConfig();
|
|
15210
15223
|
if (!config.signer) {
|
|
15211
15224
|
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
|
|
@@ -15244,7 +15257,8 @@ var Order = class {
|
|
|
15244
15257
|
const approvalResult = await this.utils.approveAuthorization({
|
|
15245
15258
|
chainId,
|
|
15246
15259
|
quoteAddress: params.executionFeeToken,
|
|
15247
|
-
amount: import_ethers24.ethers.MaxUint256.toString()
|
|
15260
|
+
amount: import_ethers24.ethers.MaxUint256.toString(),
|
|
15261
|
+
account
|
|
15248
15262
|
});
|
|
15249
15263
|
if (approvalResult.code !== 0) {
|
|
15250
15264
|
throw new Error(approvalResult.message);
|
|
@@ -19936,9 +19950,10 @@ var ERC20Token_default = [
|
|
|
19936
19950
|
|
|
19937
19951
|
// src/manager/utils/index.ts
|
|
19938
19952
|
var Utils = class {
|
|
19939
|
-
constructor(configManager, logger) {
|
|
19953
|
+
constructor(configManager, logger, client2) {
|
|
19940
19954
|
this.configManager = configManager;
|
|
19941
19955
|
this.logger = logger;
|
|
19956
|
+
this.client = client2;
|
|
19942
19957
|
}
|
|
19943
19958
|
getOrderIdFromTransaction(receipt) {
|
|
19944
19959
|
if (!receipt || !receipt.logs) {
|
|
@@ -20040,6 +20055,7 @@ var Utils = class {
|
|
|
20040
20055
|
quoteAddress,
|
|
20041
20056
|
amount,
|
|
20042
20057
|
spenderAddress,
|
|
20058
|
+
account,
|
|
20043
20059
|
signer
|
|
20044
20060
|
}) {
|
|
20045
20061
|
try {
|
|
@@ -20047,13 +20063,13 @@ var Utils = class {
|
|
|
20047
20063
|
"function approve(address spender, uint256 amount) external returns (bool)"
|
|
20048
20064
|
];
|
|
20049
20065
|
const config = this.configManager.getConfig();
|
|
20066
|
+
const approveAmount = amount ?? import_ethers25.ethers.MaxUint256;
|
|
20067
|
+
const spender = spenderAddress ?? getContractAddressByChainId(chainId).Account;
|
|
20050
20068
|
const usdcContract = new import_ethers25.ethers.Contract(
|
|
20051
20069
|
quoteAddress,
|
|
20052
20070
|
erc20Abi,
|
|
20053
20071
|
signer ?? config.signer
|
|
20054
20072
|
);
|
|
20055
|
-
const approveAmount = amount ?? import_ethers25.ethers.MaxUint256;
|
|
20056
|
-
const spender = spenderAddress ?? getContractAddressByChainId(chainId).Account;
|
|
20057
20073
|
const tx = await usdcContract.approve(spender, approveAmount);
|
|
20058
20074
|
await tx.wait();
|
|
20059
20075
|
return {
|
|
@@ -20996,12 +21012,6 @@ var Account = class {
|
|
|
20996
21012
|
*/
|
|
20997
21013
|
async getTradableAmount({ poolId, chainId }) {
|
|
20998
21014
|
const config = this.configManager.getConfig();
|
|
20999
|
-
if (!config.signer) {
|
|
21000
|
-
throw new MyxSDKError(
|
|
21001
|
-
"INVALID_SIGNER" /* InvalidSigner */,
|
|
21002
|
-
"Invalid signer"
|
|
21003
|
-
);
|
|
21004
|
-
}
|
|
21005
21015
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
21006
21016
|
const provider = await getJSONProvider(chainId);
|
|
21007
21017
|
const accountContract = new import_ethers26.ethers.Contract(
|
|
@@ -21096,9 +21106,8 @@ var Account = class {
|
|
|
21096
21106
|
};
|
|
21097
21107
|
}
|
|
21098
21108
|
}
|
|
21099
|
-
async deposit({ amount, tokenAddress, chainId }) {
|
|
21109
|
+
async deposit({ amount, tokenAddress, chainId, account }) {
|
|
21100
21110
|
const config = this.configManager.getConfig();
|
|
21101
|
-
const account = await config.signer?.getAddress() ?? "";
|
|
21102
21111
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
21103
21112
|
try {
|
|
21104
21113
|
const needApproval = await this.utils.needsApproval(
|
|
@@ -21117,6 +21126,7 @@ var Account = class {
|
|
|
21117
21126
|
quoteAddress: tokenAddress,
|
|
21118
21127
|
amount: import_ethers26.ethers.MaxUint256.toString(),
|
|
21119
21128
|
spenderAddress: contractAddress.Account,
|
|
21129
|
+
account,
|
|
21120
21130
|
signer: seamlessWallet
|
|
21121
21131
|
});
|
|
21122
21132
|
if (approvalResult.code !== 0) {
|
|
@@ -21157,7 +21167,8 @@ var Account = class {
|
|
|
21157
21167
|
chainId,
|
|
21158
21168
|
quoteAddress: tokenAddress,
|
|
21159
21169
|
amount: import_ethers26.ethers.MaxUint256.toString(),
|
|
21160
|
-
spenderAddress: contractAddress.Account
|
|
21170
|
+
spenderAddress: contractAddress.Account,
|
|
21171
|
+
account
|
|
21161
21172
|
});
|
|
21162
21173
|
if (approvalResult.code !== 0) {
|
|
21163
21174
|
throw new Error(approvalResult.message);
|
|
@@ -21441,7 +21452,6 @@ var Seamless = class {
|
|
|
21441
21452
|
return txRs;
|
|
21442
21453
|
}
|
|
21443
21454
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
|
21444
|
-
console.log("authorizeSeamlessAccount-->", approve2, seamlessAddress, chainId);
|
|
21445
21455
|
const config = this.configManager.getConfig();
|
|
21446
21456
|
const accessToken = await this.configManager.getAccessToken();
|
|
21447
21457
|
if (!accessToken) {
|
|
@@ -21451,7 +21461,7 @@ var Seamless = class {
|
|
|
21451
21461
|
if (approve2) {
|
|
21452
21462
|
const balanceRes = await this.account.getWalletQuoteTokenBalance(masterAddress);
|
|
21453
21463
|
const balance = balanceRes.data;
|
|
21454
|
-
const forwarderContract2 = await getForwarderContract(
|
|
21464
|
+
const forwarderContract2 = await getForwarderContract(chainId);
|
|
21455
21465
|
const pledgeFee = await forwarderContract2.getRelayFee();
|
|
21456
21466
|
const gasFee = BigInt(pledgeFee) * BigInt(FORWARD_PLEDGE_FEE_RADIO);
|
|
21457
21467
|
if (gasFee > 0 && gasFee > BigInt(balance)) {
|
|
@@ -21468,7 +21478,7 @@ var Seamless = class {
|
|
|
21468
21478
|
permitParams = [];
|
|
21469
21479
|
}
|
|
21470
21480
|
}
|
|
21471
|
-
const forwarderContract = await getForwarderContract(
|
|
21481
|
+
const forwarderContract = await getForwarderContract(chainId);
|
|
21472
21482
|
const nonce = await forwarderContract.nonces(masterAddress);
|
|
21473
21483
|
const gasLimit = SEAMLESS_ACCOUNT_GAS_LIMIT;
|
|
21474
21484
|
const provider = await getJSONProvider(config.chainId);
|
|
@@ -21615,10 +21625,9 @@ var Seamless = class {
|
|
|
21615
21625
|
}
|
|
21616
21626
|
};
|
|
21617
21627
|
}
|
|
21618
|
-
async createSeamless({ password, chainId }) {
|
|
21628
|
+
async createSeamless({ password, chainId, account }) {
|
|
21619
21629
|
const config = this.configManager.getConfig();
|
|
21620
21630
|
const signer = config.signer;
|
|
21621
|
-
const account = await signer?.getAddress() ?? "";
|
|
21622
21631
|
if (!signer) {
|
|
21623
21632
|
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
|
|
21624
21633
|
}
|
|
@@ -21646,7 +21655,8 @@ var Seamless = class {
|
|
|
21646
21655
|
chainId,
|
|
21647
21656
|
quoteAddress: erc20Address,
|
|
21648
21657
|
amount: import_ethers27.ethers.MaxUint256.toString(),
|
|
21649
|
-
spenderAddress: forwarderContract.target
|
|
21658
|
+
spenderAddress: forwarderContract.target,
|
|
21659
|
+
account
|
|
21650
21660
|
});
|
|
21651
21661
|
return {
|
|
21652
21662
|
code: 0,
|
|
@@ -21679,7 +21689,7 @@ var MyxClient = class {
|
|
|
21679
21689
|
this.logger = new Logger({
|
|
21680
21690
|
logLevel: options.logLevel
|
|
21681
21691
|
});
|
|
21682
|
-
this.utils = new Utils(this.configManager, this.logger);
|
|
21692
|
+
this.utils = new Utils(this.configManager, this.logger, this);
|
|
21683
21693
|
this.account = new Account(this.configManager, this.logger, this.utils, this);
|
|
21684
21694
|
this.seamless = new Seamless(this.configManager, this.logger, this.utils, this.account);
|
|
21685
21695
|
this.markets = new Markets(this.configManager, this.utils);
|
package/dist/index.mjs
CHANGED
|
@@ -1732,7 +1732,7 @@ var RotationProvider = class extends BaseProvider {
|
|
|
1732
1732
|
// package.json
|
|
1733
1733
|
var package_default = {
|
|
1734
1734
|
name: "@myx-trade/sdk",
|
|
1735
|
-
version: "0.1.
|
|
1735
|
+
version: "0.1.129",
|
|
1736
1736
|
private: false,
|
|
1737
1737
|
publishConfig: {
|
|
1738
1738
|
access: "public"
|
|
@@ -13989,7 +13989,8 @@ var Position = class {
|
|
|
13989
13989
|
adjustAmount,
|
|
13990
13990
|
quoteToken,
|
|
13991
13991
|
poolOracleType,
|
|
13992
|
-
chainId
|
|
13992
|
+
chainId,
|
|
13993
|
+
account
|
|
13993
13994
|
}) {
|
|
13994
13995
|
const config = this.configManager.getConfig();
|
|
13995
13996
|
this.logger.debug("adjustCollateral params-->", {
|
|
@@ -14032,7 +14033,8 @@ var Position = class {
|
|
|
14032
14033
|
chainId,
|
|
14033
14034
|
quoteAddress: quoteToken,
|
|
14034
14035
|
amount: ethers5.MaxUint256.toString(),
|
|
14035
|
-
signer: seamlessWallet
|
|
14036
|
+
signer: seamlessWallet,
|
|
14037
|
+
account
|
|
14036
14038
|
});
|
|
14037
14039
|
if (approvalResult.code !== 0) {
|
|
14038
14040
|
throw new Error(approvalResult.message);
|
|
@@ -14084,7 +14086,8 @@ var Position = class {
|
|
|
14084
14086
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14085
14087
|
chainId,
|
|
14086
14088
|
quoteAddress: quoteToken,
|
|
14087
|
-
amount: ethers5.MaxUint256.toString()
|
|
14089
|
+
amount: ethers5.MaxUint256.toString(),
|
|
14090
|
+
account
|
|
14088
14091
|
});
|
|
14089
14092
|
if (approvalResult.code !== 0) {
|
|
14090
14093
|
throw new Error(approvalResult.message);
|
|
@@ -14243,7 +14246,8 @@ var Order = class {
|
|
|
14243
14246
|
chainId: params.chainId,
|
|
14244
14247
|
quoteAddress: params.executionFeeToken,
|
|
14245
14248
|
amount: ethers6.MaxUint256.toString(),
|
|
14246
|
-
signer: seamlessWallet
|
|
14249
|
+
signer: seamlessWallet,
|
|
14250
|
+
account: params.address
|
|
14247
14251
|
});
|
|
14248
14252
|
this.logger.info("approvalResult-->", approvalResult);
|
|
14249
14253
|
if (approvalResult.code !== 0) {
|
|
@@ -14305,7 +14309,8 @@ var Order = class {
|
|
|
14305
14309
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14306
14310
|
chainId: params.chainId,
|
|
14307
14311
|
quoteAddress: params.executionFeeToken,
|
|
14308
|
-
amount: ethers6.MaxUint256.toString()
|
|
14312
|
+
amount: ethers6.MaxUint256.toString(),
|
|
14313
|
+
account: params.address
|
|
14309
14314
|
});
|
|
14310
14315
|
if (approvalResult.code !== 0) {
|
|
14311
14316
|
throw new Error(approvalResult.message);
|
|
@@ -14431,7 +14436,8 @@ var Order = class {
|
|
|
14431
14436
|
chainId,
|
|
14432
14437
|
quoteAddress: params[0].executionFeeToken,
|
|
14433
14438
|
amount: ethers6.MaxUint256.toString(),
|
|
14434
|
-
signer: seamlessWallet
|
|
14439
|
+
signer: seamlessWallet,
|
|
14440
|
+
account: params[0].address
|
|
14435
14441
|
});
|
|
14436
14442
|
if (approvalResult.code !== 0) {
|
|
14437
14443
|
throw new Error(approvalResult.message);
|
|
@@ -14474,7 +14480,8 @@ var Order = class {
|
|
|
14474
14480
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14475
14481
|
chainId,
|
|
14476
14482
|
quoteAddress: params[0].executionFeeToken,
|
|
14477
|
-
amount: ethers6.MaxUint256.toString()
|
|
14483
|
+
amount: ethers6.MaxUint256.toString(),
|
|
14484
|
+
account: params[0].address
|
|
14478
14485
|
});
|
|
14479
14486
|
if (approvalResult.code !== 0) {
|
|
14480
14487
|
throw new Error(approvalResult.message);
|
|
@@ -14558,7 +14565,8 @@ var Order = class {
|
|
|
14558
14565
|
chainId: params.chainId,
|
|
14559
14566
|
quoteAddress: params.executionFeeToken,
|
|
14560
14567
|
amount: ethers6.MaxUint256.toString(),
|
|
14561
|
-
signer: seamlessWallet
|
|
14568
|
+
signer: seamlessWallet,
|
|
14569
|
+
account: params.address
|
|
14562
14570
|
});
|
|
14563
14571
|
if (approvalResult.code !== 0) {
|
|
14564
14572
|
throw new Error(approvalResult.message);
|
|
@@ -14613,7 +14621,8 @@ var Order = class {
|
|
|
14613
14621
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14614
14622
|
chainId: params.chainId,
|
|
14615
14623
|
quoteAddress: params.executionFeeToken,
|
|
14616
|
-
amount: ethers6.MaxUint256.toString()
|
|
14624
|
+
amount: ethers6.MaxUint256.toString(),
|
|
14625
|
+
account: params.address
|
|
14617
14626
|
});
|
|
14618
14627
|
if (approvalResult.code !== 0) {
|
|
14619
14628
|
throw new Error(approvalResult.message);
|
|
@@ -14754,7 +14763,8 @@ var Order = class {
|
|
|
14754
14763
|
chainId: params.chainId,
|
|
14755
14764
|
quoteAddress: params.executionFeeToken,
|
|
14756
14765
|
amount: ethers6.MaxUint256.toString(),
|
|
14757
|
-
signer: seamlessWallet2
|
|
14766
|
+
signer: seamlessWallet2,
|
|
14767
|
+
account: params.address
|
|
14758
14768
|
});
|
|
14759
14769
|
if (approvalResult.code !== 0) {
|
|
14760
14770
|
throw new Error(approvalResult.message);
|
|
@@ -14806,7 +14816,8 @@ var Order = class {
|
|
|
14806
14816
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14807
14817
|
chainId: params.chainId,
|
|
14808
14818
|
quoteAddress: params.executionFeeToken,
|
|
14809
|
-
amount: ethers6.MaxUint256.toString()
|
|
14819
|
+
amount: ethers6.MaxUint256.toString(),
|
|
14820
|
+
account: params.address
|
|
14810
14821
|
});
|
|
14811
14822
|
if (approvalResult.code !== 0) {
|
|
14812
14823
|
throw new Error(approvalResult.message);
|
|
@@ -14893,7 +14904,8 @@ var Order = class {
|
|
|
14893
14904
|
chainId: params.chainId,
|
|
14894
14905
|
quoteAddress: params.executionFeeToken,
|
|
14895
14906
|
amount: ethers6.MaxUint256.toString(),
|
|
14896
|
-
signer: seamlessWallet
|
|
14907
|
+
signer: seamlessWallet,
|
|
14908
|
+
account: params.address
|
|
14897
14909
|
});
|
|
14898
14910
|
if (approvalResult.code !== 0) {
|
|
14899
14911
|
throw new Error(approvalResult.message);
|
|
@@ -14945,7 +14957,8 @@ var Order = class {
|
|
|
14945
14957
|
const approvalResult = await this.utils.approveAuthorization({
|
|
14946
14958
|
chainId: params.chainId,
|
|
14947
14959
|
quoteAddress: params.executionFeeToken,
|
|
14948
|
-
amount: ethers6.MaxUint256.toString()
|
|
14960
|
+
amount: ethers6.MaxUint256.toString(),
|
|
14961
|
+
account: params.address
|
|
14949
14962
|
});
|
|
14950
14963
|
if (approvalResult.code !== 0) {
|
|
14951
14964
|
throw new Error(approvalResult.message);
|
|
@@ -15115,7 +15128,7 @@ var Order = class {
|
|
|
15115
15128
|
};
|
|
15116
15129
|
}
|
|
15117
15130
|
}
|
|
15118
|
-
async updateOrderTpSl(params, quoteAddress, chainId) {
|
|
15131
|
+
async updateOrderTpSl(params, quoteAddress, chainId, account) {
|
|
15119
15132
|
const config = this.configManager.getConfig();
|
|
15120
15133
|
if (!config.signer) {
|
|
15121
15134
|
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
|
|
@@ -15154,7 +15167,8 @@ var Order = class {
|
|
|
15154
15167
|
const approvalResult = await this.utils.approveAuthorization({
|
|
15155
15168
|
chainId,
|
|
15156
15169
|
quoteAddress: params.executionFeeToken,
|
|
15157
|
-
amount: ethers6.MaxUint256.toString()
|
|
15170
|
+
amount: ethers6.MaxUint256.toString(),
|
|
15171
|
+
account
|
|
15158
15172
|
});
|
|
15159
15173
|
if (approvalResult.code !== 0) {
|
|
15160
15174
|
throw new Error(approvalResult.message);
|
|
@@ -19846,9 +19860,10 @@ var ERC20Token_default = [
|
|
|
19846
19860
|
|
|
19847
19861
|
// src/manager/utils/index.ts
|
|
19848
19862
|
var Utils = class {
|
|
19849
|
-
constructor(configManager, logger) {
|
|
19863
|
+
constructor(configManager, logger, client2) {
|
|
19850
19864
|
this.configManager = configManager;
|
|
19851
19865
|
this.logger = logger;
|
|
19866
|
+
this.client = client2;
|
|
19852
19867
|
}
|
|
19853
19868
|
getOrderIdFromTransaction(receipt) {
|
|
19854
19869
|
if (!receipt || !receipt.logs) {
|
|
@@ -19950,6 +19965,7 @@ var Utils = class {
|
|
|
19950
19965
|
quoteAddress,
|
|
19951
19966
|
amount,
|
|
19952
19967
|
spenderAddress,
|
|
19968
|
+
account,
|
|
19953
19969
|
signer
|
|
19954
19970
|
}) {
|
|
19955
19971
|
try {
|
|
@@ -19957,13 +19973,13 @@ var Utils = class {
|
|
|
19957
19973
|
"function approve(address spender, uint256 amount) external returns (bool)"
|
|
19958
19974
|
];
|
|
19959
19975
|
const config = this.configManager.getConfig();
|
|
19976
|
+
const approveAmount = amount ?? ethers7.MaxUint256;
|
|
19977
|
+
const spender = spenderAddress ?? getContractAddressByChainId(chainId).Account;
|
|
19960
19978
|
const usdcContract = new ethers7.Contract(
|
|
19961
19979
|
quoteAddress,
|
|
19962
19980
|
erc20Abi,
|
|
19963
19981
|
signer ?? config.signer
|
|
19964
19982
|
);
|
|
19965
|
-
const approveAmount = amount ?? ethers7.MaxUint256;
|
|
19966
|
-
const spender = spenderAddress ?? getContractAddressByChainId(chainId).Account;
|
|
19967
19983
|
const tx = await usdcContract.approve(spender, approveAmount);
|
|
19968
19984
|
await tx.wait();
|
|
19969
19985
|
return {
|
|
@@ -20906,12 +20922,6 @@ var Account = class {
|
|
|
20906
20922
|
*/
|
|
20907
20923
|
async getTradableAmount({ poolId, chainId }) {
|
|
20908
20924
|
const config = this.configManager.getConfig();
|
|
20909
|
-
if (!config.signer) {
|
|
20910
|
-
throw new MyxSDKError(
|
|
20911
|
-
"INVALID_SIGNER" /* InvalidSigner */,
|
|
20912
|
-
"Invalid signer"
|
|
20913
|
-
);
|
|
20914
|
-
}
|
|
20915
20925
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
20916
20926
|
const provider = await getJSONProvider(chainId);
|
|
20917
20927
|
const accountContract = new ethers8.Contract(
|
|
@@ -21006,9 +21016,8 @@ var Account = class {
|
|
|
21006
21016
|
};
|
|
21007
21017
|
}
|
|
21008
21018
|
}
|
|
21009
|
-
async deposit({ amount, tokenAddress, chainId }) {
|
|
21019
|
+
async deposit({ amount, tokenAddress, chainId, account }) {
|
|
21010
21020
|
const config = this.configManager.getConfig();
|
|
21011
|
-
const account = await config.signer?.getAddress() ?? "";
|
|
21012
21021
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
21013
21022
|
try {
|
|
21014
21023
|
const needApproval = await this.utils.needsApproval(
|
|
@@ -21027,6 +21036,7 @@ var Account = class {
|
|
|
21027
21036
|
quoteAddress: tokenAddress,
|
|
21028
21037
|
amount: ethers8.MaxUint256.toString(),
|
|
21029
21038
|
spenderAddress: contractAddress.Account,
|
|
21039
|
+
account,
|
|
21030
21040
|
signer: seamlessWallet
|
|
21031
21041
|
});
|
|
21032
21042
|
if (approvalResult.code !== 0) {
|
|
@@ -21067,7 +21077,8 @@ var Account = class {
|
|
|
21067
21077
|
chainId,
|
|
21068
21078
|
quoteAddress: tokenAddress,
|
|
21069
21079
|
amount: ethers8.MaxUint256.toString(),
|
|
21070
|
-
spenderAddress: contractAddress.Account
|
|
21080
|
+
spenderAddress: contractAddress.Account,
|
|
21081
|
+
account
|
|
21071
21082
|
});
|
|
21072
21083
|
if (approvalResult.code !== 0) {
|
|
21073
21084
|
throw new Error(approvalResult.message);
|
|
@@ -21351,7 +21362,6 @@ var Seamless = class {
|
|
|
21351
21362
|
return txRs;
|
|
21352
21363
|
}
|
|
21353
21364
|
async authorizeSeamlessAccount({ approve: approve2, seamlessAddress, chainId }) {
|
|
21354
|
-
console.log("authorizeSeamlessAccount-->", approve2, seamlessAddress, chainId);
|
|
21355
21365
|
const config = this.configManager.getConfig();
|
|
21356
21366
|
const accessToken = await this.configManager.getAccessToken();
|
|
21357
21367
|
if (!accessToken) {
|
|
@@ -21361,7 +21371,7 @@ var Seamless = class {
|
|
|
21361
21371
|
if (approve2) {
|
|
21362
21372
|
const balanceRes = await this.account.getWalletQuoteTokenBalance(masterAddress);
|
|
21363
21373
|
const balance = balanceRes.data;
|
|
21364
|
-
const forwarderContract2 = await getForwarderContract(
|
|
21374
|
+
const forwarderContract2 = await getForwarderContract(chainId);
|
|
21365
21375
|
const pledgeFee = await forwarderContract2.getRelayFee();
|
|
21366
21376
|
const gasFee = BigInt(pledgeFee) * BigInt(FORWARD_PLEDGE_FEE_RADIO);
|
|
21367
21377
|
if (gasFee > 0 && gasFee > BigInt(balance)) {
|
|
@@ -21378,7 +21388,7 @@ var Seamless = class {
|
|
|
21378
21388
|
permitParams = [];
|
|
21379
21389
|
}
|
|
21380
21390
|
}
|
|
21381
|
-
const forwarderContract = await getForwarderContract(
|
|
21391
|
+
const forwarderContract = await getForwarderContract(chainId);
|
|
21382
21392
|
const nonce = await forwarderContract.nonces(masterAddress);
|
|
21383
21393
|
const gasLimit = SEAMLESS_ACCOUNT_GAS_LIMIT;
|
|
21384
21394
|
const provider = await getJSONProvider(config.chainId);
|
|
@@ -21525,10 +21535,9 @@ var Seamless = class {
|
|
|
21525
21535
|
}
|
|
21526
21536
|
};
|
|
21527
21537
|
}
|
|
21528
|
-
async createSeamless({ password, chainId }) {
|
|
21538
|
+
async createSeamless({ password, chainId, account }) {
|
|
21529
21539
|
const config = this.configManager.getConfig();
|
|
21530
21540
|
const signer = config.signer;
|
|
21531
|
-
const account = await signer?.getAddress() ?? "";
|
|
21532
21541
|
if (!signer) {
|
|
21533
21542
|
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
|
|
21534
21543
|
}
|
|
@@ -21556,7 +21565,8 @@ var Seamless = class {
|
|
|
21556
21565
|
chainId,
|
|
21557
21566
|
quoteAddress: erc20Address,
|
|
21558
21567
|
amount: ethers9.MaxUint256.toString(),
|
|
21559
|
-
spenderAddress: forwarderContract.target
|
|
21568
|
+
spenderAddress: forwarderContract.target,
|
|
21569
|
+
account
|
|
21560
21570
|
});
|
|
21561
21571
|
return {
|
|
21562
21572
|
code: 0,
|
|
@@ -21589,7 +21599,7 @@ var MyxClient = class {
|
|
|
21589
21599
|
this.logger = new Logger({
|
|
21590
21600
|
logLevel: options.logLevel
|
|
21591
21601
|
});
|
|
21592
|
-
this.utils = new Utils(this.configManager, this.logger);
|
|
21602
|
+
this.utils = new Utils(this.configManager, this.logger, this);
|
|
21593
21603
|
this.account = new Account(this.configManager, this.logger, this.utils, this);
|
|
21594
21604
|
this.seamless = new Seamless(this.configManager, this.logger, this.utils, this.account);
|
|
21595
21605
|
this.markets = new Markets(this.configManager, this.utils);
|