Query editor
with raw as (selects.contract_address as slip_token,s.symbol as slip_symbol,s.amount_raw as slip_amount_raw,s.amount as slip_amount,s.price_usd as slip_token_price,-- coalesce(s.amount_usd, case when s.contract_address = token_bought_address and token_bought_amount !=0-- then s.amount*t.amount_usd/token_bought_amount-- when s.contract_address = token_sold_address and token_sold_amount !=0-- then s.amount*t.amount_usd/token_sold_amount-- else null end) as slip_usd,coalesce(s.amount_usd, 0) as slip_usd,t.*from zeroex.trades tjoin tokens_base.transfers s on t.tx_hash = s.tx_hashwhere t.blockchain = 'base'-- test-- and t.tx_hash = 0xeccfea79892282b01672008f0841b39bbb16a66bfc41dc2e6af811ad8d71b628and (t.block_date between timestamp '{{start_date}}' and timestamp '{{end_date}}')and (t.block_month between date_trunc('month', timestamp '{{start_date}}') and date_trunc('month', timestamp '{{end_date}}'))-- and s.blockchain = 'base'and (s.block_date between timestamp '{{start_date}}' and timestamp '{{end_date}}')and (s.block_month between date_trunc('month', timestamp '{{start_date}}') and date_trunc('month', timestamp '{{end_date}}'))and s.to = from_hex('{{fee_wallet}}') -- token transfer to pos slip) select tx_from,sum(slip_usd) as total_slip,sum(amount_usd) as total_volume,avg(1.0000*slip_usd / amount_usd) as avg_slip_pct,count(*) as tx_ct,get_href('https://basescan.org/tx/' || cast(max(tx_hash) as varchar), 'BaseScan') as tx_example,min(block_time) as first_ts,max(block_time) as last_tsfrom rawgroup by 1order by 2 desc