Skip to content

Comments

feat: OKX sol swap#729

Merged
kvhnuke merged 24 commits intodevop/package-updates-2-10from
feat/okx-sol-swap
Aug 4, 2025
Merged

feat: OKX sol swap#729
kvhnuke merged 24 commits intodevop/package-updates-2-10from
feat/okx-sol-swap

Conversation

@kvhnuke
Copy link
Contributor

@kvhnuke kvhnuke commented Jul 9, 2025

Summary by CodeRabbit

  • New Features

    • Added support for the OKX provider for Solana token swaps, including integration with OKX's DEX aggregator API.
    • OKX is now available as a swap provider alongside existing options for Solana.
    • New fee configurations for OKX with specific rates for supported wallets.
  • Improvements

    • Enhanced transaction handling to support raw serialized Solana transactions, ensuring accurate fee estimation and processing.
    • Improved logging and debugging information for swap trades.
    • Updated swap transaction processing to handle raw Solana transaction data without deserialization.
  • Documentation

    • Added detailed type definitions for OKX API interactions to ensure robust and type-safe provider integration.
  • Tests

    • Added comprehensive tests for the OKX provider covering quote retrieval, swap transaction creation, and error handling.

Julian-dev28 and others added 5 commits July 7, 2025 17:13
commit 0928965
Author: julian.martinez <julian_martinez28@outlook.com>
Date:   Mon Jul 7 17:08:14 2025 -0700

    end of buffer

commit 2f286c9
Author: julian.martinez <julian_martinez28@outlook.com>
Date:   Mon Jul 7 15:59:32 2025 -0700

    update okx provider logic

commit 12b50c2
Merge: a687ae4 98ad4a2
Author: julian.martinez <julian_martinez28@outlook.com>
Date:   Mon Jul 7 15:49:53 2025 -0700

    Merge branch 'main' of https://github.com/Julian-dev28/enKrypt

commit a687ae4
Author: Julian Martinez <julian.martinez@okg.com>
Date:   Mon Jun 16 21:50:08 2025 -0700

    update request/response params

commit 98ad4a2
Author: julian.martinez <julian_martinez28@outlook.com>
Date:   Mon Jun 16 19:18:08 2025 -0700

    update request/response params

commit eff5837
Author: julian.martinez <julian_martinez28@outlook.com>
Date:   Thu Jun 12 18:39:25 2025 -0700

    add okx provider

commit 934e55b
Author: julian.martinez <julian_martinez28@outlook.com>
Date:   Wed Jun 11 10:29:01 2025 -0700

    add okx provider
@coderabbitai
Copy link

coderabbitai bot commented Jul 9, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • develop
  • devop/vite-migrate

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

These changes introduce support for the OKX DEX aggregator as a new provider for Solana swaps. The update includes a new provider implementation, type definitions, configuration entries, and integration into the swap workflow. Additionally, transaction handling is updated to support raw Solana transactions, including fee logic and type adjustments.

Changes

File(s) Change Summary
packages/swap/src/providers/okx/index.ts, packages/swap/src/providers/okx/types.ts Added OKX provider implementation and related type definitions for Solana swaps, including API interaction, quote, swap, and status logic.
packages/swap/src/configs.ts Added OKX provider fee configurations for enkrypt and mew wallets with specific referrer addresses and fee rates.
packages/swap/src/types/index.ts Extended ProviderName enum to include okx.
packages/swap/src/index.ts Integrated OKX provider into the Solana swap provider list within the Swap class initialization logic.
packages/extension/src/ui/action/views/swap/libs/solana-gasvals.ts Introduced support for RawTransaction type, updated transaction handling and fee estimation functions to accommodate raw serialized Solana transactions, and adjusted exported types accordingly.
packages/extension/src/ui/action/views/swap/libs/swap-txs.ts Changed Solana transaction handling to pass through raw transaction objects with new metadata fields instead of deserializing them, and removed related imports and error handling.
packages/extension/src/ui/action/views/swap/views/swap-best-offer/index.vue Added debug logging for trade details and a type assertion for the fees prop in the transaction-fee-view component. No logic changes to trade selection.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant SwapModule
    participant OKXProvider
    participant OKXAPI
    participant SolanaRPC

    User->>UI: Initiate Solana swap
    UI->>SwapModule: Request swap providers for Solana
    SwapModule->>OKXProvider: Initialize with token list
    OKXProvider->>OKXAPI: Fetch supported tokens

    User->>UI: Select tokens and amount
    UI->>SwapModule: Request quote
    SwapModule->>OKXProvider: getQuote()
    OKXProvider->>OKXAPI: Request quote
    OKXAPI-->>OKXProvider: Return quote data
    OKXProvider-->>SwapModule: Return structured quote

    UI->>SwapModule: Confirm swap
    SwapModule->>OKXProvider: getSwap()
    OKXProvider->>OKXAPI: Request swap transaction
    OKXAPI-->>OKXProvider: Return base64 transaction
    OKXProvider-->>SwapModule: Return swap transaction

    SwapModule->>SolanaRPC: Submit transaction
    SolanaRPC-->>SwapModule: Return transaction status
    SwapModule->>OKXProvider: getStatus()
    OKXProvider->>SolanaRPC: Query transaction status
    SolanaRPC-->>OKXProvider: Return status
    OKXProvider-->>SwapModule: Return status
    SwapModule-->>UI: Update swap status
Loading

Possibly related PRs

  • add okx provider #726: The main PR and the retrieved PR add okx provider #726 both modify the same file packages/extension/src/ui/action/views/swap/libs/solana-gasvals.ts to add support for a new RawTransaction type and update transaction handling functions accordingly, indicating a direct and strong code-level relationship.

Suggested reviewers

  • gamalielhere
  • SemajaM
  • olgakup
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/okx-sol-swap

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Jul 9, 2025

💼 Build Files
chrome: enkrypt-chrome-da71ff54.zip
firefox: enkrypt-firefox-da71ff54.zip

💉 Virus total analysis
chrome: da71ff54
firefox: da71ff54

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (5)
packages/extension/src/ui/action/views/swap/views/swap-best-offer/index.vue (2)

64-64: Consider removing the type assertion.

The type assertion as GasFeeType may mask underlying type issues. If gasCostValues doesn't naturally match GasFeeType, investigate the root cause rather than forcing the type.

-:fees="gasCostValues as GasFeeType"
+:fees="gasCostValues"

If this causes type errors, address the underlying type mismatch in the component definition or data handling.


313-320: Consider making debug logging conditional.

The detailed trade logging is useful for debugging but might be too verbose for production. Consider making it conditional based on environment or a debug flag.

-swapData.trades.forEach((trade, index) => {
-  console.log(`Trade ${index + 1}:`, {
-    provider: trade.provider,
-    fromAmount: trade.fromTokenAmount.toString(),
-    toAmount: trade.toTokenAmount.toString(),
-    additionalFees: trade.additionalNativeFees.toString(),
-  });
-});
+if (process.env.NODE_ENV === 'development') {
+  swapData.trades.forEach((trade, index) => {
+    console.log(`Trade ${index + 1}:`, {
+      provider: trade.provider,
+      fromAmount: trade.fromTokenAmount.toString(),
+      toAmount: trade.toTokenAmount.toString(),
+      additionalFees: trade.additionalNativeFees.toString(),
+    });
+  });
+}
packages/swap/src/providers/okx/index.ts (2)

95-108: Consider using optional chaining for cleaner code.

The static analysis tool correctly identifies opportunities to use optional chaining here, which would make the code more concise.

Apply optional chaining:

-        if (error.response && error.response.headers) {
-          const retryAfter =
-            error.response.headers.get &&
-            error.response.headers.get("Retry-After");
+        const retryAfter = error.response?.headers?.get?.("Retry-After");
          if (retryAfter) {
            const retryAfterMs = parseInt(retryAfter, 10) * 1000;
            if (!isNaN(retryAfterMs)) {
              delay = Math.max(delay, retryAfterMs);
              logger.info(
                `OKX API Retry-After header present, waiting ${delay}ms`,
              );
            }
          }
-        }

604-608: Use optional chaining for consistency.

Similar to the previous comment, optional chaining would improve readability here.

-        hasData: !!data,
-        hasDataArray: !!(data && data.data),
-        dataLength: data && data.data ? data.data.length : 0,
+        hasData: !!data,
+        hasDataArray: !!data?.data,
+        dataLength: data?.data?.length ?? 0,
        code: data?.code,
        message: data?.msg || data?.message,
packages/extension/src/ui/action/views/swap/libs/solana-gasvals.ts (1)

149-156: Consider making the default fee configurable.

While 10000 lamports (0.00001 SOL) is a reasonable default for most Solana transactions, complex transactions might require higher fees. Consider making this configurable or deriving it from transaction size/complexity.

+      // Default fees based on typical Solana transaction costs
+      // Simple transfers: ~5000 lamports
+      // Token transfers: ~10000 lamports  
+      // Complex swaps: ~15000-20000 lamports
       const defaultFee = 10000; // 0.00001 SOL

Consider adding a comment to document the rationale for this default value, or potentially increase it slightly for swap transactions which tend to be more complex.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc24615 and 1d4d997.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (8)
  • packages/extension/src/ui/action/views/swap/libs/solana-gasvals.ts (3 hunks)
  • packages/extension/src/ui/action/views/swap/libs/swap-txs.ts (1 hunks)
  • packages/extension/src/ui/action/views/swap/views/swap-best-offer/index.vue (3 hunks)
  • packages/swap/src/configs.ts (1 hunks)
  • packages/swap/src/index.ts (2 hunks)
  • packages/swap/src/providers/okx/index.ts (1 hunks)
  • packages/swap/src/providers/okx/types.ts (1 hunks)
  • packages/swap/src/types/index.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/swap/src/index.ts (1)
packages/swap/src/providers/okx/index.ts (1)
  • OKX (135-825)
🪛 Biome (1.9.4)
packages/swap/src/providers/okx/index.ts

[error] 95-95: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 97-98: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 604-604: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 605-605: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: buildAll
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (10)
packages/swap/src/types/index.ts (1)

131-131: LGTM!

The addition of the OKX provider to the enum follows the established naming convention and is consistent with the integration pattern used by other providers.

packages/swap/src/index.ts (2)

50-50: LGTM!

The import statement follows the established pattern for other providers.


123-123: LGTM!

The OKX provider is correctly added to the Solana providers list, following the same instantiation pattern as other providers (Jupiter, Rango, Changelly) with proper type casting and constructor parameters.

packages/swap/src/configs.ts (1)

68-77: Please verify OKX referrer addresses

The OKX entries in packages/swap/src/configs.ts exactly mirror Jupiter’s referrer addresses:

  • enkrypt: HXWkRK9a4H1EuBiqP4sVfFsEpd2NasoQPScoXL1NgSE2
  • mew: CmrkoXWiTW37ZqUZcfJtxiKhy9eRMBQHq1nm8HpmRXH4

Confirm that OKX should indeed share these same referral addresses—or update them to the correct ones if they differ.

packages/extension/src/ui/action/views/swap/libs/swap-txs.ts (1)

112-127: No downstream impact—raw Solana transactions are fully supported

All consumers of the new isRawData and hasThirdPartySignatures properties have been updated:

• getSwapTransactions is only used for fee estimation; executeSwap continues to consume the original EnkryptSolanaTransaction objects.
• solana-gasvals.ts correctly branches on isRawData (skips blockhash updates, applies a default fee).
• send-transactions.ts deserializes serialized and handles third-party signatures as before.

No further changes are needed.

packages/swap/src/providers/okx/index.ts (3)

49-128: Excellent implementation of rate limiting and retry logic!

The rate limiting implementation with a 2-second minimum interval and the retry logic with exponential backoff are well-designed. The handling of 429 errors and respect for the Retry-After header demonstrates good API citizenship.


746-748: Good handling of the required parameters.

The implementation correctly uses string "true" for autoSlippage and includes maxAutoSlippageBps as noted in the API requirements. This aligns with the type definitions despite their optional marking.


639-663: Thorough base64 validation implementation!

The multi-step validation of the transaction data (regex check, decode test, and logging) provides excellent debugging capabilities and ensures data integrity before returning to the caller.

packages/extension/src/ui/action/views/swap/libs/solana-gasvals.ts (2)

26-42: Well-structured addition of raw transaction support!

The new RawTransaction type and its integration into the TaggedTransaction union are properly implemented. The type includes all necessary fields for handling raw serialized transactions.


204-210: Good defensive programming for null message handling.

The null check for msg with a fallback to the default fee ensures the fee calculation doesn't fail even in unexpected scenarios.

@kvhnuke kvhnuke changed the base branch from develop to devop/package-updates-2-10 July 17, 2025 18:26
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (6)
packages/swap/tests/okx.test.ts (3)

287-318: Remove console.log statements from tests

Test files should not contain console.log statements. Consider using test framework's logging capabilities or remove them entirely.

-      console.log("🚀 Testing USDC -> SOL swap with unwrapping detection");

       const usdcToSolQuote = await okx.getQuote(usdcToSolQuoteOptions, {
         infiniteApproval: true,
         walletIdentifier: "enkrypt",
         slippage: "0.5",
       });

-      console.log(
-        "🔍 USDC → SOL quote result:",
-        usdcToSolQuote ? "SUCCESS" : "FAILED",
-      );

       if (usdcToSolQuote) {
         expect(usdcToSolQuote).not.toBeNull();
         expect(usdcToSolQuote.provider).toBe(ProviderName.okx);

-        console.log("🔍 Getting USDC → SOL swap transaction...");
         const usdcToSolSwap = await okx.getSwap(usdcToSolQuote.quote);
-        console.log(
-          "🔍 USDC → SOL swap result:",
-          usdcToSolSwap ? "SUCCESS" : "FAILED",
-        );

         if (usdcToSolSwap) {
           expect(usdcToSolSwap).not.toBeNull();
           expect(usdcToSolSwap.transactions.length).toBeGreaterThanOrEqual(1);
-          console.log(
-            `✅ USDC → SOL swap transaction created with ${usdcToSolSwap.transactions.length} transaction(s)`,
-          );
-          console.log("✅ Unwrapping detection logic executed");
         }
       }

359-389: Remove console.log statements from tests

Similar to the previous test, remove debugging console.log statements.

-      console.log(
-        "🚀 Testing SOL -> USDC swap with Wrapped SOL account detection",
-      );

       const solQuote = await okx.getQuote(solQuoteOptions, {
         infiniteApproval: true,
         walletIdentifier: "enkrypt",
         slippage: "0.5",
       });

-      console.log("🔍 SOL quote result:", solQuote ? "SUCCESS" : "FAILED");

       if (solQuote) {
         expect(solQuote).not.toBeNull();
         expect(solQuote.provider).toBe(ProviderName.okx);

-        console.log("🔍 Getting SOL swap transaction...");
         const solSwap = await okx.getSwap(solQuote.quote);
-        console.log("🔍 SOL swap result:", solSwap ? "SUCCESS" : "FAILED");

         if (solSwap) {
           expect(solSwap).not.toBeNull();
           expect(solSwap.transactions[0]).toHaveProperty("kind");
           expect((solSwap.transactions[0] as SolanaTransaction).kind).toBe(
             "versioned",
           );
-          console.log("✅ SOL swap transaction created successfully");
-          console.log(
-            "✅ Wrapped SOL account detection and creation logic executed",
-          );
         }
       }

452-469: Remove console.log statements

Remove debugging console.log statements from the test.

       const serializedTx = (swap!.transactions[0] as SolanaTransaction)
         .serialized;
-      console.log("Serialized transaction length:", serializedTx.length);
-      console.log("First 100 chars:", serializedTx.substring(0, 100));

       // Test if it's valid base64
       let buffer: Buffer;
       try {
         buffer = Buffer.from(serializedTx, "base64");
-        console.log("Decoded buffer length:", buffer.length);
-        console.log(
-          "First 20 bytes:",
-          Array.from(buffer.slice(0, 20))
-            .map((b) => b.toString(16).padStart(2, "0"))
-            .join(" "),
-        );
       } catch (e) {
-        console.error("Failed to decode base64:", e);
         throw e;
       }
packages/swap/src/providers/okx/index.ts (3)

101-114: Use optional chaining for cleaner code

Replace the nested conditionals with optional chaining for better readability.

-        if (error.response && error.response.headers) {
-          const retryAfter =
-            error.response.headers.get &&
-            error.response.headers.get("Retry-After");
+        const retryAfter = error.response?.headers?.get?.("Retry-After");
           if (retryAfter) {
             const retryAfterMs = parseInt(retryAfter, 10) * 1000;
             if (!isNaN(retryAfterMs)) {
               delay = Math.max(delay, retryAfterMs);
               logger.info(
                 `OKX API Retry-After header present, waiting ${delay}ms`,
               );
             }
           }
-        }

56-76: Consider encapsulating rate limiting state

The global mutable state for rate limiting (lastRequestTime, requestCount) could cause issues if multiple OKX provider instances are used concurrently. Consider moving this state into the OKX class or using a more robust rate limiting solution.

Consider moving the rate limiting state into the OKX class to avoid potential concurrency issues:

export class OKX extends ProviderClass {
  private lastRequestTime = 0;
  private requestCount = 0;
  private readonly MIN_REQUEST_INTERVAL = 2000;
  
  private async rateLimitedRequest(): Promise<void> {
    // Rate limiting logic here
  }
}

632-636: Use optional chaining for cleaner null checks

Simplify the nested property checks using optional chaining.

       logger.info(`OKX: Swap API response structure:`, {
         hasData: !!data,
-        hasDataArray: !!(data && data.data),
-        dataLength: data && data.data ? data.data.length : 0,
+        hasDataArray: !!data?.data,
+        dataLength: data?.data?.length ?? 0,
         code: data?.code,
         message: data?.msg || data?.message,
       });
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d4d997 and 6c073a3.

📒 Files selected for processing (2)
  • packages/swap/src/providers/okx/index.ts (1 hunks)
  • packages/swap/tests/okx.test.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/swap/tests/okx.test.ts (3)
packages/swap/src/providers/okx/index.ts (1)
  • OKX (141-927)
packages/swap/src/types/index.ts (2)
  • getQuoteOptions (142-148)
  • BN (47-47)
packages/swap/src/utils/solana.ts (1)
  • isValidSolanaAddressAsync (469-473)
🪛 Biome (1.9.4)
packages/swap/tests/okx.test.ts

[error] 547-547: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)


[error] 34-34: Shouldn't redeclare 'isValidSolanaAddressAsync'. Consider to delete it or rename it.

'isValidSolanaAddressAsync' is defined here:

(lint/suspicious/noRedeclare)

packages/swap/src/providers/okx/index.ts

[error] 101-101: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 103-104: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 632-632: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 633-633: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 905-905: The catch clause that only rethrows the original error is useless.

An unnecessary catch clause can be confusing.
Unsafe fix: Remove the try/catch clause.

(lint/complexity/noUselessCatch)


[error] 908-908: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: buildAll
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (4)
packages/swap/tests/okx.test.ts (2)

44-47: LGTM!

Basic initialization test is correctly implemented.


49-95: Well-structured quote test

The test properly verifies quote retrieval with appropriate assertions and timeout handling.

packages/swap/src/providers/okx/index.ts (2)

1-46: LGTM! Well-organized imports

Imports are properly organized and all necessary dependencies are included.


168-205: Well-implemented initialization logic

The initialization properly validates the network, fetches OKX tokens, and sets up token mappings correctly.

Comment on lines 25 to 34
import { isValidSolanaAddressAsync } from "../src/utils/solana";
import {
fromToken,
amount,
fromAddress,
toAddress,
toToken,
nodeURL,
} from "./fixtures/solana/configs";
import { isValidSolanaAddressAsync } from "../src/utils/solana";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate import statement

The isValidSolanaAddressAsync function is imported twice - once at line 25 and again at line 34.

 import BN from "bn.js";
 import { isValidSolanaAddressAsync } from "../src/utils/solana";
 import {
   fromToken,
   amount,
   fromAddress,
   toAddress,
   toToken,
   nodeURL,
 } from "./fixtures/solana/configs";
-import { isValidSolanaAddressAsync } from "../src/utils/solana";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { isValidSolanaAddressAsync } from "../src/utils/solana";
import {
fromToken,
amount,
fromAddress,
toAddress,
toToken,
nodeURL,
} from "./fixtures/solana/configs";
import { isValidSolanaAddressAsync } from "../src/utils/solana";
import BN from "bn.js";
import { isValidSolanaAddressAsync } from "../src/utils/solana";
import {
fromToken,
amount,
fromAddress,
toAddress,
toToken,
nodeURL,
} from "./fixtures/solana/configs";
🧰 Tools
🪛 Biome (1.9.4)

[error] 34-34: Shouldn't redeclare 'isValidSolanaAddressAsync'. Consider to delete it or rename it.

'isValidSolanaAddressAsync' is defined here:

(lint/suspicious/noRedeclare)

🤖 Prompt for AI Agents
In packages/swap/tests/okx.test.ts between lines 25 and 34, there is a duplicate
import of isValidSolanaAddressAsync from ../src/utils/solana. Remove the second
import statement at line 34 to avoid redundancy and potential confusion.

@kvhnuke kvhnuke merged commit 88ebdd6 into devop/package-updates-2-10 Aug 4, 2025
4 of 5 checks passed
@kvhnuke kvhnuke deleted the feat/okx-sol-swap branch August 4, 2025 20:43
This was referenced Aug 4, 2025
This was referenced Nov 20, 2025
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