Yakuzaevm3
    Updated 2023-02-07
    --made by : https://app.flipsidecrypto.com/velocity/queries/8c79c7a3-10e6-4d2c-9dde-4982dd6d65a3 **ali3n**
    with aaa as ( select hour::date as day, symbol, decimals, avg (price) as usdprice
    from ethereum.core.fact_hourly_token_prices
    where (symbol in ('USDC','USDT','WETH','WBTC','DAI',))
    group by 1,2,3),

    gmxtable as (select block_timestamp, tx_hash, origin_from_address, RAW_AMOUNT as volume,
    case when contract_address = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' then 'USDC'
    when contract_address = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' then 'WETH'
    when contract_address = '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f' then 'WBTC'
    when contract_address = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' then 'DAI'
    when contract_address = '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9' then 'USDT'
    else contract_address end as Token_Symbol
    from arbitrum.core.fact_token_transfers
    where origin_to_address in ('0x3d6ba331e3d9702c5e8a8d254e5d8a285f223aba','0xb87a436b93ffe9d75c5cfa7bacfff96430b09868')
    and RAW_AMOUNT is not null ),


    maintable as (select t1.*, (t1.volume / pow (10,t2.decimals)) * t2.usdprice as Volume1
    from gmxtable t1 join aaa t2 on t1.block_timestamp::date = t2.day and t1.Token_Symbol = t2.symbol
    where Volume1 > 1 ),


    all_data as (select tx_hash, block_timestamp, Volume1 as Total_Volume
    from maintable)

    select block_timestamp::date as date,
    case when Total_Volume < 50 then 'Volume < $50' when Total_Volume >= 50 and Total_Volume < 200 then '$50 <= Volume < $200'
    when Total_Volume >= 200 and Total_Volume < 1000 then '$200 <= Volume < $1000' when Total_Volume >= 1000 and Total_Volume < 5000 then '$1000 <= Volume < $5000'
    when Total_Volume >= 5000 and Total_Volume < 10000 then '$5000 <= Volume < $10000' else 'More Than $10000' end as type,
    count (distinct tx_hash) as "Number Trade"
    from all_data
    group by 1,2


    Run a query to Download Data