Query editor
WITHbase_arb AS (SELECT*,CASEWHEN from_amount_usd > 47.5AND from_amount_usd <= 52.5 THEN 50WHEN from_amount_usd > 95AND from_amount_usd <= 105 THEN 100WHEN from_amount_usd > 950AND from_amount_usd <= 1050 THEN 1000WHEN from_amount_usd > 10000 THEN 10000ELSE NULLEND AS usd_value_bucket,'WETH' as gas_tokenfromquery_3798398wheresrcChain = 'base'and dstChain = 'arbitrum'AND ((from_amount_usd > 47.5AND from_amount_usd <= 52.5)OR (from_amount_usd > 95AND from_amount_usd <= 105)OR (from_amount_usd > 950AND from_amount_usd <= 1050)OR (from_amount_usd > 10000))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 (selectusd_value_bucket,from_amount_usd,(TRY_CAST((from_amount - to_amount) as DOUBLE) / POWER(10, token_decimals)