Moe0avavaav
    Updated 2023-01-26
    --0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e




    (select
    'SWAP' as action,
    date_trunc({{scale}},block_timestamp) as date,
    count (distinct tx_hash) as txns,
    sum(txns)over( order by date rows between unbounded preceding and current row ) as cumulative_txns,
    count (distinct origin_from_address) as wallets,
    sum(wallets)over( order by date rows between unbounded preceding and current row ) as cumulative_wallets,
    sum (event_inputs:value/1e6) as value,
    sum(value)over( order by date rows between unbounded preceding and current row ) as cumulative_value,
    avg (event_inputs:value/1e6) as avg_value,
    median (event_inputs:value/1e6) as median_value,
    max (event_inputs:value/1e6) as max_value,
    txns / wallets as txn_per_wallet,
    value / wallets as value_per_wallet
    from avalanche.core.fact_event_logs
    where contract_address = '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e'
    and event_inputs:value/1e6 < 1e9
    and tx_hash in (select tx_hash from avalanche.core.fact_event_logs
    where event_name ilike 'Swap'
    )
    and block_timestamp >= '2022-07-01'
    and tx_status = 'SUCCESS'
    group by date)

    union all


    (select
    'TRANSFER' as action,
    date_trunc({{scale}},block_timestamp) as date,
    count (distinct tx_hash) as txns,
    Run a query to Download Data