kidaSynapse Bridge Volume (Optimism)
    Updated 2023-01-05
    with
    lp_addresses as (
    select distinct
    event_inputs:swapAddress::string as lp_address
    from optimism.core.fact_event_logs
    where event_name = 'NewSwapPool' and origin_from_address = '0x0af91fa049a7e1894f480bfe5bba20142c6c29a9'
    ),
    native_prices as (
    select
    date(block_timestamp) as date,
    replace(feed_name, ' / USD') as symbol,
    median(coalesce(latest_answer_adj, latest_answer_unadj / pow(10,8))) as price --using median cause there will be some nulls / zeroes
    from ethereum.chainlink.ez_oracle_feeds
    where feed_category = 'Cryptocurrency (USD pairs)'
    and feed_name in ('ETH / USD')
    group by 1,2
    order by 1
    ),
    eth_bridge_txs as (
    select
    block_timestamp::date as date,
    tx_hash,
    origin_from_address as bridger,
    amount_usd
    from optimism.core.ez_eth_transfers
    where eth_to_address in (
    '0xaf41a65f786339e7911f4acdad6bd49426f2dc6b', --main bridge
    '0x9cd619c50562a38edbdc3451ade7b58caa71ab32', -- zap
    '0x470f9522ff620ee45df86c58e54e6a645fe3b4a7' -- zap 2
    )
    and origin_from_address <> '0x230a1ac45690b9ae1176389434610b9526d2f21b' -- must be by user
    ),

    token_bridges as (
    select
    Run a query to Download Data