Query editor
-- FOMO trader PnL v5 (last 90 days, USD mark-to-market)---- Changes from the reviewed version (only one substantive):-- 1. Wallets with unpriced router fees are KEPT (fee treated as $0,-- count disclosed) instead of excluded. If FOMO ever collects fees-- in the traded token itself, unpriced fees would correlate with-- trading obscure/rugged tokens - excluding those wallets would be-- the same survivorship bias removed elsewhere. The error from a-- $0 fee is bounded and tiny; the bias from exclusion is not.-- 2. Comment noting the amount_display fallback if that column errors.---- Accepted from the reviewed version:-- - Stablecoin router fees valued at face amount (fewer NULL fees)-- - Unpriced legs kept for position deltas, required only for cash flow-- (fixes phantom positions from dropping NULL-amount_usd legs)-- - Missing START basis => wallet excluded: these are mostly airdrop /-- transfer-in recipients whose cost basis is unknowable; zero-costing-- them manufactures profit-- - Unpriced quote-boundary cash legs => wallet excluded (unmeasurable)-- - start_prices capped at window start (no look-ahead)-- - Headline labeled pre-network-fee---- Missing end price => position valued at $0 (dead/rug proxy), disclosed.WITHparams AS (SELECTNOW() - INTERVAL '90' DAY AS start_time,NOW() AS end_time,DATE(NOW() - INTERVAL '90' DAY) AS start_day),quote_assets(mint) AS (VALUES('So11111111111111111111111111111111111111112'), -- Wrapped SOL('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), -- USDC('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') -- USDT),router_transfers AS (SELECTtr.tx_id,tr.from_owner AS trader,-- Stables valued at face amount; if amount_display errors on-- your engine, substitute tr.amount / 1e6 for these two mints.CASEWHEN tr.token_mint_address IN ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') THEN tr.amount_displayELSE tr.amount_usdEND AS router_fee_usdFROM tokens_solana.transfers trCROSS JOIN params pWHERE tr.to_owner = 'R4rNJHaffSUotNmqSKNEfDcJE8A7zJUkaoM5Jkd7cYX'AND tr.from_owner IS NOT NULLAND tr.from_owner <> 'R4rNJHaffSUotNmqSKNEfDcJE8A7zJUkaoM5Jkd7cYX'AND tr.action = 'transfer'AND tr.block_time >= p.start_timeAND tr.block_time < p.end_time