mamad-5XN3k3Aptos L0 inbound
    Updated 2025-01-14
    -- forked from 0xham-d / in total @ https://flipsidecrypto.xyz/0xham-d/q/ugfze9yitufw/in-total

    with pricet as (
    select
    hour::date as p_date,
    symbol,
    avg(price) as usd_price
    from crosschain.price.ez_prices_hourly
    where blockchain = 'ethereum'
    group by 1 ,2
    )

    select
    --date_trunc('day',block_timestamp) as date,
    --distinct direction, --inbound/outbound
    distinct source_chain_name as source,
    destination_chain_name as destination,
    count(distinct tx_hash) as txs,
    count(distinct receiver) as receivers,
    count(distinct sender) as senders,
    --count(distinct source_chain_name) as sources,
    --count(distinct destination_chain_name) as destinations,
    --token_address,
    --count(distinct b.symbol) as tokens
    --(amount_unadj/pow(10, decimals)) as amount
    round(sum((amount_unadj/pow(10, decimals))*usd_price),0) as amount_usd
    from aptos.defi.fact_bridge_activity a
    join aptos.core.dim_tokens b using(token_address)
    join pricet c on block_timestamp::date = p_date::date and lower(b.symbol) = lower(c.symbol)
    where platform = 'layerzero'
    and block_timestamp::date >= '2024-01-01'
    and direction = 'inbound'
    group by 1,2
    order by 1 asc


    Last run: about 2 months ago
    SOURCE
    DESTINATION
    TXS
    RECEIVERS
    SENDERS
    AMOUNT_USD
    1
    ArbitrumAptos2257831403182247258821
    2
    AvalancheAptos109571717501217028570
    3
    BSCAptos1762501133802524673967
    4
    BaseAptos175135179483
    5
    EthereumAptos1116281537366193619
    6
    OptimismAptos1449011103431152792085
    7
    PolygonAptos153364984141125876270
    8
    Polygon zkEVMAptos232215751
    8
    345B
    49s