Query editor
-- GT Airdrop | STEP 3 FINAL - per-wallet airdrop statistics and eligibility.---- References STEP 2 FINAL (query 8936214), which already has Dolomite re-attributed and-- merged into each wallet's position. Nothing Dolomite-specific is needed here: the merge-- happens upstream, so these are the same rules the task describes.---- query_8936214 = per wallet / per day staked GMX at 00:00 UTC (direct + Dolomite, merged)-- columns: account, "date", total_staked---- RULES FROM THE TASK-- Snapshot period : 2026-10-01 00:00 UTC .. 2026-11-01 00:00 UTC (31 days max)-- Daily average : sum of the daily snapshots / number of elapsed snapshot days-- Condition 1 : staked GMX at the end of the period >= daily average-- Condition 2 : daily average >= 100 staked GMX-- Allocation : 1 GT per daily-average staked GMX (1:1), eligible wallets only---- DYNAMIC DIVISOR (min(elapsed days, 31))-- LEAST(DATE_DIFF('day', DATE '2026-10-01', CURRENT_DATE) + 1, 31)-- CURRENT_DATE 2026-10-01 -> min(1, 31) = 1-- CURRENT_DATE 2026-10-09 -> min(9, 31) = 9-- CURRENT_DATE 2026-11-01 -> min(32, 31) = 31-- CURRENT_DATE 2026-11-15 -> min(46, 31) = 31-- So the average is always taken over the days that actually exist and never diluted by-- days still in the future. From 2026-11-01 it is frozen at 31.---- OUTPUT (4 columns)-- account wallet address-- daily_avg_staked_gmx sum of the daily snapshots / snapshot_days-- staked_gmx_end_of_period balance at the latest snapshot (00:00 UTC) - Condition 1 basis-- gt_allocation = daily_avg_staked_gmx (1 GT per staked GMX, 1:1)---- TOLERANCE ON CONDITION 1-- Balances are IEEE-754 doubles, so SUM(x)/n is not exactly the same object as the last x.-- A wallet whose balance is flat all period has end == average mathematically but can land-- a few 1e-11 below it in floating point. Measured: -5.8e-11 on a 342,170 GMX balance,-- -2.9e-11 on 133,486, -1.5e-11 on 118,090 - all would have been wrongly dropped. Condition-- 1 therefore uses a 1e-6 GMX tolerance: seven orders above the noise, far below any-- meaningful GMX amount.---- Dropping the WHERE clause returns every wallet instead of the eligible set only.WITH params AS (SELECT-- min(elapsed days, 31): 1 on 2026-10-01, 9 on 2026-10-09, 31 from 2026-11-01 onwardLEAST(DATE_DIFF('day', DATE '2026-10-01', CURRENT_DATE) + 1, 31) AS snapshot_days, 1e-6 AS condition_tolerance), per_wallet AS (SELECTaccount, SUM(total_staked) AS sum_staked_gmx, MAX_BY(total_staked, "date") AS staked_gmx_end_of_periodFROM query_8936214GROUP BY account), stats AS (SELECTw.account