RayyykMost swap from asset by users after bridging from Ethereum by number of swaps
    Updated 2022-08-01
    with table_1 as (select min(block_timestamp) as initial,
    origin_from_address as bridger
    from ethereum.core.fact_event_logs
    where tx_status = 'SUCCESS'
    and origin_to_address = lower('0xa0c68C638235ee32657E8f720a23cec1bfc77c77')
    group by 2),

    table_2 as (select min(block_timestamp) as poly_initial,
    bridger
    from table_1 g
    join polygon.core.fact_event_logs h on g.bridger = h.origin_from_address
    where tx_status = 'SUCCESS'
    group by 2),

    table_3 as (select poly_initial,
    g.bridger
    from table_2 g
    join table_1 h on g.bridger = h.bridger
    where poly_initial > initial),

    table_4 as (select *
    from polygon.core.fact_event_logs g
    join table_3 h on g.origin_from_address = h.bridger and g.block_timestamp = h.poly_initial
    where tx_status = 'SUCCESS'),

    table_5 as (select tx_hash
    from polygon.core.dim_labels g
    join table_4 h on g.address = h.origin_to_address
    where tx_status = 'SUCCESS'
    and not label_subtype = 'bridge'
    and label_subtype = 'swap_contract')

    select symbol_in,
    count(distinct(g.tx_hash)) swap_from_count
    from polygon.sushi.ez_swaps g
    join table_5 h on g.tx_hash = h.tx_hash
    Run a query to Download Data