saeedmznFlash Bounty: GMX Protocol Overview - Total Generated Fees
    Updated 2023-03-23
    with tokens as (
    select ADDRESS,
    case when ADDRESS = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' then 'USDC'
    when ADDRESS = '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9' then 'USDT'
    when ADDRESS = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' then 'WETH'
    when ADDRESS = '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f' then 'WBTC'
    when ADDRESS = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' then 'DAI'
    when ADDRESS = '0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0' then 'UNI'
    when ADDRESS = '0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a' then 'MIM'
    when ADDRESS = '0xf97f4df75117a78c1a5a0dbb814af92458539fb4' then 'LINK'
    when ADDRESS = '0x17fc002b466eec40dae837fc4be5c67993ddbd6f' then 'FRAX'
    end as token
    from arbitrum.core.dim_labels
    group by 1,2
    ),
    token_prices as (
    select
    date_trunc(day,hour)::date daily,
    symbol ,
    decimals ,
    avg (price) as price
    from ethereum.core.fact_hourly_token_prices
    where symbol in (select token from tokens )
    and iff(symbol='UNI',TOKEN_ADDRESS='0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',true)
    group by 1,2,3
    ),
    swap_from as (select
    BLOCK_TIMESTAMP::date daily,
    t.token swap_from_token ,
    TX_HASH,
    event_inputs:inputValue/pow(10,decimals)*price swap_from_amount,
    event_inputs:sender swapper
    from arbitrum.core.fact_event_logs LEFT join tokens t on ADDRESS = event_inputs:inputToken
    join token_prices p on BLOCK_TIMESTAMP::date = daily and symbol = token
    where lower(contract_address) = lower ('0xaBBc5F99639c9B6bCb58544ddf04EFA6802F4064')
    and event_name = 'Swap'
    Run a query to Download Data