hessShare of REF copy
    Updated 2024-10-05
    WITH prices as (
    select date(block_timestamp) as date,
    TOKEN_IN_CONTRACT,
    (sum(AMOUNT_OUT)/sum(AMOUNT_IN)) as price
    from near.defi.ez_dex_swaps
    where SYMBOL_OUT in ('wNEAR')
    and AMOUNT_OUT > 0
    and AMOUNT_IN > 0
    and TOKEN_IN_CONTRACT = 'gear.enleap.near'
    group by 1, 2
    ),
    near_price as (
    select hour::date as date,
    'Near' as symbol,
    min(price) as near_price
    from near.price.ez_prices_hourly
    where symbol = 'NEAR'
    and hour::date >= '2024-01-01'
    group by 1, 2
    ),
    gear as (
    select a.date,
    'gear.enleap.near' as tok_address,
    price * near_price as price
    from prices a
    join near_price b on a.date = b.date
    )
    ,
    uwon_price as (
    select date(block_timestamp) as date,
    TOKEN_IN_CONTRACT,
    (sum(AMOUNT_OUT)/sum(AMOUNT_IN)) as price
    from near.defi.ez_dex_swaps
    where SYMBOL_OUT in ('wNEAR')
    QueryRunArchived: QueryRun has been archived