MLDZMNswap.from.1
    Updated 2022-12-07
    with tb1 as (select
    hour::date as day,
    avg(price) as price_token
    from ethereum.core.fact_hourly_token_prices where SYMBOL = 'WETH'
    group by 1),
    tb2 AS (
    select
    RECORDED_HOUR::date as day,
    SYMBOL,
    avg(close) as price_token
    from solana.core.fact_token_prices_hourly
    group by 1,2),

    tb3 as (select
    BLOCK_HOUR::date as day,
    ASSET_ID,
    avg(PRICE_USD) as price_token
    from algorand.defi.ez_price_pool_balances
    group by 1,2),
    tb6 as ( select
    BLOCK_TIMESTAMP,
    TX_GROUP_ID as tx,
    SWAP_FROM_AMOUNT*a.price_token as amount_usd,
    SWAP_TO_AMOUNT*b.price_token as amount_usd1,
    abs(amount_usd-amount_usd1) as difference_usd
    from algorand.defi.fact_swap s
    join tb3 a on s.SWAP_FROM_ASSET_ID=a.ASSET_ID and s.BLOCK_TIMESTAMP::date=a.day
    join tb3 b on s.SWAP_to_ASSET_ID=b.ASSET_ID and s.BLOCK_TIMESTAMP::date=b.day
    having difference_usd<100
    ),

    tb4 as (select
    date_trunc('day',TIMESTAMP) as day,
    TOKEN_CONTRACT,
    Run a query to Download Data