Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE-693 | Implement rankRoutesByDirectQuoteInGivenOut API #619

Open
wants to merge 2 commits into
base: BE-692
Choose a base branch
from

Conversation

deividaspetraitis
Copy link
Collaborator

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
Collaborator 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
Collaborator 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
Collaborator 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
Collaborator 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.

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.

1 participant