Files
mev-beta/pkg/uniswap/constants.go
Krypto Kajun 850223a953 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>
2025-10-17 00:12:55 -05:00

73 lines
1.6 KiB
Go

// Package uniswap provides mathematical functions for Uniswap V3 calculations.
package uniswap
import (
"math"
"math/big"
"sync"
)
var (
// Global cached constants initialized once to avoid recomputing them
q96 *big.Int
q192 *big.Int
lnBase float64 // ln(1.0001)
invLnBase float64 // 1 / ln(1.0001)
q96Float *big.Float
q192Float *big.Float
once sync.Once
)
// InitConstants initializes all global cached constants
func InitConstants() {
once.Do(func() {
q96 = new(big.Int).Exp(big.NewInt(2), big.NewInt(96), nil)
q192 = new(big.Int).Exp(big.NewInt(2), big.NewInt(192), nil)
lnBase = math.Log(1.0001)
invLnBase = 1.0 / lnBase
q96Float = new(big.Float).SetPrec(256).SetInt(q96)
q192Float = new(big.Float).SetPrec(256).SetInt(q192)
})
}
// initConstants initializes all global cached constants (alias for internal use)
func initConstants() {
InitConstants()
}
// GetQ96 returns the cached value of 2^96
func GetQ96() *big.Int {
initConstants()
return q96
}
// GetQ192 returns the cached value of 2^192
func GetQ192() *big.Int {
initConstants()
return q192
}
// GetLnBase returns the cached value of ln(1.0001)
func GetLnBase() float64 {
initConstants()
return lnBase
}
// GetInvLnBase returns the cached value of 1/ln(1.0001)
func GetInvLnBase() float64 {
initConstants()
return invLnBase
}
// GetQ96Float returns the cached value of 2^96 as big.Float
func GetQ96Float() *big.Float {
initConstants()
return q96Float
}
// GetQ192Float returns the cached value of 2^192 as big.Float
func GetQ192Float() *big.Float {
initConstants()
return q192Float
}