This project connects to a public blockchain RPC endpoint, collects and analyzes on-chain data related to DeFi activity, and extracts insights relevant to trading, MEV, and risk analysis. All data used is publicly available and obtained via free RPC access.
pip install web3 pandas numpy requests tqdm pyarrowFirst run these
python download_dex.py
python download_cex.pyThen run each cells in analysis.ipynb file
Caution: the needed block range in download_cex.py and download_dex.py is determined by the starting block number and ending block number we get from download_dex.py at the time I ran it. So the block number range is hard coded to ensure reproducibility in main function of download_cex.py, feel free to modify to align with your starting and ending block number.
- downloaded data:
dex_swaps.parquet,ethusdt_1s.parquet,perp_events.parquet,
- Network: Base
- Access method: Public RPC endpoint
- swap transactions of WETH/USDC from DEXs: Uniswap v3 / SushiSwap v2 (cpAMM)
- perp orders/fills of WETH/USDC from SynFutures
- Trades history of ETH/USDT from CEX: coinbase
This project meant to mainly do an quick discovery on DEX/DEX CEX/DEX arbing opportunities, lots of details are definitely not resolved, as it meant to be a short insight gainning project.
Swap transaction history: those datasets offers swap transaction history happend in those exchange, although we cannot know the exact price-size curve at certain timestamp from this datasets (it might need us to further investigate specifically how each exchange works, and gather additional data), we can still try to gain a rough sense of what's the price level on that dex at certain time.
perp orders/fills: Perp events capture actual derivatives trading activity directly from the perp smart contract. This is interesting because perps often deviate from spot due to leverage demand, funding dynamics, and liquidation pressure. Having perp trade events also letting us find arb opportunity when perp is traded below or above spot.
Trade history in CEX: CEX trades provide a high-frequency, timestamped reference of the broader market price and liquidity for the same underlying. Compared with on-chain swaps, CEX trade feeds are usually denser and closer to the “global” price discovery venue, so they are useful as a benchmark to (1) estimate how fast DEX/perp prices converge back to the broader market after dislocations, and (2) evaluate whether apparent on-chain edges are likely tradable after adding realistic frictions such as transfer latency, fees, spreads, and slippage. In this project we mainly do (2)
After collecting and analyzing the data, the following insights were observed (times are in UTC+0):
- There was arbing opportunities between ETH/USDT in coinbase and WETH/USDC on UniswapV3 (Base), which for example at 2025-12-23 19:06:45+00:00 - 19:06:51+00:00, we can buy at least 50k USDT value of WETH at price 2950.5(that's in USDT, I use 1.0003:1 per the price on binance during those time) and sell ETH/USDT on coinbase at price 2954 2025-12-23 19:06:47+00:00.
- Interestingly we can see ETH/USDT on coinbase is not super liquid, so trades tend to be more around that time(when there's arbing opportunity), like the mean of number of trades happening every sec is 0.215395, but at that time it's like 51 trades in nearly 3 sec. For uniswap, it's also getting more trades around that time. Thus, we would know that we need really fast speed to be able to really taking those arbing opportunities, and we might able to having some strategy to work around those (like somebody buy on DEX, but might not able to get hit on CEX, so they might lower price again and again, and we place some buy orders low when selling price is being reached high in DEX)
- There's also arbing opportunities between WETH/USDC on UniswapV3 (Base) and on SushiSwap (Base), at 2025-12-23 18:30:09+00:00 somebody buy on Uniswap with 2941.557342, and somebody sell on SushiSwap with 2948.028567 at 2025-12-23 18:30:13+00:00.
- There's no obvious arbing strats works between perp and DEX, if there's more time, I might dive deep into the dynamics of perp markets and how its events affect perp and spots' trading.
The findings from this analysis can be applied to:
- CEX/DEX arbing, if we could monitor CEX and simulate a realtime price - size curve for DEX, we could find profitable arbing opportunities.
- DEX/DEX arbing, similar idea, buy on one and sell on another, need us to be able to simulate realtime price-size curve
All data is sourced from public blockchain RPC endpoints. The analysis is fully reproducible using the provided scripts and configuration.