Query editor
WITHbase_arb AS (SELECT*,'WETH' as gas_tokenfromquery_3798398wheresrcChain in ('ethereum')and dstChain in ('base', 'arbitrum', 'optimism')and token_symbol = 'WETH'and from_time > TIMESTAMP '2024-05-29 14:00:00'),with_gas_token_price as (selecta.*,CASEWHEN a.value >= a.from_amount THEN (a.value + a.gas_fees - a.from_amount)else a.value + a.gas_feesend as costs_in_eth,b.price as gas_token_price,b.decimals as gas_token_decimalsfrombase_arb aLEFT JOIN prices.usd b ON b.minute >= TRY_CAST('2021-11-01 00:00:00' AS TIMESTAMP)AND b.blockchain = 'ethereum'AND DATE_TRUNC('minute', a.from_time) = b.minuteAND a.gas_token = b.symbol),base_arb_bus_taxi as (selectfrom_amount_usd,(TRY_CAST((from_amount - to_amount) as DOUBLE) / POWER(10, token_decimals)) * token_price + (TRY_CAST(costs_in_eth as DOUBLE) / POWER(10, gas_token_decimals)) * gas_token_price as total_costs,from_amount - to_amount as cost_amount,token_decimals,token_price,costs_in_eth,gas_token_decimals,gas_token_price,((TRY_CAST((from_amount - to_amount) as DOUBLE) / POWER(10, token_decimals)) * token_price + (TRY_CAST(costs_in_eth as DOUBLE) / POWER(10, gas_token_decimals)) * gas_token_price) * 10000 / from_amount_usd as total_costs_in_bps,to_time - from_time as time_taken,date_diff('second', from_time, to_time) as time_taken_s,from_time,txn_type,from_tx_hash,to_tx_hashfromwith_gas_token_pricewheredate_diff('second', from_time, to_time) > 0