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

Feat: in given out for /custom-direct-quote #420

Merged
merged 11 commits into from
Aug 17, 2024
Merged

Feat: in given out for /custom-direct-quote #420

merged 11 commits into from
Aug 17, 2024

Conversation

deividaspetraitis
Copy link
Collaborator

@deividaspetraitis deividaspetraitis commented Jul 31, 2024

This PR implements in given out for /custom-direct-quote.

Several tests were added to ensure old and new functionality correctness. Some code parts were removed as result to moving towards encapsulated requests.

Note that testTestGetCustomQuote_GetCustomDirectQuotesInGivenOut_Mainnet_UOSMOUSDC requires some improvements as its counterpart TestGetCustomQuote_GetCustomDirectQuotesInGivenOut_Mainnet but I am not sure do we want to spent time on that right now.

Note that there are no integration tests either ( old functionality is not covered too ).

Changes includes updating swagger docs.

Summary by CodeRabbit

  • New Features

    • Enhanced API documentation for the /router/custom-direct-quote endpoint, providing detailed parameter descriptions and usage examples.
    • Introduced a new method for retrieving custom quotes based on a specified output token in multi-pool scenarios.
    • Added structured request handling for custom token swap quotes.
  • Bug Fixes

    • Improved error handling and response clarity for various input validation scenarios.
  • Tests

    • Expanded test coverage for direct custom quote functionality, including new test cases for exact amount in and out scenarios.

Copy link
Contributor

coderabbitai bot commented Jul 31, 2024

Walkthrough

These changes significantly enhance the API documentation and functionality for token quote retrieval within the router service. Key improvements include clearer parameter descriptions, new request structures, and expanded testing for robust error handling. The updates ensure that developers have a comprehensive understanding of input and output requirements, simplifying the use of enhanced features for token swaps.

Changes

Files Change Summary
docs/docs.go, docs/swagger.json, docs/swagger.yaml Enhanced descriptions and parameter requirements for the /router/custom-direct-quote endpoint. Introduced new parameters and updated examples for better clarity.
router/usecase/router_usecase.go, router/usecase/router_usecase_test.go Added a new method, GetCustomDirectQuoteMultiPoolInGivenOut, to improve quote retrieval based on output tokens, and updated error references in existing methods.
router/delivery/http/router_handler.go Updated function signatures for clarity, refined parameter handling, and improved error handling with structured request unmarshalling.
tests/quote.py, tests/quote_response.py, tests/route.py, tests/sqs_service.py Enhanced testing frameworks with new methods and refactored existing ones to improve validation and modularity across various test suites.
tests/test_router_direct_custom_quote_in_given_out.py, tests/test_router_direct_custom_quote_out_given_in.py Introduced new test suites specifically for validating the /router/custom-direct-quote endpoint, focusing on exact amount scenarios.
tests/test_router_quote_in_given_out.py, tests/test_router_quote_out_given_in.py Refactored existing tests to utilize class-based structures for better organization and improved encapsulation of functionalities.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RouterHandler
    participant RouterUsecase
    participant QuoteService

    Client->>RouterHandler: Request Quote
    RouterHandler->>RouterUsecase: GetCustomDirectQuoteMultiPoolInGivenOut
    RouterUsecase->>QuoteService: Fetch Quote based on Output Token
    QuoteService-->>RouterUsecase: Return Quote
    RouterUsecase-->>RouterHandler: Return Quote Response
    RouterHandler-->>Client: Respond with Quote
Loading

🐇 In the meadow, where bunnies hop,
The tokens dance, and the swaps don’t stop!
With clearer paths and quotes so bright,
We cheer for changes, oh what a delight!
Hopping through code, we celebrate,
New features await, it’s time to create!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 96b07e9 and 154acd5.

Files selected for processing (14)
  • docs/docs.go (2 hunks)
  • docs/swagger.json (2 hunks)
  • docs/swagger.yaml (2 hunks)
  • domain/mocks/router_usecase_mock.go (2 hunks)
  • domain/mvc/router.go (1 hunks)
  • router/delivery/http/export_test.go (1 hunks)
  • router/delivery/http/router_handler.go (5 hunks)
  • router/delivery/http/router_handler_test.go (2 hunks)
  • router/types/errors.go (1 hunks)
  • router/types/get_direct_custom_quote_request.go (1 hunks)
  • router/types/get_direct_custom_quote_request_test.go (1 hunks)
  • router/types/get_quote_request_test.go (1 hunks)
  • router/usecase/router_usecase.go (3 hunks)
  • router/usecase/router_usecase_test.go (3 hunks)
Additional comments not posted (35)
router/delivery/http/export_test.go (1)

1-1: Verify the removal of GetPoolsValidTokenInTokensOut references.

Ensure that all references to the GetPoolsValidTokenInTokensOut function are removed or updated in the codebase.

Verification successful

All references to GetPoolsValidTokenInTokensOut have been successfully removed.

  • No occurrences of the function usage, definition, or references in comments or documentation were found in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to the removed function `GetPoolsValidTokenInTokensOut` are removed or updated.

# Test: Search for the function usage. Expect: No occurrences of the function.
rg --type go 'GetPoolsValidTokenInTokensOut'

Length of output: 44


Script:

#!/bin/bash
# Description: Verify that the definition of the function `GetPoolsValidTokenInTokensOut` is removed from the codebase.

# Test: Search for the function definition. Expect: No occurrences of the function definition.
rg --type go 'func GetPoolsValidTokenInTokensOut'

# Description: Verify that there are no comments or documentation referencing `GetPoolsValidTokenInTokensOut`.

# Test: Search for comments or documentation references. Expect: No occurrences of the function in comments or documentation.
rg --type go 'GetPoolsValidTokenInTokensOut' -g '*.md' -g '*.go'

Length of output: 116

router/types/errors.go (3)

7-7: LGTM! Verify the usage of ErrValidationFailed.

The new error variable ErrValidationFailed is correctly defined.

Ensure that this new error is used consistently throughout the codebase.

Verification successful

The new error variable ErrValidationFailed is used consistently throughout the codebase.

  • router/usecase/router_usecase.go: Used in error messages.
  • router/usecase/router_usecase_test.go: Used in test cases.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new error variable `ErrValidationFailed`.

# Test: Search for the usage of the new error variable. Expect: Consistent usage throughout the codebase.
rg --type go 'ErrValidationFailed'

Length of output: 1020


15-15: LGTM! Verify the usage of ErrPoolIDNotValid.

The new error variable ErrPoolIDNotValid is correctly defined.

Ensure that this new error is used consistently throughout the codebase.

Verification successful

Verified the usage of ErrPoolIDNotValid.

The new error variable ErrPoolIDNotValid is used consistently in the following files:

  • router/types/get_direct_custom_quote_request_test.go
  • router/types/get_direct_custom_quote_request.go
  • router/delivery/http/router_handler_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new error variable `ErrPoolIDNotValid`.

# Test: Search for the usage of the new error variable. Expect: Consistent usage throughout the codebase.
rg --type go 'ErrPoolIDNotValid'

Length of output: 402


17-17: LGTM! Verify the usage of ErrNumOfTokenInDenomPoolsMismatch.

The new error variable ErrNumOfTokenInDenomPoolsMismatch is correctly defined.

Ensure that this new error is used consistently throughout the codebase.

Verification successful

The usage of ErrNumOfTokenInDenomPoolsMismatch is consistent and appropriate.

  • The error is used in a validation check in router/types/get_direct_custom_quote_request.go.
  • The error is tested in router/types/get_direct_custom_quote_request_test.go to ensure correct behavior.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new error variable `ErrNumOfTokenInDenomPoolsMismatch`.

# Test: Search for the usage of the new error variable. Expect: Consistent usage throughout the codebase.
rg --type go 'ErrNumOfTokenInDenomPoolsMismatch'

Length of output: 386


Script:

#!/bin/bash
# Extract and review the relevant lines of code where `ErrNumOfTokenInDenomPoolsMismatch` is used.

# Get the context of the usage in `router/types/get_direct_custom_quote_request.go`
rg --type go -A 5 -B 5 'ErrNumOfTokenInDenomPoolsMismatch' router/types/get_direct_custom_quote_request.go

# Get the context of the usage in `router/types/get_direct_custom_quote_request_test.go`
rg --type go -A 5 -B 5 'ErrNumOfTokenInDenomPoolsMismatch' router/types/get_direct_custom_quote_request_test.go

Length of output: 1033

router/types/get_direct_custom_quote_request.go (4)

92-130: LGTM! Verify the implementation of Validate.

The new method Validate is correctly implemented.

Ensure that this new method is used consistently throughout the codebase.

Verification successful

The Validate method is used consistently throughout the codebase.

  • router/types/get_direct_custom_quote_request.go
  • router/delivery/http/router_handler.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new method `Validate`.

# Test: Search for the usage of the new method. Expect: Consistent usage throughout the codebase.
rg --type go 'Validate'

Length of output: 17887


71-90: LGTM! Verify the implementation of SwapMethod.

The new method SwapMethod is correctly implemented.

Ensure that this new method is used consistently throughout the codebase.

Verification successful

The SwapMethod method is used consistently and correctly throughout the codebase.

  • router/types/get_quote_request.go
  • router/types/get_quote_request_test.go
  • router/delivery/http/router_handler.go
  • router/types/get_direct_custom_quote_request_test.go
  • router/types/get_direct_custom_quote_request.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new method `SwapMethod`.

# Test: Search for the usage of the new method. Expect: Consistent usage throughout the codebase.
rg --type go 'SwapMethod'

Length of output: 5121


1-22: LGTM! Verify the usage of GetDirectCustomQuoteRequest.

The new struct GetDirectCustomQuoteRequest and its fields are correctly defined.

Ensure that this new struct is used consistently throughout the codebase.

Verification successful

Verified the usage of GetDirectCustomQuoteRequest.

The struct GetDirectCustomQuoteRequest is used consistently and appropriately throughout the codebase.

  • Instantiated and populated in router/delivery/http/router_handler.go.
  • Methods and tests defined in router/types/get_direct_custom_quote_request.go and router/types/get_direct_custom_quote_request_test.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new struct `GetDirectCustomQuoteRequest`.

# Test: Search for the usage of the new struct. Expect: Consistent usage throughout the codebase.
rg --type go 'GetDirectCustomQuoteRequest'

Length of output: 3605


Script:

#!/bin/bash
# Extract relevant code from router/delivery/http/router_handler.go to verify the usage of GetDirectCustomQuoteRequest
rg --type go -A 10 'var req types.GetDirectCustomQuoteRequest' router/delivery/http/router_handler.go

Length of output: 303


24-69: LGTM! Verify the implementation of UnmarshalHTTPRequest.

The new method UnmarshalHTTPRequest is correctly implemented.

Ensure that this new method is used consistently throughout the codebase.

Verification successful

I will now gather more information about the context in which UnmarshalHTTPRequest is used in these files to ensure consistent usage.


Verified the implementation and consistent usage of UnmarshalHTTPRequest.

The method UnmarshalHTTPRequest is implemented and tested for both GetQuoteRequest and GetDirectCustomQuoteRequest. The interface RequestUnmarshaler further enforces consistent usage.

  • router/types/get_quote_request_test.go: Testing UnmarshalHTTPRequest for GetQuoteRequest.
  • router/types/get_quote_request.go: Implementation for GetQuoteRequest.
  • router/types/get_direct_custom_quote_request_test.go: Testing UnmarshalHTTPRequest for GetDirectCustomQuoteRequest.
  • router/delivery/http/http.go: Interface RequestUnmarshaler uses UnmarshalHTTPRequest.
  • router/types/get_direct_custom_quote_request.go: Implementation for GetDirectCustomQuoteRequest.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new method `UnmarshalHTTPRequest`.

# Test: Search for the usage of the new method. Expect: Consistent usage throughout the codebase.
rg --type go 'UnmarshalHTTPRequest'

Length of output: 1121


Script:

#!/bin/bash
# Extract lines around the usage of `UnmarshalHTTPRequest` to understand the context.

# Extract lines from `router/types/get_quote_request_test.go`
rg --type go -A 10 -B 10 'UnmarshalHTTPRequest' router/types/get_quote_request_test.go

# Extract lines from `router/types/get_quote_request.go`
rg --type go -A 10 -B 10 'UnmarshalHTTPRequest' router/types/get_quote_request.go

# Extract lines from `router/types/get_direct_custom_quote_request_test.go`
rg --type go -A 10 -B 10 'UnmarshalHTTPRequest' router/types/get_direct_custom_quote_request_test.go

# Extract lines from `router/delivery/http/http.go`
rg --type go -A 10 -B 10 'UnmarshalHTTPRequest' router/delivery/http/http.go

# Extract lines from `router/types/get_direct_custom_quote_request.go`
rg --type go -A 10 -B 10 'UnmarshalHTTPRequest' router/types/get_direct_custom_quote_request.go

Length of output: 5151

domain/mvc/router.go (1)

72-74: LGTM! The new method enhances flexibility in quote retrieval.

The addition of GetCustomDirectQuoteMultiPoolInGivenOut to the RouterUsecase interface allows for more flexible quote retrieval based on output tokens and input denominations.

router/types/get_quote_request_test.go (1)

32-34: LGTM! The new fields enhance test coverage.

The addition of TokenInDenom and TokenOutDenom to the test cases in TestGetQuoteRequestUnmarshal ensures that the unmarshalling process correctly handles token denominations.

Also applies to: 40-42

domain/mocks/router_usecase_mock.go (1)

97-102: LGTM! The new method enhances the mock's capability.

The addition of GetCustomDirectQuoteMultiPoolInGivenOut to the RouterUsecaseMock struct allows for more comprehensive testing of scenarios where the output token is known and multiple input denominations are considered.

router/types/get_direct_custom_quote_request_test.go (3)

18-49: Good coverage of valid and invalid scenarios.

The test cases cover a range of valid and invalid scenarios for the UnmarshalHTTPRequest method.


132-195: Good coverage of swap method scenarios.

The test cases cover a range of valid and invalid scenarios for the SwapMethod method.


197-287: Good coverage of validation scenarios.

The test cases cover a range of valid and invalid scenarios for the Validate method.

docs/swagger.yaml (6)

156-162: Improved clarity in endpoint description.

The updated description for the /router/custom-direct-quote endpoint is clear and accurately reflects its functionality.


Line range hint 166-205:
Accurate and clear parameter descriptions.

The updated parameter descriptions for the /router/custom-direct-quote endpoint are accurate and clear.


205-205: Improved clarity in endpoint description.

The updated description for the /router/quote endpoint is clear and accurately reflects its functionality.


205-205: Accurate and clear parameter descriptions.

The updated parameter descriptions for the /router/quote endpoint are accurate and clear.


205-205: Accurate operationId.

The updated operationId for the /router/quote endpoint accurately reflects its functionality.


205-205: Accurate operationId.

The retained operationId for the /router/custom-direct-quote endpoint accurately reflects its functionality.

router/delivery/http/router_handler_test.go (1)

167-229: Good coverage of valid and invalid scenarios.

The test cases cover a range of valid and invalid scenarios for the GetDirectCustomQuote method.

router/delivery/http/router_handler.go (2)

151-204: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to GetDirectCustomQuote match the new signature.

Verification successful

Function usage verified.

The function GetDirectCustomQuote is consistently used with the new signature across the codebase.

  • router/delivery/http/router_handler.go
  • router/delivery/http/router_handler_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `GetDirectCustomQuote` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'GetDirectCustomQuote'

Length of output: 16463


64-67: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to GetOptimalQuote match the new signature.

Verification successful

LGTM! But verify the function usage in the codebase.

The code changes are approved.

All function calls to GetOptimalQuote match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `GetOptimalQuote` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'GetOptimalQuote'

Length of output: 14574

docs/swagger.json (2)

Line range hint 129-168:
Approved: Improved clarity for /router/custom-direct-quote endpoint.

The updated description and parameters improve the clarity and usability of the API documentation.


Line range hint 138-176:
Approved: Improved clarity for /router/quote endpoint.

The updated description and parameters improve the clarity and usability of the API documentation.

docs/docs.go (2)

Line range hint 138-177:
Approved: Improved clarity for /router/custom-direct-quote endpoint.

The updated description and parameters improve the clarity and usability of the API documentation.


147-176: Approved: Improved clarity for /router/quote endpoint.

The updated description and parameters improve the clarity and usability of the API documentation.

router/usecase/router_usecase.go (4)

22-22: Import statement approved.

The import statement for types is necessary for the new error handling strategy.


491-500: Error handling changes approved.

The error handling in GetCustomDirectQuoteMultiPool has been updated to use types.ErrValidationFailed, aligning with the broader error handling strategy.


525-539: New function GetCustomDirectQuoteMultiPoolInGivenOut added.

The new function extends the existing functionality by allowing users to obtain a quote based on a specified output token. The function includes error handling to ensure the returned quote is of the expected type.


Line range hint 1071-1078:
Error handling changes approved.

The error handling in TestGetCustomQuote_GetCustomDirectQuotes_Mainnet_UOSMOUSDC has been updated to use types.ErrValidationFailed, aligning with the broader error handling strategy.

router/usecase/router_usecase_test.go (4)

20-20: Import statement approved.

The import statement for types is necessary for the new error handling strategy.


1071-1078: Error handling changes approved.

The error handling in TestGetCustomQuote_GetCustomDirectQuotes_Mainnet_UOSMOUSDC has been updated to use types.ErrValidationFailed, aligning with the broader error handling strategy.


1156-1295: New test function TestGetCustomQuote_GetCustomDirectQuotesInGivenOut_Mainnet_UOSMOUSDC added.

The new test function validates the functionality of the GetCustomDirectQuoteMultiPoolInGivenOut method, ensuring it accurately calculates quotes across multiple pool routes.


1216-1221: Error handling changes approved.

The error handling in TestGetCustomQuote_GetCustomDirectQuotesInGivenOut_Mainnet_UOSMOUSDC has been updated to use types.ErrValidationFailed, aligning with the broader error handling strategy.

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

Nice work!

Could you please add am integration test and ensure it passes as well as previous "in given out" tests? Then, we can merge this 🙏

@@ -69,6 +69,9 @@ type RouterUsecase interface {
// GetCustomDirectQuoteMultiPool calculates direct custom quote for given tokenIn and tokenOutDenom over given poolID route.
// Otherwise it implements same rules as GetCustomDirectQuote.
GetCustomDirectQuoteMultiPool(ctx context.Context, tokenIn sdk.Coin, tokenOutDenom []string, poolIDs []uint64) (domain.Quote, error)
// GetCustomDirectQuoteMultiPool calculates direct custom quote for given tokenOut and tokenInDenom over given poolID route.
// Otherwise it implements same rules as GetCustomDirectQuote.
Copy link
Member

Choose a reason for hiding this comment

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

Let's be more specific about what ie means to implement the same rules

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have updated docs to use different terminology to avoid duplicating GetCustomDirectQuote description for each method that uses it as underlying mechanism. Does it make sense?

Comment on lines 193 to 204
if req.SwapMethod() == domain.TokenSwapMethodExactIn {
tokenIn, tokenOutDenom = req.TokenIn, req.TokenOutDenom
} else {
tokenIn, tokenOutDenom = req.TokenOut, req.TokenInDenom
}

var quote domain.Quote
if req.SwapMethod() == domain.TokenSwapMethodExactIn {
quote, err = a.RUsecase.GetCustomDirectQuoteMultiPool(ctx, *tokenIn, tokenOutDenom, req.PoolID)
} else {
quote, err = a.RUsecase.GetCustomDirectQuoteMultiPoolInGivenOut(ctx, *tokenIn, tokenOutDenom, req.PoolID)
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to do this check twice or can we group it under a single if/else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since I have updated to include humanDenoms functionality, I think now grouping to in a single branch would add more readability issues and duplicated code. Please let me know what do you think. 🙏

Comment on lines +26 to +28
// NOTE: Currently method for some cases returns an error, while for others
// it returns a response error. This is not consistent and should be fixed.
func (r *GetDirectCustomQuoteRequest) UnmarshalHTTPRequest(c echo.Context) error {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I'm following the consistency take here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am referring that within a method it returns return c.JSON(domain.GetStatusCode(err), domain.ResponseError{Message: err.Error()}) or for example return ErrTokenInNotValid, which is inconsistent and sometimes lead to some confusion. I have ported such behaviour from original implementation to avoid different behaviour for the clients.

Copy link
Member

Choose a reason for hiding this comment

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

I see - is there a reason why we cannot fix it right now by always returning an error and then letting the caller handle this as needed?

Copy link
Collaborator Author

@deividaspetraitis deividaspetraitis Aug 16, 2024

Choose a reason for hiding this comment

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

I think it could be done right now, but at the same time I feel like we already spent some reasonable amount of time improving existing code base while working on this task. From my experience constantly iterating and improving bit by bit allows move faster and hepls to avoid stucking for too long on one code block. Let me know if you think I should still address this particular improvement under this PR. 🙏

Copy link
Member

Choose a reason for hiding this comment

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

No problems - I understand this stream of work has been ongoing for some time with many iterations. It should be pretty quick - I will do it in a follow-up PR

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

This query seems to be failing:

http://206.81.19.9:9092/router/custom-direct-quote?tokenOut=1000000ibc%2F27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2&tokenInDenom=uosmo%2Cuion&poolID=1%2C2

The failure occurs in PrepareResult.

Could we create a functional mainnet test off this example?

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

Nice work!

I'll be good with approving and merging upon previous comments being addressed and also an integration PR created where we can run all tests with no failures 🙏

router/delivery/http/router_handler.go Show resolved Hide resolved
router/delivery/http/router_handler.go Outdated Show resolved Hide resolved
@deividaspetraitis
Copy link
Collaborator Author

deividaspetraitis commented Aug 6, 2024

Will get back to this later, switching for higher priority tasks for now. Stopped at integration tests:

If somebody would call /quote and would try to feed results to /get-direct-custom-quote that would not work for a multi routes. I am not entirely sure is that valid case at all? I came up with this edge case following the idea that I could use results from /quote to generate inputs for testing /get-direct-custom-quote to avoid flakiness in the tests

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 154acd5 and 0de918b.

Files selected for processing (6)
  • docs/docs.go (3 hunks)
  • docs/swagger.json (3 hunks)
  • docs/swagger.yaml (2 hunks)
  • domain/mvc/router.go (1 hunks)
  • router/delivery/http/router_handler.go (5 hunks)
  • router/delivery/http/router_handler_test.go (2 hunks)
Additional comments not posted (6)
domain/mvc/router.go (1)

74-74: Verify implementation of new interface method.

The new method GetCustomDirectQuoteMultiPoolInGivenOut has been added to the RouterUsecase interface. Ensure that all implementations of this interface have been updated to include this method.

Verification successful

All implementations of the RouterUsecase interface have been updated with the new method.

The method GetCustomDirectQuoteMultiPoolInGivenOut is correctly implemented in both the mock and the actual use case files, ensuring the interface update is complete. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all implementations of the `RouterUsecase` interface include the new method.

# Test: Search for the interface implementation. Expect: All implementations include the new method.
ast-grep --lang go --pattern $'type $_ struct {
  $$$
}

func ($_ *$_) GetCustomDirectQuoteMultiPoolInGivenOut(ctx context.Context, tokenOut sdk.Coin, tokenInDenom []string, poolIDs []uint64) (domain.Quote, error) {
  $$$
}'

Length of output: 840


Script:

#!/bin/bash
# Description: Search for the implementation of the `GetCustomDirectQuoteMultiPoolInGivenOut` method in Go files.

# Test: Search for the method implementation. Expect: All implementations of the method.
ast-grep --lang go --pattern $'func ($_ *$_) GetCustomDirectQuoteMultiPoolInGivenOut(ctx context.Context, tokenOut sdk.Coin, tokenInDenom []string, poolIDs []uint64) (domain.Quote, error) {
  $$$
}'

Length of output: 1821

docs/swagger.yaml (1)

160-165: Verify documentation consistency and accuracy.

The updated documentation for the /router/custom-direct-quote endpoint includes new parameters and refined descriptions. Ensure that the documentation is consistent with the actual implementation and accurately describes the functionality.

Verification successful

Documentation is consistent and accurate. The documentation for the /router/custom-direct-quote endpoint in swagger.yaml is consistent with the implementation in router/delivery/http/router_handler.go and matches the details found in docs/docs.go. No discrepancies were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation consistency and accuracy for the `/router/custom-direct-quote` endpoint.

# Test: Search for the endpoint implementation and compare with the documentation. Expect: Consistent parameter usage and descriptions.
rg --type go 'func GetDirectCustomQuote' -A 20

Length of output: 48


Script:

#!/bin/bash
# Search for the `/router/custom-direct-quote` endpoint in the Go files to locate the implementation.
rg '/router/custom-direct-quote' --type go -A 20

Length of output: 3159

router/delivery/http/router_handler_test.go (1)

168-370: Verify comprehensiveness and consistency of test cases.

The new test function TestGetDirectCustomQuote includes various test cases for the /router/custom-direct-quote endpoint. Ensure that the test cases comprehensively cover all scenarios and are consistent with the expected behavior.

Verification successful

The test cases in TestGetDirectCustomQuote appear to cover a broad range of scenarios, including valid and invalid requests, as well as edge cases like human-readable denominations and incorrect formats. This suggests that the test suite is comprehensive and consistent with the expected behavior of the /router/custom-direct-quote endpoint.

  • Comprehensive Coverage: The test cases include both successful and erroneous scenarios, ensuring that the endpoint handles different types of inputs correctly.
  • Consistency: The expected responses and errors align with the intended functionality of the endpoint.

No additional scenarios appear to be missing from the current set of test cases.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the comprehensiveness and consistency of the test cases for the `/router/custom-direct-quote` endpoint.

# Test: Search for the test function implementation and review all test cases. Expect: Comprehensive and consistent test coverage.
ast-grep --lang go --pattern $'func (s *RouterHandlerSuite) TestGetDirectCustomQuote() {
  $$$
}'

Length of output: 17226

router/delivery/http/router_handler.go (1)

167-217: Structured request handling is a good improvement.

The use of UnmarshalRequest and req.Validate() enhances the robustness of the parameter handling.

Ensure that all usages of GetDirectCustomQuote in the codebase are updated to match the new parameter handling.

Verification successful

Verification successful: GetDirectCustomQuote usage is consistent with new parameter handling.

The GetDirectCustomQuote function and its associated request struct are properly defined and tested, ensuring robust parameter handling. No further updates are needed for its usage in the codebase.

  • The function is used in router/delivery/http/router_handler.go.
  • It is tested in router/delivery/http/router_handler_test.go.
  • The request struct GetDirectCustomQuoteRequest is defined and tested in router/types/get_direct_custom_quote_request.go and router/types/get_direct_custom_quote_request_test.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `GetDirectCustomQuote` in the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new parameter handling.
rg --type go 'GetDirectCustomQuote'

Length of output: 4025

docs/swagger.json (1)

Line range hint 135-184:
Documentation changes enhance clarity and usability.

The updated descriptions and new parameters provide clearer guidance on the input requirements.

Ensure that the parameter descriptions in the documentation are consistent with the actual functionality.

Verification successful

Parameter descriptions are consistent with functionality.

The parameter descriptions in the documentation align with their usage in the codebase, confirming their accuracy. The parameters tokenIn, tokenOutDenom, tokenOut, tokenInDenom, and humanDenoms are used in contexts consistent with their documented purpose.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of parameter descriptions with functionality.

# Test: Search for parameter usage in the codebase. Expect: Consistency with documentation.
rg --type go 'tokenIn|tokenOutDenom|tokenOut|tokenInDenom|humanDenoms'

Length of output: 109558

docs/docs.go (1)

Line range hint 144-193:
Documentation enhancements align with swagger.json.

The changes improve the accuracy and usability of the documentation.

Ensure that the documentation in docs.go is consistent with swagger.json.

Verification successful

Documentation is consistent between docs.go and swagger.json.

The content for the /router/custom-direct-quote endpoint is aligned in both files, with only minor formatting differences in inline code snippets. No significant discrepancies were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of documentation between `docs.go` and `swagger.json`.

# Test: Compare the documentation for `/router/custom-direct-quote` in both files. Expect: Consistency.
diff <(rg --type json '/router/custom-direct-quote' docs/swagger.json) <(rg '/router/custom-direct-quote' docs/docs.go)

Length of output: 227


Script:

#!/bin/bash
# Locate `docs.go` and `swagger.json` files and check for the `/router/custom-direct-quote` endpoint.

# Find the `docs.go` file
fd --type f --name docs.go

# Find the `swagger.json` file
fd --type f --name swagger.json

# Search for the `/router/custom-direct-quote` endpoint in `docs.go`
rg '/router/custom-direct-quote' $(fd --type f --name docs.go)

# Search for the `/router/custom-direct-quote` endpoint in `swagger.json`
rg '/router/custom-direct-quote' $(fd --type f --name swagger.json)

Length of output: 3173


Script:

#!/bin/bash
# Extract and compare the documentation for `/router/custom-direct-quote` in `docs/docs.go` and `docs/swagger.json`.

# Extract the relevant section from `docs/docs.go`
rg -A 10 '/router/custom-direct-quote' docs/docs.go

# Extract the relevant section from `docs/swagger.json`
rg -A 10 '/router/custom-direct-quote' docs/swagger.json

Length of output: 1678

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
router/usecase/router_usecase_test.go (1)

1154-1155: Clarify the test description.

The comment above the test function should be more descriptive about what the test is verifying. Consider adding details about the expected behavior and edge cases being tested.

-// This test runs tests against GetCustomDirectQuotes to ensure that the method correctly calculates
-// quote across multi pool route.
+// This test verifies the GetCustomDirectQuoteMultiPoolInGivenOut method for calculating quotes
+// across multiple pool routes, ensuring correct handling of various input scenarios and error conditions.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0de918b and 68e835c.

Files selected for processing (1)
  • router/usecase/router_usecase_test.go (3 hunks)

router/usecase/router_usecase_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
router/usecase/router_usecase.go (1)

550-564: Add Comments for Clarity.

The logic in GetCustomDirectQuoteMultiPoolInGivenOut is sound, but adding comments would improve maintainability by clarifying the purpose and steps of the function.

+ // GetCustomDirectQuoteMultiPoolInGivenOut retrieves a direct quote for multiple pools, processing the output for exact amounts in given out.
+ // It converts the quote type from quoteExactAmountIn to quoteExactAmountOut.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 68e835c and ff1a9d8.

Files selected for processing (6)
  • docs/docs.go (3 hunks)
  • docs/swagger.json (3 hunks)
  • docs/swagger.yaml (2 hunks)
  • router/delivery/http/router_handler.go (5 hunks)
  • router/usecase/router_usecase.go (3 hunks)
  • router/usecase/router_usecase_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • router/delivery/http/router_handler.go
  • router/usecase/router_usecase_test.go
Additional comments not posted (19)
docs/swagger.yaml (6)

160-166: Clarify endpoint capabilities and parameter requirements.

The updated description provides clear instructions on the parameters required for different swap methods. Ensure that users understand the distinction between "exact amount in" and "exact amount out" methods.


169-171: Ensure consistency in parameter descriptions.

The description for tokenIn is clear and consistent with the requirements for the exact amount in swap method.


175-180: Verify parameter usage for exact amount in swap.

The tokenOutDenom parameter is correctly described for the exact amount in swap method. Ensure its usage is consistent across the documentation.


181-186: Check new parameter tokenOut for exact amount out swap.

The addition of tokenOut for the exact amount out swap method is well documented. Verify its integration with the API logic.


187-191: Review new parameter tokenInDenom for exact amount out swap.

The tokenInDenom parameter is correctly introduced for the exact amount out swap method. Ensure its implementation aligns with the API's functionality.


199-204: Evaluate the humanDenoms parameter for usability.

The humanDenoms parameter enhances usability by allowing human-readable denominations. Confirm that this feature works as intended in the API.

docs/swagger.json (6)

135-135: Confirm endpoint description accuracy.

The description accurately reflects the requirements for using different swap methods. Ensure consistency with the YAML documentation.


144-147: Verify parameter tokenIn for exact amount in swap.

The tokenIn parameter is correctly documented for the exact amount in swap method. Ensure consistency with related documentation.


151-155: Check parameter tokenOutDenom for exact amount in swap.

The tokenOutDenom parameter is well documented for the exact amount in swap method. Confirm its proper usage in the API.


157-161: Review new parameter tokenOut for exact amount out swap.

The tokenOut parameter is accurately described for the exact amount out swap method. Verify its integration with the API logic.


165-169: Assess new parameter tokenInDenom for exact amount out swap.

The tokenInDenom parameter is correctly introduced for the exact amount out swap method. Ensure its implementation aligns with the API's functionality.


179-184: Evaluate the humanDenoms parameter for usability.

The humanDenoms parameter enhances usability by allowing human-readable denominations. Confirm that this feature works as intended in the API.

docs/docs.go (6)

144-144: Confirm endpoint description accuracy.

The description accurately reflects the requirements for using different swap methods. Ensure consistency with the YAML and JSON documentation.


153-156: Verify parameter tokenIn for exact amount in swap.

The tokenIn parameter is correctly documented for the exact amount in swap method. Ensure consistency with related documentation.


160-164: Check parameter tokenOutDenom for exact amount in swap.

The tokenOutDenom parameter is well documented for the exact amount in swap method. Confirm its proper usage in the API.


166-170: Review new parameter tokenOut for exact amount out swap.

The tokenOut parameter is accurately described for the exact amount out swap method. Verify its integration with the API logic.


174-178: Assess new parameter tokenInDenom for exact amount out swap.

The tokenInDenom parameter is correctly introduced for the exact amount out swap method. Ensure its implementation aligns with the API's functionality.


188-193: Evaluate the humanDenoms parameter for usability.

The humanDenoms parameter enhances usability by allowing human-readable denominations. Confirm that this feature works as intended in the API.

router/usecase/router_usecase.go (1)

491-500: Consistent Error Handling Improvement.

The use of types.ErrValidationFailed standardizes error handling, enhancing consistency across the application.

@deividaspetraitis deividaspetraitis self-assigned this Aug 15, 2024
@deividaspetraitis
Copy link
Collaborator Author

This query seems to be failing:

http://206.81.19.9:9092/router/custom-direct-quote?tokenOut=1000000ibc%2F27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2&tokenInDenom=uosmo%2Cuion&poolID=1%2C2

The failure occurs in PrepareResult.

Could we create a functional mainnet test off this example?

This one seems was resolved too.

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM - nice work!

Comment on lines +26 to +28
// NOTE: Currently method for some cases returns an error, while for others
// it returns a response error. This is not consistent and should be fixed.
func (r *GetDirectCustomQuoteRequest) UnmarshalHTTPRequest(c echo.Context) error {
Copy link
Member

Choose a reason for hiding this comment

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

I see - is there a reason why we cannot fix it right now by always returning an error and then letting the caller handle this as needed?

* Feat: in given out for /custom-direct-quote

e2e tests for exact amount out init

* fix merge error

* WIP

* WIP

* Feat: in given out for /custom-direct-quote

e2e tests for /custom-direct-quote

* Feat: in given out for /custom-direct-quote

Break run_quote_test into smaller individual parts for reusability

* Feat: in given out for /custom-direct-quote

Introduce calculate_expected_base_out_quote_spot_price

* Feat: in given out for /custom-direct-quote

Add synthetic tests for /quote and /custom-direct-quote

* Update tests/route.py

---------

Co-authored-by: Deividas Petraitis <[email protected]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Outside diff range, codebase verification and nitpick comments (1)
tests/test_synthetic_geo.py (1)

73-73: Address TODO comments for smarter selection.

The TODO comment suggests that the selection logic for tokens could be improved. Consider implementing a more dynamic selection process.

# TODO: Implement dynamic selection logic for tokens
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ff1a9d8 and 4c25823.

Files selected for processing (9)
  • tests/quote.py (7 hunks)
  • tests/quote_response.py (2 hunks)
  • tests/route.py (1 hunks)
  • tests/sqs_service.py (2 hunks)
  • tests/test_router_direct_custom_quote_in_given_out.py (1 hunks)
  • tests/test_router_direct_custom_quote_out_given_in.py (1 hunks)
  • tests/test_router_quote_in_given_out.py (4 hunks)
  • tests/test_router_quote_out_given_in.py (8 hunks)
  • tests/test_synthetic_geo.py (2 hunks)
Additional context used
Ruff
tests/test_router_direct_custom_quote_out_given_in.py

1-1: time imported but unused

Remove unused import: time

(F401)


5-5: from sqs_service import * used; unable to detect undefined names

(F403)


6-6: from quote import * used; unable to detect undefined names

(F403)


7-7: from quote_response import * used; unable to detect undefined names

(F403)


8-8: from rand_util import * used; unable to detect undefined names

(F403)


9-9: from e2e_math import * used; unable to detect undefined names

(F403)


10-10: from decimal import * used; unable to detect undefined names

(F403)


11-11: from constants import * used; unable to detect undefined names

(F403)


12-12: from util import * used; unable to detect undefined names

(F403)


13-13: from route import * used; unable to detect undefined names

(F403)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: id_from_swap_pair may be undefined, or defined from star imports

(F405)


27-27: Coin may be undefined, or defined from star imports

(F405)


32-32: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


42-42: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


45-45: Quote may be undefined, or defined from star imports

(F405)


51-51: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


54-54: QuoteExactAmountInResponse may be undefined, or defined from star imports

(F405)


59-59: Do not assign a lambda expression, use a def

Rewrite service_call as a def

(E731)


61-61: Quote may be undefined, or defined from star imports

(F405)


64-64: QuoteExactAmountInResponse may be undefined, or defined from star imports

(F405)

tests/test_router_direct_custom_quote_in_given_out.py

1-1: time imported but unused

Remove unused import: time

(F401)


5-5: from sqs_service import * used; unable to detect undefined names

(F403)


6-6: from quote import * used; unable to detect undefined names

(F403)


7-7: from quote_response import * used; unable to detect undefined names

(F403)


8-8: from rand_util import * used; unable to detect undefined names

(F403)


9-9: from e2e_math import * used; unable to detect undefined names

(F403)


10-10: from decimal import * used; unable to detect undefined names

(F403)


11-11: from constants import * used; unable to detect undefined names

(F403)


12-12: from util import * used; unable to detect undefined names

(F403)


13-13: from route import * used; unable to detect undefined names

(F403)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: id_from_swap_pair may be undefined, or defined from star imports

(F405)


27-27: Coin may be undefined, or defined from star imports

(F405)


32-32: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


42-42: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


45-45: Quote may be undefined, or defined from star imports

(F405)


51-51: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


54-54: QuoteExactAmountOutResponse may be undefined, or defined from star imports

(F405)


59-59: Do not assign a lambda expression, use a def

Rewrite service_call as a def

(E731)


61-61: Quote may be undefined, or defined from star imports

(F405)


64-64: QuoteExactAmountOutResponse may be undefined, or defined from star imports

(F405)

tests/test_synthetic_geo.py

71-71: constants may be undefined, or defined from star imports

(F405)


71-71: constants may be undefined, or defined from star imports

(F405)


82-82: constants may be undefined, or defined from star imports

(F405)


82-82: constants may be undefined, or defined from star imports

(F405)


93-93: constants may be undefined, or defined from star imports

(F405)


93-93: constants may be undefined, or defined from star imports

(F405)

tests/test_router_quote_in_given_out.py

74-74: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


87-87: Local variable coin is assigned to but never used

Remove assignment to unused variable coin

(F841)


87-87: Coin may be undefined, or defined from star imports

(F405)


93-93: Local variable amount_out is assigned to but never used

Remove assignment to unused variable amount_out

(F841)


95-95: Coin may be undefined, or defined from star imports

(F405)


100-100: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


103-103: Quote may be undefined, or defined from star imports

(F405)


106-106: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


166-166: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)

tests/test_router_quote_out_given_in.py

88-88: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


90-90: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


90-90: USDC may be undefined, or defined from star imports

(F405)


104-104: Local variable amount_in is assigned to but never used

Remove assignment to unused variable amount_in

(F841)


106-106: Coin may be undefined, or defined from star imports

(F405)


111-111: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


114-114: Quote may be undefined, or defined from star imports

(F405)


117-117: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


126-126: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


138-138: constants may be undefined, or defined from star imports

(F405)


225-225: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


234-234: ExactAmountInQuote may be undefined, or defined from star imports

(F405)

tests/quote.py

15-15: QuoteExactAmountOutResponse may be undefined, or defined from star imports

(F405)


35-35: Local variable response_json is assigned to but never used

Remove assignment to unused variable response_json

(F841)


124-124: QuoteExactAmountInResponse may be undefined, or defined from star imports

(F405)


137-137: Do not assign a lambda expression, use a def

Rewrite service_call as a def

(E731)


142-142: QuoteExactAmountInResponse may be undefined, or defined from star imports

(F405)


182-182: relative_error may be undefined, or defined from star imports

(F405)


187-187: Decimal may be undefined, or defined from star imports

(F405)


191-191: relative_error may be undefined, or defined from star imports

(F405)


217-217: get_last_route_token_out may be undefined, or defined from star imports

(F405)


217-217: get_last_route_token_out may be undefined, or defined from star imports

(F405)


221-221: get_last_quote_route_token_out may be undefined, or defined from star imports

(F405)


221-221: get_last_quote_route_token_out may be undefined, or defined from star imports

(F405)


269-269: QuoteExactAmountOutResponse may be undefined, or defined from star imports

(F405)


282-282: Do not assign a lambda expression, use a def

Rewrite service_call as a def

(E731)


287-287: QuoteExactAmountOutResponse may be undefined, or defined from star imports

(F405)


336-336: relative_error may be undefined, or defined from star imports

(F405)


361-361: get_last_route_token_in may be undefined, or defined from star imports

(F405)


361-361: get_last_route_token_in may be undefined, or defined from star imports

(F405)


365-365: get_last_quote_route_token_in may be undefined, or defined from star imports

(F405)


365-365: get_last_quote_route_token_in may be undefined, or defined from star imports

(F405)

Additional comments not posted (33)
tests/route.py (3)

12-12: LGTM!

The function correctly retrieves the last token in denomination from the route's pools.


13-18: LGTM! Consider performance testing.

The function correctly retrieves the last token in denomination from the quote's routes and pools. Consider performance testing if the number of routes and pools is large.


20-25: LGTM!

The function correctly retrieves the last token out denomination from the quote's routes and pools.

tests/quote_response.py (4)

44-49: LGTM!

The method correctly retrieves pool IDs from the route's pools.


51-56: LGTM!

The method correctly retrieves token out denominations from the route's pools.


69-74: LGTM!

The method correctly retrieves pool IDs from the route's pools.


76-81: LGTM!

The method correctly retrieves token in denominations from the route's pools.

tests/test_router_direct_custom_quote_out_given_in.py (3)

22-23: LGTM! Verify parameter values.

The parameterized test method is well-structured. Ensure that all parameters and expected values are accurate for the tests.


25-51: LGTM!

The method correctly executes the logic for running the custom direct quote test.

Tools
Ruff

27-27: Coin may be undefined, or defined from star imports

(F405)


32-32: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


42-42: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


45-45: Quote may be undefined, or defined from star imports

(F405)


51-51: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


21-22: Ensure all imported names are defined.

Due to wildcard imports, names like USDC_PRECISION and id_from_swap_pair may be undefined. Ensure these names are correctly imported or defined.

Tools
Ruff

21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: id_from_swap_pair may be undefined, or defined from star imports

(F405)

tests/test_router_direct_custom_quote_in_given_out.py (3)

26-26: Clarify the use of Coin.

The Coin class or function may be undefined due to the use of star imports. Ensure it is defined in the imported modules.

Verification successful

Coin class is defined in the codebase.

The Coin class is defined in the file tests/quote_response.py, confirming its presence and availability for use. The initial concern regarding its definition due to star imports does not apply here.

  • tests/quote_response.py: Contains the definition of class Coin.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition of `Coin`.

# Test: Search for the definition in the codebase.
rg --type python 'class Coin'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify the definition of `Coin`.

# Test: Search for the definition of `Coin` as a class or function in the codebase.
rg 'class Coin|def Coin'

Length of output: 113


32-32: Clarify the use of ExactAmountOutQuote.

The ExactAmountOutQuote class or function may be undefined due to the use of star imports. Ensure it is defined in the imported modules.

Tools
Ruff

32-32: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


21-21: Verify the definition of USDC_PRECISION and id_from_swap_pair.

These identifiers may be undefined due to the use of star imports. Ensure they are defined in the imported modules.

Verification successful

Definitions Verified for USDC_PRECISION and id_from_swap_pair.

  • USDC_PRECISION is defined in tests/constants.py.
  • id_from_swap_pair is defined in tests/util.py.

Both identifiers are correctly defined in the codebase, so there is no issue with undefined identifiers due to star imports.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definitions of `USDC_PRECISION` and `id_from_swap_pair`.

# Test: Search for the definitions in the codebase.
rg --type python 'USDC_PRECISION'
rg --type python 'id_from_swap_pair'

Length of output: 132


Script:

#!/bin/bash
# Description: Verify the definitions of `USDC_PRECISION` and `id_from_swap_pair`.

# Test: Search for the definitions in Python files in the codebase.
rg 'USDC_PRECISION' --glob '*.py'
rg 'id_from_swap_pair' --glob '*.py'

Length of output: 4022

Tools
Ruff

21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: USDC_PRECISION may be undefined, or defined from star imports

(F405)


21-21: id_from_swap_pair may be undefined, or defined from star imports

(F405)

tests/test_synthetic_geo.py (1)

71-71: Verify the definition of constants.

The constants identifier may be undefined due to the use of star imports. Ensure it is defined in the imported modules.

Verification successful

The constants module is defined and accessible. The constants module is imported in various test files, including tests/test_synthetic_geo.py, where it is used to access constants like USDC and UOSMO. The module is defined in tests/constants.py, ensuring that these constants are available for use.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition of `constants`.

# Test: Search for the definition in the codebase.
rg --type python 'constants'

Length of output: 59


Script:

#!/bin/bash
# Description: Verify the definition of `constants`.

# Test: Search for the definition in Python files.
rg --glob '*.py' 'constants'

Length of output: 2373

Tools
Ruff

71-71: constants may be undefined, or defined from star imports

(F405)


71-71: constants may be undefined, or defined from star imports

(F405)

tests/sqs_service.py (1)

175-175: Replace print statements with logging.

Using print statements for debugging is not ideal for production code. Consider using a logging framework to provide more control over logging levels and outputs.

tests/test_router_quote_in_given_out.py (4)

100-100: Verify ExactAmountOutQuote definition and import.

Ensure that ExactAmountOutQuote is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

100-100: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


74-75: Verify ExactAmountOutQuote definition and import.

Ensure that ExactAmountOutQuote is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

74-74: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


103-103: Verify Quote definition and import.

Ensure that Quote is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Verification successful

Quote is defined and used correctly.

The Quote class is defined in tests/quote.py and includes the choose_error_tolerance method. There are no issues with its definition or import in the context of the codebase. The usage in tests/test_router_quote_in_given_out.py appears to be correct. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and import of `Quote`.

# Test: Search for the definition of `Quote`. Expect: The class is defined and properly imported.
ast-grep --lang python --pattern 'class Quote { $$$ }'

Length of output: 498


Script:

#!/bin/bash
# Description: Verify the definition and import of `Quote`.

# Search for the definition of the `Quote` class in Python files.
ast-grep --lang python --pattern 'class Quote: $$$'

# Search for import statements related to `Quote`.
rg 'import.*Quote' -A 2
rg 'from.*import.*Quote' -A 2

Length of output: 7102

Tools
Ruff

103-103: Quote may be undefined, or defined from star imports

(F405)


89-89: Verify Coin definition and import.

Ensure that Coin is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Verification successful

Coin is defined and accessible via star imports.

The Coin class is defined in tests/quote_response.py and is imported using star imports (from quote_response import *) in several test files, including tests/test_router_quote_in_given_out.py. This ensures that Coin is accessible in these files.

  • tests/test_router_direct_custom_quote_out_given_in.py
  • tests/test_router_quote_out_given_in.py
  • tests/quote.py
  • tests/test_router_direct_custom_quote_in_given_out.py
  • tests/test_router_quote_in_given_out.py

No further action is needed regarding the import of Coin.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and import of `Coin`.

# Test: Search for the definition of `Coin`. Expect: The class is defined and properly imported.
ast-grep --lang python --pattern 'class Coin { $$$ }'

Length of output: 496


Script:

#!/bin/bash
# Corrected pattern to search for the definition of `Coin` in Python files.
ast-grep --lang python --pattern 'class Coin: $$$'

# Search for import statements that include `Coin`.
rg --python 'import .*Coin' -A 2
rg --python 'from .* import .*Coin' -A 2

Length of output: 1168


Script:

#!/bin/bash
# Search for import statements that include `Coin` using the correct syntax.
rg 'import .*Coin' -A 2
rg 'from .* import .*Coin' -A 2

Length of output: 59


Script:

#!/bin/bash
# Search for import statements of `tests/quote_response.py` to check if `Coin` is accessible in other files.
rg 'import .*quote_response' -A 2
rg 'from .*quote_response import .*' -A 2

Length of output: 1080

tests/test_router_quote_out_given_in.py (8)

106-106: Verify Coin definition and import.

Ensure that Coin is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

106-106: Coin may be undefined, or defined from star imports

(F405)


111-111: Verify ExactAmountOutQuote definition and import.

Ensure that ExactAmountOutQuote is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

111-111: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


114-114: Verify Quote definition and import.

Ensure that Quote is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

114-114: Quote may be undefined, or defined from star imports

(F405)


163-163: LGTM!

The logic for multi-hop direct quote testing appears correct.


225-225: Verify ExactAmountInQuote definition and import.

Ensure that ExactAmountInQuote is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

225-225: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


253-253: LGTM!

The logic for orderbook functionality testing appears correct.


138-138: Verify constants definition and import.

Ensure that constants is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Verification successful

constants is properly imported and defined

The constants module is imported in the file tests/test_router_quote_out_given_in.py using a star import (from constants import *). The necessary constants like UOSMO, USDC, and UOSMO_USDC_POOL_ID are defined within the constants module. Therefore, the usage of constants in the code snippet is valid.

  • The constants module is imported in tests/test_router_quote_out_given_in.py.
  • The constants UOSMO, USDC, and UOSMO_USDC_POOL_ID are defined in tests/constants.py.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and import of `constants`.

# Test: Search for the definition of `constants`. Expect: The module is defined and properly imported.
ast-grep --lang python --pattern 'module constants { $$$ }'

Length of output: 508


Script:

#!/bin/bash
# Description: Verify the import and definition of `constants`.

# Search for any import statements for `constants`.
rg 'import constants' --context 2

# Search for any definition of `constants` in the codebase.
rg 'constants' --context 5

Length of output: 20870

Tools
Ruff

138-138: constants may be undefined, or defined from star imports

(F405)


88-90: Verify ExactAmountInQuote definition and import.

Ensure that ExactAmountInQuote is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Verification successful

ExactAmountInQuote is defined and used correctly, but check imports.

The ExactAmountInQuote class is defined in tests/quote.py and contains the necessary methods used in the test file. However, ensure that the import mechanism in tests/test_router_quote_out_given_in.py is clear and maintainable, as the class is not explicitly imported. Consider adding an explicit import if it's currently imported indirectly.

  • Definition found in: tests/quote.py
  • Usage in: tests/test_router_quote_out_given_in.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and import of `ExactAmountInQuote`.

# Test: Search for the definition of `ExactAmountInQuote`. Expect: The class is defined and properly imported.
ast-grep --lang python --pattern 'class ExactAmountInQuote { $$$ }'

Length of output: 524


Script:

#!/bin/bash
# Description: Verify the definition and import of `ExactAmountInQuote`.

# Test: Search for the definition of `ExactAmountInQuote`. Expect: The class is defined.
ast-grep --lang python --pattern 'class ExactAmountInQuote: $$$'

# Test: Search for imports of `ExactAmountInQuote` in the test file.
rg 'ExactAmountInQuote' tests/test_router_quote_out_given_in.py -A 3

Length of output: 12471

Tools
Ruff

88-88: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


90-90: ExactAmountInQuote may be undefined, or defined from star imports

(F405)


90-90: USDC may be undefined, or defined from star imports

(F405)

tests/quote.py (6)

137-137: Replace lambda with def.

Consider replacing the lambda expression with a def for better readability and maintainability.

Tools
Ruff

137-137: Do not assign a lambda expression, use a def

Rewrite service_call as a def

(E731)


221-221: Verify get_last_quote_route_token_out definition and import.

Ensure that get_last_quote_route_token_out is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Verification successful

Function get_last_quote_route_token_out is properly imported and defined.

The function get_last_quote_route_token_out is defined in tests/route.py and is imported into tests/quote.py via a star import from route. While star imports can sometimes lead to namespace issues, in this context, the function is correctly imported and accessible.

  • Definition: tests/route.py at line 20
  • Import: from route import * in tests/quote.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and import of `get_last_quote_route_token_out`.

# Test: Search for the definition of `get_last_quote_route_token_out`. Expect: The function is defined and properly imported.
ast-grep --lang python --pattern 'def get_last_quote_route_token_out($$$) { $$$ }'

Length of output: 554


Script:

#!/bin/bash
# Corrected script to verify the definition of `get_last_quote_route_token_out`.

# Test: Search for the definition of `get_last_quote_route_token_out`. Expect: The function is defined.
ast-grep --lang python --pattern 'def get_last_quote_route_token_out($$$): $$$'

Length of output: 398


Script:

#!/bin/bash
# Check import statements in tests/quote.py to verify if get_last_quote_route_token_out is imported.

# Search for import statements in tests/quote.py
rg '^import |^from ' tests/quote.py

Length of output: 285

Tools
Ruff

221-221: get_last_quote_route_token_out may be undefined, or defined from star imports

(F405)


221-221: get_last_quote_route_token_out may be undefined, or defined from star imports

(F405)


104-104: Verify conftest and related methods definition and import.

Ensure that conftest and related methods are defined and properly imported, as static analysis indicates they may be undefined due to star imports.

Verification successful

conftest.py is properly defined and imported.

The conftest.py file is present in the tests directory and is correctly imported in tests/quote.py. No issues with undefined imports related to conftest were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and import of `conftest` and related methods.

# Test: Search for the definition of `conftest`. Expect: The module and related methods are defined and properly imported.
ast-grep --lang python --pattern 'module conftest { $$$ }'

Length of output: 506


Script:

#!/bin/bash
# Search for the conftest.py file in the repository
fd --type f --name 'conftest.py'

# Check for imports related to conftest in tests/quote.py
rg 'import' tests/quote.py -A 2

Length of output: 577


Script:

#!/bin/bash
# Corrected command to search for the conftest.py file in the repository
fd 'conftest.py'

Length of output: 34


217-217: Verify get_last_route_token_out definition and import.

Ensure that get_last_route_token_out is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Verification successful

Function get_last_route_token_out is defined and used correctly.

The function get_last_route_token_out is defined in tests/route.py and used appropriately in tests/quote.py. There are no issues with its definition or usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and import of `get_last_route_token_out`.

# Test: Search for the definition of `get_last_route_token_out`. Expect: The function is defined and properly imported.
ast-grep --lang python --pattern 'def get_last_route_token_out($$$) { $$$ }'

Length of output: 542


Script:

#!/bin/bash
# Description: Verify the definition and import of `get_last_route_token_out`.

# Test: Search for the definition of `get_last_route_token_out`. Expect: The function is defined and properly imported.
ast-grep --lang python --pattern 'def get_last_route_token_out($$):'

Length of output: 70


Script:

#!/bin/bash
# Description: Search for `get_last_route_token_out` in import statements and usages.

# Search for import statements containing `get_last_route_token_out`.
rg 'import .*\bget_last_route_token_out\b' -A 2

# Search for any usage of `get_last_route_token_out` in the codebase.
rg '\bget_last_route_token_out\b' -A 2

Length of output: 463

Tools
Ruff

217-217: get_last_route_token_out may be undefined, or defined from star imports

(F405)


217-217: get_last_route_token_out may be undefined, or defined from star imports

(F405)


182-182: Verify relative_error definition and import.

Ensure that relative_error is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

182-182: relative_error may be undefined, or defined from star imports

(F405)


187-187: Verify Decimal definition and import.

Ensure that Decimal is defined and properly imported, as static analysis indicates it may be undefined due to star imports.

Tools
Ruff

187-187: Decimal may be undefined, or defined from star imports

(F405)

tests/test_synthetic_geo.py Show resolved Hide resolved
tests/sqs_service.py Show resolved Hide resolved
tests/test_router_quote_in_given_out.py Outdated Show resolved Hide resolved
tests/test_router_quote_in_given_out.py Outdated Show resolved Hide resolved
tests/test_router_quote_out_given_in.py Show resolved Hide resolved
tests/quote.py Show resolved Hide resolved
@p0mvn p0mvn merged commit ae2b8eb into v25.x Aug 17, 2024
7 checks passed
@p0mvn p0mvn deleted the SQS-303 branch August 17, 2024 07:09
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4c25823 and 3b01c02.

Files selected for processing (2)
  • tests/sqs_service.py (3 hunks)
  • tests/test_router_quote_in_given_out.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/sqs_service.py
Additional context used
Ruff
tests/test_router_quote_in_given_out.py

74-74: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


91-91: Coin may be undefined, or defined from star imports

(F405)


96-96: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


99-99: Quote may be undefined, or defined from star imports

(F405)


102-102: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)


162-162: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)

Additional comments not posted (1)
tests/test_router_quote_in_given_out.py (1)

162-162: Avoid star imports to prevent undefined references.

The use of star imports can lead to undefined references, making the code harder to maintain. Ensure ExactAmountOutQuote is explicitly imported.

Tools
Ruff

162-162: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)

Comment on lines +86 to +91
TestExactAmountOutQuote.run_top_liq_combos_default_exponent(environment_url, amount_str, token_out_denom, denom_in)

# Compute expected base out quote spot price
# First, get the USD price of each denom, and then divide to get the expected spot price
in_base_usd_quote_price = conftest.get_usd_price_scaled(denom_in)
out_base_usd_quote_price = conftest.get_usd_price_scaled(token_out_denom)
expected_in_base_out_quote_price = out_base_usd_quote_price / in_base_usd_quote_price
@staticmethod
def run_top_liq_combos_default_exponent(environment_url, amount_str, token_out_denom, denom_in):
token_out_coin = amount_str + token_out_denom
coin = Coin(token_out_denom, amount_str)
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid star imports to prevent undefined references.

The use of star imports can lead to undefined references, making the code harder to maintain. Ensure Coin is explicitly imported.

- from route import *
+ from route import Coin
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
TestExactAmountOutQuote.run_top_liq_combos_default_exponent(environment_url, amount_str, token_out_denom, denom_in)
# Compute expected base out quote spot price
# First, get the USD price of each denom, and then divide to get the expected spot price
in_base_usd_quote_price = conftest.get_usd_price_scaled(denom_in)
out_base_usd_quote_price = conftest.get_usd_price_scaled(token_out_denom)
expected_in_base_out_quote_price = out_base_usd_quote_price / in_base_usd_quote_price
@staticmethod
def run_top_liq_combos_default_exponent(environment_url, amount_str, token_out_denom, denom_in):
token_out_coin = amount_str + token_out_denom
coin = Coin(token_out_denom, amount_str)
TestExactAmountOutQuote.run_top_liq_combos_default_exponent(environment_url, amount_str, token_out_denom, denom_in)
@staticmethod
def run_top_liq_combos_default_exponent(environment_url, amount_str, token_out_denom, denom_in):
token_out_coin = amount_str + token_out_denom
coin = Coin(token_out_denom, amount_str)
Tools
Ruff

91-91: Coin may be undefined, or defined from star imports

(F405)

Comment on lines +74 to +75
quote = ExactAmountOutQuote.run_quote_test(environment_url, token_out_coin, denom_in, False, False, EXPECTED_LATENCY_UPPER_BOUND_MS)

Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid star imports to prevent undefined references.

The use of star imports can lead to undefined references, making the code harder to maintain. Ensure ExactAmountOutQuote is explicitly imported.

- from quote import *
+ from quote import ExactAmountOutQuote
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
quote = ExactAmountOutQuote.run_quote_test(environment_url, token_out_coin, denom_in, False, False, EXPECTED_LATENCY_UPPER_BOUND_MS)
from quote import ExactAmountOutQuote
quote = ExactAmountOutQuote.run_quote_test(environment_url, token_out_coin, denom_in, False, False, EXPECTED_LATENCY_UPPER_BOUND_MS)
Tools
Ruff

74-74: ExactAmountOutQuote may be undefined, or defined from star imports

(F405)

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