Install
$ agentstack add skill-brainbytes-dev-everything-claude-trading-cross-chain-arbitrage ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Cross-Chain and CEX-DEX Arbitrage
When to Activate
- Identifying and evaluating arbitrage opportunities between centralized and decentralized exchanges
- Analyzing cross-chain price discrepancies and bridge-based arbitrage
- Designing triangular or multi-hop arbitrage strategies
- Assessing execution risk, latency, gas costs, and bridge risks for arbitrage operations
- Building or evaluating atomic arbitrage strategies using flash loans
Core Concepts
CEX-DEX Arbitrage
Price Discrepancy Sources:
- CEX prices update via order book; DEX prices update via AMM formula on each trade
- During volatile periods, DEX prices lag because they require on-chain transactions to update
- Stale liquidity on DEXs creates arbitrage until arbitrageurs align prices
- Typical discrepancy: 0.1-0.5% in calm markets, 1-5% during volatility spikes
Execution Flow:
1. Monitor CEX order books and DEX pool prices simultaneously
2. Detect discrepancy exceeding threshold (gas + fees + slippage)
3. Execute simultaneously:
a. Buy on cheaper venue
b. Sell on more expensive venue
4. Net inventory to zero
Two modes:
- Atomic (DEX-only): single transaction using flash loans, no capital risk
- Non-atomic (CEX-DEX): requires capital on both venues, execution risk between legs
CEX-DEX Specific Challenges:
- Latency asymmetry — CEX APIs respond in milliseconds; DEX transactions take 12+ seconds (Ethereum) to confirm
- Inventory management — must pre-fund both CEX and DEX sides; capital is fragmented
- Settlement mismatch — CEX fills are instant; DEX fills are probabilistic until block confirmation
- Gas price spikes — during volatile periods when arb opportunities are largest, gas prices also spike
- MEV competition — on-chain leg is visible to searchers who may frontrun or sandwich
Cross-Chain Arbitrage
Bridge Arbitrage:
- Same asset trades at different prices on different chains
- Opportunity: buy on cheap chain, bridge to expensive chain, sell
- Bottleneck: bridge latency (minutes to hours) and bridge fees (0.1-0.5%)
- Risk: price can converge during bridge transit, erasing profit
- Bridge liquidity limits: large arbs may exceed bridge capacity
Types of Cross-Chain Price Discrepancies:
1. Native token pricing: ETH on Ethereum vs ETH on Arbitrum
- Usually tight ( USDC -> DAI -> ETH
Pool 1 (ETH/USDC): 1 ETH = 2000 USDC
Pool 2 (USDC/DAI): 1 USDC = 1.002 DAI
Pool 3 (DAI/ETH): 2000 DAI = 1.003 ETH
Execution:
1. Start with 10 ETH
2. Swap 10 ETH -> 20,000 USDC (Pool 1)
3. Swap 20,000 USDC -> 20,040 DAI (Pool 2)
4. Swap 20,040 DAI -> 10.03 ETH (Pool 3)
5. Profit: 0.03 ETH minus gas costs
Profitability condition:
product(exchange_rates_around_cycle) > 1 + total_fees + gas_cost/trade_size
Multi-Hop Optimization:
- More hops = more potential inefficiency to capture
- But also more gas costs and slippage per hop
- Optimal path finding is a graph problem: Bellman-Ford algorithm detects negative cycles (profitable arbitrage loops)
- DEX aggregators (1inch, Paraswap) solve this for users but extract some value
Atomic Arbitrage with Flash Loans
Flash Loan Arbitrage Pattern:
Single transaction:
1. Borrow X tokens from Aave/dYdX (flash loan, no collateral)
2. Execute arbitrage trades across DEX pools
3. Repay loan + fee (0.05% on Aave, 0% on dYdX)
4. Keep profit
Advantages:
- Zero capital requirement (borrow and repay in same tx)
- Zero market risk (atomic execution — all or nothing)
- No inventory to manage
Constraints:
- Must complete within single transaction (single block)
- Cannot cross chains (flash loans are same-chain only)
- Gas costs can be high for complex multi-hop routes
- Competitive — many searchers target same opportunities
Methodology
Opportunity Detection
- Price monitoring — maintain real-time price feeds for same asset across venues
- Threshold calculation — minimum spread = gascost + bridgefee + slippage + risk_premium
- Liquidity check — verify sufficient depth on both sides to execute at expected prices
- Path optimization — for multi-hop, find the optimal route maximizing net profit
- Execution decision — only proceed if expected profit exceeds minimum threshold after all costs
Profitability Calculation
Atomic (flash loan) arbitrage:
Net profit = gross_spread * trade_size - gas_cost - flash_loan_fee - slippage
CEX-DEX arbitrage:
Net profit = gross_spread * trade_size - gas_cost - CEX_fees - slippage
- capital_cost * execution_time - hedge_cost
Cross-chain arbitrage:
Net profit = gross_spread * trade_size - gas_cost_chain_A - gas_cost_chain_B
- bridge_fee - slippage - bridge_time_risk_premium
Break-even spread:
min_spread = (total_costs) / trade_size
Latency and Infrastructure
Competitive advantage sources:
1. Co-located nodes (reduces block propagation latency)
2. Private mempool access (Flashbots, MEV-boost builders)
3. Pre-signed transactions ready to submit
4. Multi-chain node infrastructure
5. Custom DEX routing algorithms
6. Direct builder relationships for bundle inclusion
Latency hierarchy:
- HFT on CEX: microseconds
- MEV searcher on-chain: milliseconds to submit, 12s to confirm
- Cross-chain arb: minutes to hours (bridge dependent)
Risk Management for Arbitrage
Position limits:
- Max single arb size: limited by pool depth (aim for 3x normal: pause (costs eat profits)
- Bridge delays >2x normal: stop bridging (increased risk)
- Failed transaction rate >20%: investigate and halt
- Cumulative loss exceeds daily profit: halt and review
Examples
Example 1: CEX-DEX ETH Arbitrage
CEX (Binance): ETH/USDT bid = $2,005.00
DEX (Uniswap): ETH/USDC pool price = $2,000.00
Spread: $5.00 (0.25%)
Costs:
- Uniswap fee: 0.05% = $1.00 per ETH
- Gas for DEX swap: $8 (20 ETH batch)
- Binance taker fee: 0.075% = $1.50 per ETH
- Slippage estimate: 0.02% = $0.40 per ETH
Net profit per ETH: $5.00 - $1.00 - $0.40 - $1.50 - $0.40 = $1.70
For 20 ETH batch: $34.00 - $8 gas = $26.00 net
Execution: Buy 20 ETH on Uniswap, sell 20 ETH on Binance simultaneously
Capital required: $40,000 USDC on-chain + 20 ETH on Binance
Annualized return on capital depends on frequency of opportunities.
Example 2: Cross-Chain Stablecoin Arbitrage
USDC on Ethereum: $1.000
USDC on Arbitrum (via Curve): $0.997 (slight discount)
Strategy:
1. Buy USDC on Arbitrum Curve pool at $0.997
2. Bridge to Ethereum via native bridge (free, but 7-day delay)
Or use fast bridge (Across, Hop) for ~0.05% fee, 2 min
Fast bridge execution:
- Gross profit: 0.3%
- Bridge fee: 0.05%
- Gas (Arbitrum swap): $0.50
- Gas (Ethereum receive): $5
- Net profit: 0.25% - ($5.50 / trade_size)
Break-even trade size: $5.50 / 0.0025 = $2,200 minimum
For $50,000 trade: $125 - $5.50 = $119.50 profit
Risk: USDC discount could widen during transit. Bridge smart contract risk.
Example 3: Triangular Flash Loan Arbitrage
Detected opportunity on Uniswap v3 (Ethereum):
Pool A (WETH/USDC 0.05%): 1 WETH = 2,001 USDC
Pool B (USDC/DAI 0.01%): 1 USDC = 1.0008 DAI
Pool C (DAI/WETH 0.30%): 2,000 DAI = 1.001 WETH
Cycle product: (1/2001) * (1/1.0008) * (2000 * 1.001) = 1.00089
Gross profit per cycle: 0.089%
Flash loan execution:
1. Borrow 100 WETH from Aave
2. Swap 100 WETH -> 200,100 USDC (Pool A, fee: 100 USDC)
3. Swap 200,100 USDC -> 200,260 DAI (Pool B, fee: 20 USDC equiv)
4. Swap 200,260 DAI -> 100.16 WETH (Pool C, fee: 600 DAI equiv)
5. Repay 100 WETH + 0.05 WETH (flash loan fee)
6. Profit: 0.11 WETH (~$220)
7. Gas cost: ~$30
Net profit: ~$190 in a single atomic transaction
Submit via Flashbots to prevent frontrunning.
Quality Gate
Before executing arbitrage strategies, verify:
- [ ] All costs are precisely calculated — gas, fees, slippage, bridge fees, capital costs
- [ ] Liquidity depth is verified on both sides — check order book / pool reserves at trade size
- [ ] Execution risk is quantified — what happens if one leg fails (CEX-DEX) or bridge delays (cross-chain)?
- [ ] Smart contract interactions are tested on testnet or fork before mainnet deployment
- [ ] Flash loan logic includes revert-on-loss safety check (transaction reverts if unprofitable)
- [ ] Bridge risks are assessed and exposure limited — never bridge more than acceptable loss amount
- [ ] Competition level is understood — if margins are sub-$10, likely not worth manual execution
- [ ] Gas estimation includes priority fees during volatile periods when arb opportunities are most common
- [ ] Monitoring and alerting systems are in place for live arbitrage bots
- [ ] Regulatory considerations: market manipulation concerns for certain arbitrage strategies
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: brainbytes-dev
- Source: brainbytes-dev/everything-claude-trading
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.