MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / fetchPortfolio

Function fetchPortfolio

src/components/WalletButton.tsx:318–334  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 2

WalletButtonFunction · 0.85
onRefreshEvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected