Afonso_DiazOvertime
    Updated 2025-02-20
    with

    main as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    utils.udf_hex_to_int(data)::bigint / 1e18 as amount,
    iff(topics[1] = '0x0000000000000000000000000000000000000000000000000000000000000000', 'Stake', 'Unstake') as event_name
    from
    monad.testnet.fact_event_logs
    where
    tx_succeeded
    and origin_to_address = '0xb2f82d0f38dc453d596ad40a37799446cc89274a'
    and topics[0] = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
    and contract_address = lower('0xb2f82D0f38dc453D596Ad40A37799446Cc89274A')
    )

    select
    date,
    sum(case when event_name = 'Stake' then volume else 0 end) as deposits_mon,
    sum(case when event_name = 'Unstake' then volume else 0 end) as unstake_mon,
    sum(deposits_mon - unstake_mon) over (order by date) as tvl
    from (
    select
    date_trunc('day', block_timestamp) as date,
    event_name,
    sum(amount) as volume
    from main
    group by date, event_name
    ) t
    group by date
    order by date


    Last run: 26 days ago
    DATE
    DEPOSITS_MON
    UNSTAKE_MON
    TVL
    1
    2025-01-20 00:00:00.0000.310.10.21
    2
    2025-01-21 00:00:00.0000.020.050.18
    3
    2025-01-22 00:00:00.0000.2900350.20.270035
    4
    2025-01-23 00:00:00.0000.0789310.0584310.290535
    5
    2025-01-24 00:00:00.0000.2120.839931-0.337396
    6
    2025-01-25 00:00:00.0000.260.21-0.287396
    7
    2025-01-26 00:00:00.0000.020.08-0.347396
    8
    2025-01-27 00:00:00.0000.11110.0932-0.329496
    9
    2025-02-06 00:00:00.0000.41320.312-0.228296
    10
    2025-02-07 00:00:00.00000.1-0.328296
    11
    2025-02-08 00:00:00.0000.010-0.318296
    12
    2025-02-09 00:00:00.00000.01-0.328296
    13
    2025-02-10 00:00:00.00000.01-0.338296
    14
    2025-02-11 00:00:00.0000.010.0002-0.328496
    15
    2025-02-13 00:00:00.0000.110.02-0.238496
    16
    2025-02-14 00:00:00.00081.784917081.546421
    17
    2025-02-15 00:00:00.0001.159614082.706035
    18
    2025-02-16 00:00:00.00011.71127094.417305
    19
    2025-02-17 00:00:00.0006.3825270.429100.370832
    20
    2025-02-18 00:00:00.0002.777730.251102.897562
    22
    1KB
    19s