Sbhn_NPeducational-silver
    Updated 2025-03-24
    with price as (
    select hour::date as datee,
    token_address,
    avg(price) as usdprice
    from avalanche.price.ez_prices_hourly
    group by 1,2
    ),

    deposit as (
    select date_trunc('day',block_timestamp) as date,
    -- symbol,
    sum(amount) as deposited,
    sum(amount_usd) as deposited_usd
    from avalanche.core.fact_event_logs
    join avalanche.core.ez_token_transfers using(tx_hash)
    where topics[0] = '0xe96d7872363f475d18b2f5390caaa5eaa96b2d38e42c62afe4ac08ebd2b13c3a'
    and to_address in (
    lower('0xa845Cbe370B99AdDaB67AfE442F2cF5784d4dC29'), -- Intelligent AVAX
    lower('0xe684F692bdf5B3B0DB7E8e31a276DE8A2E9F0025'), -- BTC.b
    lower('0xdf788ad40181894da035b827cdf55c523bf52f67'), -- sAVAX
    lower('0x9D15A28fCB96AF5e26dd0EF546D6a777C0ec34cd') -- ggAVAX
    )
    and symbol in ('ggAVAX','sAVAX','BTC.b','WAVAX')
    group by 1
    ),

    withdraw as (select date_trunc('day',block_timestamp) as date,
    -- '0x' || right(topics[2],40) as token,
    sum(ethereum.public.udf_hex_to_int(regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}')[0]) / pow(10,18) ) as withdrawn,
    sum((ethereum.public.udf_hex_to_int(regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}')[0]) / pow(10,18) )*usdprice) as withdrawn_usd
    from avalanche.core.fact_event_logs
    join price on '0x' || right(topics[2],40)=token_address and block_timestamp::date=datee
    where topics[0] = '0x7c7bb9f0b469c21da4666496577565b8e0f6a5da9834e8d15b12603b260ca6c6'
    and '0x' || right(topics[2],40) in ('0x152b9d0fdc40c096757f570a51e494bd4b943e50','0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7','0xa25eaf2906fa1a3a13edac9b9657108af7b703e3','0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be')
    group by 1)

    Last run: 2 months ago
    DATE
    Deposited USD
    Withdrawn USD
    NET Flows USD
    TVL
    1
    2025-03-24 00:00:00.0003212.656243735-2585.471428571627.1848151634691303.91869516
    2
    2025-03-23 00:00:00.00053614.377736122-3245.062550369.3152361224690676.73387999
    3
    2025-03-22 00:00:00.0007603.266842546-1665.8475397315937.4193028164640307.41864387
    4
    2025-03-21 00:00:00.00031701.482590761-5.64393040431695.8386603574634369.99934105
    5
    2025-03-20 00:00:00.00024133.10713318-53168.261577546-29035.1544443664602674.1606807
    6
    2025-03-19 00:00:00.000337.41667261-19.291458333318.1252142774631709.31512506
    7
    2025-03-18 00:00:00.00058895.177038676-1419.06725342757476.1097852494631391.18991079
    8
    2025-03-17 00:00:00.000499.443120492-4785.130604379-4285.6874838884573915.08012554
    9
    2025-03-16 00:00:00.00026077.510763971-39460.390430391-13382.879666424578200.76760942
    10
    2025-03-15 00:00:00.0006607.651795355-18061.093188107-11453.4413927524591583.64727585
    11
    2025-03-14 00:00:00.0004910.448241247-947.5380166373962.9102246094603037.0886686
    12
    2025-03-13 00:00:00.00015480.766852174-12034.4217196013446.3451325734599074.17844399
    13
    2025-03-12 00:00:00.00012812.318297837-9627.9428331193184.3754647184595627.83331142
    14
    2025-03-11 00:00:00.00052414.872757311-1561.4474310750853.4253262414592443.4578467
    15
    2025-03-10 00:00:00.00015113.926394171-17128.845889265-2014.9194950954541590.03252046
    16
    2025-03-09 00:00:00.0009846.863614624-4533.5397247395313.3238898864543604.95201555
    17
    2025-03-08 00:00:00.00027001.787606072-5551.89221449.8956060724538291.62812567
    18
    2025-03-07 00:00:00.00015302.838824521-14035.6870926541267.1517318674516841.73251959
    19
    2025-03-06 00:00:00.00086168.662307036-131118.25131344-44949.5890064044515574.58078773
    20
    2025-03-05 00:00:00.000198226.767432822-137708.80246722460517.9649655984560524.16979413
    79
    7KB
    31s