SajjadiiiBDR 1 non
    Updated 2022-11-01
    with Bridge as (
    select block_timestamp as send_date ,origin_from_address as eth_user
    from ethereum.core.ez_token_transfers
    where origin_to_address = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1' -- Optimism: Gateway
    and block_timestamp::date >= CURRENT_DATE() - interval '{{number_of_timeframe }} {{timeframe}}'
    and origin_to_address = to_address
    ),

    first_event as (
    select a.from_address , tx_hash ,
    min(a.block_timestamp) as first_event_time
    from optimism.core.fact_transactions a
    join Bridge b
    on a.from_address = b.eth_user
    where a.block_timestamp > b.send_date
    and block_timestamp::date >= CURRENT_DATE() - interval '{{number_of_timeframe}} {{timeframe}}'
    group by 1,2
    order by 3 asc
    ),

    NFT as (
    select concat('8.Buy NFT: ', address_name )as Destinations, count (distinct tx_hash)as transactions, count (distinct buyer_address) as users
    from optimism.core.ez_nft_sales a
    join optimism.core.dim_labels b
    on a.nft_address = b.address
    where tx_hash in (select tx_hash from first_event)
    and buyer_address in (select from_address from first_event)
    group by 1
    order by 2 desc
    limit 3
    ),

    delegations as (
    select concat('7.delegate to: ', address_name )as Destinations, count (distinct tx_hash)as transactions, count (distinct delegator) as users
    from optimism.core.fact_delegations a
    join optimism.core.dim_labels b
    Run a query to Download Data