PS0G1Top 5 popular destinations after bridging by users and transaction
    Updated 2022-10-24
    --credit alik110
    with standardbridge as (
    select block_timestamp,
    tx_hash,
    origin_from_address,
    'ETH' as symbol,
    amount_usd
    from ethereum.core.ez_eth_transfers
    where eth_to_address = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1'
    union ALL
    select block_timestamp,
    tx_hash,
    origin_from_address,
    symbol,
    amount_usd
    from ethereum.core.ez_token_transfers
    where to_address = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1'),

    table1 as (
    select t1.block_timestamp,
    t1.tx_hash,
    t1.origin_from_address,
    t1.origin_to_address
    from optimism.core.fact_event_logs t1 join standardbridge t2 on t1.origin_from_address = t2.origin_from_address and t1.block_timestamp > t2.block_timestamp)

    select origin_to_address,
    case when origin_to_address = '0x1111111254760f7ab3f16433eea9304126dcd199' then '1inch Exchange'
    when origin_to_address = '0x9c12939390052919af3155f41bf4160fd3666a6f' then 'Velodrome Finance' else address_Name end as destination_label,
    count (distinct tx_hash) as TX_Count,
    count (distinct origin_from_address) as Users_Count
    from table1 t1 full outer join optimism.core.dim_labels t2 on t1.origin_to_address = t2.address
    where destination_label is not null
    group by 1,2 having Users_count > 100
    order by 3 DESC
    limit 5
    Run a query to Download Data