Skip to content

Conversation

@0xh3rman
Copy link
Collaborator

@0xh3rman 0xh3rman commented Dec 5, 2025

  • Standardizes error handling across swappers by removing unused error variants, consolidating error types, and replacing legacy errors with ComputeQuoteError and TransactionError.
  • Updates dependencies to use typeshare from workspace and applies typeshare annotations to SwapperError.
  • Refactors provider and testkit code to support new error handling and adds prioritization for InputAmountTooSmall errors in quote aggregation.
  • Also updates proxy client API versioning and error mapping, and replaces NotSupportedPair with NotSupportedAsset throughout the codebase.

Standardizes error handling across swappers by removing unused error variants, consolidating error types, and replacing legacy errors with ComputeQuoteError and TransactionError. Updates dependencies to use typeshare from workspace and applies typeshare annotations to SwapperError. Refactors provider and testkit code to support new error handling and adds prioritization for InputAmountTooSmall errors in quote aggregation. Also updates proxy client API versioning and error mapping, and replaces NotSupportedPair with NotSupportedAsset throughout the codebase.
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 5, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/swapper/src/chainlink.rs  88% smaller
  crates/swapper/src/approval/evm.rs  84% smaller
  crates/swapper/src/across/hubpool.rs  83% smaller
  crates/swapper/src/uniswap/v4/path.rs  82% smaller
  crates/swapper/src/cetus/provider.rs  74% smaller
  crates/swapper/src/thorchain/provider.rs  59% smaller
  crates/swapper/src/hyperliquid/provider/spot/provider.rs  56% smaller
  crates/swapper/src/eth_address.rs  55% smaller
  crates/swapper/src/hyperliquid/provider/spot/math.rs  51% smaller
  crates/swapper/src/jupiter/provider.rs  35% smaller
  crates/swapper/src/hyperliquid/provider/math.rs  29% smaller
  crates/swapper/src/proxy/client.rs  26% smaller
  crates/swapper/src/swapper.rs  13% smaller
  gemstone/src/gem_swapper/error.rs  13% smaller
  crates/swapper/src/testkit.rs  12% smaller
  crates/swapper/src/near_intents/provider.rs  11% smaller
  crates/swapper/src/error.rs  1% smaller
  Cargo.lock Unsupported file format
  crates/swapper/Cargo.toml Unsupported file format
  crates/swapper/src/across/api.rs  0% smaller
  crates/swapper/src/across/config_store.rs  0% smaller
  crates/swapper/src/across/provider.rs  0% smaller
  crates/swapper/src/approval/tron.rs  0% smaller
  crates/swapper/src/hyperliquid/provider/hyperliquid.rs  0% smaller
  crates/swapper/src/permit2_data.rs  0% smaller
  crates/swapper/src/proxy/provider.rs  0% smaller
  crates/swapper/src/swapper_trait.rs  0% smaller
  crates/swapper/src/uniswap/v3/path.rs  0% smaller
  crates/swapper/src/uniswap/v3/quoter_v2.rs  0% smaller
  crates/swapper/src/uniswap/v4/quoter.rs  0% smaller

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @0xh3rman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a significant refactor of the SwapperError handling system to improve consistency, clarity, and maintainability. By consolidating error types into ComputeQuoteError and TransactionError, the codebase now offers a more streamlined approach to identifying and addressing issues during both quote generation and transaction execution. These changes, coupled with dependency updates and refined error prioritization, enhance the overall robustness and user experience of the swapper functionality.

Highlights

  • Error Handling Standardization: The SwapperError enum has been significantly refactored to standardize error handling across all swappers. This involved removing several legacy and unused error variants such as NotSupportedPair, InvalidAddress, InvalidAmount, NetworkError, ABIError, and NotImplemented. Errors are now primarily categorized into ComputeQuoteError for issues during quote calculation and TransactionError for problems encountered during transaction processing.
  • Dependency and Annotation Updates: The typeshare dependency has been updated to use the workspace version, ensuring consistency across the project. Additionally, SwapperError now includes Serialize, Deserialize, Clone, PartialEq derives and typeshare annotations, improving its interoperability and serialization capabilities.
  • Codebase Refactoring for New Error Structure: Extensive updates have been made across various swapper providers (e.g., Across, Cetus, Hyperliquid, Jupiter, Near Intents, Uniswap) and approval modules. These changes ensure that all error mappings and handling logic align with the new, consolidated SwapperError structure, replacing old error variants with ComputeQuoteError or TransactionError as appropriate.
  • Prioritized Error Handling in Quote Aggregation: A new prioritized_error mechanism has been introduced to handle errors more intelligently during quote aggregation. This function ensures that InputAmountTooSmall errors are given precedence when multiple providers return different error types, providing more relevant feedback to the user.
  • Proxy Client API Versioning and Error Mapping: The proxy client now supports API versioning for its /quote and /quote_data endpoints. The error mapping for proxy responses has also been updated to correctly cast incoming errors back into the new SwapperError variants, specifically ComputeQuoteError and TransactionError.
  • Terminology Refinement: Instances of NotSupportedPair have been replaced with NotSupportedAsset throughout the codebase, providing more precise and accurate error messaging when a specific asset is not supported for a swap.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a comprehensive and well-executed refactoring of the error handling within the swapper crate. The standardization to ComputeQuoteError and TransactionError, removal of unused error variants, and making SwapperError serializable with typeshare are excellent improvements. The addition of prioritized error handling in quote aggregation will also enhance the user experience. The changes are consistent across the codebase. I have a couple of minor suggestions to further improve code clarity and maintainability.

Replaced SwapperError::InputAmountTooSmall with InputAmountError containing an optional min_amount field across swappers and tests. This allows more informative error reporting for minimum input amounts required by providers. Updated dependencies to use a fixed typeshare version instead of workspace.
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.

3 participants