Skip to content

Commit

Permalink
check use old amount
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocthanh1389 committed Aug 14, 2024
1 parent f51d986 commit f2dadb0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/parser/bebop/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func (p *Parser) ParseFromInternalCall(order storage.TradeLog, internalCall type
case p.aggregateOrderFunc.Has(contractCall.Name):
return p.parseAggregateSwap(order, contractCall, param, filledTakerAmount)
}
break
}

return order, nil
Expand Down Expand Up @@ -285,10 +286,10 @@ func (p *Parser) LogFromExchange(log ethereumTypes.Log) bool {

func (p *Parser) parseSingleSwap(order storage.TradeLog,
contractCall *tradingTypes.ContractCall,
param tradingTypes.ContractCallParam,
orderParam tradingTypes.ContractCallParam,
fillTakerAmount *big.Int) (storage.TradeLog, error) {
var rfqOrder SingleOrder
if err := unpackOrder(param.Value, &rfqOrder); err != nil {
if err := unpackOrder(orderParam.Value, &rfqOrder); err != nil {
return order, err
}

Expand All @@ -297,7 +298,7 @@ func (p *Parser) parseSingleSwap(order storage.TradeLog,
continue
}
var oldOrder OldSingleQuote
if err := unpackOrder(param.Value, &oldOrder); err == nil {
if err := unpackOrder(param.Value, &oldOrder); err == nil && oldOrder.UseOldAmount {
rfqOrder.MakerAmount = oldOrder.MakerAmount
}
break
Expand All @@ -324,10 +325,10 @@ func (p *Parser) parseSingleSwap(order storage.TradeLog,

func (p *Parser) parseMultiSwap(order storage.TradeLog,
contractCall *tradingTypes.ContractCall,
param tradingTypes.ContractCallParam,
orderParam tradingTypes.ContractCallParam,
fillTakerAmount *big.Int) (storage.TradeLog, error) {
var rfqOrder MultiOrder
if err := unpackOrder(param.Value, &rfqOrder); err != nil {
if err := unpackOrder(orderParam.Value, &rfqOrder); err != nil {
return order, err
}

Expand All @@ -336,7 +337,7 @@ func (p *Parser) parseMultiSwap(order storage.TradeLog,
continue
}
var oldOrder OldMultiQuote
if err := unpackOrder(param.Value, &oldOrder); err == nil {
if err := unpackOrder(param.Value, &oldOrder); err == nil && oldOrder.UseOldAmount {
rfqOrder.MakerAmounts = oldOrder.MakerAmounts
}
break
Expand Down Expand Up @@ -371,11 +372,11 @@ func (p *Parser) parseMultiSwap(order storage.TradeLog,

func (p *Parser) parseAggregateSwap(order storage.TradeLog,
contractCall *tradingTypes.ContractCall,
param tradingTypes.ContractCallParam,
orderParam tradingTypes.ContractCallParam,
filledTakerAmount *big.Int) (storage.TradeLog, error) {

var rfqOrder AggregateOrder
if err := unpackOrder(param.Value, &rfqOrder); err != nil {
if err := unpackOrder(orderParam.Value, &rfqOrder); err != nil {
return order, err
}

Expand All @@ -384,7 +385,7 @@ func (p *Parser) parseAggregateSwap(order storage.TradeLog,
continue
}
var oldOrder OldAggregateQuote
if err := unpackOrder(param.Value, &oldOrder); err == nil {
if err := unpackOrder(param.Value, &oldOrder); err == nil && oldOrder.UseOldAmount {
rfqOrder.MakerAmounts = oldOrder.MakerAmounts
}
break
Expand Down

0 comments on commit f2dadb0

Please sign in to comment.