mucrypto2023-06-08 06:18 PM
    Updated 2023-06-08
    with uniswap as (select
    block_timestamp,
    from_address,
    sum(tx_fee) as total_tx_fee_spent
    from ethereum.core.fact_transactions
    where block_timestamp >= sysdate() -interval '1 month'
    and to_address = '0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b' -- uniswap: universal router
    group by 1,2
    having total_tx_fee_spent > 0.05
    qualify row_number() over (order by total_tx_fee_spent desc) <=10)

    select
    contract_address,
    case
    when contract_address = '0x0..' then 'Token name 1'
    else symbol end as symbol,
    sum(amount) as total_amount,
    count(1) as transfer_count
    from ethereum.core.ez_token_transfers
    where block_timestamp >= sysdate() - interval '1 month'
    and has_price = 'true'
    and amount is not null
    and origin_from_address in (
    select from_address
    from uniswap)
    group by 1,2
    qualify row_number() over (order by transfer_count desc) <= 10
    order by transfer_count desc