Eman-RazClassification of Deposit Volume
    Updated 2022-11-04
    with table2 as (with table1 as (with tab1 as (select date_trunc('day',block_timestamp) as date, origin_from_address as depositor,
    sum(event_inputs:value) as deposit_volume, count(distinct tx_hash) as deposit_count, contract_address, case
    when contract_address='0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9' then 'sUSD'
    when contract_address='0x7f5c764cbc14f9669b88837ca1490cca17c31607' then 'USDC' --6
    when contract_address='0xfe8b128ba8c78aabc59d4c64cee7ff28e9379921' then 'BAL'
    when contract_address='0x8700daec35af8ff88c16bdf0418774cb3d7599b4' then 'SNX'
    when contract_address='0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' then 'DAI'
    when contract_address='0x4200000000000000000000000000000000000042' then 'OP'
    when contract_address='0x94b008aa00579c1307b0ef2c499ad98a8ce58e58' then 'USDT' --6
    when contract_address='0x68f180fcce6836688e9084f035309e29bf0a2095' then 'WBTC' --8
    end as token, case
    when contract_address='0x7f5c764cbc14f9669b88837ca1490cca17c31607' or contract_address='0x94b008aa00579c1307b0ef2c499ad98a8ce58e58'
    then deposit_volume/pow(10,6)
    when contract_address='0x68f180fcce6836688e9084f035309e29bf0a2095' then deposit_volume/pow(10,8)
    else deposit_volume/pow(10,18)
    end as Deposit_vol
    from optimism.core.fact_event_logs
    where (ORIGIN_FUNCTION_SIGNATURE='0xe8eda9df' and origin_to_address='0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe'
    and event_name='Transfer' and event_inputs:from=origin_from_address) -- deposit
    group by 1,2,5
    order by 1),
    tab2 as (select date_trunc('day',hour) as date, avg(price) as avg_price, token_address
    from optimism.core.fact_hourly_token_prices
    group by 1,3
    order by 1)
    select tab1.date as date_, depositor, deposit_count, Deposit_vol*avg_price as deposit_volume
    from tab1 left join tab2 on tab1.date=tab2.date and tab1.contract_address=tab2.token_address
    order by 1)

    select depositor, sum(deposit_volume) as Total_Deposit_Volume, case
    when Total_Deposit_Volume<=1 then 'V<=1'
    when Total_Deposit_Volume>1 and Total_Deposit_Volume<=10 then '1<V<=10'
    when Total_Deposit_Volume>10 and Total_Deposit_Volume<=100 then '10<V<=100'
    when Total_Deposit_Volume>100 and Total_Deposit_Volume<=1000 then '100<V<=1k'
    when Total_Deposit_Volume>1000 and Total_Deposit_Volume<=10000 then '1k<V<=10k'
    when Total_Deposit_Volume>10000 then 'V>10k'
    Run a query to Download Data