fix(types): add missing types and fix compilation errors - WIP
Fixed compilation errors in integration code: Type System Fixes: - Add types.Logger type alias (*slog.Logger) - Add PoolInfo.LiquidityUSD field - Add ProtocolSushiSwap and ProtocolCamelot constants - Fix time.Now() call in arbiscan_validator.go Pool Discovery Fixes: - Change cache from *cache.PoolCache to cache.PoolCache (interface) - Add context.Context parameters to cache.Add() and cache.Count() calls - Fix protocol type from string to ProtocolType Docker Fixes: - Add .dockerignore to exclude test files and docs - Add go mod tidy step in Dockerfile - Add //go:build examples tag to example_usage.go Still Remaining: - Arbitrage package needs similar interface fixes - SwapEvent.TokenIn/TokenOut field name issues - More cache interface method calls need context Progress: Parser and pool discovery packages now compile correctly. Integration code (main.go, sequencer, pools) partially working. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
54
.dockerignore
Normal file
54
.dockerignore
Normal file
@@ -0,0 +1,54 @@
|
||||
# Exclude V1 codebase (not needed in V2 container)
|
||||
orig/
|
||||
|
||||
# Exclude build artifacts
|
||||
bin/
|
||||
build/
|
||||
dist/
|
||||
*.exe
|
||||
|
||||
# Exclude logs
|
||||
logs/
|
||||
*.log
|
||||
|
||||
# Exclude temporary files
|
||||
tmp/
|
||||
temp/
|
||||
*.tmp
|
||||
|
||||
# Exclude test coverage
|
||||
*.out
|
||||
coverage.html
|
||||
|
||||
# Exclude IDE files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
|
||||
# Exclude git
|
||||
.git/
|
||||
.gitignore
|
||||
|
||||
# Exclude documentation (not needed at runtime)
|
||||
docs/
|
||||
*.md
|
||||
|
||||
# Exclude environment files (passed at runtime)
|
||||
.env
|
||||
.env.*
|
||||
|
||||
# Exclude Docker/k8s files
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
|
||||
# Exclude test files
|
||||
*_test.go
|
||||
example_usage.go
|
||||
examples_test.go
|
||||
|
||||
# Exclude scripts (not needed in container)
|
||||
scripts/
|
||||
|
||||
# Exclude config (provisioned externally)
|
||||
config/
|
||||
@@ -18,6 +18,9 @@ RUN go mod download
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Update go.sum with all dependencies
|
||||
RUN go mod tidy
|
||||
|
||||
# Build the application
|
||||
RUN go build -o mev-bot-v2 -ldflags="-w -s" ./cmd/mev-bot-v2
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ func (v *ArbiscanValidator) ValidateSwap(ctx context.Context, event *types.SwapE
|
||||
SwapEvent: event,
|
||||
ArbiscanLog: matchingLog,
|
||||
Discrepancies: discrepancies,
|
||||
ValidatedAt: time.Time(),
|
||||
ValidatedAt: time.Now(),
|
||||
}
|
||||
|
||||
// Log validation result
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
//go:build examples
|
||||
// +build examples
|
||||
|
||||
package parsers
|
||||
|
||||
// This file demonstrates how to use the parser factory with multiple protocol parsers,
|
||||
|
||||
@@ -84,7 +84,7 @@ func DefaultDiscoveryConfig() *DiscoveryConfig {
|
||||
type Discovery struct {
|
||||
config *DiscoveryConfig
|
||||
client *ethclient.Client
|
||||
cache *cache.PoolCache
|
||||
cache cache.PoolCache
|
||||
logger *slog.Logger
|
||||
|
||||
mu sync.Mutex
|
||||
@@ -92,7 +92,7 @@ type Discovery struct {
|
||||
}
|
||||
|
||||
// NewDiscovery creates a new pool discovery service
|
||||
func NewDiscovery(config *DiscoveryConfig, cache *cache.PoolCache, logger *slog.Logger) (*Discovery, error) {
|
||||
func NewDiscovery(config *DiscoveryConfig, poolCache cache.PoolCache, logger *slog.Logger) (*Discovery, error) {
|
||||
if config == nil {
|
||||
config = DefaultDiscoveryConfig()
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func NewDiscovery(config *DiscoveryConfig, cache *cache.PoolCache, logger *slog.
|
||||
return &Discovery{
|
||||
config: config,
|
||||
client: client,
|
||||
cache: cache,
|
||||
cache: poolCache,
|
||||
logger: logger.With("component", "pool_discovery"),
|
||||
}, nil
|
||||
}
|
||||
@@ -124,7 +124,8 @@ func (d *Discovery) DiscoverAll(ctx context.Context) error {
|
||||
d.logger.Error("uniswap v3 discovery failed", "error", err)
|
||||
}
|
||||
|
||||
d.logger.Info("pool discovery complete", "pools_discovered", d.poolsDiscovered, "total_cached", d.cache.Count())
|
||||
count, _ := d.cache.Count(ctx)
|
||||
d.logger.Info("pool discovery complete", "pools_discovered", d.poolsDiscovered, "total_cached", count)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ func (d *Discovery) discoverUniswapV2Pools(ctx context.Context) error {
|
||||
|
||||
factories := []struct {
|
||||
address common.Address
|
||||
protocol string
|
||||
protocol mevtypes.ProtocolType
|
||||
}{
|
||||
{UniswapV2FactoryAddress, mevtypes.ProtocolUniswapV2},
|
||||
{CamelotFactoryAddress, mevtypes.ProtocolCamelot},
|
||||
@@ -173,7 +174,7 @@ func (d *Discovery) discoverUniswapV2Pools(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Add to cache
|
||||
if err := d.cache.Add(poolInfo); err != nil {
|
||||
if err := d.cache.Add(ctx, poolInfo); err != nil {
|
||||
d.logger.Warn("failed to add pool to cache", "pool", poolAddr.Hex(), "error", err)
|
||||
continue
|
||||
}
|
||||
@@ -218,7 +219,7 @@ func (d *Discovery) getUniswapV2Pool(ctx context.Context, factory common.Address
|
||||
}
|
||||
|
||||
// fetchUniswapV2PoolInfo fetches pool information
|
||||
func (d *Discovery) fetchUniswapV2PoolInfo(ctx context.Context, poolAddr, token0, token1 common.Address, protocol string) (*mevtypes.PoolInfo, error) {
|
||||
func (d *Discovery) fetchUniswapV2PoolInfo(ctx context.Context, poolAddr, token0, token1 common.Address, protocol mevtypes.ProtocolType) (*mevtypes.PoolInfo, error) {
|
||||
// getReserves() returns (uint112,uint112,uint32)
|
||||
// Simplified - in production use generated bindings
|
||||
calldata := []byte{0x09, 0x02, 0xf1, 0xac} // getReserves selector
|
||||
@@ -290,7 +291,7 @@ func (d *Discovery) discoverUniswapV3Pools(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Add to cache
|
||||
if err := d.cache.Add(poolInfo); err != nil {
|
||||
if err := d.cache.Add(ctx, poolInfo); err != nil {
|
||||
d.logger.Warn("failed to add pool to cache", "pool", poolAddr.Hex(), "error", err)
|
||||
continue
|
||||
}
|
||||
@@ -391,8 +392,9 @@ func (d *Discovery) GetStats() map[string]interface{} {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
|
||||
count, _ := d.cache.Count(context.Background())
|
||||
return map[string]interface{}{
|
||||
"pools_discovered": d.poolsDiscovered,
|
||||
"pools_cached": d.cache.Count(),
|
||||
"pools_cached": count,
|
||||
}
|
||||
}
|
||||
|
||||
8
pkg/types/logger.go
Normal file
8
pkg/types/logger.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
// Logger is an alias for structured logger
|
||||
type Logger = *slog.Logger
|
||||
@@ -25,6 +25,7 @@ type PoolInfo struct {
|
||||
Reserve0 *big.Int
|
||||
Reserve1 *big.Int
|
||||
Liquidity *big.Int
|
||||
LiquidityUSD *big.Int // Total liquidity in USD (estimated)
|
||||
|
||||
// Fee information
|
||||
Fee uint32 // Fee in basis points (e.g., 30 = 0.3%)
|
||||
|
||||
@@ -20,6 +20,8 @@ const (
|
||||
ProtocolBalancerV3 ProtocolType = "balancer-v3"
|
||||
ProtocolKyberClassic ProtocolType = "kyber-classic"
|
||||
ProtocolKyberElastic ProtocolType = "kyber-elastic"
|
||||
ProtocolSushiSwap ProtocolType = "sushiswap"
|
||||
ProtocolCamelot ProtocolType = "camelot"
|
||||
ProtocolCamelotV2 ProtocolType = "camelot-v2"
|
||||
ProtocolCamelotV3AlgebraV1 ProtocolType = "camelot-v3-algebra-v1"
|
||||
ProtocolCamelotV3AlgebraV19 ProtocolType = "camelot-v3-algebra-v1.9"
|
||||
|
||||
Reference in New Issue
Block a user