mohammadhop ➡️ eth
    Updated 2022-11-01
    with A as (select
    block_timestamp,
    TX_HASH,
    ORIGIN_FROM_ADDRESS,
    AMOUNT,
    SYMBOL
    from ethereum.core.ez_token_transfers
    where ORIGIN_TO_ADDRESS = lower('0x25ace71c97b33cc4729cf772ae268934f7ab5fa1')
    and SYMBOL IN ('USDC' , 'USDT', 'LUSD', 'TUSD')

    union all

    select
    block_timestamp,
    TX_HASH,
    ORIGIN_FROM_ADDRESS,
    AMOUNT_USD as amount,
    'ETH' as SYMBOL
    from ethereum.core.ez_eth_transfers
    where ORIGIN_TO_ADDRESS = lower('0x25ace71c97b33cc4729cf772ae268934f7ab5fa1'))

    select
    count(distinct TX_HASH) as withdrawn_tx,
    sum(AMOUNT) as withdrawn_amount,
    count(distinct ORIGIN_FROM_ADDRESS) as withdrawn_users,
    date_trunc('week',block_timestamp) as block_week,
    sum(withdrawn_amount) over (partition by SYMBOL order by block_week) as cum_withdrawn_amount,
    sum(withdrawn_tx) over (partition by SYMBOL order by block_week) as cum_withdrawn_tx,
    sum(withdrawn_users) over (partition by SYMBOL order by block_week) as cum_withdrawn_user,
    avg(withdrawn_amount) over (order by block_week rows between 30 preceding and 1 preceding) as "30week_moving_avg_amount",
    avg(withdrawn_tx) over (order by block_week rows between 30 preceding and 1 preceding) as "30week_moving_avg_tx",
    avg(withdrawn_users) over (order by block_week rows between 30 preceding and 1 preceding) as "30week_moving_avg_user",
    SYMBOL
    from A
    group by block_week,SYMBOL


    Run a query to Download Data