Hessishsevdrag - trades vol t
    Updated 2024-06-16
    -- forked from sevdrag - trades vol @ https://flipsidecrypto.xyz/edit/queries/f0ecda95-55db-43d6-a1d7-312c7c85a7ae

    with trades as (SELECT DISTINCT tx_hash
    from kaia.core.fact_event_logs
    where
    ORIGIN_TO_ADDRESS = '0x0000000000000068f116a894984e2db1123eb395'
    and CONTRACT_ADDRESS = '0x4e3f3a3dba12cec714cba0508a1bab8ead85af31'
    ),

    all_vol as (SELECT date_trunc('hour',block_timestamp) as time,
    VALUE::string as price,
    TO_ADDRESS as seller
    FROM kaia.core.fact_traces
    WHERE tx_hash in (SELECT DISTINCT tx_hash from trades) and
    TO_ADDRESS != '0x0000000000000068f116a894984e2db1123eb395' --operator
    and FROM_ADDRESS = '0x0000000000000068f116a894984e2db1123eb395'
    )



    SELECT
    sum(price) as "Volume in $KLAY"--, "Volume in $KLAY"*avg(close) as "Volume in USD", avg(close)
    from all_vol
    --join crosschain.price.fact_prices_ohlc_hourly on HOUr::date=time::date
    --where ASSET_ID = 'klaytn'
    --and PROVIDER = 'coinmarketcap'









    QueryRunArchived: QueryRun has been archived