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, 0) as slip_usd,-- 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,t.*from zeroex.trades tjoin tokens_base.transfers s on t.tx_hash = s.tx_hashwhere t.blockchain = 'base'and t.tx_from = from_hex('{{taker}}')and (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.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 count(distinct tx_hash) as tip_ct,sum(slip_usd) as total_tip,max(slip_usd) as tip_max,sum(amount_usd) as total_volume,avg(100.00*slip_usd/amount_usd) as tip_pct,max(100.00*slip_usd/amount_usd) as tip_pct_maxfrom raw