@continuumdao/ctm-mpc-defi 0.2.38 → 0.2.40

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.
@@ -31,7 +31,14 @@ function gmxResolvedApiBaseUrls(chainId) {
31
31
  if (!primary) {
32
32
  throw new Error(`GMX API URLs are not configured for chain ${chainId}.`);
33
33
  }
34
- return [primary, ...getApiFallbackUrls(chainId)];
34
+ const urls = [primary, ...getApiFallbackUrls(chainId)].map((url) => url.replace(/\/$/, ""));
35
+ const peer = gmxApiPeerFallback(urls[0]);
36
+ if (peer && !urls.includes(peer)) urls.push(peer);
37
+ return urls;
38
+ }
39
+ function gmxApiPeerFallback(primary) {
40
+ if (primary.includes(".gmxapi.io")) return primary.replace(".gmxapi.io", ".gmxapi.ai");
41
+ return void 0;
35
42
  }
36
43
  function buildGmxUrl(baseUrl, path, query) {
37
44
  const base = baseUrl.replace(/\/$/, "");
@@ -492,6 +499,7 @@ var require5 = module$1.createRequire(url.fileURLToPath((typeof document === 'un
492
499
  var { getMaxAllowedLeverage } = require5("@gmx-io/sdk/utils/markets");
493
500
  function gmxMarketMaxLeverageBps(marketInfo) {
494
501
  return getMaxAllowedLeverage({
502
+ marketAddress: marketInfo.marketTokenAddress,
495
503
  minCollateralFactor: marketInfo.minCollateralFactor,
496
504
  minCollateralFactorForLiquidation: marketInfo.minCollateralFactorForLiquidation,
497
505
  positionFeeFactorForBalanceWasNotImproved: marketInfo.positionFeeFactorForBalanceWasNotImproved
@@ -1635,7 +1643,7 @@ async function buildApproveStepsIfNeeded(args) {
1635
1643
  }
1636
1644
  async function buildNativeWrapPrepSteps(args) {
1637
1645
  const weth = viem.getAddress(args.nativeWrapped);
1638
- const router = viem.getAddress(args.exchangeRouter);
1646
+ const router = viem.getAddress(args.tokenRouter);
1639
1647
  const steps = [];
1640
1648
  steps.push({
1641
1649
  to: weth,
@@ -1727,6 +1735,7 @@ async function buildEvmMultisignBodyGmxGmDepositBatch(args) {
1727
1735
  throw new Error("Collateral token is not a pool token for the selected GM market.");
1728
1736
  }
1729
1737
  const exchangeRouter = gmxContractAddress(args.chainId, "ExchangeRouter");
1738
+ const tokenRouter = gmxContractAddress(args.chainId, "SyntheticsRouter");
1730
1739
  const depositVault = gmxContractAddress(args.chainId, "DepositVault");
1731
1740
  const executionFee = await gmxEstimateGmExecutionFee({
1732
1741
  chainId: args.chainId,
@@ -1742,7 +1751,7 @@ async function buildEvmMultisignBodyGmxGmDepositBatch(args) {
1742
1751
  rpcUrl: args.rpcUrl,
1743
1752
  executorAddress: executor,
1744
1753
  nativeWrapped: args.nativeWrapped,
1745
- exchangeRouter,
1754
+ tokenRouter,
1746
1755
  amountWei
1747
1756
  })
1748
1757
  );
@@ -1753,7 +1762,7 @@ async function buildEvmMultisignBodyGmxGmDepositBatch(args) {
1753
1762
  rpcUrl: args.rpcUrl,
1754
1763
  executorAddress: executor,
1755
1764
  token: collateralAddr,
1756
- spender: exchangeRouter,
1765
+ spender: tokenRouter,
1757
1766
  amountWei
1758
1767
  })
1759
1768
  );
@@ -1839,6 +1848,7 @@ async function buildEvmMultisignBodyGmxGmWithdrawBatch(args) {
1839
1848
  const gmAmountWei = parseGmxTokenAmount(args.gmAmountHuman, gmDecimals);
1840
1849
  if (gmAmountWei === 0n) throw new Error("GM amount is zero after converting with token decimals.");
1841
1850
  const exchangeRouter = gmxContractAddress(args.chainId, "ExchangeRouter");
1851
+ const tokenRouter = gmxContractAddress(args.chainId, "SyntheticsRouter");
1842
1852
  const withdrawalVault = gmxContractAddress(args.chainId, "WithdrawalVault");
1843
1853
  const executionFee = await gmxEstimateGmExecutionFee({
1844
1854
  chainId: args.chainId,
@@ -1851,7 +1861,7 @@ async function buildEvmMultisignBodyGmxGmWithdrawBatch(args) {
1851
1861
  rpcUrl: args.rpcUrl,
1852
1862
  executorAddress: executor,
1853
1863
  token: gmToken,
1854
- spender: exchangeRouter,
1864
+ spender: tokenRouter,
1855
1865
  amountWei: gmAmountWei
1856
1866
  });
1857
1867
  const multicallData = [
@@ -2314,7 +2324,7 @@ var gmxProtocolModule = {
2314
2324
  id: "gmx.gmDeposit",
2315
2325
  protocolId: GMX_PROTOCOL_ID,
2316
2326
  chainCategory: "evm",
2317
- description: "Deposit collateral into a GMX GM liquidity pool (ExchangeRouter multicall)",
2327
+ description: "Deposit collateral into a GMX v2.2c GM liquidity pool (ExchangeRouter multicall)",
2318
2328
  commonParams: ["keyGen", "purposeText", "useCustomGas"],
2319
2329
  params: {
2320
2330
  marketSymbol: { type: "string", required: true, description: "GM market symbol e.g. ETH/USD [WETH-USDC]" },
@@ -2326,7 +2336,7 @@ var gmxProtocolModule = {
2326
2336
  id: "gmx.gmWithdraw",
2327
2337
  protocolId: GMX_PROTOCOL_ID,
2328
2338
  chainCategory: "evm",
2329
- description: "Withdraw GM market tokens from a GMX liquidity pool",
2339
+ description: "Withdraw GM market tokens from a GMX v2.2c liquidity pool",
2330
2340
  commonParams: ["keyGen", "purposeText", "useCustomGas"],
2331
2341
  params: {
2332
2342
  marketSymbol: { type: "string", required: true, description: "GM market symbol" },