SalehNeat_staking_total
    Updated 2024-10-21
    with lst_neat_price as (
    select
    TO_TIMESTAMP(value[0]::string) as avg_date
    ,value[1] as avg_price
    from (
    select livequery.live.udf_api(
    'https://api.coingecko.com/api/v3/coins/neat/market_chart?vs_currency=usd&days=300&interval=daily&precision=3') as resp
    )
    ,lateral flatten (input => resp:data:prices)
    where avg_date>='2024-05-24'
    )
    ,lst_neat_price_one_day as (
    select top 1
    TO_TIMESTAMP(value[0]::string) as avg_date
    ,value[1] as avg_price
    from (
    select livequery.live.udf_api(
    'https://api.coingecko.com/api/v3/coins/neat/market_chart?vs_currency=usd&days=0&interval=daily&precision=3') as resp
    )
    ,lateral flatten (input => resp:data:prices)
    order by avg_date
    )
    ,lst_stake as (
    select
    block_timestamp::date as date
    ,tx_hash
    ,signer_id as staker
    ,args:amount/1e8 as amount
    from near.core.fact_actions_events_function_call
    where block_timestamp::date>='2024-05-24'
    and RECEIPT_SUCCEEDED=true
    and RECEIVER_ID='neat-staking.near'
    and args:msg='"Stake"'
    and METHOD_NAME='ft_on_transfer'
    and PREDECESSOR_ID='neat.nrc-20.near'
    )
    QueryRunArchived: QueryRun has been archived