Updated 2025-03-14
    WITH tb1 AS (
    SELECT
    TRUNC(block_timestamp, 'day') AS day,
    'sei' AS chain,
    origin_from_address,
    tx_hash,
    DECODED_LOG:"amount" / POW(10, 6) AS amount -- Adjust decimals if necessary
    FROM sei.defi.ez_dex_swaps -- SEI DEX swaps table
    WHERE DECODED_LOG:"token" = '0xSEI_TOKEN_DEPOSIT_ADDRESS' -- Replace with actual SEI token address
    AND event_name = 'TokenDeposit' -- Verify if this event name is correct for SEI
    AND TX_SUCCEEDED = 'TRUE'
    ),
    tb2 AS (
    SELECT
    TRUNC(block_timestamp, 'day') AS day,
    'sei' AS chain,
    origin_from_address,
    tx_hash,
    DECODED_LOG:"amount" / POW(10, 6) AS amount -- Adjust decimals if necessary
    FROM sei.defi.ez_dex_swaps -- SEI DEX swaps table
    WHERE DECODED_LOG:"token" = '0xSEI_TOKEN_REFUND_ADDRESS' -- Replace with actual SEI token address
    AND event_name = 'TokenRefund' -- Verify if this event name is correct for SEI
    AND TX_SUCCEEDED = 'TRUE'
    ),
    tb3 AS (
    SELECT
    TRUNC(hour, 'day') AS day,
    AVG(price) AS avg_price
    FROM sei.price.ez_prices_hourly -- SEI pricing table
    WHERE symbol = 'SEI'
    AND hour::DATE = CURRENT_DATE
    GROUP BY 1
    ),
    tb4 AS (
    SELECT
    TRUNC(a.day, 'month') AS monthly,
    Last run: about 2 months ago
    MONTH
    Stakers
    unStakers
    Stake transaction
    unStake transaction
    Stake Amount (OLAS)
    unStake Amount (OLAS)
    Stake Amount (USD)
    unStake Amount (USD)
    AVG Stake Amount (USD)
    AVG unStake Amount (USD)
    Cumulative Stake Amount (OLAS)
    Cumulative Stake Amount (USD)
    Cumulative unStake Amount (OLAS)
    Cumulative unStake Amount (USD)
    Total Staked (OLAS)
    Total Staked (USD)
    1
    2024-05-01 00:00:00.000177683491562634.517225515-15601002.288905861-593.49422.8718879823.8044512593.5303819444791.145666159-9481.1-3607.03708953112.4303819441184.108576659
    2
    2024-09-01 00:00:00.000216135582349105601.542898007-6054040175.578987832-23032.140369.03020444665.994671347148486.81105123156491.064830386-74421.1-28313.135389574065.71105123128177.929440886
    3
    2024-11-01 00:00:00.0003251668256231196530.15577416-895010455213.915113501-340502.07945551.774442562546.5522944622544598.77512537968079.881002573-1485791.1-565261.79503951058807.67512537402818.085963073
    4
    2024-10-01 00:00:00.0003641179314991199581.80829998-516360456374.901058687-196446.5802490.198604789393.6805214431348068.61935121512865.965889072-590781.1-224759.7155895757287.519351212288106.250299572
    5
    2024-07-01 00:00:00.00086212571001617.349809379-1000615.312648229-380.4452.3942126393.8044516188.8275586566158.958500553-11421.1-4345.10038954767.7275586561813.858111053
    6
    2024-06-01 00:00:00.00014926297941977.947367332-940752.500186165-357.61832.533670663.8044514571.4777492775543.645852324-10421.1-3964.65538954150.3777492771578.990462824
    7
    2024-02-01 00:00:00.0002697942525.152026286-450199.79146264-171.200252.5290058564.0761964297521.1356440152861.378450087-6831.1-2598.8578395690.035644015262.520610587
    8
    2024-01-01 00:00:00.000206135972151.907261909-2125818.682358257-808.4456256.0643137658.3344909796995.9836177292661.586987447-6381.1-2427.6575895614.883617729233.929397947
    9
    2025-03-01 00:00:00.0009066262220897750-669900341544.49875-254860.10551303.6049570611158.4550257889199.772132653001406.60730901-3713441.1-1412760.09928954175758.672132651588646.50801951
    10
    2024-04-01 00:00:00.0009412241601988.212915302-630756.405662562-239.680353.1386127083.99467259959.0131564293788.856760298-7921.1-3013.54288952037.913156429775.313870798
    11
    2025-01-01 00:00:00.000159140416354550510-476370209438.77695-181232.58465503.458598437511.9564538145081949.772132651933402.38105901-2365091.1-899787.08353952716858.672132651033615.29751951
    12
    2023-12-01 00:00:00.000188114701967.682622354-1750748.595015262-665.778756.5666229419.5111254844.076355821842.90462919-4256.1-1619.2119645587.97635582223.69266469
    13
    2024-08-01 00:00:00.0001726143819026696.440594568-246010156.527342001-935.894723.1884185894.92576157942885.26815322416315.485842553-13881.1-5280.995089529004.16815322411034.490753053
    14
    2024-12-01 00:00:00.0003371618094241986840.99700728-402930755883.723106433-153292.70385934.34329185361.5393958734531439.772132651723963.60410901-1888721.1-718554.49888952642718.672132651005409.10521951
    15
    2025-02-01 00:00:00.0003342298806411909500-678450726459.7275-258112.91025825.522417614402.672246886991449.772132652659862.10855901-3043541.1-1157899.99378953947908.672132651501962.11476951
    16
    2023-10-01 00:00:00.0002118148.1-4.13.0816045-1.55982450.171200250.11141603578.13.0816045-4.1-1.559824541.52178
    17
    2023-11-01 00:00:00.00022141381022868.293733466-25021091.228009428-951.873397.9074493449.3320920592876.3937334661094.309613928-2506.1-953.4332145370.293733466140.876399428
    18
    2024-03-01 00:00:00.00027147943449.664597112-460171.072647648-175.00472.1654765534.0698767447970.8002411273032.451097735-7291.1-2773.8625395679.700241127258.588558235
    18
    3KB
    16s