aster2709volume_usd
    Updated 2025-01-07
    with eth_price as (
    select price from blast.price.ez_prices_hourly
    where token_address = '0x4300000000000000000000000000000000000004'
    order by hour desc
    limit 1
    ),

    btc_price as (
    select price from ethereum.price.ez_prices_hourly
    where token_address = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'
    order by hour desc
    limit 1
    ),

    eth_volume as (
    select sum(a.volume * b.price) as volume_usd from (
    select cast(decoded_log['exchangedQuote'] as float) / 1e18 as volume from blast.core.ez_decoded_event_logs
    where event_name = 'PositionChanged'
    and contract_address = '0xffc0555ec5f5c44a6b529cef94b9055799696272'
    and cast(decoded_log['tradeType'] as float) < 2) a cross join eth_price b),

    btc_volume as (
    select sum(a.volume * b.price) as volume_usd from (
    select cast(decoded_log['exchangedQuote'] as float) / 1e18 as volume from blast.core.ez_decoded_event_logs
    where event_name = 'PositionChanged'
    and contract_address = '0x0c2309c6554aabbfbca7d5219545795dcaf6f4a9'
    and cast(decoded_log['tradeType'] as float) < 2) a cross join btc_price b)

    select sum(volume_usd) from (
    select * from eth_volume
    union all
    select * from btc_volume)
    QueryRunArchived: QueryRun has been archived