Skip to content

SettlementsPanel's available-liquidity data is fetched once on mount and never refreshed after settlement actions #256

Description

@Jagadeeshftw

📌 Description

SettlementsPanel (src/components/SettlementsPanel.tsx) fetches pools via a dedicated useEffect(() => { ... fetchPools(...) ... }, []) with an EMPTY dependency array, storing the result in pools state and deriving availableLiquidity from it via useMemo. This availableLiquidity is passed into SettlementForm to validate a proposed amount against real liquidity (SettlementForm's validate() rejects an amount exceeding availableLiquidity[asset]). However, opening, executing, or cancelling a settlement (open/runSettlementAction) never re-triggers this pools fetch — only the settlements list itself is reloaded/patched. After a settlement reserves or releases liquidity, pools/availableLiquidity keeps showing the figures from whenever the panel first mounted, so the client-side "Amount exceeds available liquidity" check can pass or fail based on stale numbers that no longer match the backend's actual liquidity state.

🧩 Requirements and context

  • Re-fetch pools (or otherwise refresh availableLiquidity) whenever a settlement action that plausibly changes liquidity succeeds — at minimum after open() (which reserves liquidity) and after cancelSettlement (which releases it).
  • The refresh should not block or visually disrupt the settlements list/table; it can run in the background the same way the initial pools fetch does.
  • This is a client-side-only validation aid — the backend remains the source of truth and will still reject an over-limit amount regardless of this fix; the goal is keeping the friendlier client-side check reasonably fresh.

🛠️ Suggested execution

  • Extract the pools-fetching logic in src/components/SettlementsPanel.tsx into a reusable function (or reuse useAsync's reload/refresh) that can be called both on mount and after a settlement action settles successfully.
  • Call that refresh after open()'s run(...) succeeds and after a successful cancelSettlement via runSettlementAction.
  • Extend src/components/SettlementsPanel.test.tsx with a test asserting fetchPools is called again after opening (or cancelling) a settlement, not just once on mount.

✅ Acceptance criteria

  • availableLiquidity is refreshed after settlement actions that change liquidity, not only once on mount.
  • The refresh happens silently, without disrupting the visible settlements table.
  • Test coverage for the refresh being triggered by a settlement action.

🔒 Security notes

No new attack surface; the backend remains authoritative — this only keeps a client-side convenience check from going stale.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26bugSomething isn't workingfrontendFrontend / UI work

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions