Query editor
--Key Logic Points:-- The code looks for price discrepancies for the same token pair across different DEXs within a single block.-- It assumes a fixed trade amount to estimate potential profits.-- The 0.5% threshold filters out minor price differences that might not be profitable after considering fees and-- slippage (which are not included in this calculation).-- The calculation assumes that the entire trade amount can be executed at the given prices, which may not-- always be realistic due to liquidity constraints.-- Limitations:-- This analysis doesn't account for transaction fees, slippage, or gas costs.-- It doesn't consider the actual liquidity available for each trade.-- The profitability of real-world arbitrage would likely be lower due to these factors and the-- speed required to execute such trades.WITH------------------------------ Tokens ------------------------------tokens AS (SELECT address, symbol, decimalsFROM dune.caravanserai.result_dim_contracts),------------------------------ 10KSwap ------------------------------tenkswap AS (SELECTblocks.time AS block_timestamp,swaps.block_number,swaps.transaction_hash,swaps.event_index,swaps.transaction_index,'10KSwap' AS dex,swaps.token_0 AS token_in_address,swaps.token_1 AS token_out_address,CASEWHEN swaps.amount_0_in > 0 THEN swaps.amount_0_inELSE swaps.amount_0_outEND AS amount_in,CASEWHEN swaps.amount_1_in > 0 THEN swaps.amount_1_inELSE swaps.amount_1_outEND AS amount_outFROM dune.caravanserai.result_10k_swap_events AS swapsJOIN starknet.blocks ON swaps.block_number = blocks.numberWHERE swaps.block_number = {{Block Number}}),------------------------------ Ekubo ------------------------------ekubo AS (SELECTswaps.block_time AS block_timestamp,swaps.block_number,swaps.transaction_hash,swaps.event_index,swaps.transaction_index,'Ekubo' AS dex,swaps.token_0 AS token_in_address,swaps.token_1 AS token_out_address,abs(token0_delta) AS amount_in,abs(token1_delta) AS amount_outFROM dune.caravanserai.result_ekobu_swap_events AS swapsWHERE swaps.block_number = {{Block Number}}),