Yousefi_1994Swaps for sushi on Polygon, Ethereum and Harmony
    Updated 2022-06-27
    with hourly_sushi_prices as (
    select
    hour as times,
    price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'SUSHI'
    and hour::date >= '2022-01-01'
    ),
    swap_to_SUSHI_harmony as (
    select
    swap.block_timestamp as swap_time,
    swap.tx_hash as tx_hash,
    swap.amount1in as amount_1_in,
    swap.amount0in as amount_0_in,
    price.price as price
    from mdao_harmony.swaps swap
    join hourly_sushi_prices price
    on (swap.block_timestamp::date = price.times::date and hour(swap.block_timestamp) = hour(price.times))
    where (token1_symbol like '%1SUSHI%' and token1_name like 'SushiToken' and amount1in != 0 and amount1out = 0)
    or (token0_symbol like '%1SUSHI%' and token0_name like 'SushiToken' and amount0in != 0 and amount0out = 0)
    and swap_time >= '2022-01-01'
    ),
    swap_in_final_harmony as (
    select
    'Harmony' as chain,
    swap_time::date as days,
    count(tx_hash) as number_of_swaps,
    sum(amount_1_in/1e18 * price + amount_0_in/1e18 * price) as total_amount_usd
    from swap_to_SUSHI_harmony
    group by chain, days
    order by days
    ),
    swap_from_SUSHI_harmony as (
    select
    swap.block_timestamp as swap_time,
    swap.tx_hash as tx_hash,
    Run a query to Download Data