@sodax/dapp-kit 1.5.5-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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sodax/dapp-kit",
3
3
  "license": "MIT",
4
- "version": "1.5.5-beta",
4
+ "version": "1.5.6-beta",
5
5
  "description": "dapp-kit of New World",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "viem": "2.29.2",
19
- "@sodax/sdk": "1.5.5-beta",
20
- "@sodax/types": "1.5.5-beta"
19
+ "@sodax/sdk": "1.5.6-beta",
20
+ "@sodax/types": "1.5.6-beta"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "19.0.8",
@@ -124,20 +124,26 @@ export function createSupplyLiquidityParamsProps({
124
124
  const tickLower = ClService.priceToTick(minPriceNum, token0, token1, tickSpacing);
125
125
  const tickUpper = ClService.priceToTick(maxPriceNum, token0, token1, tickSpacing);
126
126
 
127
- // Apply slippage BEFORE calculating liquidity
128
- const slippageMultiplier = BigInt(Math.floor((100 - slippage) * 100)); // e.g., 0.5% => 9950
129
-
130
- const amount0ForLiquidity = (amount0BigInt * slippageMultiplier) / 10000n;
131
- const amount1ForLiquidity = (amount1BigInt * slippageMultiplier) / 10000n;
132
-
133
- // Calculate liquidity based on reduced amounts (accounting for slippage)
127
+ // Calculate liquidity from full amounts (the desired deposit)
134
128
  const liquidity = ClService.calculateLiquidityFromAmounts(
135
- amount0ForLiquidity,
136
- amount1ForLiquidity,
129
+ amount0BigInt,
130
+ amount1BigInt,
137
131
  tickLower,
138
132
  tickUpper,
139
133
  BigInt(poolData.currentTick),
140
134
  );
135
+
136
+ // Apply slippage to get max amounts — the ceiling the contract is allowed to pull.
137
+ // If price moves unfavorably, the contract may need slightly more tokens than expected.
138
+ const { amount0Max, amount1Max } = ClService.calculateMaxAmountsForSlippage(
139
+ liquidity,
140
+ tickLower,
141
+ tickUpper,
142
+ BigInt(poolData.currentTick),
143
+ poolData.sqrtPriceX96,
144
+ slippage,
145
+ );
146
+
141
147
  const tokenId = positionId ? BigInt(positionId) : undefined;
142
148
 
143
149
  return {
@@ -145,8 +151,8 @@ export function createSupplyLiquidityParamsProps({
145
151
  tickLower,
146
152
  tickUpper,
147
153
  liquidity,
148
- amount0Max: amount0BigInt,
149
- amount1Max: amount1BigInt,
154
+ amount0Max,
155
+ amount1Max,
150
156
  sqrtPriceX96: poolData.sqrtPriceX96,
151
157
  positionId,
152
158
  isValidPosition,