Hosseingeneral
    Updated 2023-11-12
    with raw as
    (
    select
    origin_from_address as user,block_timestamp,'Arbitrum' as chain,tx_hash,amount_in_usd,amount_out_usd,symbol_in as token_in, symbol_out as token_out, platform
    from arbitrum.defi.ez_dex_swaps
    union all
    select
    origin_from_address as user,block_timestamp,'Avalanche',tx_hash,amount_in_usd,amount_out_usd,symbol_in as token_in, symbol_out as token_out, platform
    from avalanche.defi.ez_dex_swaps
    union all
    select
    origin_from_address as user,block_timestamp,'Optimism',tx_hash,amount_in_usd,amount_out_usd,symbol_in as token_in, symbol_out as token_out, platform
    from optimism.defi.ez_dex_swaps
    union all
    select
    origin_from_address as user,block_timestamp,'Polygon',tx_hash,amount_in_usd,amount_out_usd,symbol_in as token_in, symbol_out as token_out, platform
    from polygon.defi.ez_dex_swaps
    union all
    select
    origin_from_address as user,block_timestamp,'Ethereum',tx_hash,amount_in_usd,amount_out_usd,symbol_in as token_in, symbol_out as token_out, platform
    from polygon.defi.ez_dex_swaps
    ),

    platforms as (
    select
    *, case when platform like 'uniswap%' then 'Uniswap'
    when platform like 'trader-joe%' then 'Traderjoe'
    when platform like 'kyberswap%' then 'Kyberswap'
    when platform like 'hashflow%' then 'Hashflow'
    when platform like 'dodo%' then 'Dodo'
    when platform like 'pancakeswap%' then 'Pancakeswap'
    when platform like 'quickswap%' then 'Quickswap'
    when platform like 'zyberswap%' then 'Zuickswap'
    when platform like 'velodrome%' then 'Velodrome'
    when platform like 'camelot%' then 'Camelot'
    else upper(SUBSTRING(platform, 1, 1)) || SUBSTRING(platform, 2) end as program
    Run a query to Download Data