feat(core): implement core MEV bot functionality with market scanning and Uniswap V3 pricing

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Krypto Kajun
2025-09-14 10:16:29 -05:00
parent 5db7587923
commit c16182d80c
1364 changed files with 473970 additions and 1202 deletions

View File

@@ -35,14 +35,14 @@ func (s State) String() string {
// Config holds circuit breaker configuration
type Config struct {
Name string
MaxFailures uint64
ResetTimeout time.Duration
MaxRequests uint64
SuccessThreshold uint64
OnStateChange func(name string, from State, to State)
IsFailure func(error) bool
Logger *logger.Logger
Name string
MaxFailures uint64
ResetTimeout time.Duration
MaxRequests uint64
SuccessThreshold uint64
OnStateChange func(name string, from State, to State)
IsFailure func(error) bool
Logger *logger.Logger
}
// Counts holds the circuit breaker statistics
@@ -56,12 +56,12 @@ type Counts struct {
// CircuitBreaker implements the circuit breaker pattern
type CircuitBreaker struct {
config *Config
mutex sync.RWMutex
state int32
generation uint64
counts Counts
expiry time.Time
config *Config
mutex sync.RWMutex
state int32
generation uint64
counts Counts
expiry time.Time
}
// NewCircuitBreaker creates a new circuit breaker
@@ -246,7 +246,7 @@ func (cb *CircuitBreaker) setState(state State, now time.Time) {
}
if cb.config.Logger != nil {
cb.config.Logger.Info(fmt.Sprintf("Circuit breaker '%s' state changed from %s to %s",
cb.config.Logger.Info(fmt.Sprintf("Circuit breaker '%s' state changed from %s to %s",
cb.config.Name, prev.String(), state.String()))
}
}
@@ -278,8 +278,8 @@ func (cb *CircuitBreaker) Reset() {
// Errors
var (
ErrOpenState = fmt.Errorf("circuit breaker is open")
ErrTooManyRequests = fmt.Errorf("too many requests")
ErrOpenState = fmt.Errorf("circuit breaker is open")
ErrTooManyRequests = fmt.Errorf("too many requests")
)
// TwoStepCircuitBreaker extends CircuitBreaker with two-step recovery
@@ -292,7 +292,7 @@ type TwoStepCircuitBreaker struct {
func NewTwoStepCircuitBreaker(config *Config) *TwoStepCircuitBreaker {
return &TwoStepCircuitBreaker{
CircuitBreaker: NewCircuitBreaker(config),
failFast: true,
failFast: true,
}
}
@@ -405,4 +405,4 @@ func (m *Manager) Reset() {
for _, breaker := range m.breakers {
breaker.Reset()
}
}
}