@myx-trade/sdk 0.1.6 → 0.1.9

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 CHANGED
@@ -522,6 +522,8 @@ interface MarketDetailResponse {
522
522
  feedId: string;
523
523
  activeTime: number;
524
524
  capType: MarketCapType;
525
+ baseReserveRatio: string;
526
+ quoteReserveRatio: string;
525
527
  }
526
528
 
527
529
  declare class Address {
@@ -538,6 +540,7 @@ declare class Address {
538
540
  interface GetHistoryOrdersParams {
539
541
  limit?: number;
540
542
  chainId?: number;
543
+ poolId?: string;
541
544
  }
542
545
  declare enum OrderTypeEnum {
543
546
  Market = 0,
@@ -592,6 +595,9 @@ interface HistoryOrderItem {
592
595
  tradingFee: string;
593
596
  fundingFee: string;
594
597
  realizedPnl: string;
598
+ baseSymbol: string;
599
+ quoteSymbol: string;
600
+ leverage: number;
595
601
  }
596
602
  /**
597
603
  * Get history orders
@@ -614,6 +620,9 @@ interface PositionHistoryItem {
614
620
  openTime: number;
615
621
  closeTime: number;
616
622
  realizedPnl: string;
623
+ baseSymbol: string;
624
+ quoteSymbol: string;
625
+ leverage: number;
617
626
  }
618
627
  declare const getPositionHistory: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<PositionHistoryItem[]>>;
619
628
  /**
@@ -632,6 +641,9 @@ interface TradeFlowItem {
632
641
  afterCollateralAmount: string;
633
642
  txHash: string;
634
643
  txTime: number;
644
+ baseSymbol: string;
645
+ quoteSymbol: string;
646
+ leverage: number;
635
647
  }
636
648
  declare const getTradeFlow: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<TradeFlowItem[]>>;
637
649
 
@@ -1469,12 +1481,26 @@ declare class Account {
1469
1481
  private logger;
1470
1482
  private utils;
1471
1483
  constructor(configManager: ConfigManager, logger: Logger, utils: Utils);
1484
+ getWalletQuoteTokenBalance(quoteAddress: string): Promise<{
1485
+ code: number;
1486
+ data: any;
1487
+ }>;
1472
1488
  /**
1473
1489
  * get tradable amount
1474
1490
  */
1475
1491
  getTradableAmount({ poolId }: {
1476
1492
  poolId: string;
1477
- }): Promise<any>;
1493
+ }): Promise<{
1494
+ code: number;
1495
+ data: {
1496
+ profitIsReleased: any;
1497
+ freeAmount: any;
1498
+ tradeableProfit: any;
1499
+ };
1500
+ } | {
1501
+ code: number;
1502
+ data?: undefined;
1503
+ }>;
1478
1504
  getTradeFlow(params: GetHistoryOrdersParams): Promise<{
1479
1505
  code: number;
1480
1506
  data: TradeFlowItem[];
package/dist/index.d.ts CHANGED
@@ -522,6 +522,8 @@ interface MarketDetailResponse {
522
522
  feedId: string;
523
523
  activeTime: number;
524
524
  capType: MarketCapType;
525
+ baseReserveRatio: string;
526
+ quoteReserveRatio: string;
525
527
  }
526
528
 
527
529
  declare class Address {
@@ -538,6 +540,7 @@ declare class Address {
538
540
  interface GetHistoryOrdersParams {
539
541
  limit?: number;
540
542
  chainId?: number;
543
+ poolId?: string;
541
544
  }
542
545
  declare enum OrderTypeEnum {
543
546
  Market = 0,
@@ -592,6 +595,9 @@ interface HistoryOrderItem {
592
595
  tradingFee: string;
593
596
  fundingFee: string;
594
597
  realizedPnl: string;
598
+ baseSymbol: string;
599
+ quoteSymbol: string;
600
+ leverage: number;
595
601
  }
596
602
  /**
597
603
  * Get history orders
@@ -614,6 +620,9 @@ interface PositionHistoryItem {
614
620
  openTime: number;
615
621
  closeTime: number;
616
622
  realizedPnl: string;
623
+ baseSymbol: string;
624
+ quoteSymbol: string;
625
+ leverage: number;
617
626
  }
618
627
  declare const getPositionHistory: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<PositionHistoryItem[]>>;
619
628
  /**
@@ -632,6 +641,9 @@ interface TradeFlowItem {
632
641
  afterCollateralAmount: string;
633
642
  txHash: string;
634
643
  txTime: number;
644
+ baseSymbol: string;
645
+ quoteSymbol: string;
646
+ leverage: number;
635
647
  }
636
648
  declare const getTradeFlow: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<TradeFlowItem[]>>;
637
649
 
@@ -1469,12 +1481,26 @@ declare class Account {
1469
1481
  private logger;
1470
1482
  private utils;
1471
1483
  constructor(configManager: ConfigManager, logger: Logger, utils: Utils);
1484
+ getWalletQuoteTokenBalance(quoteAddress: string): Promise<{
1485
+ code: number;
1486
+ data: any;
1487
+ }>;
1472
1488
  /**
1473
1489
  * get tradable amount
1474
1490
  */
1475
1491
  getTradableAmount({ poolId }: {
1476
1492
  poolId: string;
1477
- }): Promise<any>;
1493
+ }): Promise<{
1494
+ code: number;
1495
+ data: {
1496
+ profitIsReleased: any;
1497
+ freeAmount: any;
1498
+ tradeableProfit: any;
1499
+ };
1500
+ } | {
1501
+ code: number;
1502
+ data?: undefined;
1503
+ }>;
1478
1504
  getTradeFlow(params: GetHistoryOrdersParams): Promise<{
1479
1505
  code: number;
1480
1506
  data: TradeFlowItem[];
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ __export(index_exports, {
62
62
  bigintAmountSlipperCalculator: () => bigintAmountSlipperCalculator,
63
63
  bigintTradingGasPriceWithRatio: () => bigintTradingGasPriceWithRatio,
64
64
  bigintTradingGasToRatioCalculator: () => bigintTradingGasToRatioCalculator,
65
- formatUnits: () => import_ethers24.formatUnits,
65
+ formatUnits: () => import_ethers23.formatUnits,
66
66
  getAllTickers: () => getAllTickers,
67
67
  getAllowanceApproved: () => getAllowanceApproved,
68
68
  getBalanceOf: () => getBalanceOf,
@@ -86,7 +86,7 @@ __export(index_exports, {
86
86
  getTokenInfo: () => getTokenInfo,
87
87
  getTradeFlow: () => getTradeFlow,
88
88
  market: () => market_exports,
89
- parseUnits: () => import_ethers24.parseUnits,
89
+ parseUnits: () => import_ethers23.parseUnits,
90
90
  pool: () => pool_exports,
91
91
  quote: () => quote_exports,
92
92
  removeFavorite: () => removeFavorite,
@@ -1827,7 +1827,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1827
1827
  // package.json
1828
1828
  var package_default = {
1829
1829
  name: "@myx-trade/sdk",
1830
- version: "0.1.6",
1830
+ version: "0.1.9",
1831
1831
  private: false,
1832
1832
  publishConfig: {
1833
1833
  access: "public"
@@ -9615,6 +9615,7 @@ var import_wretch = __toESM(require("wretch"));
9615
9615
  var client = (0, import_wretch.default)();
9616
9616
  var buildQueryOptions = (url, params) => {
9617
9617
  if (params) {
9618
+ params = JSON.parse(JSON.stringify(params));
9618
9619
  if (url.includes("?")) {
9619
9620
  return url + "&" + new URLSearchParams(params).toString();
9620
9621
  }
@@ -10872,7 +10873,6 @@ __export(pool_exports, {
10872
10873
  });
10873
10874
 
10874
10875
  // src/lp/pool/get.ts
10875
- var import_ethers21 = require("ethers");
10876
10876
  var getMarketInfo = (chainId2) => {
10877
10877
  const marketId2 = Market[chainId2].marketId;
10878
10878
  return marketId2;
@@ -10892,7 +10892,7 @@ var getMarketPoolId = async ({
10892
10892
  const contract = await getPoolManagerContract(chainId2);
10893
10893
  const data = [marketId2, baseToken];
10894
10894
  const request = await contract.getMarketPool(marketId2, baseToken);
10895
- return request.poolId === import_ethers21.ZeroAddress || !request.poolId ? void 0 : request.poolId;
10895
+ return request.poolId === "0x0000000000000000000000000000000000000000000000000000000000000000" || !request.poolId ? void 0 : request.poolId;
10896
10896
  } catch (error) {
10897
10897
  console.error(error);
10898
10898
  throw typeof error === "string" ? error : await getErrorTextFormError(error);
@@ -11062,7 +11062,7 @@ var cancelTpSl = async (params) => {
11062
11062
  };
11063
11063
 
11064
11064
  // src/common/tokenInfo.ts
11065
- var import_ethers22 = require("ethers");
11065
+ var import_ethers21 = require("ethers");
11066
11066
  async function checkImageExists(url) {
11067
11067
  try {
11068
11068
  const res = await fetch(url, { method: "HEAD" });
@@ -11082,14 +11082,14 @@ var getTokenInfo = async (chainId2, tokenAddress, account) => {
11082
11082
  token.decimals(),
11083
11083
  token.totalSupply()
11084
11084
  ]);
11085
- const normalized = import_ethers22.ethers.getAddress(tokenAddress);
11085
+ const normalized = import_ethers21.ethers.getAddress(tokenAddress);
11086
11086
  const iconUrl = `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${chainId2}/assets/${normalized}/logo.png`;
11087
11087
  const fallbackIcon = "";
11088
11088
  const icon = await checkImageExists(iconUrl) ? iconUrl : fallbackIcon;
11089
11089
  let balance;
11090
11090
  if (account) {
11091
11091
  const rawBalance = await token.balanceOf(account);
11092
- balance = Number(import_ethers22.ethers.formatUnits(rawBalance, decimals));
11092
+ balance = Number(import_ethers21.ethers.formatUnits(rawBalance, decimals));
11093
11093
  }
11094
11094
  return {
11095
11095
  address: tokenAddress,
@@ -11097,7 +11097,7 @@ var getTokenInfo = async (chainId2, tokenAddress, account) => {
11097
11097
  symbol,
11098
11098
  decimals,
11099
11099
  icon,
11100
- totalSupply: Number(import_ethers22.ethers.formatUnits(totalSupply, decimals)),
11100
+ totalSupply: Number(import_ethers21.ethers.formatUnits(totalSupply, decimals)),
11101
11101
  ...account ? { balance } : {}
11102
11102
  };
11103
11103
  } catch (e) {
@@ -11144,7 +11144,7 @@ var getOracleFee = async (chainId2, marketId2) => {
11144
11144
  };
11145
11145
 
11146
11146
  // src/lp/pool/reprime.ts
11147
- var import_ethers23 = require("ethers");
11147
+ var import_ethers22 = require("ethers");
11148
11148
  var reprime = async (chainId2, poolId) => {
11149
11149
  try {
11150
11150
  await checkParams({ chainId: chainId2 });
@@ -11158,14 +11158,14 @@ var reprime = async (chainId2, poolId) => {
11158
11158
  if (!_amount) {
11159
11159
  throw new Error("Invalid Market");
11160
11160
  }
11161
- console.log(Number((0, import_ethers23.formatUnits)(_amount, pool.quoteDecimals)));
11161
+ console.log(Number((0, import_ethers22.formatUnits)(_amount, pool.quoteDecimals)));
11162
11162
  await checkParams({
11163
11163
  tokenAddress: pool.quoteToken,
11164
11164
  contractAddress: address_default[chainId2].ORACLE_RESERVE,
11165
11165
  decimals: pool.quoteDecimals,
11166
11166
  account,
11167
11167
  chainId: chainId2,
11168
- amount: Number((0, import_ethers23.formatUnits)(_amount, pool.quoteDecimals))
11168
+ amount: Number((0, import_ethers22.formatUnits)(_amount, pool.quoteDecimals))
11169
11169
  });
11170
11170
  const chainInfo = CHAIN_INFO[chainId2];
11171
11171
  const contract = await getPoolManagerContract(chainId2);
@@ -11215,7 +11215,7 @@ var TriggerType = /* @__PURE__ */ ((TriggerType3) => {
11215
11215
  })(TriggerType || {});
11216
11216
 
11217
11217
  // src/lp/index.ts
11218
- var import_ethers24 = require("ethers");
11218
+ var import_ethers23 = require("ethers");
11219
11219
 
11220
11220
  // src/manager/subscription/websocket/socket.ts
11221
11221
  var import_mitt = __toESM(require("mitt"));
@@ -11425,7 +11425,7 @@ var MyxWebSocketClient = class {
11425
11425
  */
11426
11426
  connect() {
11427
11427
  return new Promise((resolve, reject) => {
11428
- if (this.ws?.readyState === WebSocket.OPEN) {
11428
+ if (this.ws?.readyState === WebSocket.OPEN || this.ws?.readyState === WebSocket.CONNECTING) {
11429
11429
  resolve();
11430
11430
  return;
11431
11431
  }
@@ -11579,10 +11579,10 @@ var MyxWebSocketClient = class {
11579
11579
  "WebSocket is not connected"
11580
11580
  );
11581
11581
  }
11582
- if (this.ws.readyState !== WebSocket.OPEN) {
11582
+ if (this.ws.readyState !== WebSocket.OPEN && this.ws.readyState !== WebSocket.CONNECTING) {
11583
11583
  this.reconnect();
11584
11584
  }
11585
- this.ws?.send(message);
11585
+ this.ws.send(message);
11586
11586
  }
11587
11587
  /**
11588
11588
  * disconnect
@@ -11599,7 +11599,9 @@ var MyxWebSocketClient = class {
11599
11599
  */
11600
11600
  reconnect() {
11601
11601
  if (this.ws) {
11602
- this.ws.reconnect();
11602
+ if (this.ws.readyState !== WebSocket.CONNECTING) {
11603
+ this.ws.reconnect();
11604
+ }
11603
11605
  } else {
11604
11606
  this.connect().catch((err) => {
11605
11607
  this.logger.error(err);
@@ -12218,7 +12220,7 @@ var getContractAddressByChainId = (chainId2) => {
12218
12220
  };
12219
12221
 
12220
12222
  // src/manager/position/index.ts
12221
- var import_ethers25 = require("ethers");
12223
+ var import_ethers24 = require("ethers");
12222
12224
  var Position = class {
12223
12225
  constructor(configManager, logger, utils) {
12224
12226
  this.configManager = configManager;
@@ -12403,7 +12405,7 @@ var Position = class {
12403
12405
  }
12404
12406
  const updateParams = {
12405
12407
  poolId,
12406
- referencePrice: import_ethers25.ethers.parseUnits(priceData?.price ?? "0", 30),
12408
+ referencePrice: import_ethers24.ethers.parseUnits(priceData?.price ?? "0", 30),
12407
12409
  oracleUpdateData: priceData?.vaa ?? "0",
12408
12410
  publishTime: priceData.publishTime
12409
12411
  };
@@ -12425,12 +12427,12 @@ var Position = class {
12425
12427
  if (needsApproval) {
12426
12428
  this.logger.debug("adjust collateral approve-->", {
12427
12429
  quoteToken,
12428
- amount: import_ethers25.ethers.MaxUint256.toString(),
12430
+ amount: import_ethers24.ethers.MaxUint256.toString(),
12429
12431
  spenderAddress: contractAddress.POSITION_MANAGER
12430
12432
  });
12431
12433
  const approvalResult = await this.utils.approveAuthorization({
12432
12434
  quoteAddress: quoteToken,
12433
- amount: import_ethers25.ethers.MaxUint256.toString(),
12435
+ amount: import_ethers24.ethers.MaxUint256.toString(),
12434
12436
  spenderAddress: contractAddress.POSITION_MANAGER
12435
12437
  });
12436
12438
  if (approvalResult.code !== 0) {
@@ -12992,7 +12994,8 @@ var Order = class {
12992
12994
  slPrice: params.slPrice,
12993
12995
  executionFeeToken: params.executionFeeToken,
12994
12996
  useOrderCollateral: true,
12995
- useAccountBalance: false
12997
+ useAccountBalance: false,
12998
+ paymentType: 0
12996
12999
  }
12997
13000
  };
12998
13001
  console.log(data);
@@ -13053,7 +13056,7 @@ var Order = class {
13053
13056
  };
13054
13057
 
13055
13058
  // src/manager/utils/index.ts
13056
- var import_ethers26 = require("ethers");
13059
+ var import_ethers25 = require("ethers");
13057
13060
 
13058
13061
  // src/abi/Emiter.json
13059
13062
  var Emiter_default = [
@@ -16735,7 +16738,7 @@ var Utils = class {
16735
16738
  if (!receipt || !receipt.logs) {
16736
16739
  return null;
16737
16740
  }
16738
- const emiterInterface = new import_ethers26.ethers.Interface(Emiter_default);
16741
+ const emiterInterface = new import_ethers25.ethers.Interface(Emiter_default);
16739
16742
  const orderPlacedEvent = Emiter_default.find(
16740
16743
  (item) => item.type === "event" && item.name === "OrderPlaced"
16741
16744
  );
@@ -16743,7 +16746,7 @@ var Utils = class {
16743
16746
  this.logger.error("OrderPlaced event not found in Emiter ABI");
16744
16747
  return null;
16745
16748
  }
16746
- const eventTopic = import_ethers26.ethers.id(
16749
+ const eventTopic = import_ethers25.ethers.id(
16747
16750
  "OrderPlaced(address,address,bytes32,uint256,uint256,uint8,uint8,uint8,uint8,uint256,uint256,uint256,uint8,bool,uint16,address,uint256,uint16)"
16748
16751
  );
16749
16752
  this.logger.info("Looking for OrderPlaced events with topic:", eventTopic);
@@ -16787,7 +16790,7 @@ var Utils = class {
16787
16790
  const config = this.configManager.getConfig();
16788
16791
  const owner = await config.signer.getAddress();
16789
16792
  const spender = spenderAddress ?? getContractAddressByChainId(config.chainId).ORDER_MANAGER;
16790
- const tokenContract = new import_ethers26.ethers.Contract(
16793
+ const tokenContract = new import_ethers25.ethers.Contract(
16791
16794
  quoteAddress,
16792
16795
  erc20Abi,
16793
16796
  config.signer
@@ -16809,8 +16812,8 @@ var Utils = class {
16809
16812
  spenderAddress
16810
16813
  );
16811
16814
  const currentAllowance = currentAllowanceRes.data;
16812
- const allowanceBigInt = import_ethers26.ethers.getBigInt(currentAllowance);
16813
- const requiredBigInt = import_ethers26.ethers.getBigInt(requiredAmount);
16815
+ const allowanceBigInt = import_ethers25.ethers.getBigInt(currentAllowance);
16816
+ const requiredBigInt = import_ethers25.ethers.getBigInt(requiredAmount);
16814
16817
  const needsApproval = allowanceBigInt < requiredBigInt;
16815
16818
  return needsApproval;
16816
16819
  } catch (error) {
@@ -16828,12 +16831,12 @@ var Utils = class {
16828
16831
  "function approve(address spender, uint256 amount) external returns (bool)"
16829
16832
  ];
16830
16833
  const config = this.configManager.getConfig();
16831
- const usdcContract = new import_ethers26.ethers.Contract(
16834
+ const usdcContract = new import_ethers25.ethers.Contract(
16832
16835
  quoteAddress,
16833
16836
  erc20Abi,
16834
16837
  config.signer
16835
16838
  );
16836
- const approveAmount = amount ?? import_ethers26.ethers.MaxUint256;
16839
+ const approveAmount = amount ?? import_ethers25.ethers.MaxUint256;
16837
16840
  const spender = spenderAddress ?? getContractAddressByChainId(config.chainId).ORDER_MANAGER;
16838
16841
  const tx = await usdcContract.approve(spender, approveAmount);
16839
16842
  await tx.wait();
@@ -16855,7 +16858,7 @@ var Utils = class {
16855
16858
  const orderManagerAddress = getContractAddressByChainId(
16856
16859
  config.chainId
16857
16860
  ).ORDER_MANAGER;
16858
- const orderManagerContract = new import_ethers26.ethers.Contract(
16861
+ const orderManagerContract = new import_ethers25.ethers.Contract(
16859
16862
  orderManagerAddress,
16860
16863
  OrderManager_default,
16861
16864
  config.signer
@@ -16935,7 +16938,7 @@ var Utils = class {
16935
16938
  };
16936
16939
 
16937
16940
  // src/manager/account/index.ts
16938
- var import_ethers27 = require("ethers");
16941
+ var import_ethers26 = require("ethers");
16939
16942
 
16940
16943
  // src/abi/Account.json
16941
16944
  var Account_default = [
@@ -17568,19 +17571,46 @@ var Account = class {
17568
17571
  this.logger = logger;
17569
17572
  this.utils = utils;
17570
17573
  }
17574
+ async getWalletQuoteTokenBalance(quoteAddress) {
17575
+ const config = this.configManager.getConfig();
17576
+ const erc20Contract = new import_ethers26.ethers.Contract(
17577
+ quoteAddress,
17578
+ IERC20Metadata_default,
17579
+ config.signer
17580
+ );
17581
+ const balance = await erc20Contract.balanceOf(config.signer.getAddress());
17582
+ return {
17583
+ code: 0,
17584
+ data: balance
17585
+ };
17586
+ }
17571
17587
  /**
17572
17588
  * get tradable amount
17573
17589
  */
17574
17590
  async getTradableAmount({ poolId }) {
17575
17591
  const config = this.configManager.getConfig();
17576
17592
  const contractAddress = getContractAddressByChainId(config.chainId);
17577
- const accountContract = new import_ethers27.ethers.Contract(
17593
+ const accountContract = new import_ethers26.ethers.Contract(
17578
17594
  contractAddress.Account,
17579
17595
  Account_default,
17580
17596
  config.signer
17581
17597
  );
17582
- const assets = await accountContract.getTradableAmount(config.signer.getAddress(), poolId);
17583
- return assets;
17598
+ try {
17599
+ const assets = await accountContract.getTradableAmount(config.signer.getAddress(), poolId);
17600
+ const data = {
17601
+ profitIsReleased: assets[0],
17602
+ freeAmount: assets[1],
17603
+ tradeableProfit: assets[2]
17604
+ };
17605
+ return {
17606
+ code: 0,
17607
+ data
17608
+ };
17609
+ } catch (error) {
17610
+ return {
17611
+ code: -1
17612
+ };
17613
+ }
17584
17614
  }
17585
17615
  async getTradeFlow(params) {
17586
17616
  const accessToken = await this.configManager.getAccessToken();
@@ -17599,7 +17629,7 @@ var Account = class {
17599
17629
  };
17600
17630
 
17601
17631
  // src/manager/index.ts
17602
- var import_ethers28 = require("ethers");
17632
+ var import_ethers27 = require("ethers");
17603
17633
  var MyxClient = class {
17604
17634
  /**
17605
17635
  * 获取配置管理器(用于访问 accessToken 相关方法)
@@ -17620,7 +17650,7 @@ var MyxClient = class {
17620
17650
  this.subscription = new SubScription(this.configManager, this.logger);
17621
17651
  const lp = MxSDK.getInstance();
17622
17652
  if (options.walletClient?.transport) {
17623
- const provider = new import_ethers28.BrowserProvider(options.walletClient?.transport);
17653
+ const provider = new import_ethers27.BrowserProvider(options.walletClient?.transport);
17624
17654
  if (provider) {
17625
17655
  lp.setProvider(provider);
17626
17656
  }
package/dist/index.mjs CHANGED
@@ -1741,7 +1741,7 @@ var RotationProvider = class extends BaseProvider {
1741
1741
  // package.json
1742
1742
  var package_default = {
1743
1743
  name: "@myx-trade/sdk",
1744
- version: "0.1.6",
1744
+ version: "0.1.9",
1745
1745
  private: false,
1746
1746
  publishConfig: {
1747
1747
  access: "public"
@@ -9529,6 +9529,7 @@ import wretch from "wretch";
9529
9529
  var client = wretch();
9530
9530
  var buildQueryOptions = (url, params) => {
9531
9531
  if (params) {
9532
+ params = JSON.parse(JSON.stringify(params));
9532
9533
  if (url.includes("?")) {
9533
9534
  return url + "&" + new URLSearchParams(params).toString();
9534
9535
  }
@@ -10786,7 +10787,6 @@ __export(pool_exports, {
10786
10787
  });
10787
10788
 
10788
10789
  // src/lp/pool/get.ts
10789
- import { ZeroAddress as ZeroAddress3 } from "ethers";
10790
10790
  var getMarketInfo = (chainId2) => {
10791
10791
  const marketId2 = Market[chainId2].marketId;
10792
10792
  return marketId2;
@@ -10806,7 +10806,7 @@ var getMarketPoolId = async ({
10806
10806
  const contract = await getPoolManagerContract(chainId2);
10807
10807
  const data = [marketId2, baseToken];
10808
10808
  const request = await contract.getMarketPool(marketId2, baseToken);
10809
- return request.poolId === ZeroAddress3 || !request.poolId ? void 0 : request.poolId;
10809
+ return request.poolId === "0x0000000000000000000000000000000000000000000000000000000000000000" || !request.poolId ? void 0 : request.poolId;
10810
10810
  } catch (error) {
10811
10811
  console.error(error);
10812
10812
  throw typeof error === "string" ? error : await getErrorTextFormError(error);
@@ -11339,7 +11339,7 @@ var MyxWebSocketClient = class {
11339
11339
  */
11340
11340
  connect() {
11341
11341
  return new Promise((resolve, reject) => {
11342
- if (this.ws?.readyState === WebSocket.OPEN) {
11342
+ if (this.ws?.readyState === WebSocket.OPEN || this.ws?.readyState === WebSocket.CONNECTING) {
11343
11343
  resolve();
11344
11344
  return;
11345
11345
  }
@@ -11493,10 +11493,10 @@ var MyxWebSocketClient = class {
11493
11493
  "WebSocket is not connected"
11494
11494
  );
11495
11495
  }
11496
- if (this.ws.readyState !== WebSocket.OPEN) {
11496
+ if (this.ws.readyState !== WebSocket.OPEN && this.ws.readyState !== WebSocket.CONNECTING) {
11497
11497
  this.reconnect();
11498
11498
  }
11499
- this.ws?.send(message);
11499
+ this.ws.send(message);
11500
11500
  }
11501
11501
  /**
11502
11502
  * disconnect
@@ -11513,7 +11513,9 @@ var MyxWebSocketClient = class {
11513
11513
  */
11514
11514
  reconnect() {
11515
11515
  if (this.ws) {
11516
- this.ws.reconnect();
11516
+ if (this.ws.readyState !== WebSocket.CONNECTING) {
11517
+ this.ws.reconnect();
11518
+ }
11517
11519
  } else {
11518
11520
  this.connect().catch((err) => {
11519
11521
  this.logger.error(err);
@@ -12906,7 +12908,8 @@ var Order = class {
12906
12908
  slPrice: params.slPrice,
12907
12909
  executionFeeToken: params.executionFeeToken,
12908
12910
  useOrderCollateral: true,
12909
- useAccountBalance: false
12911
+ useAccountBalance: false,
12912
+ paymentType: 0
12910
12913
  }
12911
12914
  };
12912
12915
  console.log(data);
@@ -17482,6 +17485,19 @@ var Account = class {
17482
17485
  this.logger = logger;
17483
17486
  this.utils = utils;
17484
17487
  }
17488
+ async getWalletQuoteTokenBalance(quoteAddress) {
17489
+ const config = this.configManager.getConfig();
17490
+ const erc20Contract = new ethers7.Contract(
17491
+ quoteAddress,
17492
+ IERC20Metadata_default,
17493
+ config.signer
17494
+ );
17495
+ const balance = await erc20Contract.balanceOf(config.signer.getAddress());
17496
+ return {
17497
+ code: 0,
17498
+ data: balance
17499
+ };
17500
+ }
17485
17501
  /**
17486
17502
  * get tradable amount
17487
17503
  */
@@ -17493,8 +17509,22 @@ var Account = class {
17493
17509
  Account_default,
17494
17510
  config.signer
17495
17511
  );
17496
- const assets = await accountContract.getTradableAmount(config.signer.getAddress(), poolId);
17497
- return assets;
17512
+ try {
17513
+ const assets = await accountContract.getTradableAmount(config.signer.getAddress(), poolId);
17514
+ const data = {
17515
+ profitIsReleased: assets[0],
17516
+ freeAmount: assets[1],
17517
+ tradeableProfit: assets[2]
17518
+ };
17519
+ return {
17520
+ code: 0,
17521
+ data
17522
+ };
17523
+ } catch (error) {
17524
+ return {
17525
+ code: -1
17526
+ };
17527
+ }
17498
17528
  }
17499
17529
  async getTradeFlow(params) {
17500
17530
  const accessToken = await this.configManager.getAccessToken();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"