Skip to content

Replace OKX and Panora SDK with thin client#100

Merged
0xh3rman merged 2 commits intomainfrom
okx-api-client
Feb 23, 2026
Merged

Replace OKX and Panora SDK with thin client#100
0xh3rman merged 2 commits intomainfrom
okx-api-client

Conversation

@0xh3rman
Copy link
Collaborator

No description provided.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 23, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  packages/swapper/src/panora/integration.test.ts  36% smaller
  packages/swapper/src/panora/provider.ts  24% smaller
  packages/swapper/src/okx/provider.test.ts  15% smaller
  pnpm-lock.yaml  5% smaller
  .env.example Unsupported file format
  .github/workflows/docker.yml  0% smaller
  apps/api/src/index.ts  0% smaller
  package.json  0% smaller
  packages/swapper/package.json  0% smaller
  packages/swapper/src/okx/README.md Unsupported file format
  packages/swapper/src/okx/auth.test.ts  0% smaller
  packages/swapper/src/okx/auth.ts  0% smaller
  packages/swapper/src/okx/client.ts  0% smaller
  packages/swapper/src/okx/integration.test.ts  0% smaller
  packages/swapper/src/okx/models.ts  0% smaller
  packages/swapper/src/okx/provider.ts  0% smaller
  packages/swapper/src/panora/client.ts  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 refactors the integration with OKX and Panora exchange services by replacing their bulky third-party SDKs with lightweight, custom-developed API clients. This change aims to provide greater control over API interactions, reduce bundle size, and potentially improve performance by directly managing requests and authentication. The core functionality of fetching quotes and swap data remains consistent, but the underlying implementation is now more tailored and self-contained.

Highlights

  • SDK Replacement: Replaced the official @okx-dex/okx-dex-sdk and @panoraexchange/swap-sdk with custom-built thin clients for direct API interaction, reducing external dependencies.
  • OKX Thin Client Implementation: Introduced a new OkxDexClient with custom authentication logic (HMAC-SHA256 signing) and dedicated models for API requests and responses, along with comprehensive unit tests for the authentication utilities.
  • Panora Thin Client Implementation: Implemented a new PanoraClient for direct interaction with the Panora API, simplifying the provider's configuration and API calls.
  • Provider Updates: Refactored OkxProvider and PanoraProvider to utilize their respective new thin clients, streamlining API calls and removing reliance on the deprecated SDKs.
  • Dependency Management: Removed the heavyweight OKX and Panora SDKs from packages/swapper/package.json and updated minor development dependencies in the root package.json.

🧠 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
  • apps/api/src/index.ts
    • Updated PanoraProvider instantiation to remove the rpcUrl parameter, reflecting changes in the new PanoraClient.
  • package.json
    • Updated knip development dependency from 5.84.0 to 5.84.1.
    • Updated oxfmt development dependency from 0.33.0 to 0.34.0.
  • packages/swapper/package.json
    • Removed @okx-dex/okx-dex-sdk dependency.
    • Removed @panoraexchange/swap-sdk dependency.
  • packages/swapper/src/okx/README.md
    • Updated the description to reflect the use of a thin HMAC-SHA256 authenticated HTTP client instead of the official SDK.
    • Clarified that authentication is handled via HMAC-SHA256 request signing in client.ts.
    • Updated the method for fetching the full liquidity list to reference the OKX DEX API endpoint directly.
    • Adjusted data flow steps to refer to OkxDexClient methods instead of OKXDexClient.dex.
  • packages/swapper/src/okx/auth.test.ts
    • Added a new test file for OKX auth utilities.
    • Implemented tests for buildQueryString function, covering empty parameters, query string construction, undefined/null value filtering, and special character encoding.
    • Implemented tests for the sign function, verifying stable HMAC-SHA256 signature generation and changes with different timestamps, paths, and secrets.
    • Implemented tests for buildHeaders function, ensuring all required OKX headers are included and the signature matches the HMAC-SHA256 calculation.
  • packages/swapper/src/okx/auth.ts
    • Added a new file containing authentication utilities for the OKX API.
    • Defined OkxClientConfig interface for API credentials.
    • Implemented buildQueryString function to construct URL query strings from parameters.
    • Implemented sign function to generate HMAC-SHA256 signatures for API requests.
    • Implemented buildHeaders function to construct all necessary HTTP headers for OKX API requests.
  • packages/swapper/src/okx/client.ts
    • Added a new file defining the OkxDexClient class.
    • Implemented OkxDexClient to handle direct HTTP requests to the OKX DEX aggregator API.
    • Provided methods for getQuote, getSwapData, and getChainData.
    • Included a private get method for handling generic GET requests with authentication headers.
  • packages/swapper/src/okx/integration.test.ts
    • Removed import of @okx-dex/okx-dex-sdk.
    • Imported OkxDexClient from ./client.
    • Updated createClient function to instantiate the new OkxDexClient.
    • Modified calls to client methods from client.dex.getChainData to client.getChainData.
  • packages/swapper/src/okx/models.ts
    • Added a new file defining interfaces for OKX API responses and parameters.
    • Defined OkxApiResponse, TokenInfo, QuoteData, TransactionData, ChainData, QuoteParams, and SwapParams interfaces.
  • packages/swapper/src/okx/provider.test.ts
    • Removed import of OKXDexClient from @okx-dex/okx-dex-sdk.
    • Imported OkxDexClient type from ./client.
    • Updated the mock client object to directly expose getQuote, getSwapData, and getChainData methods, aligning with the new OkxDexClient structure.
  • packages/swapper/src/okx/provider.ts
    • Removed imports from @okx-dex/okx-dex-sdk.
    • Imported OkxDexClient and types from ./client and ./models respectively.
    • Updated the OkxProvider constructor to use the new OkxDexClient.
    • Modified calls to client methods from this.client.dex.getQuote, this.client.dex.getSwapData, and this.client.dex.getChainData to this.client.getQuote, this.client.getSwapData, and this.client.getChainData respectively.
  • packages/swapper/src/panora/client.ts
    • Added a new file defining the PanoraClient class.
    • Defined PanoraClientConfig and PanoraQuoteParams interfaces.
    • Implemented buildQueryString for constructing URL query parameters.
    • Implemented PanoraClient to handle direct HTTP POST requests to the Panora /swap endpoint with an API key header.
  • packages/swapper/src/panora/integration.test.ts
    • Renamed packages/swapper/src/panora/provider.test.ts to packages/swapper/src/panora/integration.test.ts.
    • Added dotenv configuration for environment variables.
    • Changed the integration test environment variable check from PANORA_INTEGRATION_TEST to INTEGRATION_TEST.
    • Updated PanoraProvider instantiation in beforeAll to use apiKey instead of panoraApiKey and removed rpcUrl.
    • Adjusted the assertion for outputValue to be greater than 0 instead of 10.
  • packages/swapper/src/panora/provider.ts
    • Removed imports from @panoraexchange/swap-sdk.
    • Imported PanoraClient and PanoraClientConfig from ./client.
    • Updated PanoraProviderOptions interface to use apiKey instead of PanoraConfig properties.
    • Refactored the PanoraProvider constructor to instantiate the new PanoraClient.
    • Modified buildIntegratorFeeParams to accept integratorFeeAddress as a string instead of a template literal type.
    • Updated getQuote method to directly pass parameters to this.client.getQuote instead of wrapping them in a params object.
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

The pull request successfully replaces the OKX and Panora SDKs with lightweight HTTP clients, which helps in reducing the overall dependency footprint of the package. The implementation of HMAC-SHA256 signing for OKX is correct for the current scope. However, there are a few areas for improvement: a hardcoded API key in the Panora client should be moved to environment variables for security, and the Panora getQuote method should likely send parameters in the request body rather than the query string to align with standard API practices. Additionally, using URLSearchParams would make the query string construction more robust.

@0xh3rman 0xh3rman merged commit ed2c133 into main Feb 23, 2026
4 checks passed
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