0x94e34878a1BbEeb628E457845271B0cDa8E2230dvolumeAllTakers (range of blocks)
    Updated 2024-07-23
    with all_trades as (
    select
    tr1.tx_hash,
    lo.block_number,
    tr1.symbol as in_token,
    tr2.symbol as out_token,
    tr1.AMOUNT_USD as amount_in,
    tr2.AMOUNT_USD as amount_out,
    lo.decoded_log:taker as taker,
    CASE
    when amount_in is not null then amount_in
    else amount_out
    end as volume_usd
    from
    blast.core.ez_decoded_event_logs lo
    left join blast.core.ez_token_transfers tr1 on lo.tx_hash = tr1.tx_hash
    left join blast.core.ez_token_transfers tr2 on tr1.tx_hash = tr2.tx_hash
    where
    lo.contract_address = '0xb1a49c54192ea59b233200ea38ab56650dfb448c'
    and lo.event_name = 'OrderComplete'
    and tr1.from_Address = tr1.origin_from_address
    and tr1.to_Address = '0xb1a49c54192ea59b233200ea38ab56650dfb448c'
    and tr2.from_Address = '0xb1a49c54192ea59b233200ea38ab56650dfb448c'
    and tr2.to_Address = tr2.origin_from_address -- blocks on excel 3719373 and 3979093 (last snapshot)
    and lo.block_number between {{start_block}} and {{end_block}} -- specify the block range here
    )
    select
    taker,
    sum(case when block_number between {{start_block}} and {{end_block}} then volume_usd else 0 end) as block_range_vol,
    avg(block_vol) as avg_vol_per_block,
    count(case when block_number between {{start_block}} and {{end_block}} then tx_hash else null end) as block_range_tx,
    avg(block_tx) as avg_tx_per_block,
    round(100.0 * sum(case when block_number between {{start_block}} and {{end_block}} then volume_usd else 0 end) /
    sum(sum(case when block_number between {{start_block}} and {{end_block}} then volume_usd else 0 end)) over (), 2) as market_share_pct
    from (
    select
    QueryRunArchived: QueryRun has been archived