fix(multicall): resolve critical multicall parsing corruption issues
- 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>
This commit is contained in:
111
docs/master-plan/07-pancakeswap-integration.md
Normal file
111
docs/master-plan/07-pancakeswap-integration.md
Normal file
@@ -0,0 +1,111 @@
|
||||
# PancakeSwap Integration Plan
|
||||
|
||||
## Overview
|
||||
|
||||
This document outlines the implementation plan for PancakeSwap exchange support in the MEV bot. PancakeSwap is a decentralized exchange running on Binance Smart Chain, offering similar functionality to Uniswap but with BNB chain-specific features.
|
||||
|
||||
## Contract Architecture
|
||||
|
||||
### Core Contracts
|
||||
- Router: `0x10ED43C718612782E9E672E01bCc53Bb3a3b6B2e` (V2), `0x13f4EA83D0bd40E75C8222255bc855a9243358F6` (V3)
|
||||
- Factory: `0xcA143Ce32Fe78f1f7019d7d551a6402fC535aa17` (V2), `0x0BFbCF9fa4f9C56B0F40a6C1cA9bC67Ec9872923` (V3)
|
||||
- MasterChef: `0xa5f8C5Dbd5F286960b9d90548680aE5ebFf07652` (V2 farming)
|
||||
- MasterChefV3: `0x556B9306565093C852F783C116e951053Ac0C548`
|
||||
|
||||
### Unique Features
|
||||
- Syrup Pools (single asset staking)
|
||||
- Prediction markets
|
||||
- Lottery
|
||||
- NFT marketplace integration
|
||||
|
||||
## Core Functions
|
||||
|
||||
### V2 Swap Functions
|
||||
- `swapExactTokensForTokens`
|
||||
- `swapTokensForExactTokens`
|
||||
- `swapExactBNBForTokens`
|
||||
- `swapTokensForExactBNB`
|
||||
- `getAmountsOut`
|
||||
- `getAmountsIn`
|
||||
|
||||
### V3 Swap Functions
|
||||
- `exactInputSingle`
|
||||
- `exactOutputSingle`
|
||||
- `exactInput`
|
||||
- `exactOutput`
|
||||
|
||||
### Liquidity Functions
|
||||
- `addLiquidity`
|
||||
- `addLiquidityBNB`
|
||||
- `removeLiquidity`
|
||||
- `removeLiquidityBNB`
|
||||
|
||||
### Farming Functions
|
||||
- `deposit` (to MasterChef)
|
||||
- `withdraw` (from MasterChef)
|
||||
- `pendingCake` (pending rewards)
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
1. Create PancakeSwap struct implementing the Exchange interface
|
||||
2. Implement both V2 and V3 contract support
|
||||
3. Handle BNB-specific swap functions
|
||||
4. Implement MasterChef integration for yield farming
|
||||
5. Add Syrup Pool support
|
||||
6. Create BSC-specific gas estimation
|
||||
7. Implement PCS-specific routing logic
|
||||
8. Add support for PCS tokens and farms
|
||||
|
||||
## Pricing Mechanisms
|
||||
|
||||
### V2 Pricing
|
||||
- Standard constant product AMM formula
|
||||
- 0.25% swap fee (compared to 0.3% on Uniswap)
|
||||
- Use reserves to calculate price impact
|
||||
|
||||
### V3 Pricing
|
||||
- Concentrated liquidity model
|
||||
- Tick-based pricing mechanism
|
||||
- Variable swap fees based on pool (0.01%, 0.05%, 0.25%, 1%)
|
||||
|
||||
### PCS-Specific Considerations
|
||||
- Lower standard swap fees (0.25% vs 0.3%)
|
||||
- BNB integration for direct swaps
|
||||
- Farming reward tracking in profitability calculations
|
||||
|
||||
## Testing Plan
|
||||
|
||||
1. Unit tests for V2 and V3 swap functions
|
||||
2. BNB-specific swap testing
|
||||
3. MasterChef integration testing
|
||||
4. Syrup Pool functionality verification
|
||||
5. Cross-chain arbitrage opportunity testing
|
||||
6. Edge case testing (zero amounts, max amounts)
|
||||
7. Price accuracy verification
|
||||
8. Gas optimization testing on BSC
|
||||
|
||||
## Performance Considerations
|
||||
|
||||
- BSC's faster block times (compared to Ethereum)
|
||||
- Lower gas costs for more frequent operations
|
||||
- Efficient routing between V2 and V3 pools
|
||||
- Cache frequently accessed pool information
|
||||
- Batch operations to reduce transaction costs
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- Validate BSC-specific contract addresses
|
||||
- Implement proper slippage protection
|
||||
- Handle BSC's different security model
|
||||
- Verify farm and pool parameters
|
||||
- Sanitize data from external PCS contracts
|
||||
|
||||
## Integration with MEV Bot
|
||||
|
||||
- Identify PCS-specific arbitrage opportunities
|
||||
- Monitor V2 and V3 pools for profitable swaps
|
||||
- Track farming rewards in profitability calculations
|
||||
- Include Syrup Pools in yield strategies
|
||||
- Coordinate with other exchanges for cross-chain arbitrage
|
||||
- Consider CAKE token incentives in trade decisions
|
||||
- Monitor new farm launches for early entry opportunities
|
||||
Reference in New Issue
Block a user