diff --git a/src/components/Swap/Swap.tsx b/src/components/Swap/Swap.tsx index 2a6c1b66..689a4020 100644 --- a/src/components/Swap/Swap.tsx +++ b/src/components/Swap/Swap.tsx @@ -748,7 +748,7 @@ export const Swap: React.FC = ({ onSwap( simulateResult.poolKey, - BigInt((+slippTolerance * Number(PERCENTAGE_DENOMINATOR)) / 100), + BigInt(Math.round((+slippTolerance * Number(PERCENTAGE_DENOMINATOR)) / 100)), simulateResult.targetSqrtPrice, tokenFrom, tokenTo, @@ -777,7 +777,7 @@ export const Swap: React.FC = ({ onSwap( simulateResult.poolKey, - BigInt((+slippTolerance * Number(PERCENTAGE_DENOMINATOR)) / 100), + BigInt(Math.round((+slippTolerance * Number(PERCENTAGE_DENOMINATOR)) / 100)), simulateResult.targetSqrtPrice, tokenFrom, tokenTo, diff --git a/src/store/sagas/swap.ts b/src/store/sagas/swap.ts index 1675fa7a..32d2bbbf 100644 --- a/src/store/sagas/swap.ts +++ b/src/store/sagas/swap.ts @@ -303,7 +303,7 @@ export function* handleGetSimulateResult(action: PayloadAction) { byAmountIn, xToY ? MIN_SQRT_PRICE : MAX_SQRT_PRICE ) - console.log(result) + if (result.maxSwapStepsReached || result.globalInsufficientLiquidity) { if ( byAmountIn @@ -312,7 +312,6 @@ export function* handleGetSimulateResult(action: PayloadAction) { ) { insufficientLiquidityAmountOut = byAmountIn ? result.amountOut : result.amountIn fee = pool.poolKey.feeTier.fee - priceImpact = 1 errors.push(SwapError.MaxSwapStepsReached) } @@ -351,7 +350,7 @@ export function* handleGetSimulateResult(action: PayloadAction) { actions.setSimulateResult({ poolKey: swapPossible ? poolKey : null, amountOut: validatedAmountOut, - priceImpact, + priceImpact: swapPossible ? priceImpact : 1, targetSqrtPrice, fee, errors