@myx-trade/sdk 0.1.163 → 0.1.165
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 +5 -6
- package/dist/index.mjs +5 -6
- 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.165",
|
|
1825
1825
|
private: false,
|
|
1826
1826
|
publishConfig: {
|
|
1827
1827
|
access: "public"
|
|
@@ -21101,7 +21101,6 @@ var Account = class {
|
|
|
21101
21101
|
const poolList = poolListRes.data;
|
|
21102
21102
|
const pool = poolList?.find((pool2) => pool2.poolId === poolId);
|
|
21103
21103
|
const orderRes = await this.client.order.getOrders();
|
|
21104
|
-
this.logger.info("orderRes-->", orderRes);
|
|
21105
21104
|
if (orderRes.code !== 0) {
|
|
21106
21105
|
throw new MyxSDKError(
|
|
21107
21106
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -21111,8 +21110,8 @@ var Account = class {
|
|
|
21111
21110
|
const orders = orderRes.data;
|
|
21112
21111
|
const openOrders = orders?.filter((order) => order.poolId === poolId);
|
|
21113
21112
|
const used = openOrders?.reduce((acc, order) => {
|
|
21114
|
-
const prev = BigInt(acc);
|
|
21115
|
-
const curr = BigInt(order.collateralAmount ?? 0) + prev;
|
|
21113
|
+
const prev = BigInt(import_ethers26.ethers.parseUnits(acc, pool?.quoteDecimals ?? 6));
|
|
21114
|
+
const curr = BigInt(import_ethers26.ethers.parseUnits(order.collateralAmount ?? "0", pool?.quoteDecimals ?? 6)) + prev;
|
|
21116
21115
|
return curr.toString();
|
|
21117
21116
|
}, "0");
|
|
21118
21117
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
@@ -21123,9 +21122,9 @@ var Account = class {
|
|
|
21123
21122
|
);
|
|
21124
21123
|
}
|
|
21125
21124
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
21126
|
-
const usedMargin =
|
|
21125
|
+
const usedMargin = BigInt(used ?? "0");
|
|
21127
21126
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
21128
|
-
const freeAmount = BigInt(marginAccountBalance?.freeAmount
|
|
21127
|
+
const freeAmount = BigInt(marginAccountBalance?.freeAmount ?? 0);
|
|
21129
21128
|
const accountMargin = freeAmount + quoteProfit;
|
|
21130
21129
|
if (accountMargin < usedMargin) {
|
|
21131
21130
|
return BigInt(0);
|
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.165",
|
|
1735
1735
|
private: false,
|
|
1736
1736
|
publishConfig: {
|
|
1737
1737
|
access: "public"
|
|
@@ -21011,7 +21011,6 @@ var Account = class {
|
|
|
21011
21011
|
const poolList = poolListRes.data;
|
|
21012
21012
|
const pool = poolList?.find((pool2) => pool2.poolId === poolId);
|
|
21013
21013
|
const orderRes = await this.client.order.getOrders();
|
|
21014
|
-
this.logger.info("orderRes-->", orderRes);
|
|
21015
21014
|
if (orderRes.code !== 0) {
|
|
21016
21015
|
throw new MyxSDKError(
|
|
21017
21016
|
"REQUEST_FAILED" /* RequestFailed */,
|
|
@@ -21021,8 +21020,8 @@ var Account = class {
|
|
|
21021
21020
|
const orders = orderRes.data;
|
|
21022
21021
|
const openOrders = orders?.filter((order) => order.poolId === poolId);
|
|
21023
21022
|
const used = openOrders?.reduce((acc, order) => {
|
|
21024
|
-
const prev = BigInt(acc);
|
|
21025
|
-
const curr = BigInt(order.collateralAmount ?? 0) + prev;
|
|
21023
|
+
const prev = BigInt(ethers8.parseUnits(acc, pool?.quoteDecimals ?? 6));
|
|
21024
|
+
const curr = BigInt(ethers8.parseUnits(order.collateralAmount ?? "0", pool?.quoteDecimals ?? 6)) + prev;
|
|
21026
21025
|
return curr.toString();
|
|
21027
21026
|
}, "0");
|
|
21028
21027
|
const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
|
|
@@ -21033,9 +21032,9 @@ var Account = class {
|
|
|
21033
21032
|
);
|
|
21034
21033
|
}
|
|
21035
21034
|
const marginAccountBalance = marginAccountBalanceRes.data;
|
|
21036
|
-
const usedMargin =
|
|
21035
|
+
const usedMargin = BigInt(used ?? "0");
|
|
21037
21036
|
const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
|
|
21038
|
-
const freeAmount = BigInt(marginAccountBalance?.freeAmount
|
|
21037
|
+
const freeAmount = BigInt(marginAccountBalance?.freeAmount ?? 0);
|
|
21039
21038
|
const accountMargin = freeAmount + quoteProfit;
|
|
21040
21039
|
if (accountMargin < usedMargin) {
|
|
21041
21040
|
return BigInt(0);
|