Skip to content

Commit dcbf63b

Browse files
authored
fix: tick falsy value (#2816)
1 parent 8d2e3c3 commit dcbf63b

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

packages/pancake-liquidity-widgets/src/components/Content/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export default function Content({
308308
);
309309

310310
useEffect(() => {
311-
if (!tickLower && !tickUpper && pool) selectPriceRange(0.2);
311+
if (tickLower === null && tickUpper === null && pool) selectPriceRange(0.2);
312312
}, [pool, selectPriceRange, tickLower, tickUpper]);
313313

314314
return (

packages/pancake-liquidity-widgets/src/hooks/usePoolInfo/pancakev3.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ export default function usePoolInfo(
7676
const { owner, tickLower, tickUpper, liquidity, token0, token1, fee } =
7777
positionInfo;
7878

79-
if (!tickLower || !tickUpper || !liquidity || !fee) {
79+
if (
80+
(!tickLower && tickLower !== 0) ||
81+
(!tickUpper && tickUpper !== 0) ||
82+
!liquidity ||
83+
!fee
84+
) {
8085
setError(`can't get position info`);
8186
return;
8287
}
@@ -89,16 +94,16 @@ export default function usePoolInfo(
8994
isPancakeV3
9095
? token0
9196
: token0 === PANCAKE_NATIVE_TOKEN_ADDRESS
92-
? NATIVE_TOKEN_ADDRESS
93-
: token0
97+
? NATIVE_TOKEN_ADDRESS
98+
: token0
9499
)?.toLowerCase();
95100

96101
const token1Address = (
97102
isPancakeV3
98103
? token1
99104
: token1 === PANCAKE_NATIVE_TOKEN_ADDRESS
100-
? NATIVE_TOKEN_ADDRESS
101-
: token1
105+
? NATIVE_TOKEN_ADDRESS
106+
: token1
102107
)?.toLowerCase();
103108

104109
if (

packages/pancake-liquidity-widgets/src/hooks/useZapInState.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ export const ZapContextProvider = ({
301301
if (
302302
initTickLower !== undefined &&
303303
initTickLower % pool.tickSpacing === 0 &&
304-
!tickLower
304+
tickLower === null
305305
) {
306306
setTickLower(initTickLower);
307307
}
308308

309309
if (
310310
initTickUpper !== undefined &&
311311
initTickUpper % pool.tickSpacing === 0 &&
312-
!tickUpper
312+
tickUpper === null
313313
) {
314314
setTickUpper(initTickUpper);
315315
}

packages/pancake-liquidity-widgets/src/utils/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ export const getPoolInfo = async ({
357357
if (!fee) return null;
358358

359359
const { sqrtPriceX96, liquidity, tick, tickSpacing } = positionInfo;
360-
if (!sqrtPriceX96 || !liquidity || !tick || !tickSpacing) return null;
360+
if (!sqrtPriceX96 || !liquidity || (!tick && tick !== 0) || !tickSpacing)
361+
return null;
361362

362363
return new Pool(
363364
token0,
@@ -608,7 +609,7 @@ export const getPositionInfo = async ({
608609
number,
609610
number,
610611
number,
611-
bigint
612+
bigint,
612613
];
613614

614615
tickLower = tickLowerFromRpc;
@@ -627,7 +628,7 @@ export const getPositionInfo = async ({
627628
{ currency0: string; currency1: string; fee: number },
628629
number,
629630
number,
630-
bigint
631+
bigint,
631632
];
632633

633634
tickLower = tickLowerFromRpc;

0 commit comments

Comments
 (0)