@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.js CHANGED
@@ -2092,7 +2092,13 @@ function useLiquidityAmounts(minPrice, maxPrice, poolData) {
2092
2092
  }
2093
2093
  try {
2094
2094
  const amount0BigInt = BigInt(Math.floor(amount0 * 10 ** poolData.token0.decimals));
2095
- const amount1BigInt = sdk.ClService.calculateAmount1FromAmount0(amount0BigInt, tickLower, tickUpper, currentTick);
2095
+ const amount1BigInt = sdk.ClService.calculateAmount1FromAmount0(
2096
+ amount0BigInt,
2097
+ tickLower,
2098
+ tickUpper,
2099
+ currentTick,
2100
+ poolData.sqrtPriceX96
2101
+ );
2096
2102
  const amount1 = Number(amount1BigInt) / 10 ** poolData.token1.decimals;
2097
2103
  setLiquidityToken1Amount(amount1.toFixed(6));
2098
2104
  } catch (err) {
@@ -2114,7 +2120,13 @@ function useLiquidityAmounts(minPrice, maxPrice, poolData) {
2114
2120
  }
2115
2121
  try {
2116
2122
  const amount1BigInt = BigInt(Math.floor(amount1 * 10 ** poolData.token1.decimals));
2117
- const amount0BigInt = sdk.ClService.calculateAmount0FromAmount1(amount1BigInt, tickLower, tickUpper, currentTick);
2123
+ const amount0BigInt = sdk.ClService.calculateAmount0FromAmount1(
2124
+ amount1BigInt,
2125
+ tickLower,
2126
+ tickUpper,
2127
+ currentTick,
2128
+ poolData.sqrtPriceX96
2129
+ );
2118
2130
  const amount0 = Number(amount0BigInt) / 10 ** poolData.token0.decimals;
2119
2131
  setLiquidityToken0Amount(amount0.toFixed(6));
2120
2132
  } catch (err) {
@@ -2303,24 +2315,29 @@ function createSupplyLiquidityParamsProps({
2303
2315
  const tickSpacing = poolData.tickSpacing;
2304
2316
  const tickLower = sdk.ClService.priceToTick(minPriceNum, token0, token1, tickSpacing);
2305
2317
  const tickUpper = sdk.ClService.priceToTick(maxPriceNum, token0, token1, tickSpacing);
2306
- const slippageMultiplier = BigInt(Math.floor((100 - slippage) * 100));
2307
- const amount0ForLiquidity = amount0BigInt * slippageMultiplier / 10000n;
2308
- const amount1ForLiquidity = amount1BigInt * slippageMultiplier / 10000n;
2309
2318
  const liquidity = sdk.ClService.calculateLiquidityFromAmounts(
2310
- amount0ForLiquidity,
2311
- amount1ForLiquidity,
2319
+ amount0BigInt,
2320
+ amount1BigInt,
2312
2321
  tickLower,
2313
2322
  tickUpper,
2314
2323
  BigInt(poolData.currentTick)
2315
2324
  );
2325
+ const { amount0Max, amount1Max } = sdk.ClService.calculateMaxAmountsForSlippage(
2326
+ liquidity,
2327
+ tickLower,
2328
+ tickUpper,
2329
+ BigInt(poolData.currentTick),
2330
+ poolData.sqrtPriceX96,
2331
+ slippage
2332
+ );
2316
2333
  const tokenId = positionId ? BigInt(positionId) : void 0;
2317
2334
  return {
2318
2335
  poolKey,
2319
2336
  tickLower,
2320
2337
  tickUpper,
2321
2338
  liquidity,
2322
- amount0Max: amount0BigInt,
2323
- amount1Max: amount1BigInt,
2339
+ amount0Max,
2340
+ amount1Max,
2324
2341
  sqrtPriceX96: poolData.sqrtPriceX96,
2325
2342
  positionId,
2326
2343
  isValidPosition,