Query editor
WITHbase_arb AS (SELECT*,CASEWHEN from_amount_usd <= 50 THEN 'a. 5-50'WHEN from_amount_usd <= 100 THEN 'b. 51-100'WHEN from_amount_usd <= 500 THEN 'c. 101-500'WHEN from_amount_usd <= 1000 THEN 'd. 501-1k'WHEN from_amount_usd <= 5000 THEN 'e. 1k-5k'WHEN from_amount_usd <= 10000 THEN 'f. 5k-10k'ELSE 'g. 10k+'END AS amount_bin,'WETH' as gas_tokenfromquery_3798398wheresrcChain in ('base', 'arbitrum', 'optimism')and dstChain in ('ethereum')and token_symbol = 'USDC'-- and from_time > TIMESTAMP '2024-05-29 14:00:00'and from_time > TIMESTAMP '{{start_date}}'),with_gas_token_price as (selecta.*,(a.value + a.gas_fees) 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,amount_bin,(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,