adriaparcerisasgains arbs 4.2
    Updated 2023-04-13
    with
    token_prices as (
    select trunc(hour,'day') as date,
    symbol,
    --decimals,
    avg(price) as token_price
    from ethereum.core.fact_hourly_token_prices
    where date>=CURRENT_DATE-INTERVAL '3 MONTHS'
    --where (token_address = '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' or symbol in ('DAI', 'FRAX', 'LINK', 'MIM', 'USDC', 'USDT', 'WBTC', 'WETH'))
    group by 1,2
    ),
    swaps as (
    select
    e.block_timestamp,
    e.origin_from_address,
    e.tx_hash,
    case when e.contract_address = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' then 'DAI'
    when e.contract_address = '0x17fc002b466eec40dae837fc4be5c67993ddbd6f' then 'FRAX'
    when e.contract_address = '0xf97f4df75117a78c1a5a0dbb814af92458539fb4' then 'LINK'
    when e.contract_address = '0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a' then 'MIM'
    when e.contract_address = '0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0' then 'UNI'
    when e.contract_address = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' then 'USDC'
    when e.contract_address = '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9' then 'USDT'
    when e.contract_address = '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f' then 'WBTC'
    when e.contract_address = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' then 'WETH'
    else y.symbol
    end as token_sold,
    y.decimals as decimals_sold,
    try_to_number(e.event_inputs:value::string) as volume_sold
    from arbitrum.core.fact_event_logs e
    join arbitrum.core.dim_contracts y on e.contract_address=y.address
    join arbitrum.core.fact_token_transfers t on e.tx_hash=t.tx_hash
    where e.origin_to_address in ('0x2f67a8d26f370b922b31b199c7946c3ed53c10c6','0x6c612c804c84e3d20e3109c8efd06cd2d8b28f46','0xcfa6ebd475d89db04cad5a756fff1cb2bc5be33c')
    and e.event_name = 'Transfer'
    and e.event_inputs:from = e.Origin_From_Address
    and e.tx_status= 'SUCCESS'
    Run a query to Download Data