Query editor
SELECTCOUNT(*) AS total_qualifying_users,ROUND(SUM(total_locked_usd), 0) AS total_tam_90d,ROUND(SUM(total_locked_usd) / 3, 0) AS total_tam_monthly_avg,ROUND(AVG(total_locked_usd), 0) AS avg_locked_per_user,ROUND(MIN(total_locked_usd), 0) AS min_locked_usd,ROUND(MAX(total_locked_usd), 0) AS max_locked_usd,ROUND(SUM(total_locked_usd) * 0.5 / 3, 0) AS borrow_capacity_monthlyFROM (WITHLongTermTrades AS (SELECTcondition_id,maker,amount,token_outcome,question,event_market_nameFROM polymarket_polygon.market_tradesWHEREblock_time >= NOW() - INTERVAL '90' dayAND event_market_name NOT LIKE '%Up or Down%'AND question NOT LIKE '%Up or Down%'AND maker NOT IN (0xc5d563a36ae78145c45a50134d48a1215220f80a,0x4bfb41d5b3570defd03c39a9a4d8de6bd8b8982e)),-- 改动:SUM(amount) 替代 ABS(YES - NO)-- Yes和No是独立ERC-1155 token,各自可单独抵押GrossPositions AS (SELECTmaker AS user_address,condition_id,SUM(amount) AS gross_exposureFROM LongTermTradesGROUP BY maker, condition_id),UserProfile AS (SELECTuser_address,SUM(gross_exposure) AS total_locked_exposureFROM GrossPositionsGROUP BY user_addressHAVING SUM(gross_exposure) > 50000),RankedUsers AS (SELECTuser_address,ROUND(total_locked_exposure, 0) AS total_locked_usd,ROUND(total_locked_exposure * 0.5, 0) AS estimated_borrow_capacityFROM UserProfile)SELECT total_locked_usd FROM RankedUsers)