gustavo123Daily Net Stake
    Updated 2025-04-08
    with deposit as (
    select
    date_trunc('day', block_timestamp) as day,
    sum(full_decoded_log:data[2]:value) / pow(10, 18) as daily_deposit
    from ronin.core.ez_decoded_event_logs
    where event_name = 'Deposit'
    and full_decoded_log:data[2]:name = 'assets'
    and contract_address = '0xcad9e7aa2c3ef07bad0a7b69f97d059d8f36edd2'
    group by 1
    ),

    withdraw as (
    select
    date_trunc('day', block_timestamp) as day,
    sum(full_decoded_log:data[3]:value) / pow(10, 18) as daily_withdraw
    from ronin.core.ez_decoded_event_logs
    where event_name = 'Withdraw'
    and full_decoded_log:data[3]:name = 'assets'
    and contract_address = '0xcad9e7aa2c3ef07bad0a7b69f97d059d8f36edd2'
    group by 1
    ),

    combined as (
    select
    coalesce(d.day, w.day) as day,
    coalesce(d.daily_deposit, 0) as hourly_RON_deposited,
    - coalesce(w.daily_withdraw, 0) as hourly_RON_withdrawn,
    coalesce(d.daily_deposit, 0) - coalesce(w.daily_withdraw, 0) as net_hourly_stake,
    sum(coalesce(d.daily_deposit, 0) - coalesce(w.daily_withdraw, 0))
    over (order by coalesce(d.day, w.day)) as cumulative_net_stake
    from deposit d
    full outer join withdraw w
    on d.day = w.day
    )

    select *
    Last run: about 1 month ago
    DAY
    HOURLY_RON_DEPOSITED
    HOURLY_RON_WITHDRAWN
    NET_HOURLY_STAKE
    CUMULATIVE_NET_STAKE
    1
    2025-04-27 00:00:00.00010051.297-1009.7408288689041.5561711327052928.26836744
    2
    2025-04-26 00:00:00.0009360.0878713-10920.620244175-1560.5323728767043886.7121963
    3
    2025-04-25 00:00:00.00084067.791504443-44044.59640107140023.1951033737045447.24456918
    4
    2025-04-24 00:00:00.000183450.7-184859.83082523-1409.130825237005424.04946581
    5
    2025-04-23 00:00:00.000111077.2903-111787.526565347-710.2362653477006833.18029104
    6
    2025-04-22 00:00:00.0001619-3289.970525427-1670.9705254277007543.41655639
    7
    2025-04-21 00:00:00.00017050-18905.70269261-1855.702692617009214.38708181
    8
    2025-04-20 00:00:00.00012612.95167447-14256.448486683-1643.4968122137011070.08977442
    9
    2025-04-19 00:00:00.000115555.3455-124622.042282804-9066.6967828047012713.58658664
    10
    2025-04-18 00:00:00.000514065.577447269-1218.315534435512847.2619128347021780.28336944
    11
    2025-04-17 00:00:00.000173622.6-1287.87580876172334.724191246508933.02145661
    12
    2025-04-16 00:00:00.000100342.955778855-3288.18456914597054.771209716336598.29726537
    13
    2025-04-15 00:00:00.000470525.345-42963.880917214427561.4640827866239543.52605566
    14
    2025-04-14 00:00:00.00033902.21124238-6868.95753243827033.2537099415811982.06197287
    15
    2025-04-13 00:00:00.00027978.36652444-29483.189948762-1504.8234243235784948.80826293
    16
    2025-04-12 00:00:00.00060602.889551279-49103.10771127511499.7818400045786453.63168725
    17
    2025-04-11 00:00:00.00042196.641556077-42077.975702742118.6658533355774953.84984725
    18
    2025-04-10 00:00:00.000773257.871620351-772852.52355535405.3480655774835.18399391
    19
    2025-04-09 00:00:00.000291986.034819769-288822.4686708013163.5661489675774429.83592891
    20
    2025-04-08 00:00:00.00063916.668181873-30158.66584048333758.002341395771266.26977994
    38
    3KB
    8s