Afonso_Diaz2023-06-11 10:59 PM
    Updated 2023-06-16
    with

    t as (

    select
    a.timestamp::date as date,
    'NEAR' as symbol,
    avg(a.price_usd) as price_usd
    from near.core.fact_prices a
    where a.symbol = 'wNEAR'
    group by 1, 2

    union all

    select
    a.recorded_at::date as date,
    symbol,
    avg(a.price) as price_usd
    from osmosis.core.dim_prices a
    where a.symbol in('OSMO', 'ATOM')
    group by 1, 2
    ),

    t2 as (
    select
    tx_hash,
    'Near' as chain,
    block_timestamp,
    tx_signer as user,
    (stake_amount * price_usd)/1e24 as amount
    from near.core.dim_staking_actions
    join t on block_timestamp::date = t.date and symbol = 'NEAR'
    where action = 'Stake'

    union all

    Run a query to Download Data