fix(compilation): resolve type system and interface errors
- Add GetPoolsByToken method to cache interface and implementation - Fix interface pointer types (use interface not *interface) - Fix SwapEvent.TokenIn/TokenOut usage to use GetInputToken/GetOutputToken methods - Fix ethereum.CallMsg import and usage - Fix parser factory and validator initialization in main.go - Remove unused variables and imports WIP: Still fixing main.go config struct field mismatches 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -271,19 +271,13 @@ func (c *Calculator) calculateSwapOutputCurve(pool *types.PoolInfo, tokenIn, tok
|
||||
return nil, 0, fmt.Errorf("pool has nil reserves")
|
||||
}
|
||||
|
||||
// Determine direction
|
||||
var reserveIn, reserveOut *big.Int
|
||||
if tokenIn == pool.Token0 {
|
||||
reserveIn = pool.Reserve0
|
||||
reserveOut = pool.Reserve1
|
||||
} else if tokenIn == pool.Token1 {
|
||||
reserveIn = pool.Reserve1
|
||||
reserveOut = pool.Reserve0
|
||||
} else {
|
||||
// Determine direction (validate token is in pool)
|
||||
if tokenIn != pool.Token0 && tokenIn != pool.Token1 {
|
||||
return nil, 0, fmt.Errorf("token not in pool")
|
||||
}
|
||||
|
||||
// Simplified: assume 1:1 swap with low slippage for stablecoins
|
||||
// TODO: Implement proper Curve StableSwap math using reserves and amp coefficient
|
||||
// This is a rough approximation - actual Curve math is more complex
|
||||
fee := pool.Fee
|
||||
if fee == 0 {
|
||||
|
||||
@@ -56,7 +56,7 @@ type Detector struct {
|
||||
config *DetectorConfig
|
||||
pathFinder *PathFinder
|
||||
calculator *Calculator
|
||||
poolCache *cache.PoolCache
|
||||
poolCache cache.PoolCache
|
||||
logger *slog.Logger
|
||||
|
||||
// Statistics
|
||||
@@ -72,7 +72,7 @@ func NewDetector(
|
||||
config *DetectorConfig,
|
||||
pathFinder *PathFinder,
|
||||
calculator *Calculator,
|
||||
poolCache *cache.PoolCache,
|
||||
poolCache cache.PoolCache,
|
||||
logger *slog.Logger,
|
||||
) *Detector {
|
||||
if config == nil {
|
||||
@@ -153,7 +153,9 @@ func (d *Detector) DetectOpportunitiesForSwap(ctx context.Context, swapEvent *me
|
||||
)
|
||||
|
||||
// Get affected tokens
|
||||
tokens := []common.Address{swapEvent.TokenIn, swapEvent.TokenOut}
|
||||
tokenIn, _ := swapEvent.GetInputToken()
|
||||
tokenOut, _ := swapEvent.GetOutputToken()
|
||||
tokens := []common.Address{tokenIn, tokenOut}
|
||||
|
||||
allOpportunities := make([]*Opportunity, 0)
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ func DefaultPathFinderConfig() *PathFinderConfig {
|
||||
|
||||
// PathFinder finds arbitrage paths between tokens
|
||||
type PathFinder struct {
|
||||
cache *cache.PoolCache
|
||||
cache cache.PoolCache
|
||||
config *PathFinderConfig
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
// NewPathFinder creates a new path finder
|
||||
func NewPathFinder(cache *cache.PoolCache, config *PathFinderConfig, logger *slog.Logger) *PathFinder {
|
||||
func NewPathFinder(cache cache.PoolCache, config *PathFinderConfig, logger *slog.Logger) *PathFinder {
|
||||
if config == nil {
|
||||
config = DefaultPathFinderConfig()
|
||||
}
|
||||
@@ -427,11 +427,11 @@ func (pf *PathFinder) getCommonTokens(ctx context.Context, baseToken common.Addr
|
||||
// ARB
|
||||
arb := common.HexToAddress("0x912CE59144191C1204E64559FE8253a0e49E6548")
|
||||
|
||||
common := []common.Address{weth, usdc, usdt, dai, arb}
|
||||
commonTokens := []common.Address{weth, usdc, usdt, dai, arb}
|
||||
|
||||
// Filter out the base token itself
|
||||
filtered := make([]common.Address, 0)
|
||||
for _, token := range common {
|
||||
for _, token := range commonTokens {
|
||||
if token != baseToken {
|
||||
filtered = append(filtered, token)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user