@sodax/sdk 1.5.4-beta → 1.5.6-beta

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.cjs CHANGED
@@ -8744,7 +8744,7 @@ var universalRouterAbi = [
8744
8744
  ];
8745
8745
 
8746
8746
  // ../types/dist/constants/index.js
8747
- var CONFIG_VERSION = 39;
8747
+ var CONFIG_VERSION = 40;
8748
8748
  var AVALANCHE_MAINNET_CHAIN_ID = "0xa86a.avax";
8749
8749
  var ARBITRUM_MAINNET_CHAIN_ID = "0xa4b1.arbitrum";
8750
8750
  var BASE_MAINNET_CHAIN_ID = "0x2105.base";
@@ -9885,7 +9885,7 @@ var spokeChainConfig = {
9885
9885
  },
9886
9886
  [BITCOIN_MAINNET_CHAIN_ID]: {
9887
9887
  addresses: {
9888
- assetManager: "bc1pxguu2r4p9jcxp3gj7dh4r4jd9qzccwpyap3nj5nlapy28s76lhrqw522fz"
9888
+ assetManager: "bc1pcz4pyrfgv7v6tx8a404mafyvt73cnm80yuv8tqwrywxmqxpja8ys4pjyl5"
9889
9889
  },
9890
9890
  chain: baseChainInfo[BITCOIN_MAINNET_CHAIN_ID],
9891
9891
  bnUSD: "no",
@@ -11691,10 +11691,10 @@ var swapSupportedTokens = {
11691
11691
  spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.WAL
11692
11692
  ],
11693
11693
  [INJECTIVE_MAINNET_CHAIN_ID]: [
11694
- // spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
11695
- // spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
11696
- // spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC,
11697
- spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.SODA
11694
+ spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
11695
+ spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
11696
+ spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC
11697
+ // spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.SODA, // NOTE: not in solver wiki
11698
11698
  ],
11699
11699
  [NEAR_MAINNET_CHAIN_ID]: [
11700
11700
  spokeChainConfig[NEAR_MAINNET_CHAIN_ID].supportedTokens.NEAR,
@@ -35085,7 +35085,7 @@ var AssetService = class {
35085
35085
  });
35086
35086
  }
35087
35087
  };
35088
- var ClService = class {
35088
+ var ClService = class _ClService {
35089
35089
  config;
35090
35090
  relayerApiEndpoint;
35091
35091
  hubProvider;
@@ -36103,6 +36103,68 @@ var ClService = class {
36103
36103
  );
36104
36104
  return amount0;
36105
36105
  }
36106
+ /**
36107
+ * Calculate amount0Max and amount1Max for a given liquidity and slippage tolerance.
36108
+ * For concentrated liquidity, a price drop increases the amount0 needed and a price rise increases the amount1 needed.
36109
+ * This calculates the worst-case amounts for each token independently.
36110
+ */
36111
+ static calculateMaxAmountsForSlippage(liquidity, tickLower, tickUpper, currentTick, sqrtPriceX96, slippagePercent) {
36112
+ const amount0AtCurrent = v3Sdk.PositionMath.getToken0Amount(
36113
+ Number(currentTick),
36114
+ Number(tickLower),
36115
+ Number(tickUpper),
36116
+ sqrtPriceX96,
36117
+ liquidity
36118
+ );
36119
+ const amount1AtCurrent = v3Sdk.PositionMath.getToken1Amount(
36120
+ Number(currentTick),
36121
+ Number(tickLower),
36122
+ Number(tickUpper),
36123
+ sqrtPriceX96,
36124
+ liquidity
36125
+ );
36126
+ const SLIPPAGE_SCALE = 1000000000n;
36127
+ const slippageScaled = BigInt(Math.round(slippagePercent * Number(SLIPPAGE_SCALE) / 100));
36128
+ const sqrtPriceX96Squared = sqrtPriceX96 * sqrtPriceX96;
36129
+ const sqrtPriceX96Down = _ClService.sqrtBigInt(
36130
+ sqrtPriceX96Squared * (SLIPPAGE_SCALE - slippageScaled) / SLIPPAGE_SCALE
36131
+ );
36132
+ const sqrtPriceX96Up = _ClService.sqrtBigInt(
36133
+ sqrtPriceX96Squared * (SLIPPAGE_SCALE + slippageScaled) / SLIPPAGE_SCALE
36134
+ );
36135
+ const tickDown = v3Sdk.TickMath.getTickAtSqrtRatio(sqrtPriceX96Down);
36136
+ const tickUp = v3Sdk.TickMath.getTickAtSqrtRatio(sqrtPriceX96Up);
36137
+ const amount0AtPriceDrop = v3Sdk.PositionMath.getToken0Amount(
36138
+ tickDown,
36139
+ Number(tickLower),
36140
+ Number(tickUpper),
36141
+ sqrtPriceX96Down,
36142
+ liquidity
36143
+ );
36144
+ const amount1AtPriceRise = v3Sdk.PositionMath.getToken1Amount(
36145
+ tickUp,
36146
+ Number(tickLower),
36147
+ Number(tickUpper),
36148
+ sqrtPriceX96Up,
36149
+ liquidity
36150
+ );
36151
+ const amount0Max = amount0AtPriceDrop > amount0AtCurrent ? amount0AtPriceDrop : amount0AtCurrent;
36152
+ const amount1Max = amount1AtPriceRise > amount1AtCurrent ? amount1AtPriceRise : amount1AtCurrent;
36153
+ return { amount0Max, amount1Max };
36154
+ }
36155
+ /**
36156
+ * Integer square root via Newton's method. Returns floor(sqrt(n)).
36157
+ */
36158
+ static sqrtBigInt(n) {
36159
+ if (n < 0n) throw new Error("sqrtBigInt: negative input");
36160
+ if (n < 2n) return n;
36161
+ let x = 1n << (BigInt(n.toString(2).length) + 1n) / 2n;
36162
+ while (true) {
36163
+ const next = (x + n / x) / 2n;
36164
+ if (next >= x) return x;
36165
+ x = next;
36166
+ }
36167
+ }
36106
36168
  /**
36107
36169
  * Helper: Convert price to nearest valid tick
36108
36170
  * @param price - The price as a number