StangFASTretenrate rate of old user
    Updated 2023-08-30
    -- forked from 03 - new users @ https://flipsidecrypto.xyz/edit/queries/ebc3c058-42cf-402b-ad73-100e0f9f8d46

    -- forked from 01 - overview @ https://flipsidecrypto.xyz/edit/queries/c0d9cfc9-1dd4-4275-b5c4-3016d8c8de32

    --- tx signer
    --- relay.aurora

    --- tx receiver
    --- aurora-silo-dev.near aurora pass
    --- aurora aurora plus

    with

    near_price AS
    (
    SELECT
    date_trunc( 'day' , a.timestamp ) AS date
    , avg( a.price_usd ) AS price
    FROM
    near.price.fact_prices a
    WHERE
    a.symbol = 'wNEAR'
    GROUP BY 1
    ORDER BY 1 DESC
    )
    ,
    raw_tx AS
    (
    SELECT
    a.block_timestamp AS date_time
    , substring( a.tx:receipt[0]:outcome:logs[0] , charindex('(', a.tx:receipt[0]:outcome:logs[0] ) + 1, charindex(')', a.tx:receipt[0]:outcome:logs[0] ) - charindex('(', a.tx:receipt[0]:outcome:logs[0] ) - 1) AS user
    , a.tx_hash AS tx
    , ( a.transaction_fee / 1e24 ) * b.price AS tx_fee
    FROM
    near.core.fact_transactions a
    JOIN
    Run a query to Download Data