- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing - Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives - Added LRU caching system for address validation with 10-minute TTL - Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures - Fixed duplicate function declarations and import conflicts across multiple files - Added error recovery mechanisms with multiple fallback strategies - Updated tests to handle new validation behavior for suspicious addresses - Fixed parser test expectations for improved validation system - Applied gofmt formatting fixes to ensure code style compliance - Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot - Resolved critical security vulnerabilities in heuristic address extraction - Progress: Updated TODO audit from 10% to 35% complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2.4 KiB
2.4 KiB
Arbitrage Executor Hardening Plan
Overview
Replace simulated flash-swap execution paths with on-chain integrations, accurate gas handling, and post-trade reconciliation. The current implementation relies on mock receipts, placeholder calldata, and synthetic pool data.
Tasks
-
Contract Integration
- Add Go bindings for the flash swap/aggregator contract (generate via
abigenif absent). - Define canonical calldata struct matching the on-chain function signature (token path, pool info, slippage limits, recipient).
- Add Go bindings for the flash swap/aggregator contract (generate via
-
Transaction Submission
- Replace
submitTransactionwith actual contract call using flash swap aggregator binding. - Implement nonce management and ensure transactions are signed with the configured key manager.
- Replace
-
Gas Estimation & Pricing
- Swap placeholder gas limit with
client.EstimateGas(include calldata and value). - Fetch base fee + priority tip dynamically; tie into Arbitrum fee/tip suggestions.
- Enforce config-driven max fee/tip thresholds (fallback to abort rather than cap to static value).
- Swap placeholder gas limit with
-
Confirmation & Reverts
- Replace simulated receipt in
waitForConfirmationwith pollingTransactionReceipt, respecting context timeout. - Decode revert reasons/logs for diagnostics; handle dropped/replace-by-fee scenarios.
- Replace simulated receipt in
-
Profit/Loss Calculation
- Update
calculateActualProfitto parse emitted events/logs for actual amounts in/out. - Subtract real gas cost from on-chain data; convert to
UniversalDecimalwith correct symbols. - Emit structured logs/metrics for realized profit, slippage, and gas usage.
- Update
-
Fallback & Simulation
- Move current simulation helpers into a
*_test.goor dev-only path; guard with build tags if necessary.
- Move current simulation helpers into a
-
Tests
- Unit tests using mocked contract interface for success, revert, and timeout.
- Integration test with geth simulated backend or fork network verifying end-to-end flash swap.
-
Documentation
- Update
docs/5_development/anddocs/6_operations/with new requirements (contract addresses, env vars). - Note the removal of simulated paths; include troubleshooting steps for on-chain failures.
- Update
References:
pkg/arbitrage/executor.go(simulateFlashSwapArbitrage, executeArbitrage)pkg/arbitrage/flash_executor.go(submitTransaction, waitForConfirmation, calculateActualProfit)