MasiDaily Swap to selected tokens
    Updated 2023-05-15
    with tb1 as ( select trunc(block_timestamp,'day') as day,
    tx_id,
    swapper,
    b.symbol as symbol_in,
    'Bonk' as symbol_out,
    swap_to_amount
    from solana.core.fact_swaps a join solana.core.dim_tokens b on a.swap_from_mint = b.token_address
    where swap_to_mint = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263')
    ,
    tb2 as ( select trunc(block_timestamp,'day') as day,
    tx_hash as tx_id,
    origin_from_address as swapper,
    symbol_in,
    symbol_out,
    amount_out_usd
    from ethereum.core.ez_dex_swaps
    where symbol_out in ('PEPE','CHAD','SHIB','WOJAK','BOB','TURBO','FLOKI')
    )
    ,
    tb3 as ( select trunc(RECORDED_HOUR,'day') as day,
    avg(close) as avg_price
    from solana.core.ez_token_prices_hourly
    where symbol = 'bonk'
    group by 1)
    ,
    tb4 as ( select a.day,
    tx_id,
    swapper,
    symbol_in,
    symbol_out,
    swap_to_amount*avg_price as amount_out_usd
    from tb1 a join tb3 b on a.day = b.day)
    ,
    tb5 as ( select *
    from tb2
    UNION
    Run a query to Download Data