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>
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package scanner
|
|
|
|
import (
|
|
"math/big"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
)
|
|
|
|
// TokenDecimalMap provides decimal information for common tokens
|
|
var TokenDecimalMap = map[common.Address]int{
|
|
common.HexToAddress("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"): 18, // WETH
|
|
common.HexToAddress("0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"): 6, // USDC
|
|
common.HexToAddress("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"): 6, // USDT
|
|
common.HexToAddress("0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f"): 8, // WBTC
|
|
common.HexToAddress("0x912CE59144191C1204E64559FE8253a0e49E6548"): 18, // ARB
|
|
}
|
|
|
|
// GetTokenDecimals returns decimals for a token (defaults to 18)
|
|
func GetTokenDecimals(token common.Address) int {
|
|
if decimals, ok := TokenDecimalMap[token]; ok {
|
|
return decimals
|
|
}
|
|
return 18
|
|
}
|
|
|
|
// NormalizeToEther converts token amount to ether equivalent considering decimals
|
|
func NormalizeToEther(amount *big.Int, token common.Address) *big.Float {
|
|
if amount == nil {
|
|
return big.NewFloat(0)
|
|
}
|
|
|
|
decimals := GetTokenDecimals(token)
|
|
divisor := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(decimals)), nil)
|
|
|
|
result := new(big.Float).Quo(
|
|
new(big.Float).SetInt(amount),
|
|
new(big.Float).SetInt(divisor),
|
|
)
|
|
|
|
return result
|
|
}
|