ArioGogopool
    Updated 2024-02-19
    -- forked from Sbhn_NP / 2023-08-27 11:49 PM @ https://flipsidecrypto.xyz/Sbhn_NP/q/6RZ1XJ6ukWsn/2023-08-27-11-49-pm

    --reference : cloudr3n
    with price as (
    select hour::date as datee,
    symbol,
    avg(price) as usdprice
    from avalanche.price.ez_hourly_token_prices
    where symbol = 'WAVAX'
    group by 1,2
    ),


    base as (
    SELECT
    block_timestamp,
    iff(event_name='Deposit','Deposit','Withdraw') as type,
    case when event_name='Deposit' then decoded_log:assets::integer*pow(10,-18)
    when event_name='Withdraw' then decoded_log:assets::integer*(-1)*pow(10,-18)
    else 0
    end as amount,
    case when event_name='Deposit' then decoded_log:shares::integer*pow(10,-18)
    when event_name='Withdraw' then decoded_log:shares::integer*(-1)*pow(10,-18)
    else 0 end as shares,
    contract_address
    FROM
    avalanche.core.ez_decoded_event_logs
    WHERE
    contract_address=lower('0xA25EaF2906FA1a3a13EdAc9B9657108Af7B703e3')


    )

    select
    date_trunc('day',block_timestamp) as date,
    sum(amount*usdprice) as avax,
    Last run: about 1 year ago
    DATE
    AVAX
    TVL
    1
    2024-02-12 00:00:00.000288846.8509941738952593.94908741
    2
    2024-02-13 00:00:00.000-69133.7282890178883460.22079839
    3
    2024-02-14 00:00:00.000-152613.9506815598730846.27011683
    4
    2024-02-15 00:00:00.000-7683.738671528723162.53144531
    5
    2024-02-16 00:00:00.000-3328.8202537168719833.71119159
    6
    2024-02-10 00:00:00.000267483.5026624188695081.296697
    7
    2024-02-11 00:00:00.000-31334.1986037638663747.09809323
    8
    2024-02-17 00:00:00.000-109830.0540994198610003.65709217
    9
    2024-02-18 00:00:00.000-38660.3164756458571343.34061653
    10
    2024-02-19 00:00:00.000-163.9601135158571179.38050301
    11
    2024-02-08 00:00:00.00098032.0183940798481166.50411859
    12
    2024-02-09 00:00:00.000-53568.7100840148427597.79403458
    13
    2024-02-07 00:00:00.000269980.3587918538383134.48572451
    14
    2024-02-06 00:00:00.000138085.9089272878113154.12693266
    15
    2024-02-05 00:00:00.00091373.9290634777975068.21800537
    16
    2024-02-03 00:00:00.00079546.5039663157886988.47040295
    17
    2024-02-04 00:00:00.000-3294.1814610547883694.2889419
    18
    2024-02-02 00:00:00.000389691.9726473847807441.96643664
    19
    2024-02-01 00:00:00.00032742.3030242817417749.99378925
    20
    2024-01-31 00:00:00.000160884.9162150247385007.69076497
    ...
    290
    16KB
    10s