Skip to content

Commit

Permalink
Update services/rfq/relayer/quoter/quoter.go
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
trajan0x and coderabbitai[bot] authored Mar 14, 2024
1 parent 6d4d33e commit 0dca5ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions services/rfq/relayer/quoter/quoter.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func (m *Manager) generateQuote(ctx context.Context, keyTokenID string, chainID
originStr := strings.Split(keyTokenID, "-")[0]
origin, err := strconv.Atoi(originStr)
if err != nil {
logger.Error("Error converting origin chainID", "error", err)
return nil, fmt.Errorf("error converting origin chainID: %w", err)
}

Check warning on line 311 in services/rfq/relayer/quoter/quoter.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/quoter/quoter.go#L309-L311

Added lines #L309 - L311 were not covered by tests
originTokenAddr := common.HexToAddress(strings.Split(keyTokenID, "-")[1])
Expand All @@ -316,26 +317,31 @@ func (m *Manager) generateQuote(ctx context.Context, keyTokenID string, chainID
if errors.Is(err, errMinGasExceedsQuoteAmount) {
quoteAmount = big.NewInt(0)
} else if err != nil {
logger.Error("Error getting quote amount", "error", err)
return nil, err
}

Check warning on line 322 in services/rfq/relayer/quoter/quoter.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/quoter/quoter.go#L320-L322

Added lines #L320 - L322 were not covered by tests

// Calculate the fee for this route
destToken, err := m.config.GetTokenName(uint32(chainID), address.Hex())
if err != nil {
logger.Error("Error getting dest token ID", "error", err)
return nil, fmt.Errorf("error getting dest token ID: %w", err)
}

Check warning on line 329 in services/rfq/relayer/quoter/quoter.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/quoter/quoter.go#L327-L329

Added lines #L327 - L329 were not covered by tests
fee, err := m.feePricer.GetTotalFee(ctx, uint32(origin), uint32(chainID), destToken, true)
if err != nil {
logger.Error("Error getting total fee", "error", err)
return nil, fmt.Errorf("error getting total fee: %w", err)
}

Check warning on line 334 in services/rfq/relayer/quoter/quoter.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/quoter/quoter.go#L332-L334

Added lines #L332 - L334 were not covered by tests
originRFQAddr, err := m.config.GetRFQAddress(origin)
if err != nil {
logger.Error("Error getting RFQ address", "error", err)
return nil, fmt.Errorf("error getting RFQ address: %w", err)
}

Check warning on line 339 in services/rfq/relayer/quoter/quoter.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/quoter/quoter.go#L337-L339

Added lines #L337 - L339 were not covered by tests

// Build the quote
destAmount, err := m.getDestAmount(ctx, quoteAmount, chainID)
if err != nil {
logger.Error("Error getting dest amount", "error", err)
return nil, fmt.Errorf("error getting dest amount: %w", err)
}

Check warning on line 346 in services/rfq/relayer/quoter/quoter.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/quoter/quoter.go#L344-L346

Added lines #L344 - L346 were not covered by tests
quote = &model.PutQuoteRequest{
Expand Down

0 comments on commit 0dca5ef

Please sign in to comment.