tomingbuy_sell_detail
    Updated 2024-03-09
    with buyers as (
    select
    ORIGIN_FROM_ADDRESS as buyer,
    block_number as buy_block,
    AMOUNT_OUT as Buy_Volume,
    AMOUNT_IN as Buy_Cost
    from ethereum.defi.ez_dex_swaps
    WHERE
    TOKEN_OUT = '0x38e382f74dfb84608f3c1f10187f6bef5951de93'
    and SYMBOL_IN = 'WETH'
    -- and EVENT_NAME = 'Swap'
    ),

    sellers as (
    select
    ORIGIN_FROM_ADDRESS as seller,
    block_number as sell_block,
    AMOUNT_IN as Sell_Volume,
    AMOUNT_OUT as Sell_Income
    from ethereum.defi.ez_dex_swaps
    where TOKEN_IN = '0x38e382f74dfb84608f3c1f10187f6bef5951de93'
    and SYMBOL_OUT = 'WETH'
    -- and EVENT_NAME = 'Swap'
    )

    SELECT
    buy_block,
    sum(Buy_Volume)/1000 as Buy_Volume_by_block,
    sum(Sell_Volume)/1000 as Sell_Volume_by_block,
    count(buyer) as b_num,
    count(seller) as s_num,
    count(DISTINCT(buyer)) as u_b_num,
    count(DISTINCT(seller)) as u_s_num,
    -- (sum(Buy_Cost)+sum(Sell_Income))/(sum(Buy_Volume)+sum(Sell_Volume))*1000000 as price,
    sum(Buy_Cost)/sum(Buy_Volume)*100 as price,
    sum(Buy_cost),
    QueryRunArchived: QueryRun has been archived