Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0
Why this matters
useDepositToPool (useApi.ts:1569) and useWithdrawFromPool (useApi.ts:1639) carry full optimistic-update/rollback logic, but their mutationFn only calls /pool/build-deposit / /pool/build-withdraw which return an UNSIGNED xdr (lines 1581,1651) - no signing or submission happens in the mutation. onMutate optimistically increments pool.stats.totalDeposits and depositor.depositAmount (lines 1598-1610), then onSettled immediately invalidates pool.stats and pool.depositor (lines 1627-1630), refetching the pre-deposit server values and wiping the optimistic bump within ~one round-trip - all before useDepositOperation even calls signTransaction/submitPoolTransaction (useRepaymentOperation.ts:160-163). Net effect: the user briefly sees an inflated pool/portfolio balance that does not correspond to any settled (or even signed) deposit, and if they then reject the wallet signature the number still flickered up with no deposit; onError rollback (lines 1615-1625) only covers a failed build, never a failed sign/submit.
Acceptance criteria
Files to touch
frontend/src/app/hooks/useApi.ts
frontend/src/app/hooks/useRepaymentOperation.ts
Out of scope
- The unused useRepayLoan optimistic hook (defined but never imported)
Why this matters
useDepositToPool (useApi.ts:1569) and useWithdrawFromPool (useApi.ts:1639) carry full optimistic-update/rollback logic, but their mutationFn only calls /pool/build-deposit / /pool/build-withdraw which return an UNSIGNED xdr (lines 1581,1651) - no signing or submission happens in the mutation. onMutate optimistically increments pool.stats.totalDeposits and depositor.depositAmount (lines 1598-1610), then onSettled immediately invalidates pool.stats and pool.depositor (lines 1627-1630), refetching the pre-deposit server values and wiping the optimistic bump within ~one round-trip - all before useDepositOperation even calls signTransaction/submitPoolTransaction (useRepaymentOperation.ts:160-163). Net effect: the user briefly sees an inflated pool/portfolio balance that does not correspond to any settled (or even signed) deposit, and if they then reject the wallet signature the number still flickered up with no deposit; onError rollback (lines 1615-1625) only covers a failed build, never a failed sign/submit.
Acceptance criteria
Files to touch
frontend/src/app/hooks/useApi.tsfrontend/src/app/hooks/useRepaymentOperation.tsOut of scope