kidaCeler Bridge Fee (Polygon)
    Updated 2023-01-05
    with
    origin_bridge_txs as (
    select
    block_timestamp,
    tx_hash,
    event_inputs:token as token_address,
    event_inputs:transferId as transferId,
    event_inputs:amount as bridged_amount
    from polygon.core.fact_event_logs
    where origin_to_address in (
    '0x88dcdc47d2f83a99cf0000fdf667a468bb958a78', --v2
    '0xa251c4691c1ffd7d9b128874c023427513d8ac5c' --2.0
    )
    and tx_status = 'SUCCESS'
    and event_name = 'Send'
    ),

    decimals as (
    select
    token_in as contract_address,
    median(case when event_inputs:amount1In::decimal < event_inputs:amount0In::decimal then event_inputs:amount0In else event_inputs:amount1In end / amount_in) as decimals
    from polygon.sushi.ez_swaps s
    join polygon.core.fact_event_logs t
    on t.event_index = s.event_index and s.tx_hash = t.tx_hash
    group by 1
    ),

    prices as (
    select
    date(block_timestamp) as date,
    token_in as token_address,
    symbol_in as symbol,
    avg(amount_in_usd / amount_in) as price
    from polygon.sushi.ez_swaps
    group by 1, 2, 3
    ),
    Run a query to Download Data