@myx-trade/sdk 0.1.156 → 0.1.158
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.js +25 -17
- package/dist/index.mjs +25 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1821,7 +1821,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
|
|
|
1821
1821
|
// package.json
|
|
1822
1822
|
var package_default = {
|
|
1823
1823
|
name: "@myx-trade/sdk",
|
|
1824
|
-
version: "0.1.
|
|
1824
|
+
version: "0.1.158",
|
|
1825
1825
|
private: false,
|
|
1826
1826
|
publishConfig: {
|
|
1827
1827
|
access: "public"
|
|
@@ -14374,19 +14374,12 @@ var Order = class {
|
|
|
14374
14374
|
);
|
|
14375
14375
|
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({ poolId: params.poolId, chainId: params.chainId, address: params.address });
|
|
14376
14376
|
const totalCollateralAmount = BigInt(params.collateralAmount) + BigInt(tradingFee);
|
|
14377
|
-
this.logger.info("availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
14378
|
-
this.logger.info("totalCollateralAmount-->", totalCollateralAmount.toString());
|
|
14379
|
-
this.logger.info("totalNetWorkFee-->", totalNetWorkFee.toString());
|
|
14380
14377
|
const needAmount = BigInt(tradingFee) + BigInt(params.collateralAmount) + totalNetWorkFee;
|
|
14381
|
-
this.logger.info("needAmount-->", needAmount.toString());
|
|
14382
14378
|
let depositAmount = BigInt(0);
|
|
14383
|
-
this.logger.info("availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
14384
14379
|
const diff = needAmount - availableAccountMarginBalance;
|
|
14385
|
-
this.logger.info("diff-->", diff.toString());
|
|
14386
14380
|
if (diff > BigInt(0)) {
|
|
14387
14381
|
depositAmount = diff;
|
|
14388
14382
|
}
|
|
14389
|
-
this.logger.info("depositAmount-->", depositAmount.toString());
|
|
14390
14383
|
const depositData = {
|
|
14391
14384
|
token: params.executionFeeToken,
|
|
14392
14385
|
amount: depositAmount.toString()
|
|
@@ -21470,6 +21463,8 @@ var Seamless = class {
|
|
|
21470
21463
|
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Signer is required for permit");
|
|
21471
21464
|
}
|
|
21472
21465
|
const masterAddress = await config.signer.getAddress();
|
|
21466
|
+
const forwarderContract = await getForwarderContract(chainId);
|
|
21467
|
+
const forwarderAddress = forwarderContract.target;
|
|
21473
21468
|
const brokerAddress = config.brokerAddress;
|
|
21474
21469
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
21475
21470
|
const erc20Contract = new import_ethers27.ethers.Contract(
|
|
@@ -21490,6 +21485,17 @@ var Seamless = class {
|
|
|
21490
21485
|
deadline.toString(),
|
|
21491
21486
|
chainId
|
|
21492
21487
|
);
|
|
21488
|
+
const forwarderSignPermit = await signPermit(
|
|
21489
|
+
config.signer,
|
|
21490
|
+
// 使用 signer 而不是 provider
|
|
21491
|
+
erc20Contract,
|
|
21492
|
+
masterAddress,
|
|
21493
|
+
forwarderAddress,
|
|
21494
|
+
import_ethers27.ethers.MaxUint256.toString(),
|
|
21495
|
+
(nonces + 1).toString(),
|
|
21496
|
+
deadline.toString(),
|
|
21497
|
+
chainId
|
|
21498
|
+
);
|
|
21493
21499
|
const brokerSeamlessUSDPermitParams = {
|
|
21494
21500
|
token: erc20Contract.target,
|
|
21495
21501
|
owner: masterAddress,
|
|
@@ -21500,7 +21506,17 @@ var Seamless = class {
|
|
|
21500
21506
|
r: brokerSignPermit.r,
|
|
21501
21507
|
s: brokerSignPermit.s
|
|
21502
21508
|
};
|
|
21503
|
-
|
|
21509
|
+
const forwarderPermitParams = {
|
|
21510
|
+
token: erc20Contract.target,
|
|
21511
|
+
owner: masterAddress,
|
|
21512
|
+
spender: forwarderAddress,
|
|
21513
|
+
value: import_ethers27.ethers.MaxUint256,
|
|
21514
|
+
deadline,
|
|
21515
|
+
v: forwarderSignPermit.v,
|
|
21516
|
+
r: forwarderSignPermit.r,
|
|
21517
|
+
s: forwarderSignPermit.s
|
|
21518
|
+
};
|
|
21519
|
+
return [brokerSeamlessUSDPermitParams, forwarderPermitParams];
|
|
21504
21520
|
} catch (error) {
|
|
21505
21521
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
|
|
21506
21522
|
}
|
|
@@ -21731,14 +21747,6 @@ var Seamless = class {
|
|
|
21731
21747
|
wallet,
|
|
21732
21748
|
authorized: isAuthorized
|
|
21733
21749
|
});
|
|
21734
|
-
const forwarderContract = await getForwarderContract(chainId);
|
|
21735
|
-
const erc20Address = getContractAddressByChainId(chainId).ERC20;
|
|
21736
|
-
await this.utils.approveAuthorization({
|
|
21737
|
-
chainId,
|
|
21738
|
-
quoteAddress: erc20Address,
|
|
21739
|
-
amount: import_ethers27.ethers.MaxUint256.toString(),
|
|
21740
|
-
spenderAddress: forwarderContract.target
|
|
21741
|
-
});
|
|
21742
21750
|
return {
|
|
21743
21751
|
code: 0,
|
|
21744
21752
|
data: {
|
package/dist/index.mjs
CHANGED
|
@@ -1731,7 +1731,7 @@ var RotationProvider = class extends BaseProvider {
|
|
|
1731
1731
|
// package.json
|
|
1732
1732
|
var package_default = {
|
|
1733
1733
|
name: "@myx-trade/sdk",
|
|
1734
|
-
version: "0.1.
|
|
1734
|
+
version: "0.1.158",
|
|
1735
1735
|
private: false,
|
|
1736
1736
|
publishConfig: {
|
|
1737
1737
|
access: "public"
|
|
@@ -14284,19 +14284,12 @@ var Order = class {
|
|
|
14284
14284
|
);
|
|
14285
14285
|
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({ poolId: params.poolId, chainId: params.chainId, address: params.address });
|
|
14286
14286
|
const totalCollateralAmount = BigInt(params.collateralAmount) + BigInt(tradingFee);
|
|
14287
|
-
this.logger.info("availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
14288
|
-
this.logger.info("totalCollateralAmount-->", totalCollateralAmount.toString());
|
|
14289
|
-
this.logger.info("totalNetWorkFee-->", totalNetWorkFee.toString());
|
|
14290
14287
|
const needAmount = BigInt(tradingFee) + BigInt(params.collateralAmount) + totalNetWorkFee;
|
|
14291
|
-
this.logger.info("needAmount-->", needAmount.toString());
|
|
14292
14288
|
let depositAmount = BigInt(0);
|
|
14293
|
-
this.logger.info("availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
14294
14289
|
const diff = needAmount - availableAccountMarginBalance;
|
|
14295
|
-
this.logger.info("diff-->", diff.toString());
|
|
14296
14290
|
if (diff > BigInt(0)) {
|
|
14297
14291
|
depositAmount = diff;
|
|
14298
14292
|
}
|
|
14299
|
-
this.logger.info("depositAmount-->", depositAmount.toString());
|
|
14300
14293
|
const depositData = {
|
|
14301
14294
|
token: params.executionFeeToken,
|
|
14302
14295
|
amount: depositAmount.toString()
|
|
@@ -21380,6 +21373,8 @@ var Seamless = class {
|
|
|
21380
21373
|
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Signer is required for permit");
|
|
21381
21374
|
}
|
|
21382
21375
|
const masterAddress = await config.signer.getAddress();
|
|
21376
|
+
const forwarderContract = await getForwarderContract(chainId);
|
|
21377
|
+
const forwarderAddress = forwarderContract.target;
|
|
21383
21378
|
const brokerAddress = config.brokerAddress;
|
|
21384
21379
|
const contractAddress = getContractAddressByChainId(chainId);
|
|
21385
21380
|
const erc20Contract = new ethers9.Contract(
|
|
@@ -21400,6 +21395,17 @@ var Seamless = class {
|
|
|
21400
21395
|
deadline.toString(),
|
|
21401
21396
|
chainId
|
|
21402
21397
|
);
|
|
21398
|
+
const forwarderSignPermit = await signPermit(
|
|
21399
|
+
config.signer,
|
|
21400
|
+
// 使用 signer 而不是 provider
|
|
21401
|
+
erc20Contract,
|
|
21402
|
+
masterAddress,
|
|
21403
|
+
forwarderAddress,
|
|
21404
|
+
ethers9.MaxUint256.toString(),
|
|
21405
|
+
(nonces + 1).toString(),
|
|
21406
|
+
deadline.toString(),
|
|
21407
|
+
chainId
|
|
21408
|
+
);
|
|
21403
21409
|
const brokerSeamlessUSDPermitParams = {
|
|
21404
21410
|
token: erc20Contract.target,
|
|
21405
21411
|
owner: masterAddress,
|
|
@@ -21410,7 +21416,17 @@ var Seamless = class {
|
|
|
21410
21416
|
r: brokerSignPermit.r,
|
|
21411
21417
|
s: brokerSignPermit.s
|
|
21412
21418
|
};
|
|
21413
|
-
|
|
21419
|
+
const forwarderPermitParams = {
|
|
21420
|
+
token: erc20Contract.target,
|
|
21421
|
+
owner: masterAddress,
|
|
21422
|
+
spender: forwarderAddress,
|
|
21423
|
+
value: ethers9.MaxUint256,
|
|
21424
|
+
deadline,
|
|
21425
|
+
v: forwarderSignPermit.v,
|
|
21426
|
+
r: forwarderSignPermit.r,
|
|
21427
|
+
s: forwarderSignPermit.s
|
|
21428
|
+
};
|
|
21429
|
+
return [brokerSeamlessUSDPermitParams, forwarderPermitParams];
|
|
21414
21430
|
} catch (error) {
|
|
21415
21431
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
|
|
21416
21432
|
}
|
|
@@ -21641,14 +21657,6 @@ var Seamless = class {
|
|
|
21641
21657
|
wallet,
|
|
21642
21658
|
authorized: isAuthorized
|
|
21643
21659
|
});
|
|
21644
|
-
const forwarderContract = await getForwarderContract(chainId);
|
|
21645
|
-
const erc20Address = getContractAddressByChainId(chainId).ERC20;
|
|
21646
|
-
await this.utils.approveAuthorization({
|
|
21647
|
-
chainId,
|
|
21648
|
-
quoteAddress: erc20Address,
|
|
21649
|
-
amount: ethers9.MaxUint256.toString(),
|
|
21650
|
-
spenderAddress: forwarderContract.target
|
|
21651
|
-
});
|
|
21652
21660
|
return {
|
|
21653
21661
|
code: 0,
|
|
21654
21662
|
data: {
|