@sodax/dapp-kit 1.5.5-beta → 1.5.7-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.mjs CHANGED
@@ -2086,7 +2086,13 @@ function useLiquidityAmounts(minPrice, maxPrice, poolData) {
2086
2086
  }
2087
2087
  try {
2088
2088
  const amount0BigInt = BigInt(Math.floor(amount0 * 10 ** poolData.token0.decimals));
2089
- const amount1BigInt = ClService.calculateAmount1FromAmount0(amount0BigInt, tickLower, tickUpper, currentTick);
2089
+ const amount1BigInt = ClService.calculateAmount1FromAmount0(
2090
+ amount0BigInt,
2091
+ tickLower,
2092
+ tickUpper,
2093
+ currentTick,
2094
+ poolData.sqrtPriceX96
2095
+ );
2090
2096
  const amount1 = Number(amount1BigInt) / 10 ** poolData.token1.decimals;
2091
2097
  setLiquidityToken1Amount(amount1.toFixed(6));
2092
2098
  } catch (err) {
@@ -2108,7 +2114,13 @@ function useLiquidityAmounts(minPrice, maxPrice, poolData) {
2108
2114
  }
2109
2115
  try {
2110
2116
  const amount1BigInt = BigInt(Math.floor(amount1 * 10 ** poolData.token1.decimals));
2111
- const amount0BigInt = ClService.calculateAmount0FromAmount1(amount1BigInt, tickLower, tickUpper, currentTick);
2117
+ const amount0BigInt = ClService.calculateAmount0FromAmount1(
2118
+ amount1BigInt,
2119
+ tickLower,
2120
+ tickUpper,
2121
+ currentTick,
2122
+ poolData.sqrtPriceX96
2123
+ );
2112
2124
  const amount0 = Number(amount0BigInt) / 10 ** poolData.token0.decimals;
2113
2125
  setLiquidityToken0Amount(amount0.toFixed(6));
2114
2126
  } catch (err) {
@@ -2297,24 +2309,29 @@ function createSupplyLiquidityParamsProps({
2297
2309
  const tickSpacing = poolData.tickSpacing;
2298
2310
  const tickLower = ClService.priceToTick(minPriceNum, token0, token1, tickSpacing);
2299
2311
  const tickUpper = ClService.priceToTick(maxPriceNum, token0, token1, tickSpacing);
2300
- const slippageMultiplier = BigInt(Math.floor((100 - slippage) * 100));
2301
- const amount0ForLiquidity = amount0BigInt * slippageMultiplier / 10000n;
2302
- const amount1ForLiquidity = amount1BigInt * slippageMultiplier / 10000n;
2303
2312
  const liquidity = ClService.calculateLiquidityFromAmounts(
2304
- amount0ForLiquidity,
2305
- amount1ForLiquidity,
2313
+ amount0BigInt,
2314
+ amount1BigInt,
2306
2315
  tickLower,
2307
2316
  tickUpper,
2308
2317
  BigInt(poolData.currentTick)
2309
2318
  );
2319
+ const { amount0Max, amount1Max } = ClService.calculateMaxAmountsForSlippage(
2320
+ liquidity,
2321
+ tickLower,
2322
+ tickUpper,
2323
+ BigInt(poolData.currentTick),
2324
+ poolData.sqrtPriceX96,
2325
+ slippage
2326
+ );
2310
2327
  const tokenId = positionId ? BigInt(positionId) : void 0;
2311
2328
  return {
2312
2329
  poolKey,
2313
2330
  tickLower,
2314
2331
  tickUpper,
2315
2332
  liquidity,
2316
- amount0Max: amount0BigInt,
2317
- amount1Max: amount1BigInt,
2333
+ amount0Max,
2334
+ amount1Max,
2318
2335
  sqrtPriceX96: poolData.sqrtPriceX96,
2319
2336
  positionId,
2320
2337
  isValidPosition,