@myx-trade/sdk 0.1.18 → 0.1.19

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
@@ -1546,7 +1546,7 @@ declare class MyxClient {
1546
1546
  /**
1547
1547
  * auth the client
1548
1548
  */
1549
- auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1549
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken" | "walletClient">): void;
1550
1550
  /**
1551
1551
  * close the client
1552
1552
  */
package/dist/index.d.ts CHANGED
@@ -1546,7 +1546,7 @@ declare class MyxClient {
1546
1546
  /**
1547
1547
  * auth the client
1548
1548
  */
1549
- auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1549
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken" | "walletClient">): void;
1550
1550
  /**
1551
1551
  * close the client
1552
1552
  */
package/dist/index.js CHANGED
@@ -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.18",
1830
+ version: "0.1.19",
1831
1831
  private: false,
1832
1832
  publishConfig: {
1833
1833
  access: "public"
@@ -1958,17 +1958,10 @@ if (typeof window !== "undefined") {
1958
1958
  }
1959
1959
  var getWalletProvider = async (chainId2) => {
1960
1960
  try {
1961
- const provider = sdk.provider;
1961
+ const walletClient = sdk.getConfigManager()?.getConfig().walletClient;
1962
+ const provider = new import_ethers3.BrowserProvider(walletClient?.transport);
1962
1963
  if (!provider) {
1963
- throw new Error("Provider missing in provider");
1964
- }
1965
- if (chainId2) {
1966
- const network = await provider.getNetwork();
1967
- console.log(provider);
1968
- console.log(`Connected to chain: ${network.chainId}, requested: ${chainId2}`);
1969
- if (Number(network.chainId) !== chainId2) {
1970
- await provider.send("wallet_switchEthereumChain", [{ chainId: BigInt(chainId2) }]);
1971
- }
1964
+ throw new Error("missing provider");
1972
1965
  }
1973
1966
  return provider;
1974
1967
  } catch (error) {
@@ -1978,7 +1971,6 @@ var getWalletProvider = async (chainId2) => {
1978
1971
  };
1979
1972
  var getSignerProvider = async (chainId2) => {
1980
1973
  const provider = await getWalletProvider(chainId2);
1981
- console.log(provider);
1982
1974
  return provider?.getSigner?.();
1983
1975
  };
1984
1976
 
@@ -9185,10 +9177,10 @@ var getLiquidityRouterContract = async (chainId2) => {
9185
9177
  const provider = await getSignerProvider(chainId2);
9186
9178
  return getContract(address, LiquidityRouter_default, provider);
9187
9179
  };
9188
- var getPoolManagerContract = async (chainId2) => {
9180
+ var getPoolManagerContract = async (chainId2, type = 1 /* Signer */) => {
9189
9181
  const addresses = address_default[chainId2];
9190
9182
  const address = addresses.POOL_MANAGER;
9191
- const provider = await getSignerProvider(chainId2);
9183
+ const provider = type === 0 /* JSON */ ? getJSONProvider(chainId2) : await getSignerProvider(chainId2);
9192
9184
  return getContract(address, PoolManager_default, provider);
9193
9185
  };
9194
9186
  var getQuotePoolContract = async (chainId2, type = 0 /* JSON */) => {
@@ -9496,18 +9488,13 @@ var getAllowanceApproved = async (chainId2, account, tokenAddress, approveAddres
9496
9488
  const provider = getJSONProvider(chainId2);
9497
9489
  const contractInterface = new import_ethers5.ethers.Interface(IERC20Metadata_default);
9498
9490
  const data = contractInterface.encodeFunctionData("allowance", [account, approveAddress]);
9499
- console.log("approve token ", tokenAddress);
9500
- console.log("approve address ", approveAddress);
9501
9491
  const callData = {
9502
9492
  to: tokenAddress,
9503
9493
  data
9504
9494
  };
9505
9495
  const result = await provider.call(callData);
9506
9496
  const allowance = BigInt(result);
9507
- console.log("Allowance:", allowance.toString());
9508
- console.log("ApproveAmount:", approveAmount.toString());
9509
9497
  if (allowance >= approveAmount) {
9510
- console.log("Allowance approved.");
9511
9498
  return true;
9512
9499
  }
9513
9500
  return false;
@@ -9520,10 +9507,7 @@ var getAllowanceApproved = async (chainId2, account, tokenAddress, approveAddres
9520
9507
  var approve = async (chainId2, account, tokenAddress, approveAddress, amount) => {
9521
9508
  try {
9522
9509
  const TokenContract = await getERC20Contract(chainId2, tokenAddress);
9523
- console.log("approve token Address", tokenAddress);
9524
9510
  const response = await TokenContract.approve(approveAddress, amount);
9525
- console.log("approve amount", approveAddress);
9526
- console.log("approve amount", amount);
9527
9511
  const receipt = await response?.wait();
9528
9512
  const isApproved = await getAllowanceApproved(chainId2, account, tokenAddress, approveAddress, amount);
9529
9513
  if (!isApproved) {
@@ -9552,13 +9536,11 @@ var checkParams = async (params) => {
9552
9536
  throw new Error(Errors[4004 /* Invalid_Amount */]);
9553
9537
  }
9554
9538
  }
9555
- console.log("checkbalance");
9556
9539
  const { tokenAddress, contractAddress, chainId: chainId2, amount, decimals, account } = params;
9557
9540
  if (amount && chainId2 && decimals && account) {
9558
9541
  const amountIn = (0, import_ethers6.parseUnits)(amount.toString(), decimals);
9559
9542
  if (tokenAddress) {
9560
9543
  const balance = await getBalanceOf(chainId2, account, tokenAddress);
9561
- console.log("balance", balance, tokenAddress);
9562
9544
  if (!balance || balance < amountIn) {
9563
9545
  throw new Error(Errors[3 /* Insufficient_Balance */]);
9564
9546
  }
@@ -9592,9 +9574,7 @@ var bigintTradingGasPriceWithRatio = async (chainId2) => {
9592
9574
  if (!gasPrice) {
9593
9575
  throw new Error("Network Error");
9594
9576
  }
9595
- console.log("gasPrice", gasPrice);
9596
9577
  const gasPriceWithRatio = bigintTradingGasToRatioCalculator(gasPrice, chainInfo.gasPriceRatio);
9597
- console.log("gasPriceWithRatio--->", gasPriceWithRatio);
9598
9578
  return {
9599
9579
  gasPrice: gasPriceWithRatio
9600
9580
  };
@@ -10070,7 +10050,6 @@ var claimBasePoolRebate = async (params) => {
10070
10050
  poolId,
10071
10051
  recipient: account
10072
10052
  };
10073
- console.log("base claim", data);
10074
10053
  const contract = await getLiquidityRouterContract(chainId2);
10075
10054
  const _gasLimit = await contract["claimBasePoolRebate((bytes32,uint8,uint256,bytes,uint64)[],bytes32,address)"].estimateGas(prices, poolId, account, {
10076
10055
  value: values[0]
@@ -10082,7 +10061,6 @@ var claimBasePoolRebate = async (params) => {
10082
10061
  gasPrice,
10083
10062
  value: values[0]
10084
10063
  });
10085
- console.log("base claim", response);
10086
10064
  return response;
10087
10065
  } catch (error) {
10088
10066
  console.error(error);
@@ -10118,7 +10096,6 @@ var claimBasePoolRebates = async (params) => {
10118
10096
  value,
10119
10097
  recipient: account
10120
10098
  };
10121
- console.log("base claim pool rebates", data);
10122
10099
  const contract = await getLiquidityRouterContract(chainId2);
10123
10100
  const _gasLimit = await contract["claimBasePoolRebates((bytes32,uint8,uint256,bytes,uint64)[],bytes32[],address)"].estimateGas(prices, poolIds, account, {
10124
10101
  value
@@ -10130,7 +10107,6 @@ var claimBasePoolRebates = async (params) => {
10130
10107
  gasPrice,
10131
10108
  value
10132
10109
  });
10133
- console.log("base claim rebates", response);
10134
10110
  return response;
10135
10111
  } catch (error) {
10136
10112
  console.error(error);
@@ -10166,7 +10142,6 @@ var Market = {
10166
10142
  var previewLpAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10167
10143
  try {
10168
10144
  const chainInfo = CHAIN_INFO[chainId2];
10169
- console.log("previewLpAmountOut data", [poolId, amountIn, price]);
10170
10145
  const basePoolContract = await getBasePoolContract(chainId2);
10171
10146
  const _gasLimit = await basePoolContract.previewLpAmountOut.estimateGas(poolId, amountIn, price);
10172
10147
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10175,7 +10150,6 @@ var previewLpAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0
10175
10150
  gasLimit,
10176
10151
  gasPrice
10177
10152
  });
10178
- console.log(request);
10179
10153
  return request;
10180
10154
  } catch (error) {
10181
10155
  console.error(error);
@@ -10185,7 +10159,6 @@ var previewLpAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0
10185
10159
  var previewBaseAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10186
10160
  try {
10187
10161
  const chainInfo = CHAIN_INFO[chainId2];
10188
- console.log("previewQuoteAmountOut data", [poolId, amountIn, price]);
10189
10162
  const basePoolContract = await getBasePoolContract(chainId2);
10190
10163
  const _gasLimit = await basePoolContract.previewBaseAmountOut.estimateGas(poolId, amountIn, price);
10191
10164
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10194,7 +10167,6 @@ var previewBaseAmountOut = async ({ chainId: chainId2, amountIn, poolId, price =
10194
10167
  gasLimit,
10195
10168
  gasPrice
10196
10169
  });
10197
- console.log("previewBaseAmountOut response", request);
10198
10170
  return request;
10199
10171
  } catch (error) {
10200
10172
  console.error(error);
@@ -10223,7 +10195,6 @@ var previewUserWithdrawData = async ({ chainId: chainId2, account, poolId, amoun
10223
10195
  const priceResponse = await getOraclePrice(chainId2, [poolId]);
10224
10196
  const _price = priceResponse.data?.[0]?.price || "0";
10225
10197
  const price = (0, import_ethers9.parseUnits)(_price, COMMON_PRICE_DECIMALS);
10226
- console.log("previewUserWithdrawData data", [poolId, amountIn, account, price]);
10227
10198
  const basePoolContract = await getBasePoolContract(chainId2);
10228
10199
  const _gasLimit = await basePoolContract.previewUserWithdrawData.estimateGas(poolId, amountIn, account, price);
10229
10200
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10233,7 +10204,6 @@ var previewUserWithdrawData = async ({ chainId: chainId2, account, poolId, amoun
10233
10204
  gasPrice
10234
10205
  });
10235
10206
  const { baseAmountOut, rebateAmount } = request;
10236
- console.log("previewUserWithdrawData result:", { baseAmountOut, rebateAmount });
10237
10207
  return {
10238
10208
  baseAmountOut,
10239
10209
  rebateAmount
@@ -10349,7 +10319,6 @@ var deposit = async (params) => {
10349
10319
  recipient: account,
10350
10320
  tpslParams
10351
10321
  };
10352
- console.log("deposit base", price, data, value);
10353
10322
  const contract = await getLiquidityRouterContract(chainId2);
10354
10323
  const _gasLimit = await contract["depositBase((bytes32,uint8,uint256,bytes,uint64)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(price, data, { value });
10355
10324
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10359,7 +10328,6 @@ var deposit = async (params) => {
10359
10328
  gasPrice,
10360
10329
  value
10361
10330
  });
10362
- console.log("deposit", result);
10363
10331
  return result;
10364
10332
  } catch (error) {
10365
10333
  console.error(error);
@@ -10421,7 +10389,6 @@ var withdraw = async (params) => {
10421
10389
  value
10422
10390
  });
10423
10391
  const receipt = await response?.wait();
10424
- console.log("base withdraw", response);
10425
10392
  return receipt;
10426
10393
  } catch (error) {
10427
10394
  console.error(error);
@@ -10440,7 +10407,6 @@ var getRewards = async (params) => {
10440
10407
  const priceResponse = await getOraclePrice(chainId2, [poolId]);
10441
10408
  const _price = priceResponse.data?.[0]?.price || "0";
10442
10409
  const price = (0, import_ethers13.parseUnits)(_price, COMMON_PRICE_DECIMALS);
10443
- console.log("pendingUserRebates base data:", [poolId, lpAmountIn, account, price]);
10444
10410
  const basePoolContract = await getBasePoolContract(chainId2);
10445
10411
  const _gasLimit = await basePoolContract.pendingUserRebates.estimateGas(poolId, account, price);
10446
10412
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10449,7 +10415,6 @@ var getRewards = async (params) => {
10449
10415
  gasLimit,
10450
10416
  gasPrice
10451
10417
  });
10452
- console.log("pendingUserRebates base result:", request);
10453
10418
  return request;
10454
10419
  } catch (error) {
10455
10420
  console.error(error);
@@ -10472,7 +10437,6 @@ var getLpPrice = async (chainId2, poolId) => {
10472
10437
  }
10473
10438
  }
10474
10439
  const data = await contract.getPoolTokenPrice(poolId, price);
10475
- console.log(`pool ${poolId} price: `, data);
10476
10440
  return data;
10477
10441
  } catch (error) {
10478
10442
  console.error(error);
@@ -10499,7 +10463,6 @@ var import_ethers15 = require("ethers");
10499
10463
  var previewLpAmountOut2 = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10500
10464
  try {
10501
10465
  const chainInfo = CHAIN_INFO[chainId2];
10502
- console.log("previewLpAmountOut data", [poolId, amountIn, price]);
10503
10466
  const quotePoolContract = await getQuotePoolContract(chainId2);
10504
10467
  const _gasLimit = await quotePoolContract.previewLpAmountOut.estimateGas(poolId, amountIn, price);
10505
10468
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10508,7 +10471,6 @@ var previewLpAmountOut2 = async ({ chainId: chainId2, amountIn, poolId, price =
10508
10471
  gasLimit,
10509
10472
  gasPrice
10510
10473
  });
10511
- console.log(request);
10512
10474
  return request;
10513
10475
  } catch (error) {
10514
10476
  console.error(error);
@@ -10518,7 +10480,6 @@ var previewLpAmountOut2 = async ({ chainId: chainId2, amountIn, poolId, price =
10518
10480
  var previewQuoteAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10519
10481
  try {
10520
10482
  const chainInfo = CHAIN_INFO[chainId2];
10521
- console.log("previewQuoteAmountOut data", [poolId, amountIn, price]);
10522
10483
  const quotePoolContract = await getQuotePoolContract(chainId2);
10523
10484
  const _gasLimit = await quotePoolContract.previewQuoteAmountOut.estimateGas(poolId, amountIn, price);
10524
10485
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10527,7 +10488,6 @@ var previewQuoteAmountOut = async ({ chainId: chainId2, amountIn, poolId, price
10527
10488
  gasLimit,
10528
10489
  gasPrice
10529
10490
  });
10530
- console.log("previewQuoteAmountOut response", request);
10531
10491
  return request;
10532
10492
  } catch (error) {
10533
10493
  console.error(error);
@@ -10595,7 +10555,6 @@ var deposit2 = async (params) => {
10595
10555
  recipient: account,
10596
10556
  tpslParams
10597
10557
  };
10598
- console.log("deposit params: price, data, value :", price, data, value);
10599
10558
  const contract = await getLiquidityRouterContract(chainId2);
10600
10559
  const _gasLimit = await contract["depositQuote((bytes32,uint8,uint256,bytes,uint64)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(price, data, { value });
10601
10560
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10605,7 +10564,6 @@ var deposit2 = async (params) => {
10605
10564
  gasPrice,
10606
10565
  value
10607
10566
  });
10608
- console.log("deposit", result);
10609
10567
  return result;
10610
10568
  } catch (error) {
10611
10569
  console.error(error);
@@ -10658,7 +10616,6 @@ var withdraw2 = async (params) => {
10658
10616
  // todo 调合约获取
10659
10617
  recipient: account
10660
10618
  };
10661
- console.log("withdraw", data);
10662
10619
  const contract = await getLiquidityRouterContract(chainId2);
10663
10620
  const _gasLimit = await contract["withdrawQuote((bytes32,uint8,uint256,bytes,uint64)[],(bytes32,uint256,uint256,address))"].estimateGas(price, data, { value });
10664
10621
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10668,9 +10625,7 @@ var withdraw2 = async (params) => {
10668
10625
  gasPrice,
10669
10626
  value
10670
10627
  });
10671
- console.log("withdraw quote with price", request);
10672
10628
  const receipt = await request?.wait();
10673
- console.log("withdraw quote receipt", receipt);
10674
10629
  return receipt;
10675
10630
  } catch (error) {
10676
10631
  console.error(error);
@@ -10698,7 +10653,6 @@ var transfer = async (chainId2, fromPoolId, toPoolId, amount) => {
10698
10653
  minLpOut: 0n,
10699
10654
  amount: (0, import_ethers17.parseUnits)(amount.toString(), decimals)
10700
10655
  };
10701
- console.log("migrateLiquiditydata", data);
10702
10656
  const contract = await getLiquidityRouterContract(chainId2);
10703
10657
  const _gasLimit = await contract.migrateLiquidity.estimateGas(data);
10704
10658
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10707,7 +10661,6 @@ var transfer = async (chainId2, fromPoolId, toPoolId, amount) => {
10707
10661
  gasLimit,
10708
10662
  gasPrice
10709
10663
  });
10710
- console.log("migrateLiquidity", result);
10711
10664
  return result;
10712
10665
  } catch (error) {
10713
10666
  throw typeof error === "string" ? error : await getErrorTextFormError(error);
@@ -10724,7 +10677,6 @@ var getRewards2 = async (params) => {
10724
10677
  const priceResponse = await getOraclePrice(chainId2, [poolId]);
10725
10678
  const _price = priceResponse.data?.[0]?.price || "0";
10726
10679
  const price = (0, import_ethers18.parseUnits)(_price, COMMON_PRICE_DECIMALS);
10727
- console.log("pendingUserRebates quote data", [poolId, account, price]);
10728
10680
  const contract = await getQuotePoolContract(chainId2);
10729
10681
  const _gasLimit = await contract.pendingUserRebates.estimateGas(poolId, account, price);
10730
10682
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10733,7 +10685,6 @@ var getRewards2 = async (params) => {
10733
10685
  gasLimit,
10734
10686
  gasPrice
10735
10687
  });
10736
- console.log("pendingUserRebates quote result:", request);
10737
10688
  return request;
10738
10689
  } catch (error) {
10739
10690
  console.error(error);
@@ -10774,7 +10725,6 @@ var claimQuotePoolRebate = async (params) => {
10774
10725
  recipient: account
10775
10726
  };
10776
10727
  const contract = await getLiquidityRouterContract(chainId2);
10777
- console.log("quote claim params", data);
10778
10728
  const _gasLimit = await contract["claimQuotePoolRebate((bytes32,uint8,uint256,bytes,uint64)[],bytes32,address)"].estimateGas(prices, poolId, account, {
10779
10729
  value: values[0]
10780
10730
  });
@@ -10785,7 +10735,6 @@ var claimQuotePoolRebate = async (params) => {
10785
10735
  gasPrice,
10786
10736
  value: values[0]
10787
10737
  });
10788
- console.log("quote claim", response);
10789
10738
  return response;
10790
10739
  } catch (error) {
10791
10740
  console.error(error);
@@ -10822,7 +10771,6 @@ var claimQuotePoolRebates = async (params) => {
10822
10771
  poolIds,
10823
10772
  recipient: account
10824
10773
  };
10825
- console.log("quote claim Rebates params", data);
10826
10774
  const contract = await getLiquidityRouterContract(chainId2);
10827
10775
  const _gasLimit = await contract["claimQuotePoolRebates((bytes32,uint8,uint256,bytes,uint64)[],bytes32[],address)"].estimateGas(prices, poolIds, account, {
10828
10776
  value
@@ -10834,7 +10782,6 @@ var claimQuotePoolRebates = async (params) => {
10834
10782
  gasPrice,
10835
10783
  value
10836
10784
  });
10837
- console.log("quote claim rebates", response);
10838
10785
  return response;
10839
10786
  } catch (error) {
10840
10787
  console.error(error);
@@ -10857,7 +10804,6 @@ var getLpPrice2 = async (chainId2, poolId) => {
10857
10804
  }
10858
10805
  }
10859
10806
  const data = await contract.getPoolTokenPrice(poolId, price);
10860
- console.log(`pool ${poolId} price: `, data);
10861
10807
  return data;
10862
10808
  } catch (error) {
10863
10809
  console.error(error);
@@ -10899,7 +10845,7 @@ var getMarketPoolId = async ({
10899
10845
  const chainInfo = CHAIN_INFO[chainId2];
10900
10846
  const addresses = address_default[chainId2];
10901
10847
  const address = addresses.POOL_MANAGER;
10902
- const contract = await getPoolManagerContract(chainId2);
10848
+ const contract = await getPoolManagerContract(chainId2, 0 /* JSON */);
10903
10849
  const data = [marketId2, baseToken];
10904
10850
  const request = await contract.getMarketPool(marketId2, baseToken);
10905
10851
  return request.poolId === "0x0000000000000000000000000000000000000000000000000000000000000000" || !request.poolId ? void 0 : request.poolId;
@@ -10998,7 +10944,6 @@ var getUserGenesisShare = async (chainId2, tokenAddress, account) => {
10998
10944
  try {
10999
10945
  const contract = await getPoolTokenContract(chainId2, tokenAddress);
11000
10946
  const request = await contract.userGenesisShare(account);
11001
- console.log(`UserGenesisShare : `, request);
11002
10947
  return request;
11003
10948
  } catch (error) {
11004
10949
  console.error(error);
@@ -11025,19 +10970,14 @@ var addTpSl = async (params) => {
11025
10970
  poolType: BigInt(poolType),
11026
10971
  tpslParams
11027
10972
  };
11028
- console.log("add tpSl params:", data);
11029
10973
  const _gasLimit = await contract.addTpsl.estimateGas(data);
11030
10974
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
11031
- console.log("gasLimit", _gasLimit, gasLimit);
11032
10975
  const { gasPrice } = await bigintTradingGasPriceWithRatio(chainId2);
11033
- console.log("gasPrice", gasPrice);
11034
10976
  const request = await contract.addTpsl(data, {
11035
10977
  gasLimit,
11036
10978
  gasPrice
11037
10979
  });
11038
- console.log("addTpsl request", request);
11039
10980
  const receipt = await request?.wait();
11040
- console.log(request);
11041
10981
  return receipt;
11042
10982
  } catch (error) {
11043
10983
  console.error(error);
@@ -11054,16 +10994,12 @@ var cancelTpSl = async (params) => {
11054
10994
  const contract = await getLiquidityRouterContract(chainId2);
11055
10995
  const _gasLimit = await contract.cancelTpsl.estimateGas(orderId);
11056
10996
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
11057
- console.log("gasLimit", _gasLimit, gasLimit);
11058
10997
  const { gasPrice } = await bigintTradingGasPriceWithRatio(chainId2);
11059
- console.log("gasPrice", gasPrice);
11060
10998
  const request = await contract.cancelTpsl(orderId, {
11061
10999
  gasLimit,
11062
11000
  gasPrice
11063
11001
  });
11064
- console.log("cancelTpSl request", request);
11065
11002
  const receipt = await request?.wait();
11066
- console.log(request);
11067
11003
  return receipt;
11068
11004
  } catch (error) {
11069
11005
  console.error(error);
@@ -11144,8 +11080,6 @@ var getOracleFee = async (chainId2, marketId2) => {
11144
11080
  if (!marketId2) return;
11145
11081
  const contract = await getMarketManageContract(chainId2);
11146
11082
  const request = await contract.getOracleFee(marketId2);
11147
- console.log("MarketManage.getOracleFee request", request);
11148
- console.log(request);
11149
11083
  return request;
11150
11084
  } catch (error) {
11151
11085
  console.error(error);
@@ -11168,7 +11102,6 @@ var reprime = async (chainId2, poolId) => {
11168
11102
  if (!_amount) {
11169
11103
  throw new Error("Invalid Market");
11170
11104
  }
11171
- console.log(Number((0, import_ethers22.formatUnits)(_amount, pool.quoteDecimals)));
11172
11105
  await checkParams({
11173
11106
  tokenAddress: pool.quoteToken,
11174
11107
  contractAddress: address_default[chainId2].ORACLE_RESERVE,
@@ -11181,13 +11114,9 @@ var reprime = async (chainId2, poolId) => {
11181
11114
  const contract = await getPoolManagerContract(chainId2);
11182
11115
  const _gasLimit = await contract.reprimePool.estimateGas({ poolId });
11183
11116
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
11184
- console.log("gasLimit", _gasLimit, gasLimit);
11185
11117
  const { gasPrice } = await bigintTradingGasPriceWithRatio(chainId2);
11186
- console.log("gasPrice", gasPrice);
11187
11118
  const request = await contract.reprimePool({ poolId });
11188
- console.log("PoolManager.reprimePool request", request);
11189
11119
  const receipt = await request?.wait();
11190
- console.log(receipt);
11191
11120
  return receipt;
11192
11121
  } catch (error) {
11193
11122
  console.error(error);
@@ -18220,7 +18149,6 @@ var Account = class {
18220
18149
  };
18221
18150
 
18222
18151
  // src/manager/index.ts
18223
- var import_ethers27 = require("ethers");
18224
18152
  var MyxClient = class {
18225
18153
  /**
18226
18154
  * 获取配置管理器(用于访问 accessToken 相关方法)
@@ -18240,12 +18168,6 @@ var MyxClient = class {
18240
18168
  this.account = new Account(this.configManager, this.logger, this.utils);
18241
18169
  this.subscription = new SubScription(this.configManager, this.logger);
18242
18170
  const lp = MxSDK.getInstance();
18243
- if (options.walletClient?.transport) {
18244
- const provider = new import_ethers27.BrowserProvider(options.walletClient?.transport);
18245
- if (provider) {
18246
- lp.setProvider(provider);
18247
- }
18248
- }
18249
18171
  lp.setConfigManager(this.configManager);
18250
18172
  }
18251
18173
  /**
package/dist/index.mjs CHANGED
@@ -1416,6 +1416,7 @@ var address_default = {
1416
1416
 
1417
1417
  // src/web3/index.ts
1418
1418
  import {
1419
+ BrowserProvider,
1419
1420
  Contract,
1420
1421
  ethers,
1421
1422
  JsonRpcProvider,
@@ -1741,7 +1742,7 @@ var RotationProvider = class extends BaseProvider {
1741
1742
  // package.json
1742
1743
  var package_default = {
1743
1744
  name: "@myx-trade/sdk",
1744
- version: "0.1.18",
1745
+ version: "0.1.19",
1745
1746
  private: false,
1746
1747
  publishConfig: {
1747
1748
  access: "public"
@@ -1872,17 +1873,10 @@ if (typeof window !== "undefined") {
1872
1873
  }
1873
1874
  var getWalletProvider = async (chainId2) => {
1874
1875
  try {
1875
- const provider = sdk.provider;
1876
+ const walletClient = sdk.getConfigManager()?.getConfig().walletClient;
1877
+ const provider = new BrowserProvider(walletClient?.transport);
1876
1878
  if (!provider) {
1877
- throw new Error("Provider missing in provider");
1878
- }
1879
- if (chainId2) {
1880
- const network = await provider.getNetwork();
1881
- console.log(provider);
1882
- console.log(`Connected to chain: ${network.chainId}, requested: ${chainId2}`);
1883
- if (Number(network.chainId) !== chainId2) {
1884
- await provider.send("wallet_switchEthereumChain", [{ chainId: BigInt(chainId2) }]);
1885
- }
1879
+ throw new Error("missing provider");
1886
1880
  }
1887
1881
  return provider;
1888
1882
  } catch (error) {
@@ -1892,7 +1886,6 @@ var getWalletProvider = async (chainId2) => {
1892
1886
  };
1893
1887
  var getSignerProvider = async (chainId2) => {
1894
1888
  const provider = await getWalletProvider(chainId2);
1895
- console.log(provider);
1896
1889
  return provider?.getSigner?.();
1897
1890
  };
1898
1891
 
@@ -9099,10 +9092,10 @@ var getLiquidityRouterContract = async (chainId2) => {
9099
9092
  const provider = await getSignerProvider(chainId2);
9100
9093
  return getContract(address, LiquidityRouter_default, provider);
9101
9094
  };
9102
- var getPoolManagerContract = async (chainId2) => {
9095
+ var getPoolManagerContract = async (chainId2, type = 1 /* Signer */) => {
9103
9096
  const addresses = address_default[chainId2];
9104
9097
  const address = addresses.POOL_MANAGER;
9105
- const provider = await getSignerProvider(chainId2);
9098
+ const provider = type === 0 /* JSON */ ? getJSONProvider(chainId2) : await getSignerProvider(chainId2);
9106
9099
  return getContract(address, PoolManager_default, provider);
9107
9100
  };
9108
9101
  var getQuotePoolContract = async (chainId2, type = 0 /* JSON */) => {
@@ -9410,18 +9403,13 @@ var getAllowanceApproved = async (chainId2, account, tokenAddress, approveAddres
9410
9403
  const provider = getJSONProvider(chainId2);
9411
9404
  const contractInterface = new ethers3.Interface(IERC20Metadata_default);
9412
9405
  const data = contractInterface.encodeFunctionData("allowance", [account, approveAddress]);
9413
- console.log("approve token ", tokenAddress);
9414
- console.log("approve address ", approveAddress);
9415
9406
  const callData = {
9416
9407
  to: tokenAddress,
9417
9408
  data
9418
9409
  };
9419
9410
  const result = await provider.call(callData);
9420
9411
  const allowance = BigInt(result);
9421
- console.log("Allowance:", allowance.toString());
9422
- console.log("ApproveAmount:", approveAmount.toString());
9423
9412
  if (allowance >= approveAmount) {
9424
- console.log("Allowance approved.");
9425
9413
  return true;
9426
9414
  }
9427
9415
  return false;
@@ -9434,10 +9422,7 @@ var getAllowanceApproved = async (chainId2, account, tokenAddress, approveAddres
9434
9422
  var approve = async (chainId2, account, tokenAddress, approveAddress, amount) => {
9435
9423
  try {
9436
9424
  const TokenContract = await getERC20Contract(chainId2, tokenAddress);
9437
- console.log("approve token Address", tokenAddress);
9438
9425
  const response = await TokenContract.approve(approveAddress, amount);
9439
- console.log("approve amount", approveAddress);
9440
- console.log("approve amount", amount);
9441
9426
  const receipt = await response?.wait();
9442
9427
  const isApproved = await getAllowanceApproved(chainId2, account, tokenAddress, approveAddress, amount);
9443
9428
  if (!isApproved) {
@@ -9466,13 +9451,11 @@ var checkParams = async (params) => {
9466
9451
  throw new Error(Errors[4004 /* Invalid_Amount */]);
9467
9452
  }
9468
9453
  }
9469
- console.log("checkbalance");
9470
9454
  const { tokenAddress, contractAddress, chainId: chainId2, amount, decimals, account } = params;
9471
9455
  if (amount && chainId2 && decimals && account) {
9472
9456
  const amountIn = parseUnits2(amount.toString(), decimals);
9473
9457
  if (tokenAddress) {
9474
9458
  const balance = await getBalanceOf(chainId2, account, tokenAddress);
9475
- console.log("balance", balance, tokenAddress);
9476
9459
  if (!balance || balance < amountIn) {
9477
9460
  throw new Error(Errors[3 /* Insufficient_Balance */]);
9478
9461
  }
@@ -9506,9 +9489,7 @@ var bigintTradingGasPriceWithRatio = async (chainId2) => {
9506
9489
  if (!gasPrice) {
9507
9490
  throw new Error("Network Error");
9508
9491
  }
9509
- console.log("gasPrice", gasPrice);
9510
9492
  const gasPriceWithRatio = bigintTradingGasToRatioCalculator(gasPrice, chainInfo.gasPriceRatio);
9511
- console.log("gasPriceWithRatio--->", gasPriceWithRatio);
9512
9493
  return {
9513
9494
  gasPrice: gasPriceWithRatio
9514
9495
  };
@@ -9984,7 +9965,6 @@ var claimBasePoolRebate = async (params) => {
9984
9965
  poolId,
9985
9966
  recipient: account
9986
9967
  };
9987
- console.log("base claim", data);
9988
9968
  const contract = await getLiquidityRouterContract(chainId2);
9989
9969
  const _gasLimit = await contract["claimBasePoolRebate((bytes32,uint8,uint256,bytes,uint64)[],bytes32,address)"].estimateGas(prices, poolId, account, {
9990
9970
  value: values[0]
@@ -9996,7 +9976,6 @@ var claimBasePoolRebate = async (params) => {
9996
9976
  gasPrice,
9997
9977
  value: values[0]
9998
9978
  });
9999
- console.log("base claim", response);
10000
9979
  return response;
10001
9980
  } catch (error) {
10002
9981
  console.error(error);
@@ -10032,7 +10011,6 @@ var claimBasePoolRebates = async (params) => {
10032
10011
  value,
10033
10012
  recipient: account
10034
10013
  };
10035
- console.log("base claim pool rebates", data);
10036
10014
  const contract = await getLiquidityRouterContract(chainId2);
10037
10015
  const _gasLimit = await contract["claimBasePoolRebates((bytes32,uint8,uint256,bytes,uint64)[],bytes32[],address)"].estimateGas(prices, poolIds, account, {
10038
10016
  value
@@ -10044,7 +10022,6 @@ var claimBasePoolRebates = async (params) => {
10044
10022
  gasPrice,
10045
10023
  value
10046
10024
  });
10047
- console.log("base claim rebates", response);
10048
10025
  return response;
10049
10026
  } catch (error) {
10050
10027
  console.error(error);
@@ -10080,7 +10057,6 @@ var Market = {
10080
10057
  var previewLpAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10081
10058
  try {
10082
10059
  const chainInfo = CHAIN_INFO[chainId2];
10083
- console.log("previewLpAmountOut data", [poolId, amountIn, price]);
10084
10060
  const basePoolContract = await getBasePoolContract(chainId2);
10085
10061
  const _gasLimit = await basePoolContract.previewLpAmountOut.estimateGas(poolId, amountIn, price);
10086
10062
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10089,7 +10065,6 @@ var previewLpAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0
10089
10065
  gasLimit,
10090
10066
  gasPrice
10091
10067
  });
10092
- console.log(request);
10093
10068
  return request;
10094
10069
  } catch (error) {
10095
10070
  console.error(error);
@@ -10099,7 +10074,6 @@ var previewLpAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0
10099
10074
  var previewBaseAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10100
10075
  try {
10101
10076
  const chainInfo = CHAIN_INFO[chainId2];
10102
- console.log("previewQuoteAmountOut data", [poolId, amountIn, price]);
10103
10077
  const basePoolContract = await getBasePoolContract(chainId2);
10104
10078
  const _gasLimit = await basePoolContract.previewBaseAmountOut.estimateGas(poolId, amountIn, price);
10105
10079
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10108,7 +10082,6 @@ var previewBaseAmountOut = async ({ chainId: chainId2, amountIn, poolId, price =
10108
10082
  gasLimit,
10109
10083
  gasPrice
10110
10084
  });
10111
- console.log("previewBaseAmountOut response", request);
10112
10085
  return request;
10113
10086
  } catch (error) {
10114
10087
  console.error(error);
@@ -10137,7 +10110,6 @@ var previewUserWithdrawData = async ({ chainId: chainId2, account, poolId, amoun
10137
10110
  const priceResponse = await getOraclePrice(chainId2, [poolId]);
10138
10111
  const _price = priceResponse.data?.[0]?.price || "0";
10139
10112
  const price = parseUnits5(_price, COMMON_PRICE_DECIMALS);
10140
- console.log("previewUserWithdrawData data", [poolId, amountIn, account, price]);
10141
10113
  const basePoolContract = await getBasePoolContract(chainId2);
10142
10114
  const _gasLimit = await basePoolContract.previewUserWithdrawData.estimateGas(poolId, amountIn, account, price);
10143
10115
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10147,7 +10119,6 @@ var previewUserWithdrawData = async ({ chainId: chainId2, account, poolId, amoun
10147
10119
  gasPrice
10148
10120
  });
10149
10121
  const { baseAmountOut, rebateAmount } = request;
10150
- console.log("previewUserWithdrawData result:", { baseAmountOut, rebateAmount });
10151
10122
  return {
10152
10123
  baseAmountOut,
10153
10124
  rebateAmount
@@ -10263,7 +10234,6 @@ var deposit = async (params) => {
10263
10234
  recipient: account,
10264
10235
  tpslParams
10265
10236
  };
10266
- console.log("deposit base", price, data, value);
10267
10237
  const contract = await getLiquidityRouterContract(chainId2);
10268
10238
  const _gasLimit = await contract["depositBase((bytes32,uint8,uint256,bytes,uint64)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(price, data, { value });
10269
10239
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10273,7 +10243,6 @@ var deposit = async (params) => {
10273
10243
  gasPrice,
10274
10244
  value
10275
10245
  });
10276
- console.log("deposit", result);
10277
10246
  return result;
10278
10247
  } catch (error) {
10279
10248
  console.error(error);
@@ -10335,7 +10304,6 @@ var withdraw = async (params) => {
10335
10304
  value
10336
10305
  });
10337
10306
  const receipt = await response?.wait();
10338
- console.log("base withdraw", response);
10339
10307
  return receipt;
10340
10308
  } catch (error) {
10341
10309
  console.error(error);
@@ -10354,7 +10322,6 @@ var getRewards = async (params) => {
10354
10322
  const priceResponse = await getOraclePrice(chainId2, [poolId]);
10355
10323
  const _price = priceResponse.data?.[0]?.price || "0";
10356
10324
  const price = parseUnits9(_price, COMMON_PRICE_DECIMALS);
10357
- console.log("pendingUserRebates base data:", [poolId, lpAmountIn, account, price]);
10358
10325
  const basePoolContract = await getBasePoolContract(chainId2);
10359
10326
  const _gasLimit = await basePoolContract.pendingUserRebates.estimateGas(poolId, account, price);
10360
10327
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10363,7 +10330,6 @@ var getRewards = async (params) => {
10363
10330
  gasLimit,
10364
10331
  gasPrice
10365
10332
  });
10366
- console.log("pendingUserRebates base result:", request);
10367
10333
  return request;
10368
10334
  } catch (error) {
10369
10335
  console.error(error);
@@ -10386,7 +10352,6 @@ var getLpPrice = async (chainId2, poolId) => {
10386
10352
  }
10387
10353
  }
10388
10354
  const data = await contract.getPoolTokenPrice(poolId, price);
10389
- console.log(`pool ${poolId} price: `, data);
10390
10355
  return data;
10391
10356
  } catch (error) {
10392
10357
  console.error(error);
@@ -10413,7 +10378,6 @@ import { parseUnits as parseUnits11 } from "ethers";
10413
10378
  var previewLpAmountOut2 = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10414
10379
  try {
10415
10380
  const chainInfo = CHAIN_INFO[chainId2];
10416
- console.log("previewLpAmountOut data", [poolId, amountIn, price]);
10417
10381
  const quotePoolContract = await getQuotePoolContract(chainId2);
10418
10382
  const _gasLimit = await quotePoolContract.previewLpAmountOut.estimateGas(poolId, amountIn, price);
10419
10383
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10422,7 +10386,6 @@ var previewLpAmountOut2 = async ({ chainId: chainId2, amountIn, poolId, price =
10422
10386
  gasLimit,
10423
10387
  gasPrice
10424
10388
  });
10425
- console.log(request);
10426
10389
  return request;
10427
10390
  } catch (error) {
10428
10391
  console.error(error);
@@ -10432,7 +10395,6 @@ var previewLpAmountOut2 = async ({ chainId: chainId2, amountIn, poolId, price =
10432
10395
  var previewQuoteAmountOut = async ({ chainId: chainId2, amountIn, poolId, price = 0n }) => {
10433
10396
  try {
10434
10397
  const chainInfo = CHAIN_INFO[chainId2];
10435
- console.log("previewQuoteAmountOut data", [poolId, amountIn, price]);
10436
10398
  const quotePoolContract = await getQuotePoolContract(chainId2);
10437
10399
  const _gasLimit = await quotePoolContract.previewQuoteAmountOut.estimateGas(poolId, amountIn, price);
10438
10400
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10441,7 +10403,6 @@ var previewQuoteAmountOut = async ({ chainId: chainId2, amountIn, poolId, price
10441
10403
  gasLimit,
10442
10404
  gasPrice
10443
10405
  });
10444
- console.log("previewQuoteAmountOut response", request);
10445
10406
  return request;
10446
10407
  } catch (error) {
10447
10408
  console.error(error);
@@ -10509,7 +10470,6 @@ var deposit2 = async (params) => {
10509
10470
  recipient: account,
10510
10471
  tpslParams
10511
10472
  };
10512
- console.log("deposit params: price, data, value :", price, data, value);
10513
10473
  const contract = await getLiquidityRouterContract(chainId2);
10514
10474
  const _gasLimit = await contract["depositQuote((bytes32,uint8,uint256,bytes,uint64)[],(bytes32,uint256,uint256,address,(uint256,uint256,uint8,uint256)[]))"].estimateGas(price, data, { value });
10515
10475
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10519,7 +10479,6 @@ var deposit2 = async (params) => {
10519
10479
  gasPrice,
10520
10480
  value
10521
10481
  });
10522
- console.log("deposit", result);
10523
10482
  return result;
10524
10483
  } catch (error) {
10525
10484
  console.error(error);
@@ -10572,7 +10531,6 @@ var withdraw2 = async (params) => {
10572
10531
  // todo 调合约获取
10573
10532
  recipient: account
10574
10533
  };
10575
- console.log("withdraw", data);
10576
10534
  const contract = await getLiquidityRouterContract(chainId2);
10577
10535
  const _gasLimit = await contract["withdrawQuote((bytes32,uint8,uint256,bytes,uint64)[],(bytes32,uint256,uint256,address))"].estimateGas(price, data, { value });
10578
10536
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10582,9 +10540,7 @@ var withdraw2 = async (params) => {
10582
10540
  gasPrice,
10583
10541
  value
10584
10542
  });
10585
- console.log("withdraw quote with price", request);
10586
10543
  const receipt = await request?.wait();
10587
- console.log("withdraw quote receipt", receipt);
10588
10544
  return receipt;
10589
10545
  } catch (error) {
10590
10546
  console.error(error);
@@ -10612,7 +10568,6 @@ var transfer = async (chainId2, fromPoolId, toPoolId, amount) => {
10612
10568
  minLpOut: 0n,
10613
10569
  amount: parseUnits13(amount.toString(), decimals)
10614
10570
  };
10615
- console.log("migrateLiquiditydata", data);
10616
10571
  const contract = await getLiquidityRouterContract(chainId2);
10617
10572
  const _gasLimit = await contract.migrateLiquidity.estimateGas(data);
10618
10573
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10621,7 +10576,6 @@ var transfer = async (chainId2, fromPoolId, toPoolId, amount) => {
10621
10576
  gasLimit,
10622
10577
  gasPrice
10623
10578
  });
10624
- console.log("migrateLiquidity", result);
10625
10579
  return result;
10626
10580
  } catch (error) {
10627
10581
  throw typeof error === "string" ? error : await getErrorTextFormError(error);
@@ -10638,7 +10592,6 @@ var getRewards2 = async (params) => {
10638
10592
  const priceResponse = await getOraclePrice(chainId2, [poolId]);
10639
10593
  const _price = priceResponse.data?.[0]?.price || "0";
10640
10594
  const price = parseUnits14(_price, COMMON_PRICE_DECIMALS);
10641
- console.log("pendingUserRebates quote data", [poolId, account, price]);
10642
10595
  const contract = await getQuotePoolContract(chainId2);
10643
10596
  const _gasLimit = await contract.pendingUserRebates.estimateGas(poolId, account, price);
10644
10597
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
@@ -10647,7 +10600,6 @@ var getRewards2 = async (params) => {
10647
10600
  gasLimit,
10648
10601
  gasPrice
10649
10602
  });
10650
- console.log("pendingUserRebates quote result:", request);
10651
10603
  return request;
10652
10604
  } catch (error) {
10653
10605
  console.error(error);
@@ -10688,7 +10640,6 @@ var claimQuotePoolRebate = async (params) => {
10688
10640
  recipient: account
10689
10641
  };
10690
10642
  const contract = await getLiquidityRouterContract(chainId2);
10691
- console.log("quote claim params", data);
10692
10643
  const _gasLimit = await contract["claimQuotePoolRebate((bytes32,uint8,uint256,bytes,uint64)[],bytes32,address)"].estimateGas(prices, poolId, account, {
10693
10644
  value: values[0]
10694
10645
  });
@@ -10699,7 +10650,6 @@ var claimQuotePoolRebate = async (params) => {
10699
10650
  gasPrice,
10700
10651
  value: values[0]
10701
10652
  });
10702
- console.log("quote claim", response);
10703
10653
  return response;
10704
10654
  } catch (error) {
10705
10655
  console.error(error);
@@ -10736,7 +10686,6 @@ var claimQuotePoolRebates = async (params) => {
10736
10686
  poolIds,
10737
10687
  recipient: account
10738
10688
  };
10739
- console.log("quote claim Rebates params", data);
10740
10689
  const contract = await getLiquidityRouterContract(chainId2);
10741
10690
  const _gasLimit = await contract["claimQuotePoolRebates((bytes32,uint8,uint256,bytes,uint64)[],bytes32[],address)"].estimateGas(prices, poolIds, account, {
10742
10691
  value
@@ -10748,7 +10697,6 @@ var claimQuotePoolRebates = async (params) => {
10748
10697
  gasPrice,
10749
10698
  value
10750
10699
  });
10751
- console.log("quote claim rebates", response);
10752
10700
  return response;
10753
10701
  } catch (error) {
10754
10702
  console.error(error);
@@ -10771,7 +10719,6 @@ var getLpPrice2 = async (chainId2, poolId) => {
10771
10719
  }
10772
10720
  }
10773
10721
  const data = await contract.getPoolTokenPrice(poolId, price);
10774
- console.log(`pool ${poolId} price: `, data);
10775
10722
  return data;
10776
10723
  } catch (error) {
10777
10724
  console.error(error);
@@ -10813,7 +10760,7 @@ var getMarketPoolId = async ({
10813
10760
  const chainInfo = CHAIN_INFO[chainId2];
10814
10761
  const addresses = address_default[chainId2];
10815
10762
  const address = addresses.POOL_MANAGER;
10816
- const contract = await getPoolManagerContract(chainId2);
10763
+ const contract = await getPoolManagerContract(chainId2, 0 /* JSON */);
10817
10764
  const data = [marketId2, baseToken];
10818
10765
  const request = await contract.getMarketPool(marketId2, baseToken);
10819
10766
  return request.poolId === "0x0000000000000000000000000000000000000000000000000000000000000000" || !request.poolId ? void 0 : request.poolId;
@@ -10912,7 +10859,6 @@ var getUserGenesisShare = async (chainId2, tokenAddress, account) => {
10912
10859
  try {
10913
10860
  const contract = await getPoolTokenContract(chainId2, tokenAddress);
10914
10861
  const request = await contract.userGenesisShare(account);
10915
- console.log(`UserGenesisShare : `, request);
10916
10862
  return request;
10917
10863
  } catch (error) {
10918
10864
  console.error(error);
@@ -10939,19 +10885,14 @@ var addTpSl = async (params) => {
10939
10885
  poolType: BigInt(poolType),
10940
10886
  tpslParams
10941
10887
  };
10942
- console.log("add tpSl params:", data);
10943
10888
  const _gasLimit = await contract.addTpsl.estimateGas(data);
10944
10889
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
10945
- console.log("gasLimit", _gasLimit, gasLimit);
10946
10890
  const { gasPrice } = await bigintTradingGasPriceWithRatio(chainId2);
10947
- console.log("gasPrice", gasPrice);
10948
10891
  const request = await contract.addTpsl(data, {
10949
10892
  gasLimit,
10950
10893
  gasPrice
10951
10894
  });
10952
- console.log("addTpsl request", request);
10953
10895
  const receipt = await request?.wait();
10954
- console.log(request);
10955
10896
  return receipt;
10956
10897
  } catch (error) {
10957
10898
  console.error(error);
@@ -10968,16 +10909,12 @@ var cancelTpSl = async (params) => {
10968
10909
  const contract = await getLiquidityRouterContract(chainId2);
10969
10910
  const _gasLimit = await contract.cancelTpsl.estimateGas(orderId);
10970
10911
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
10971
- console.log("gasLimit", _gasLimit, gasLimit);
10972
10912
  const { gasPrice } = await bigintTradingGasPriceWithRatio(chainId2);
10973
- console.log("gasPrice", gasPrice);
10974
10913
  const request = await contract.cancelTpsl(orderId, {
10975
10914
  gasLimit,
10976
10915
  gasPrice
10977
10916
  });
10978
- console.log("cancelTpSl request", request);
10979
10917
  const receipt = await request?.wait();
10980
- console.log(request);
10981
10918
  return receipt;
10982
10919
  } catch (error) {
10983
10920
  console.error(error);
@@ -11058,8 +10995,6 @@ var getOracleFee = async (chainId2, marketId2) => {
11058
10995
  if (!marketId2) return;
11059
10996
  const contract = await getMarketManageContract(chainId2);
11060
10997
  const request = await contract.getOracleFee(marketId2);
11061
- console.log("MarketManage.getOracleFee request", request);
11062
- console.log(request);
11063
10998
  return request;
11064
10999
  } catch (error) {
11065
11000
  console.error(error);
@@ -11082,7 +11017,6 @@ var reprime = async (chainId2, poolId) => {
11082
11017
  if (!_amount) {
11083
11018
  throw new Error("Invalid Market");
11084
11019
  }
11085
- console.log(Number(formatUnits(_amount, pool.quoteDecimals)));
11086
11020
  await checkParams({
11087
11021
  tokenAddress: pool.quoteToken,
11088
11022
  contractAddress: address_default[chainId2].ORACLE_RESERVE,
@@ -11095,13 +11029,9 @@ var reprime = async (chainId2, poolId) => {
11095
11029
  const contract = await getPoolManagerContract(chainId2);
11096
11030
  const _gasLimit = await contract.reprimePool.estimateGas({ poolId });
11097
11031
  const gasLimit = bigintTradingGasToRatioCalculator(_gasLimit, chainInfo.gasLimitRatio);
11098
- console.log("gasLimit", _gasLimit, gasLimit);
11099
11032
  const { gasPrice } = await bigintTradingGasPriceWithRatio(chainId2);
11100
- console.log("gasPrice", gasPrice);
11101
11033
  const request = await contract.reprimePool({ poolId });
11102
- console.log("PoolManager.reprimePool request", request);
11103
11034
  const receipt = await request?.wait();
11104
- console.log(receipt);
11105
11035
  return receipt;
11106
11036
  } catch (error) {
11107
11037
  console.error(error);
@@ -18134,7 +18064,6 @@ var Account = class {
18134
18064
  };
18135
18065
 
18136
18066
  // src/manager/index.ts
18137
- import { BrowserProvider as BrowserProvider2 } from "ethers";
18138
18067
  var MyxClient = class {
18139
18068
  /**
18140
18069
  * 获取配置管理器(用于访问 accessToken 相关方法)
@@ -18154,12 +18083,6 @@ var MyxClient = class {
18154
18083
  this.account = new Account(this.configManager, this.logger, this.utils);
18155
18084
  this.subscription = new SubScription(this.configManager, this.logger);
18156
18085
  const lp = MxSDK.getInstance();
18157
- if (options.walletClient?.transport) {
18158
- const provider = new BrowserProvider2(options.walletClient?.transport);
18159
- if (provider) {
18160
- lp.setProvider(provider);
18161
- }
18162
- }
18163
18086
  lp.setConfigManager(this.configManager);
18164
18087
  }
18165
18088
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"