feat: create v2-prep branch with comprehensive planning
Restructured project for V2 refactor: **Structure Changes:** - Moved all V1 code to orig/ folder (preserved with git mv) - Created docs/planning/ directory - Added orig/README_V1.md explaining V1 preservation **Planning Documents:** - 00_V2_MASTER_PLAN.md: Complete architecture overview - Executive summary of critical V1 issues - High-level component architecture diagrams - 5-phase implementation roadmap - Success metrics and risk mitigation - 07_TASK_BREAKDOWN.md: Atomic task breakdown - 99+ hours of detailed tasks - Every task < 2 hours (atomic) - Clear dependencies and success criteria - Organized by implementation phase **V2 Key Improvements:** - Per-exchange parsers (factory pattern) - Multi-layer strict validation - Multi-index pool cache - Background validation pipeline - Comprehensive observability **Critical Issues Addressed:** - Zero address tokens (strict validation + cache enrichment) - Parsing accuracy (protocol-specific parsers) - No audit trail (background validation channel) - Inefficient lookups (multi-index cache) - Stats disconnection (event-driven metrics) Next Steps: 1. Review planning documents 2. Begin Phase 1: Foundation (P1-001 through P1-010) 3. Implement parsers in Phase 2 4. Build cache system in Phase 3 5. Add validation pipeline in Phase 4 6. Migrate and test in Phase 5 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,148 +0,0 @@
|
||||
// Package types provides shared types used across multiple packages to avoid circular dependencies
|
||||
package types
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
// ArbitrageOpportunity represents a potential arbitrage opportunity
|
||||
// This is the canonical definition used across all packages
|
||||
type ArbitrageOpportunity struct {
|
||||
ID string // Unique identifier for the opportunity
|
||||
Path []string // Token path for the arbitrage
|
||||
Pools []string // Pools involved in the arbitrage
|
||||
AmountIn *big.Int // Input amount for the arbitrage (wei)
|
||||
Profit *big.Int // Estimated gross profit in wei
|
||||
NetProfit *big.Int // Net profit after gas costs in wei
|
||||
GasEstimate *big.Int // Estimated gas usage cost in wei
|
||||
GasCost *big.Int // Calculated gas cost in wei (optional)
|
||||
EstimatedProfit *big.Int // Cached estimated profit in wei
|
||||
RequiredAmount *big.Int // Capital required to execute in wei
|
||||
ROI float64 // Return on investment percentage
|
||||
Protocol string // DEX protocol
|
||||
ExecutionTime int64 // Estimated execution time in milliseconds
|
||||
Confidence float64 // 0-1 confidence score
|
||||
PriceImpact float64 // Price impact percentage
|
||||
MaxSlippage float64 // Maximum acceptable slippage percentage
|
||||
TokenIn common.Address // Input token address
|
||||
TokenOut common.Address // Output token address
|
||||
Timestamp int64 // Detection timestamp (unix seconds)
|
||||
DetectedAt time.Time // Detection timestamp with higher precision
|
||||
ExpiresAt time.Time // Expiration timestamp
|
||||
Urgency int // Relative urgency (1-10)
|
||||
Risk float64 // Risk assessment score (0-1)
|
||||
Profitable bool // Indicates if opportunity is currently profitable
|
||||
Quantities *OpportunityQuantities // Optional UniversalDecimal snapshots
|
||||
}
|
||||
|
||||
// DecimalAmount serialises a decimal quantity without importing math helpers.
|
||||
type DecimalAmount struct {
|
||||
Value string `json:"value"`
|
||||
Decimals uint8 `json:"decimals"`
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
// OpportunityQuantities bundles the primary decimal metrics for an opportunity.
|
||||
type OpportunityQuantities struct {
|
||||
AmountIn DecimalAmount `json:"amount_in"`
|
||||
AmountOut DecimalAmount `json:"amount_out"`
|
||||
GrossProfit DecimalAmount `json:"gross_profit"`
|
||||
NetProfit DecimalAmount `json:"net_profit"`
|
||||
GasCost DecimalAmount `json:"gas_cost"`
|
||||
ProfitPercent DecimalAmount `json:"profit_percentage"`
|
||||
PriceImpact DecimalAmount `json:"price_impact"`
|
||||
}
|
||||
|
||||
// PriceMovement represents a potential price movement
|
||||
type PriceMovement struct {
|
||||
Token0 string // Token address
|
||||
Token1 string // Token address
|
||||
Pool string // Pool address
|
||||
Protocol string // DEX protocol
|
||||
AmountIn *big.Int // Amount of token being swapped in
|
||||
AmountOut *big.Int // Amount of token being swapped out
|
||||
PriceBefore *big.Float // Price before the swap
|
||||
PriceAfter *big.Float // Price after the swap (to be calculated)
|
||||
PriceImpact float64 // Calculated price impact
|
||||
TickBefore int // Tick before the swap
|
||||
TickAfter int // Tick after the swap (to be calculated)
|
||||
Timestamp int64 // Event timestamp
|
||||
}
|
||||
|
||||
// CachedData represents cached pool data
|
||||
type CachedData struct {
|
||||
Address common.Address
|
||||
Token0 common.Address
|
||||
Token1 common.Address
|
||||
Fee int64
|
||||
Liquidity *big.Int
|
||||
SqrtPriceX96 *big.Int
|
||||
Tick int
|
||||
TickSpacing int
|
||||
LastUpdated int64
|
||||
Protocol string
|
||||
}
|
||||
|
||||
// SwapEvent represents a swap event
|
||||
type SwapEvent struct {
|
||||
Type int
|
||||
Protocol string
|
||||
PoolAddress common.Address
|
||||
Token0 common.Address
|
||||
Token1 common.Address
|
||||
Amount0 *big.Int
|
||||
Amount1 *big.Int
|
||||
SqrtPriceX96 *big.Int
|
||||
Liquidity *big.Int
|
||||
Tick int
|
||||
Timestamp int64
|
||||
TransactionHash common.Hash
|
||||
BlockNumber uint64
|
||||
Fee uint32
|
||||
}
|
||||
|
||||
// LiquidityEvent represents a liquidity event (add/remove)
|
||||
type LiquidityEvent struct {
|
||||
Type int
|
||||
Protocol string
|
||||
PoolAddress common.Address
|
||||
Token0 common.Address
|
||||
Token1 common.Address
|
||||
Amount0 *big.Int
|
||||
Amount1 *big.Int
|
||||
Liquidity *big.Int
|
||||
Tick int
|
||||
Timestamp int64
|
||||
TransactionHash common.Hash
|
||||
BlockNumber uint64
|
||||
Fee uint32
|
||||
Sender common.Address
|
||||
Recipient common.Address
|
||||
EventType string // "add" or "remove"
|
||||
}
|
||||
|
||||
// PoolData represents pool data
|
||||
type PoolData struct {
|
||||
Address common.Address
|
||||
Token0 common.Address
|
||||
Token1 common.Address
|
||||
Fee int64
|
||||
Liquidity *big.Int
|
||||
SqrtPriceX96 *big.Int
|
||||
Tick int64
|
||||
TickSpacing int
|
||||
LastUpdated int64
|
||||
Protocol string
|
||||
}
|
||||
|
||||
// Constants for event types
|
||||
const (
|
||||
Unknown = iota
|
||||
Swap
|
||||
AddLiquidity
|
||||
RemoveLiquidity
|
||||
NewPool
|
||||
)
|
||||
Reference in New Issue
Block a user