Skip to content

Read swapper's suggested gas limit if available#954

Merged
0xh3rman merged 7 commits intomainfrom
solana-gas-limit
Feb 18, 2026
Merged

Read swapper's suggested gas limit if available#954
0xh3rman merged 7 commits intomainfrom
solana-gas-limit

Conversation

@0xh3rman
Copy link
Collaborator

No description provided.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 18, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  gemstone/src/models/transaction.rs  41% smaller
  crates/gem_client/src/retry.rs  33% smaller
  crates/gem_client/src/reqwest_client.rs  32% smaller
  crates/gem_solana/src/provider/preload_mapper.rs  25% smaller
  crates/swapper/src/testkit.rs  3% smaller
  crates/swapper/src/proxy/provider.rs  3% smaller
  crates/gem_client/Cargo.toml Unsupported file format
  crates/gem_client/src/lib.rs  0% smaller
  crates/gem_client/src/testkit.rs  0% smaller
  crates/primitives/src/testkit/swap_mock.rs  0% smaller
  crates/swapper/Cargo.toml Unsupported file format

@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 enhances the swap transaction process by allowing the system to dynamically adjust the gas limit based on suggestions from the swap provider, improving flexibility and potentially optimizing transaction costs. Concurrently, it introduces comprehensive support for the Okx swap provider, expanding the range of available swap services.

Highlights

  • Dynamic Gas Limit for Swaps: The system now reads and utilizes a suggested gas limit provided by the swapper for swap transactions. If a suggested limit is not available or cannot be parsed, it gracefully falls back to a default value.
  • Okx Swap Provider Integration: The Okx swap provider has been fully integrated across various modules, including its definition in enums, instantiation, mode configuration, and block explorer linking.
  • Test Suite Enhancements: New test cases were added to specifically verify the dynamic gas limit functionality for swap transactions, and existing swap-related tests were refactored for improved clarity and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • crates/gem_solana/src/provider/preload_mapper.rs
    • Implemented dynamic gas limit retrieval for swap transactions from swap_data.
    • Added a new test case test_calculate_transaction_fee_swap_with_provider_gas_limit to validate provider-suggested gas limits.
    • Refactored existing swap test cases to use mock assets and the new mock_swap_data_with_gas_limit helper function.
  • crates/primitives/src/swap_provider.rs
    • Added Okx to the SwapProvider enum.
    • Updated SwapProvider implementations to include Okx for string representation and on-chain status.
  • crates/swapper/src/models.rs
    • Configured Okx as an OnChain SwapperProvider in ProviderType.
  • crates/swapper/src/proxy/provider.rs
    • Added new_okx function to create a ProxyProvider for Okx.
    • Modified get_quote_data to prioritize approval_gas_limit if present, otherwise using data.gas_limit.
  • crates/swapper/src/proxy/provider_factory.rs
    • Added a factory function new_okx for creating Okx proxy providers.
  • crates/swapper/src/swapper.rs
    • Integrated the Okx swap provider into the GemSwapper initialization.
  • gemstone/src/block_explorer/mod.rs
    • Extended block explorer mapping to include Okx as a SwapperProvider.
  • gemstone/src/gem_swapper/remote_types.rs
    • Added Okx to the SwapperProvider enum.
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 introduces support for reading a swapper's suggested gas limit, which is a good improvement for transaction fee accuracy. The changes are implemented for both direct Solana swaps and for proxied providers. A new provider, OKX, is also added. The implementation looks solid and is well-tested. I have one suggestion to improve the gas limit logic for proxied EVM swaps to make it more consistent.

Parse and honor provider-specified gas limits for Solana swap transactions and ensure approval-derived gas is merged with route data.

- preload_mapper: for TransactionInputType::Swap read SwapData.data.gas_limit (parse as u64) and use it instead of the hardcoded 420_000 fallback. Added mock_swap_data_with_gas_limit helper and updated/added tests to cover provider gas_limit handling and to use Asset::mock_* helpers.
- swapper proxy/provider: renamed approval gas var to approval_gas_limit and combine it with route data gas_limit (approval takes precedence if present) when building SwapperQuoteData.

These changes allow swap providers to specify custom gas limits and ensure the final quote includes gas limits from both approval checks and route data.
Add support to preserve provider-specified gas_limit for non-EVM chains and update related code and tests. Introduces SwapQuoteData::mock_with_gas_limit helper, renames check_approval to check_approval_and_limit and returns the provider gas limit for non-EVM chains (previously always None). Update call site to use the new method and propagate gas_limit into SwapperQuoteData. Add MockClient and several testkit helpers plus unit tests verifying Solana preserves provider gas limits and EVM-native chains ignore them. Also add a dev-dependency on primitives with the testkit feature to Cargo.toml.
@0xh3rman 0xh3rman merged commit e463ba7 into main Feb 18, 2026
6 checks passed
@0xh3rman 0xh3rman deleted the solana-gas-limit branch February 18, 2026 11:14

[dev-dependencies]
tokio.workspace = true
primitives = { path = "../primitives", features = ["testkit"], default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

default-features = false should not be here

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

Comments