Skip to content

Commit

Permalink
add curTick to prices dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Jun 27, 2024
1 parent 0701f4f commit e0fe630
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions web/src/components/StakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {
setQuotedToken(quotedToken)
}

// The tick spacing will determine how granular the graph is.
const { data: curTickNum } = useSimulateContract({
address: ammAddress,
abi: seawaterContract.abi,
functionName: "curTick",
args: [token0.address],
});
const curTick = useMemo(() => ({ result: BigInt(curTickNum?.result ?? 0) }), [curTickNum]);


useEffect(() => {
if (!token0AmountRaw || !curTick || tickLower === undefined || tickUpper === undefined)
return
Expand Down Expand Up @@ -252,6 +262,7 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {
token1AmountRaw,
tokenPrice,
quotedToken,
curTick,
tickUpper,
tickLower,
]);
Expand All @@ -262,15 +273,6 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {
setToken1AmountRaw(token1Balance?.value.toString() ?? token1Amount ?? "0")
}

// The tick spacing will determine how granular the graph is.
const { data: curTickNum } = useSimulateContract({
address: ammAddress,
abi: seawaterContract.abi,
functionName: "curTick",
args: [token0.address],
});
const curTick = useMemo(() => ({ result: BigInt(curTickNum?.result ?? 0) }), [curTickNum]);

const [liquidityRangeType, setLiquidityRangeType] = useState<
"full-range" | "auto" | "custom"
>("auto");
Expand Down

0 comments on commit e0fe630

Please sign in to comment.