Sbhn_NP2023-06-17 03:11 AM
    Updated 2023-06-19
    with price_near as (
    select timestamp::date as datee,
    avg(price_usd) as usdprice
    from near.core.fact_prices
    where symbol = 'wNEAR'
    group by 1
    ),

    price_sol as (
    select recorded_hour::date as datee,
    avg(close) as usdprice
    from solana.core.fact_token_prices_hourly
    where symbol ='SOL'
    group by 1
    ),

    price_osmo as (
    select recorded_hour::date as datee,
    avg(price) as usdprice
    from osmosis.core.ez_prices
    where currency = 'uosmo'
    GROUP by 1
    )

    select 'NEAR' as chain,
    date_trunc('{{Date}}',block_timestamp) as date,
    count(DISTINCT signer_id) as stakers,
    sum(amount) as native_staked,
    sum(amount*usdprice) as usd_staked,
    sum(native_staked) over (order by date) as cumu_native,
    sum(usd_staked) over (order by date) as cumu_usd
    from near.core.fact_staking_actions
    join price_near on block_timestamp::date=datee
    where date >= '{{From_Date}}'
    and action = 'staking'
    group by 1,2
    Run a query to Download Data