MoDeFiFS near report - farming yeild total
    Updated 2024-05-29
    with succeeded_txs as (
    select tx_hash as tx
    from near.core.fact_transactions
    where tx_succeeded=true
    ),

    prices as (
    select date_trunc(day, hour) as day, TOKEN_ADDRESS, avg(price) as price
    from near.price.ez_prices_hourly
    where BLOCKCHAIN='near protocol'
    group by 1,2
    ),

    reward_withdraw as (
    select try_parse_json(CLEAN_LOG):data[0]:farmer_id as farmer_id,
    symbol, try_parse_json(CLEAN_LOG):data[0]:token_id as token_id,
    try_parse_json(CLEAN_LOG):data[0]:withdraw_amount as withdraw_amountt_raw,
    withdraw_amountt_raw/pow(10,DECIMALS) as withdraw_amount,
    BLOCK_TIMESTAMP, TX_HASH
    from near.core.fact_logs a
    left join near.core.dim_ft_contract_metadata
    on try_parse_json(CLEAN_LOG):data[0]:token_id=CONTRACT_ADDRESS
    -- join succeeded_txs
    -- on tx_hash=tx
    where RECEIVER_ID='boostfarm.ref-labs.near'
    and try_parse_json(CLEAN_LOG):event='reward_withdraw'
    and try_parse_json(CLEAN_LOG):data[0]:success='true'
    and try_parse_json(CLEAN_LOG):standard='ref-farming'),

    farmers_rewards as (
    select farmer_id, symbol, sum(withdraw_amount) as amount
    from reward_withdraw
    group by 1,2)


    select date_trunc(month,date_) as "Date",
    Last run: about 1 month ago
    Date
    Token
    Amount USD
    Total Amount USD
    1
    2024-05-01 00:00:00.000REF178547.202202964755287.980627975
    2
    2024-03-01 00:00:00.000REF208587.186549709487840.300988378
    3
    2024-06-01 00:00:00.000REF67199.188579886822487.169207861
    4
    2025-01-01 00:00:00.000wNEAR39250.184474503808862.736245361
    5
    2024-08-01 00:00:00.000LINEAR26.2465489523151.415628982
    6
    2024-12-01 00:00:00.000wNEAR61733.625342487769612.551770858
    7
    2025-04-01 00:00:00.000REF13405.3637924821273655.23101729
    8
    2024-04-01 00:00:00.000REF88900.477436633576740.778425011
    9
    2024-08-01 00:00:00.000REF45524.530940209918215.29875231
    10
    2024-12-01 00:00:00.000REF85118.2817544821171702.06123735
    11
    2024-02-01 00:00:00.000LINEAR32.604822271884.218554164
    12
    2023-12-01 00:00:00.000Other4671.2896185384671.289618538
    13
    2025-01-01 00:00:00.000Other455.77875020134396.57661447
    14
    2024-12-01 00:00:00.000LINEAR23152.312083718
    15
    2025-03-01 00:00:00.000Other32.18990318734499.205839015
    16
    2024-09-01 00:00:00.000wNEAR65015.481099211578242.294031568
    17
    2024-12-01 00:00:00.000Other961.26046594633940.797864269
    18
    2024-07-01 00:00:00.000Other4144.46162099228626.936429102
    19
    2024-01-01 00:00:00.000LINEAR273.995068004851.613731892
    20
    2024-01-01 00:00:00.000REF65829.910595774219574.231943287
    67
    4KB
    110s