saeedmzn[Euler] - Total
    Updated 2025-04-10
    with euler_txns as (
    select
    tx_hash,
    block_timestamp::date date ,
    event_name type ,
    origin_from_address user ,
    UPPER(REGEXP_REPLACE(contract_name, '^EVK Vault e(.*?)ETH-[1-2]$', '\\1ETH')) symbol,
    ( decoded_log:assets) / 1e18 amount
    -- case when type = 'Deposit' then ( decoded_log:assets) / 1e18
    -- when type = 'Repay' then ( decoded_log:assets) / 1e18
    -- when type = 'Borrow' then -( decoded_log:assets) / 1e18
    -- when type = 'Withdraw' then -( decoded_log:assets) / 1e18
    -- end as amount
    from swell.core.ez_decoded_event_logs
    where origin_to_address = '0x08739cbede6e28e387685ba20e6409bd16969cde'
    and event_name in ( 'Borrow','Deposit', 'Withdraw','Repay' )
    and UPPER(REGEXP_REPLACE(contract_name, '^EVK Vault e(.*?)ETH-1$', '\\1ETH')) is not null
    and block_timestamp::date >='2025-01-17'
    ),
    prices as (
    SELECT
    DATE_TRUNC(day, hour) date,
    symbol,
    median(price) price
    FROM ethereum.price.ez_prices_hourly join euler_txns using (symbol)
    where date_trunc(day,hour)::date >= '2025-01-17'
    GROUP BY 1,2
    ),
    final as (
    select * exclude price , amount*price amount_usd from euler_txns join prices using (date , symbol)
    )
    --'Borrow','Deposit', 'Withdraw','Repay'
    select
    count (distinct tx_hash) num_txns ,
    count (distinct user) num_users ,
    sum (iff(type='Deposit',amount_usd,0)) Deposit_amount_usd ,
    Last run: 16 days ago
    NUM_TXNS
    NUM_USERS
    DEPOSIT_AMOUNT_USD
    WITHDRAW_USD
    BORROW_USD
    REPAY_USD
    1
    305624047198474.863869635939359.400998622333014.007543115177213.9852965
    1
    80B
    7s