Updated 2024-12-09
    With deposit as (
    select
    Date_trunc('{{Period}}',block_timestamp) as date_time,
    Amount_usd
    FROM ethereum.core.ez_token_transfers
    where origin_to_address = lower('0x19b5cc75846BF6286d599ec116536a333C4C2c14')
    and origin_function_signature in ('0xdf68e9d6','0x74cbca9c')
    And symbol not in ('SolvBTC','Re7LRT','rstETH','rsUSDe','mUSD','amphrETH','mETH','mBTC','steakLRT')
    --And AMOUNT_USD is null
    --Qualify row_number()over(partition by symbol order by symbol ) =1
    Union All

    SELECT
    Date_trunc('{{Period}}',block_timestamp) as date_time,
    Amount_usd
    From ethereum.core.ez_native_transfers
    Where origin_to_address = lower('0x19b5cc75846BF6286d599ec116536a333C4C2c14')
    and origin_function_signature in ('0xdf68e9d6','0x74cbca9c')
    ),
    -- Getting price of WBTC AND WETH at hourly snapshot
    token_price as (
    select
    hour,
    price,
    case
    when symbol ilike '%ETH' then 'ETH '
    else 'BTC'
    End as symbol
    from ethereum.price.ez_prices_hourly
    where token_address in (lower('0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'),lower('0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee')) -- wbtc and weth
    and extract(year from hour) = 2024
    ),

    matching as (
    select
    Date_trunc('{{Period}}',t.block_timestamp) as date_time,
    QueryRunArchived: QueryRun has been archived