@myx-trade/sdk 0.1.164 → 0.1.166
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 +10 -4
- package/dist/index.mjs +10 -4
- 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.166",
|
|
1825
1825
|
private: false,
|
|
1826
1826
|
publishConfig: {
|
|
1827
1827
|
access: "public"
|
|
@@ -14373,6 +14373,7 @@ var Order = class {
|
|
|
14373
14373
|
params.collateralAmount
|
|
14374
14374
|
);
|
|
14375
14375
|
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({ poolId: params.poolId, chainId: params.chainId, address: params.address });
|
|
14376
|
+
this.logger.info("availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
14376
14377
|
const totalCollateralAmount = BigInt(params.collateralAmount) + BigInt(tradingFee);
|
|
14377
14378
|
const needAmount = BigInt(tradingFee) + BigInt(params.collateralAmount) + totalNetWorkFee;
|
|
14378
14379
|
let depositAmount = BigInt(0);
|
|
@@ -21110,10 +21111,11 @@ var Account = class {
|
|
|
21110
21111
|
const orders = orderRes.data;
|
|
21111
21112
|
const openOrders = orders?.filter((order) => order.poolId === poolId);
|
|
21112
21113
|
const used = openOrders?.reduce((acc, order) => {
|
|
21113
|
-
const prev = BigInt(acc);
|
|
21114
|
-
const curr = BigInt(order.collateralAmount ?? 0) + prev;
|
|
21114
|
+
const prev = BigInt(import_ethers26.ethers.parseUnits(acc, pool?.quoteDecimals ?? 6));
|
|
21115
|
+
const curr = BigInt(import_ethers26.ethers.parseUnits(order.collateralAmount ?? "0", pool?.quoteDecimals ?? 6)) + prev;
|
|
21115
21116
|
return curr.toString();
|
|
21116
21117
|
}, "0");
|
|
21118
|
+
this.logger.info("used-->", used);
|
|
21117
21119
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
21118
21120
|
if (marginAccountBalanceRes.code !== 0) {
|
|
21119
21121
|
throw new MyxSDKError(
|
|
@@ -21121,11 +21123,15 @@ var Account = class {
|
|
|
21121
21123
|
"Failed to get account info"
|
|
21122
21124
|
);
|
|
21123
21125
|
}
|
|
21126
|
+
this.logger.info("marginAccountBalanceRes-->", marginAccountBalanceRes);
|
|
21124
21127
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
21125
|
-
const usedMargin =
|
|
21128
|
+
const usedMargin = BigInt(used ?? "0");
|
|
21126
21129
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
21127
21130
|
const freeAmount = BigInt(marginAccountBalance?.freeAmount ?? 0);
|
|
21131
|
+
this.logger.info("freeAmount-->", freeAmount.toString());
|
|
21132
|
+
this.logger.info("quoteProfit-->", quoteProfit.toString());
|
|
21128
21133
|
const accountMargin = freeAmount + quoteProfit;
|
|
21134
|
+
this.logger.info("accountMargin-->", accountMargin.toString());
|
|
21129
21135
|
if (accountMargin < usedMargin) {
|
|
21130
21136
|
return BigInt(0);
|
|
21131
21137
|
}
|
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.166",
|
|
1735
1735
|
private: false,
|
|
1736
1736
|
publishConfig: {
|
|
1737
1737
|
access: "public"
|
|
@@ -14283,6 +14283,7 @@ var Order = class {
|
|
|
14283
14283
|
params.collateralAmount
|
|
14284
14284
|
);
|
|
14285
14285
|
const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({ poolId: params.poolId, chainId: params.chainId, address: params.address });
|
|
14286
|
+
this.logger.info("availableAccountMarginBalance-->", availableAccountMarginBalance.toString());
|
|
14286
14287
|
const totalCollateralAmount = BigInt(params.collateralAmount) + BigInt(tradingFee);
|
|
14287
14288
|
const needAmount = BigInt(tradingFee) + BigInt(params.collateralAmount) + totalNetWorkFee;
|
|
14288
14289
|
let depositAmount = BigInt(0);
|
|
@@ -21020,10 +21021,11 @@ var Account = class {
|
|
|
21020
21021
|
const orders = orderRes.data;
|
|
21021
21022
|
const openOrders = orders?.filter((order) => order.poolId === poolId);
|
|
21022
21023
|
const used = openOrders?.reduce((acc, order) => {
|
|
21023
|
-
const prev = BigInt(acc);
|
|
21024
|
-
const curr = BigInt(order.collateralAmount ?? 0) + prev;
|
|
21024
|
+
const prev = BigInt(ethers8.parseUnits(acc, pool?.quoteDecimals ?? 6));
|
|
21025
|
+
const curr = BigInt(ethers8.parseUnits(order.collateralAmount ?? "0", pool?.quoteDecimals ?? 6)) + prev;
|
|
21025
21026
|
return curr.toString();
|
|
21026
21027
|
}, "0");
|
|
21028
|
+
this.logger.info("used-->", used);
|
|
21027
21029
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
21028
21030
|
if (marginAccountBalanceRes.code !== 0) {
|
|
21029
21031
|
throw new MyxSDKError(
|
|
@@ -21031,11 +21033,15 @@ var Account = class {
|
|
|
21031
21033
|
"Failed to get account info"
|
|
21032
21034
|
);
|
|
21033
21035
|
}
|
|
21036
|
+
this.logger.info("marginAccountBalanceRes-->", marginAccountBalanceRes);
|
|
21034
21037
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
21035
|
-
const usedMargin =
|
|
21038
|
+
const usedMargin = BigInt(used ?? "0");
|
|
21036
21039
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
21037
21040
|
const freeAmount = BigInt(marginAccountBalance?.freeAmount ?? 0);
|
|
21041
|
+
this.logger.info("freeAmount-->", freeAmount.toString());
|
|
21042
|
+
this.logger.info("quoteProfit-->", quoteProfit.toString());
|
|
21038
21043
|
const accountMargin = freeAmount + quoteProfit;
|
|
21044
|
+
this.logger.info("accountMargin-->", accountMargin.toString());
|
|
21039
21045
|
if (accountMargin < usedMargin) {
|
|
21040
21046
|
return BigInt(0);
|
|
21041
21047
|
}
|