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:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user