const KEY = process.env.POLYNODE_KEY;
async function walletTrades(wallet, limit = 100, offset = 0) {
const url = `https://api.polynode.dev/clobv2/wallets/${wallet}/trades?limit=${limit}&offset=${offset}`;
const resp = await fetch(url, { headers: { 'x-api-key': KEY } });
if (!resp.ok) throw new Error(`${resp.status} ${await resp.text()}`);
return resp.json();
}
// Total USDC traded by wallet across all fills
const all = [];
for (let offset = 0; ; offset += 1000) {
const page = await walletTrades('0xd663f0f56e5c80d4716d46c776fabb4ec4c66abc', 1000, offset);
all.push(...page.trades);
if (page.trades.length < 1000) break;
}
const totalUsd = all.reduce((acc, t) => acc + Number(t.amount_usd || 0), 0);
console.log(`${all.length} trades, $${totalUsd.toFixed(2)} total notional`);