()
| 316 | }; |
| 317 | |
| 318 | const fetchPortfolio = async () => { |
| 319 | try { |
| 320 | const res = await fetch( |
| 321 | `https://data-api.polymarket.com/value?user=${proxyAddr}`, |
| 322 | { signal: AbortSignal.timeout(8_000) } |
| 323 | ); |
| 324 | if (!res.ok) return; |
| 325 | const data = await res.json(); |
| 326 | const val = Array.isArray(data) |
| 327 | ? data.reduce((s: number, p: { currentValue?: number; value?: number }) => s + (p.currentValue ?? p.value ?? 0), 0) |
| 328 | : (data.portfolioValue ?? data.value ?? null); |
| 329 | if (!cancelled && typeof val === "number") { |
| 330 | setPortfolioValue(val); |
| 331 | try { sessionStorage.setItem("pw:portfolio", String(val)); } catch {} |
| 332 | } |
| 333 | } catch { /* ignore */ } |
| 334 | }; |
| 335 | |
| 336 | fetchBal(); |
| 337 | fetchPortfolio(); |
no outgoing calls
no test coverage detected