sepehrmhz8Untitled Query
    Updated 2022-09-13
    with deposit1 as (select date_trunc('day', a.block_timestamp) as day,
    sum(amount_usd) as deposit_usd_vol1,
    count(distinct(a.tx_hash)) as deposit_tx_count1,
    count(distinct(origin_from_address)) as deposit_wallet_count1
    from ethereum.core.fact_transactions a
    join ethereum.core.ez_token_transfers b on a.tx_hash = b.tx_hash
    where a.block_timestamp >= '2022-08-01' and a.block_timestamp < '2022-09-01'
    and a.to_address ilike '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1' --optimism
    and status = 'SUCCESS'
    group by 1),

    deposit2 as (select date_trunc('day', a.block_timestamp) as day,
    sum(amount_usd) as deposit_usd_vol2,
    count(distinct(a.tx_hash)) as deposit_tx_count2,
    count(distinct(origin_from_address)) as deposit_wallet_count2
    from ethereum.core.fact_transactions a
    join ethereum.core.ez_eth_transfers b on a.tx_hash = b.tx_hash
    where a.block_timestamp >= '2022-08-01' and a.block_timestamp < '2022-09-01'
    and a.to_address ilike '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1' --optimism
    and status = 'SUCCESS'
    group by 1)

    select a.day,
    deposit_usd_vol1 + deposit_usd_vol2 as bridge_vol,
    sum(bridge_vol) over (order by a.day) as cumu_bridge_vol,
    deposit_tx_count1 + deposit_tx_count2 as tx_count,
    sum(tx_count) over (order by a.day) as cumu_tx_count,
    deposit_wallet_count1 + deposit_wallet_count2 as wallet_count,
    sum(wallet_count) over (order by a.day) as cumu_wallet_count
    from deposit1 a
    join deposit2 b on a.day = b.day
    order by 1 desc
    Run a query to Download Data