diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 3eddeda..2100bb6 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -44,9 +44,11 @@ func (w *Worker) Run(ctx context.Context) error { continue } if err := w.processMessages(m); err != nil { + w.l.Errorw("Error when proccess msg", "error", err) return err } if err := w.listener.Ack(ctx, m); err != nil { + w.l.Errorw("Error when ack msg", "error", err) return err } } @@ -69,6 +71,7 @@ func (w *Worker) processMessages(m []evmlistenerclient.Message) error { } order, err := ps.Parse(convert.ToETHLog(log), block.Timestamp) if err != nil { + w.l.Errorw("error when parse log", "log", log, "order", order, "err", err) continue } insertOrders = append(insertOrders, order) diff --git a/pkg/parser/oneinch/parser.go b/pkg/parser/oneinch/parser.go index 3717d88..4c06aab 100644 --- a/pkg/parser/oneinch/parser.go +++ b/pkg/parser/oneinch/parser.go @@ -92,7 +92,7 @@ func (p *Parser) Parse(log ethereumTypes.Log, blockTime uint64) (storage.TradeLo } order, err = p.detectOneInchRfqTrade(order) if err != nil { - return storage.TradeLog{}, err + return order, err } return order, nil } @@ -137,7 +137,6 @@ func (p *Parser) detectOneInchRfqTrade(order storage.TradeLog) (storage.TradeLog } order, err = p.recursiveDetectOneInchRFQTrades(order, traceCall) - if err != nil { return order, err } @@ -149,9 +148,8 @@ func (p *Parser) recursiveDetectOneInchRFQTrades(tradeLog storage.TradeLog, trac var ( err error ) - isOneInchRFQTrade := p.isOneInchRFQTrades(tradeLog.MakerTokenAmount, tradeLog.OrderHash, traceCall) - if isOneInchRFQTrade { + if p.isOneInchRFQTrades(tradeLog.MakerTokenAmount, tradeLog.OrderHash, traceCall) { return p.ParseFromInternalCall(tradeLog, traceCall) } @@ -178,6 +176,7 @@ func (p *Parser) isOneInchRFQTrades(makingAmountOrder string, orderHash string, if err != nil { return false } + return orderHash == orderHashFromOutput && makingAmount == makingAmountOrder } return false diff --git a/pkg/parser/oneinchv6/parser.go b/pkg/parser/oneinchv6/parser.go index 96f29e7..cbcfb1c 100644 --- a/pkg/parser/oneinchv6/parser.go +++ b/pkg/parser/oneinchv6/parser.go @@ -94,7 +94,7 @@ func (p *Parser) Parse(log ethereumTypes.Log, blockTime uint64) (storage.TradeLo } order, err = p.detectOneInchRfqTrade(order) if err != nil { - return storage.TradeLog{}, err + return order, err } return order, nil } @@ -133,6 +133,7 @@ func (p *Parser) detectOneInchRfqTrade(order storage.TradeLog) (storage.TradeLog traceCall types.CallFrame err error ) + traceCall, err = p.traceCalls.GetTraceCall(order.TxHash) if err != nil { return order, err @@ -151,8 +152,7 @@ func (p *Parser) recursiveDetectOneInchRFQTrades(tradeLog storage.TradeLog, trac var ( err error ) - isOneInchRFQTrade := p.isOneInchRFQTrades(tradeLog.OrderHash, traceCall, count) - if isOneInchRFQTrade { + if p.isOneInchRFQTrades(tradeLog.OrderHash, traceCall, count) { return p.ParseFromInternalCall(tradeLog, traceCall) } @@ -162,6 +162,7 @@ func (p *Parser) recursiveDetectOneInchRFQTrades(tradeLog storage.TradeLog, trac return tradeLog, nil } } + return tradeLog, ErrNotFoundTraceCall } @@ -230,5 +231,5 @@ func (p *Parser) decodeOutput(output string) (string, string, string, error) { } func (p *Parser) Exchange() string { - return parser.Ex1Inch + return parser.Ex1InchV6 } diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 00d6c88..b345e28 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -14,6 +14,7 @@ const ( ExHashflow = "hashflow" ExKsRFQ = "kyberswapRFQ" Ex1Inch = "1inch" + Ex1InchV6 = "1inchV6" ExHashflowV3 = "hashflowV3" ExParaswapTaker = "paraswap_taker" ExUniswapX = "uniswapx"