adriaparcerisasavalanche euro platforms 1.5
    Updated 2024-05-08

    with
    t1 as (
    select trunc(block_timestamp,'week') as date,
    platform,
    count(distinct tx_hash) as txs,
    sum(txs) over (partition by platform order by date) as cum_txs,
    count(distinct origin_from_address) as users,
    sum(case when token_in = lower('0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD') then amount_in else amount_out end) as volume,
    avg(case when token_in = lower('0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD') then amount_in else amount_out end) as avg_volume,
    avg(avg_volume) over (partition by platform order by date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW ) as avg_volume_ma_7hour,
    sum(volume) over (partition by platform order by date) as cum_volume
    from avalanche.defi.ez_dex_swaps
    where (token_in = lower('0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD')
    or token_out = lower('0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD'))
    and block_timestamp >= '2023-05-25'
    group by 1,2
    ),
    t2_in as (
    select trunc(block_timestamp,'week') as date,
    project_name as platform,
    count(distinct tx_hash) as txs,
    sum(txs) over (partition by platform order by date) as cum_txs,
    count(distinct origin_from_address) as users,
    sum(amount) as volume,
    avg(amount) as avg_volume,
    avg(avg_volume) over (partition by platform order by date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW ) as avg_volume_ma_7hour,
    sum (volume) over (partition by platform order by date) as cum_volume
    from avalanche.core.ez_token_transfers x
    join avalanche.core.dim_labels y on x.origin_to_address=y.address
    where contract_address = lower('0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD')
    and block_timestamp >= '2023-05-25'
    group by 1,2
    ),
    t2_out as (
    select trunc(block_timestamp,'week') as date,
    QueryRunArchived: QueryRun has been archived