Query editor
/*Query outputs the following daily claim stats, given claim is a part of the token distribution strategy:- amount of token claimed- new wallets which claimed the token for the first time (in case the same wallet can claim more than once)- cumulative amount of token claimed- cumulative new wallets which claimed the token for the first time- share of the token claimed (i.e. cumulatively claimed amount / total amount allocated for the claim)- total amount allocated for the claim (set by the dashboard user via total_vol_to_claim, fixed over time)- share of the token staked on behalf which is technically considered as a part of claiming: i.e. those agreed to gettheir token staked on behalf are considered as if thy "claimed" it*/WITH-- 1. Fetching MIN and MAX days for the claim contractclaim_range AS (SELECTCAST(MIN(DATE_TRUNC('day', a.evt_block_time)) AS DATE) AS start_date,CAST(MAX(DATE_TRUNC('day', a.evt_block_time)) AS DATE) AS end_dateFROM erc20_{{blockchain}}.evt_transfer aJOIN {{blockchain}}.transactions bON a.evt_tx_hash = b.hashWHERE a.contract_address = {{token_address}}AND a."from" = {{claim_contract_address_now}}AND CAST(b.data AS VARCHAR) LIKE '%{{claim_method_id_now}}%'),-- 2. Generating time series with 1-day intervalstime_series AS (SELECT DATE_TRUNC('day', time) AS dayFROM UNNEST(SEQUENCE((SELECT start_date FROM claim_range),(SELECT end_date FROM claim_range),INTERVAL '1' DAY)) AS s(time)),-- 3. Calculating claimed volume per dayclaim_vol AS (SELECTSUM(a.value/1e18) AS amt_claimed,AVG(a.value/1e18) AS avg_amt_claimed,APPROX_PERCENTILE(a.value/1e18, 0.5) AS med_amt_claimed,DATE_TRUNC('day', a.evt_block_time) AS dayFROM erc20_{{blockchain}}.evt_transfer aJOIN {{blockchain}}.transactions bON a.evt_tx_hash = b.hashWHERE a.contract_address = {{token_address}}AND a."from" = {{claim_contract_address_now}}AND CAST(b.data AS VARCHAR) LIKE '%{{claim_method_id_now}}%'GROUP BY DATE_TRUNC('day', a.evt_block_time)),-- 2. Idenfitying the first claim day for each walletfirst_claims AS (SELECTa."to" AS claimer,MIN(DATE_TRUNC('day', a.evt_block_time)) AS first_claim_dayFROM erc20_{{blockchain}}.evt_transfer aJOIN {{blockchain}}.transactions bON a.evt_tx_hash = b.hashWHERE a.contract_address = {{token_address}}AND a."from" = {{claim_contract_address_now}}AND CAST(b.data AS VARCHAR) LIKE '%{{claim_method_id_now}}%'