Skip to content

Commit

Permalink
don't try to use existing positions when updating store
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Aug 27, 2024
1 parent 9ab7e92 commit 49b1abb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
31 changes: 18 additions & 13 deletions web/src/app/stake/pool/confirm-withdraw/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function ConfirmWithdrawLiquidity() {
if (!address || chainId !== expectedChainId) router.back();
}, [address, expectedChainId, chainId]);

const { token0, token0Amount, token0AmountRaw, token1, token1Amount, delta } =
const { token0, token0Amount, token0AmountRaw, token1, token1Amount, delta, tickLower, tickUpper } =
useStakeStore();

const { positions, updatePositionLocal } = usePositions();
Expand Down Expand Up @@ -139,10 +139,15 @@ export default function ConfirmWithdrawLiquidity() {

useEffect(() => {
if (updatePositionResult.isSuccess) {
const position = positions.find(
(p) => p.positionId === Number(positionId),
);
if (position) {
if (tickLower && tickUpper) {
const position = {
positionId: Number(positionId),
pool: {
token: token0,
},
lower: tickLower,
upper: tickUpper,
};
getUsdTokenAmountsForPosition(
position,
token0,
Expand Down Expand Up @@ -248,10 +253,10 @@ export default function ConfirmWithdrawLiquidity() {
{token0.address === fUSDC.address
? token0Amount
: getFormattedPriceFromAmount(
token0Amount,
tokenPrice,
fUSDC.decimals,
)}
token0Amount,
tokenPrice,
fUSDC.decimals,
)}
</div>
</div>

Expand All @@ -266,10 +271,10 @@ export default function ConfirmWithdrawLiquidity() {
{token1.address === fUSDC.address
? token1Amount
: getFormattedPriceFromAmount(
token1Amount,
tokenPrice,
fUSDC.decimals,
)}
token1Amount,
tokenPrice,
fUSDC.decimals,
)}
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/ConfirmStake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export const ConfirmStake = ({ mode, positionId }: ConfirmStakeProps) => {
if (updatePositionResult.isSuccess) {
const id = positionId ?? Number(mintPositionId);
if (id && tickLower && tickUpper) {
const position = positions.find((p) => p.positionId === id) ?? {
const position = {
positionId: id,
pool: {
token: token0,
Expand Down

0 comments on commit 49b1abb

Please sign in to comment.