Skip to content

Add EVM support to OKX DEX provider#94

Open
0xh3rman wants to merge 2 commits intomainfrom
okx-evm
Open

Add EVM support to OKX DEX provider#94
0xh3rman wants to merge 2 commits intomainfrom
okx-evm

Conversation

@0xh3rman
Copy link
Collaborator

  • Extend OKX DEX integration to support EVM chains (Manta/Mantle) alongside Solana.
  • Add EVM constants (chain index map and native token sentinel), new helper utilities (chainIndex, isEvmChain, dexIds) and update asset/address resolution and referral handling per chain.
  • Refactor buildSwapParams/get_quote/get_quote_data to pass chain context and split quote-data construction into EVM (hex calldata, gas, optional approval) and Solana (base58->base64 serialization, compute unit estimation) flows.
  • Add test fixtures and mocks for Manta (MANTA_USDC_ADDRESS, test wallet, createOkxEvmQuoteRequest) and expand unit/integration tests to cover EVM native/token swaps, approval behavior, and parameter propagation.

Extend OKX integration to support EVM chains (Manta) alongside Solana. Add EVM constants (chain index map and native token sentinel), new helper utilities (chainIndex, isEvmChain, dexIds) and update asset/address resolution and referral handling per chain. Refactor buildSwapParams/get_quote/get_quote_data to pass chain context and split quote-data construction into EVM (hex calldata, gas, optional approval) and Solana (base58->base64 serialization, compute unit estimation) flows. Add test fixtures and mocks for Manta (MANTA_USDC_ADDRESS, test wallet, createOkxEvmQuoteRequest) and expand unit/integration tests to cover EVM native/token swaps, approval behavior, and parameter propagation.
@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 19, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  packages/swapper/src/okx/provider.test.ts  38% smaller
  packages/swapper/src/okx/integration.test.ts  37% smaller
  packages/swapper/src/okx/provider.ts  11% smaller
  AGENTS.md Unsupported file format
  packages/swapper/src/okx/constants.ts  0% smaller
  packages/swapper/src/testkit/mock.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 enhances the OKX DEX integration by extending its functionality beyond Solana to include EVM-compatible chains such as Manta, Mantle, and XLayer. The changes involve introducing chain-specific logic for asset resolution, referral handling, and quote data processing, ensuring that the swapper can seamlessly interact with both Solana and EVM ecosystems through the OKX provider.

Highlights

  • EVM Chain Support: Added comprehensive support for EVM chains (Manta, Mantle, XLayer) to the OKX DEX provider, expanding its cross-chain capabilities beyond Solana.
  • New Constants and Utilities: Introduced new constants for EVM chain indices and a generic EVM native token address, along with helper functions (chainIndex, isEvmChain, dexIds) for dynamic chain identification and parameter handling.
  • Refactored Quote and Swap Data Logic: Refactored buildSwapParams, get_quote, and get_quote_data to dynamically adapt to either EVM or Solana chain contexts, ensuring correct asset resolution, referral handling, and quote data construction.
  • EVM-Specific Quote Data Handling: Implemented distinct logic for building EVM swap quote data, including hex calldata, gas estimation, and optional token approval, separate from Solana's base58 to base64 serialization and compute unit estimation.
  • Expanded Test Coverage: Added new test fixtures and significantly expanded unit and integration tests to cover EVM native and token swaps, validating approval behavior and correct parameter propagation across different chains.

🧠 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/src/okx/constants.ts
    • Added EVM_CHAIN_INDEX mapping for Manta, Mantle, and XLayer.
    • Defined EVM_NATIVE_TOKEN_ADDRESS.
  • packages/swapper/src/okx/integration.test.ts
    • Imported Chain, createOkxEvmQuoteRequest, and MANTA_USDC_ADDRESS.
    • Added MANTA_NATIVE_TO_USDC_REQUEST and MANTA_USDC_TO_NATIVE_REQUEST for EVM integration tests.
    • Organized integration tests into 'Solana' and 'EVM (Manta)' describe blocks.
    • Added tests for fetching live quotes and building quote data for EVM native-to-token and token-to-native swaps, including approval checks.
  • packages/swapper/src/okx/provider.test.ts
    • Imported Chain, createOkxEvmQuoteRequest, and MANTA_USDC_ADDRESS.
    • Renamed createRequest to createSolanaRequest.
    • Added evmRoute, evmTokenRoute, mockEvmSwapResponse, mockSolanaQuote, mockEvmQuote, and mockEvmTokenQuote for EVM testing.
    • Refactored tests into 'Solana' and 'EVM' describe blocks.
    • Added comprehensive unit tests for EVM get_quote and get_quote_data, covering chain index, DEX ID absence, unsupported chains, hex data, gas limits, and approval data for token swaps.
  • packages/swapper/src/okx/provider.ts
    • Imported TransactionData type.
    • Added EVM_CHAIN_INDEX, EVM_NATIVE_TOKEN_ADDRESS to imports.
    • Introduced chainIndex, isEvmChain, and dexIds helper functions.
    • Refactored assetToTokenAddress to support Solana and EVM chains.
    • Modified referralFeeAddress to return Solana or EVM referrer based on chain.
    • Updated buildSwapParams to accept and use a chain parameter for chainIndex and dexIds.
    • Modified get_quote to determine the chain from fromAsset and pass it to chainIndex and dexIds.
    • Modified get_quote_data to determine the chain and conditionally call buildEvmQuoteData or buildSolanaQuoteData.
    • Implemented buildEvmQuoteData to construct EVM-specific swap quote data, including optional approval.
    • Implemented buildSolanaQuoteData to handle Solana-specific swap quote data, including compute unit estimation and base58 to base64 serialization.
  • packages/swapper/src/testkit/mock.ts
    • Added MANTA_TEST_WALLET_ADDRESS and MANTA_USDC_ADDRESS constants.
    • Defined OKX_MANTA_USDC_REQUEST_TEMPLATE.
    • Created createOkxEvmQuoteRequest helper function for EVM quote requests.
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 successfully extends the OKX DEX integration to support EVM chains like Manta and Mantle, alongside the existing Solana support. The changes introduce new constants for EVM chains, helper utilities for chain identification and token address resolution, and refactor the quote and swap data building processes to be chain-aware. The addition of comprehensive unit and integration tests for EVM native and token swaps, including approval behavior, ensures the new functionality is robust. The code is well-structured and demonstrates a clear separation of concerns between Solana and EVM logic.

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

Comments