📌 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
🔒 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
📌 Description
SettlementsPanel(src/components/SettlementsPanel.tsx) fetches pools via a dedicateduseEffect(() => { ... fetchPools(...) ... }, [])with an EMPTY dependency array, storing the result inpoolsstate and derivingavailableLiquidityfrom it viauseMemo. ThisavailableLiquidityis passed intoSettlementFormto validate a proposed amount against real liquidity (SettlementForm'svalidate()rejects an amount exceedingavailableLiquidity[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/availableLiquiditykeeps 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
availableLiquidity) whenever a settlement action that plausibly changes liquidity succeeds — at minimum afteropen()(which reserves liquidity) and aftercancelSettlement(which releases it).🛠️ Suggested execution
src/components/SettlementsPanel.tsxinto a reusable function (or reuseuseAsync'sreload/refresh) that can be called both on mount and after a settlement action settles successfully.open()'srun(...)succeeds and after a successfulcancelSettlementviarunSettlementAction.src/components/SettlementsPanel.test.tsxwith a test assertingfetchPoolsis called again after opening (or cancelling) a settlement, not just once on mount.✅ Acceptance criteria
availableLiquidityis refreshed after settlement actions that change liquidity, not only once on mount.🔒 Security notes
No new attack surface; the backend remains authoritative — this only keeps a client-side convenience check from going stale.
📋 Guidelines