nimasadjadiBridge destinations contracts
    Updated 2022-07-30
    with
    bridge_cte as (
    select
    block_timestamp,
    event_inputs:to bridge_user,
    contract_address token_address,
    sum(event_inputs:value/1e18) amount
    from polygon.core.fact_event_logs
    where 1=1
    and tx_status = 'SUCCESS'
    and ORIGIN_FROM_ADDRESS = '0x0000000000000000000000000000000000000000'
    and ORIGIN_TO_ADDRESS = '0x0000000000000000000000000000000000000000'
    and event_name in ('Deposit', 'Transfer')
    group by 1,2,3
    )
    ,bridge_matic_cte as (
    select * from bridge_cte where token_address = '0x0000000000000000000000000000000000001010'
    )
    ,bridge_other_cte as (
    select * from bridge_cte where token_address != '0x0000000000000000000000000000000000001010'
    )
    ,after_bridge_cte as (
    select
    a.block_timestamp,
    tx_hash,
    origin_from_address,
    coalesce(c.address_name, a.origin_to_address) origin_to
    from polygon.core.ez_matic_transfers a
    join bridge_matic_cte b on a.origin_from_address = b.bridge_user and a.block_timestamp > b.block_timestamp
    join polygon.core.dim_labels c on a.origin_to_address = c.address
    where 1=1

    union
    select
    a.block_timestamp,
    tx_hash,
    Run a query to Download Data