diff --git a/src/components/modals/RemoveLiquidityModal/index.tsx b/src/components/modals/RemoveLiquidityModal/index.tsx index 23b716f..39268e9 100644 --- a/src/components/modals/RemoveLiquidityModal/index.tsx +++ b/src/components/modals/RemoveLiquidityModal/index.tsx @@ -3,7 +3,9 @@ import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import { Slider } from "@/components/ui/slider"; import { usePrepareAlgebraPositionManagerMulticall } from "@/generated"; -import { useTransactionAwait } from "@/hooks/common/useTransactionAwait"; +import { farmingClient } from "@/graphql/clients"; +import { Deposit } from "@/graphql/generated/graphql"; +import { useTransitionAwait } from "@/hooks/common/useTransactionAwait"; import { usePosition, usePositions } from "@/hooks/positions/usePositions"; import { useBurnActionHandlers, useBurnState, useDerivedBurnInfo } from "@/state/burnStore"; import { TransactionType } from "@/state/pendingTransactionsStore"; @@ -106,8 +108,38 @@ const RemoveLiquidityModal = ({ positionId }: RemoveLiquidityModalProps) => { useEffect(() => { if (!isSuccess) return; + let interval: NodeJS.Timeout; + + /* pool positions refetch */ Promise.all([refetchPosition(), refetchAllPositions()]) - .then(() => handleCloseModal?.()); + + /* farming deposits refetch */ + .then(() => { + handleCloseModal?.(); + if(sliderValue[0] !== 100) return; + interval = setInterval( + () => + farmingClient.refetchQueries({ + include: ['Deposits'], + onQueryUpdated: (query, { result: diff }) => { + const currentPos = diff.deposits.find( + (deposit: Deposit) => + deposit.id.toString() === positionId.toString() + ); + if (!currentPos) return; + + if (currentPos.eternalFarming === null) { + clearInterval(interval); + } else { + query.refetch().then(); + } + }, + }), + 2000 + ); + }); + + return () => clearInterval(interval); }, [isSuccess]); return @@ -124,26 +156,15 @@ const RemoveLiquidityModal = ({ positionId }: RemoveLiquidityModalProps) => {

{`${sliderValue}%`}

- - - - + {[25, 50, 75, 100].map((v) => ( + + ))}
{ onValueChange={(v) => setSliderValue(v)} className="[&_[role=slider]]:h-4 [&_[role=slider]]:w-4" aria-label="Liquidity Percent" + disabled={isRemoveLoading} />