SajjadiiiBDR 2d non
    Updated 2022-11-01
    with Bridge as (
    select block_timestamp as send_date ,origin_from_address as eth_user
    from ethereum.core.fact_event_logs
    where event_inputs:chainId = '10'
    and contract_address in (
    '0x3666f603cc164936c1b87e207f36beba4ac5f18a', -- usdc
    '0x3e4a3a4796d16c0cd582c382691998f7c06420b6', -- usdt
    '0x3d4cc8a61c7528fd86c55cfe061a78dcba48edd1', -- dai
    '0x22b1cbb8d98a01a3b71d034bb899775a76eb1cc2' -- matic
    )
    and block_timestamp::date >= CURRENT_DATE() - interval '{{number_of_timeframe }} {{timeframe}}'
    ),

    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
    ),
    Run a query to Download Data