StangFAST00.3 - rate
    Updated 2023-05-08
    -- forked from 00.3 - finding @ https://flipsidecrypto.xyz/edit/queries/9e7b9066-fb3d-43c6-b6b6-a3a0ec5f99f5

    -- -- -- forked from 00.0 - test @ https://flipsidecrypto.xyz/edit/queries/7e09bd5d-09c1-4a1c-8f39-c60743dade1d

    -- -- deposited , staking , withdrawing , unstaking

    -- -- deposit_and_stake , stake , stake_all , withdraw , unstake , unstake_all

    with near_price AS
    (
    SELECT
    date_trunc( 'day' , a.timestamp ) AS day
    , avg( a.price_usd ) AS price
    , a.symbol AS token
    FROM
    near.core.fact_prices a
    WHERE
    a.symbol = 'wNEAR'
    GROUP BY
    1 , 3
    ORDER BY
    1 DESC
    )

    SELECT
    date_trunc( 'week' , a.block_timestamp ) AS date

    --- count ---
    , count( DISTINCT c.tx_hash ) AS transactions

    --- rate ---
    , CASE
    when d.tx_status = 'Success' then 'Success'
    when d.tx_status = 'Fail' then 'Failure'
    END
    AS rate
    Run a query to Download Data