(force = false)
| 301 | let seq = 0; |
| 302 | |
| 303 | const fetchBal = async (force = false) => { |
| 304 | const mySeq = ++seq; |
| 305 | try { |
| 306 | // Public GET endpoint — no auth required, reads on-chain USDC.e balance |
| 307 | const url = `/api/trade/balance?address=${proxyAddr}${force ? "&force=1" : ""}`; |
| 308 | const res = await fetch(url); |
| 309 | if (!res.ok) return; |
| 310 | const data = await res.json(); |
| 311 | if (!cancelled && mySeq === seq && data.balance !== undefined) { |
| 312 | setPolyBalance(data.balance); |
| 313 | try { sessionStorage.setItem("pw:balance", String(data.balance)); } catch {} |
| 314 | } |
| 315 | } catch { /* ignore */ } |
| 316 | }; |
| 317 | |
| 318 | const fetchPortfolio = async () => { |
| 319 | try { |
no outgoing calls
no test coverage detected