Skip to content

Conversation

@deividaspetraitis
Copy link
Contributor

Implements rankRoutesByDirectQuoteInGivenOut API for computing exact amount out quotes.

This is smaller chunk of bigger PR-607 ( #607 ) implementing computing exact amount out quotes.

Implements `rankRoutesByDirectQuoteInGivenOut` API for computing exact
amount out quotes.

This is smaller chunk of bigger PR-607 ( #607 ) implementing computing exact
amount out quotes.
func (r *routerUseCaseImpl) rankRoutesByDirectQuoteInGivenOut(ctx context.Context, candidateRoutes ingesttypes.CandidateRoutes, tokenOut sdk.Coin, tokenInDenom string, maxSplitRoutes int) (domain.Quote, []route.RouteImpl, error) {
// Note that retrieving pools and taker fees is done in separate transactions.
// This is fine because taker fees don't change often.
routes, err := r.poolsUsecase.GetRoutesFromCandidates(candidateRoutes, tokenOut.Denom, tokenInDenom)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewer: this method is already covered with tests RoutesFromCandidates

return nil, nil, err
}

topQuote, routesWithAmtOut, err := r.estimateAndRankSingleRouteQuoteInGivenOut(ctx, routes, tokenOut, r.logger)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewer: method estimateAndRankSingleRouteQuoteInGivenOut is already covered with tests.

// - fails to read taker fees
// - fails to convert candidate routes to routes
// - fails to estimate direct quotes
func (r *routerUseCaseImpl) rankRoutesByDirectQuoteInGivenOut(ctx context.Context, candidateRoutes ingesttypes.CandidateRoutes, tokenOut sdk.Coin, tokenInDenom string, maxSplitRoutes int) (domain.Quote, []route.RouteImpl, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewer: this method is not tested at this moment since it gets tested once split routes are in place as it is currently with OutGivenIn and nolint:unused directive will be removed at the same time as well.

Copy link
Contributor Author

@deividaspetraitis deividaspetraitis Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to merge this PR since internal details are already covered with existing tests and this function will get tested once split routes are in place.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
18.8% Coverage on New Code (required ≥ 50%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants