Skip to content

okx: estimate compute budget #88

Open
0xh3rman wants to merge 2 commits intomainfrom
okx-cu-limit
Open

okx: estimate compute budget #88
0xh3rman wants to merge 2 commits intomainfrom
okx-cu-limit

Conversation

@0xh3rman
Copy link
Collaborator

@0xh3rman 0xh3rman commented Feb 18, 2026

  • Estimate compute unit limit and price for OKX swaps and wire it through provider and tests.
  • Add COMPUTE_UNIT_MULTIPLIER and rename DEFAULT_COMPUTE_UNIT_PRICE in Solana tx builder, use it as fallback and apply a 1.1 multiplier to gas limits returned from OKX.
  • Extend OkxRouteData with estimatedComputeUnits/estimatedComputeUnitPrice, call getGasLimit and getGasPrice in parallel, log/fallback on failures, and pass estimates into swap params and resulting SwapQuoteData.
  • Update provider unit tests to mock and verify these flows.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 18, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  packages/swapper/src/okx/provider.test.ts  39% smaller
  packages/swapper/src/okx/provider.ts  10% smaller
  packages/swapper/src/bigint_math.ts  0% smaller
  packages/swapper/src/chain/solana/tx_builder.ts  0% smaller
  packages/swapper/src/mayan/solana.ts  0% smaller
  packages/swapper/src/okx/index.ts  0% smaller
  packages/swapper/src/okx/model.ts  0% smaller
  packages/swapper/tsconfig.json  0% smaller

@gemini-code-assist
Copy link

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 significantly enhances the Solana transaction handling within the OKX swapper by introducing dynamic compute budget estimation. It ensures that swaps on OKX leverage optimized gas limits and prices, improving efficiency and reliability. Additionally, it includes a comprehensive update of several core dependencies, bringing the project up to date with the latest versions of key blockchain-related libraries.

Highlights

  • OKX Solana Compute Budget Estimation: Implemented compute unit limit and price estimation for OKX Solana swaps, applying a 1.1x multiplier to gas limits returned from OKX API.
  • Solana Transaction Builder Enhancements: Introduced a COMPUTE_UNIT_MULTIPLIER constant and renamed DEFAULT_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS to DEFAULT_COMPUTE_UNIT_PRICE in the Solana transaction builder, using it as a fallback.
  • OKX Provider Integration: Extended OkxRouteData to include estimatedComputeUnits and estimatedComputeUnitPrice, integrating parallel fetching of gas limit and price from the OKX API with graceful fallback on failures. These estimates are now passed into swap parameters and the resulting SwapQuoteData.
  • Unit Test Coverage: Enhanced unit tests for the OKX provider to mock and verify the new compute budget estimation flows and fallback mechanisms.
  • Dependency Updates: Upgraded several package dependencies, including @mysten/sui, @orca-so/whirlpools, @solana/instructions, @solana/kit, and @orca-so/whirlpools-core. Also added @ton/core.
  • TypeScript Configuration Refinement: Removed the baseUrl property from tsconfig.json in the swapper package.

🧠 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
  • packages/swapper/package.json
    • Updated @mysten/sui from 1.35.0 to 1.45.2.
    • Updated @orca-so/whirlpools from 6.0.0 to 7.0.0.
    • Updated @orca-so/whirlpools-core from 3.0.0 to 3.1.0.
    • Fixed @panoraexchange/swap-sdk specifier from ^1.3.1 to 1.3.1.
    • Updated @solana/instructions from 5.0.0 to 5.5.1.
    • Updated @solana/kit from 5.0.0 to 5.5.1.
    • Added @ton/core dependency.
  • packages/swapper/src/chain/solana/tx_builder.ts
    • Renamed DEFAULT_COMPUTE_UNIT_PRICE_MICRO_LAMPORTS to DEFAULT_COMPUTE_UNIT_PRICE.
    • Added COMPUTE_UNIT_MULTIPLIER constant with a value of 1.1.
    • Updated references to the renamed DEFAULT_COMPUTE_UNIT_PRICE constant.
    • Modified addComputeBudgetInstructions to use the new DEFAULT_COMPUTE_UNIT_PRICE.
  • packages/swapper/src/okx/model.ts
    • Added estimatedComputeUnits and estimatedComputeUnitPrice optional fields to the OkxRouteData interface.
  • packages/swapper/src/okx/provider.test.ts
    • Added mock implementations for getGasLimit and getGasPrice in createProvider.
    • Introduced mockSwapResponse helper function.
    • Updated getSwapData mock to use mockSwapResponse.
    • Added a test case to verify compute budget estimation via getGasLimit and getGasPrice.
    • Added a test case to confirm estimated compute budget is passed to get_quote_data swap params.
    • Added a test case for fallback to default compute unit price when not in route data.
    • Added a test case to handle graceful failure of getGasLimit.
  • packages/swapper/src/okx/provider.ts
    • Imported DEFAULT_COMPUTE_UNIT_PRICE and COMPUTE_UNIT_MULTIPLIER.
    • Modified buildSwapParams to accept optional computeUnitLimit and computeUnitPrice.
    • Added computeUnitLimit and computeUnitPrice to the SwapParams object, with a fallback to DEFAULT_COMPUTE_UNIT_PRICE.
    • Implemented a private asynchronous method estimateComputeBudget to fetch gas limit and price in parallel from the OKX API, applying a multiplier to the gas limit and handling failures.
    • Integrated estimateComputeBudget call within get_quote to populate estimatedComputeUnits and estimatedComputeUnitPrice in OkxRouteData.
    • Updated get_quote_data to pass estimatedComputeUnits and estimatedComputeUnitPrice from route.estimatedComputeUnits and route.estimatedComputeUnitPrice to buildSwapParams.
    • Added gasLimit to the returned SwapQuoteData using route.estimatedComputeUnits.
  • packages/swapper/tsconfig.json
    • Removed the baseUrl property from compilerOptions.
  • pnpm-lock.yaml
    • Updated numerous dependency versions and their corresponding integrity hashes to reflect changes in package.json and transitive dependencies.
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

@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 compute budget estimation for OKX swaps on Solana, a valuable enhancement for transaction reliability. The changes are well-structured, including updates to the Solana transaction builder, extending OKX data models, and implementing the estimation logic with resilient parallel API calls. The accompanying unit tests are thorough, covering new functionality and failure scenarios. Additionally, several dependencies have been updated, and a minor tsconfig.json cleanup has been performed. Overall, this is a solid set of changes. I have one suggestion to improve error logging for consistency.

@0xh3rman 0xh3rman changed the title okx: estimate compute budget and bump deps okx: estimate compute budget Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant