Skip to content

feat: integrate sei evm chain and debridge swapper (cross-chain + same-chain)#11941

Merged
gomesalexandre merged 34 commits intodevelopfrom
feat/integrate-debridge-swapper
Feb 24, 2026
Merged

feat: integrate sei evm chain and debridge swapper (cross-chain + same-chain)#11941
gomesalexandre merged 34 commits intodevelopfrom
feat/integrate-debridge-swapper

Conversation

@NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Feb 18, 2026

Description

⚠️ will require an asset regen before testing and merging as Scroll is taking precedence

Integrate Sei EVM chain (eip155:1329) as a second-class citizen and add the deBridge DLN swapper with both cross-chain bridging and same-chain swap support.

This PR combines the SEI chain integration (#11928) with the deBridge swapper for a single cohesive rollout — SEI needs deBridge for on-chain swaps since Relay only supports bridging USDC.N to SEI.

SEI Chain Integration

  • CAIP identifiers (seiChainId, seiAssetId, CHAIN_REFERENCE.SeiMainnet)
  • HDWallet support flags across all wallet implementations
  • SeiChainAdapter extending SecondClassEvmAdapter (ethers JsonRpcProvider + viem client)
  • Viem client and ethers provider configuration
  • CoinGecko adapter with sei-v2 platform mapping (~50+ token mappings including USDC)
  • Zerion chain mapping, Relay swapper chain mapping
  • Plugin registration, wallet support hooks, popular assets, market/portfolio integration
  • Feature flag: VITE_FEATURE_SEI (dev-only)

deBridge DLN Swapper

  • Cross-chain: Solver-based bridging via GET /v1.0/dln/order/create-tx — 12 EVM chains supported
  • Same-chain: DEX aggregation via GET /v1.0/chain/transaction — enables on-chain swaps (e.g., SEI ↔ USDC on Sei)
  • Status tracking: Cross-chain uses two-phase polling (source tx confirmation + DLN order status). Same-chain checks the tx receipt directly via viem client (handles SecondClassEvmAdapter chains where httpProvider is unavailable)
  • Fee estimation: Uses on-chain estimateGas with fallback to deBridge API-provided gasLimit (deBridge's off-chain simulation overestimates output on SEI by ~2.4%, causing estimateGas to revert even with fresh calldata)
  • Slippage: 3% default for same-chain swaps to compensate for simulation inaccuracy; cross-chain uses API-managed dstChainTokenOutAmount=auto
  • Fee model: Protocol fee (8 bps same-chain / 4 bps cross-chain) + operating expenses + optional affiliate fee
  • Feature flag: VITE_FEATURE_DEBRIDGE_SWAP (dev-only)

Bug Fixes

  • Fixed [object Object] passed as URL param in deBridge status checks (DebridgeOrderId type extraction)
  • Fixed status check crash on SecondClassEvmAdapter chains (SEI) — uses viem getTransactionReceipt instead of unavailable httpProvider.getTransaction
  • Replaced placeholder deBridge SVG with actual logo

New Files

  • packages/swapper/src/swappers/DebridgeSwapper/ — Complete swapper implementation
  • packages/swapper/src/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.ts — Same-chain swap API
  • headers/csps/debridge.ts — CSP headers for deBridge API domains
  • src/components/.../SwapperIcon/debridge-icon.svg — Swapper icon

Issue (if applicable)

Part of #11902
Supersedes #11928

Risk

Low risk — both features are behind independent feature flags (VITE_FEATURE_SEI, VITE_FEATURE_DEBRIDGE_SWAP), both disabled in production. No changes to existing swapper logic or shared infrastructure beyond adding new enum values and metadata types.

deBridge cross-chain bridge and same-chain DEX swap transactions via DLN protocol. Affects EVM chains only. SEI chain addition as second-class citizen.

Testing

Engineering

  1. Enable both feature flags: VITE_FEATURE_SEI=true and VITE_FEATURE_DEBRIDGE_SWAP=true
  2. Connect an EVM wallet (MetaMask, etc.)

SEI chain:
3. Verify Sei appears as an available chain in the app
4. Verify SEI native asset and USDC on Sei appear with correct market data
5. Verify wallet support detection works for supported wallet types

deBridge cross-chain:
6. Navigate to Trade, select a cross-chain pair (e.g., ETH → AVAX)
7. Verify deBridge appears as a quote option alongside existing swappers
8. Execute a small test trade and verify status tracking (Created → Fulfilled → Confirmed)

deBridge same-chain (SEI):
9. Select SEI → USDC on Sei (same-chain swap)
10. Verify deBridge quote appears with fee estimate (uses API gasLimit fallback)
11. Execute the swap and verify:
- Transaction broadcasts successfully
- Status correctly reflects success/failure from on-chain receipt
12. Test reverse direction: USDC → SEI on Sei

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/eaa9b2e6-f230-46bc-b8ff-b89cc669b78e
N/A — chain integration and swapper behind feature flags, appearing in existing trade flow.

Summary by CodeRabbit

  • New Features
    • Full SEI (Sei Mainnet) support: chain adapter, native SEI asset, wallet integrations, plugin, WalletConnect V2 and market UI visibility (feature-flag gated).
    • Debridge DLN swap integration: new swapper, quote/tx flows, status tracking, fees/unsigned txs, and Debridge swapper icon.
    • New feature flags and config to toggle SEI and Debridge functionality.

NeOMakinG and others added 6 commits February 17, 2026 23:08
Add Sei EVM chain support including:
- CAIP identifiers (seiChainId, seiAssetId)
- HDWallet support flags across all wallet implementations
- Chain adapter (SeiChainAdapter extending EvmBaseAdapter)
- Viem client and ethers provider configuration
- Feature flag (VITE_FEATURE_SEI) with dev-only enablement
- Plugin registration and wallet support hooks
- CoinGecko adapter with sei-v2 platform mapping
- Zerion chain mapping
- Relay swapper chain mapping
- CSP headers for RPC endpoint
- Asset generation scripts
- Market/portfolio/opportunities integration
- Popular assets discoverability

Part of #11902
Implement the core deBridge DLN protocol swapper for cross-chain bridging.
Supports 12 EVM chains including SEI, Ethereum, Arbitrum, Base, Polygon,
Avalanche, BSC, Optimism, Gnosis, Monad, HyperEVM, and Plasma.

Includes API types, chain ID mapping, trade quote/rate builders,
two-phase status tracking (source tx -> orderId -> order status),
and EVM transaction construction following AcrossSwapper patterns.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add SwapperName.Debridge enum, debridgeTransactionMetadata to
TradeQuoteStep and SwapperSpecificMetadata, VITE_DEBRIDGE_API_URL
to SwapperConfig, register swapper in constants map, wire slippage
and auto-slippage support, and add export.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Wire VITE_FEATURE_DEBRIDGE_SWAP and VITE_DEBRIDGE_API_URL through
config validation, Redux preferences slice, swapper enablement
logic, and test mocks. Enabled in development, disabled in production.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Allow connect-src for dln.debridge.finance and stats-api.dln.trade
to enable API calls to the deBridge DLN protocol.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add deBridge icon SVG, register in SwapperIcon component switch,
and wire debridgeTransactionMetadata in swap metadata for trade
execution tracking.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Sei (a second-class EVM chain) and a Debridge cross-chain swapper. Changes span environment/config, CSPs, CAIP/types, EVM adapters/clients, HDWallet capability flags, asset data/scripts, Debridge swapper implementation (API, utils, types, endpoints), UI wiring, plugin registration, and feature-flag gating.

Changes

Cohort / File(s) Summary
Environment & Feature Flags
\.env, \.env.development, src/config.ts, packages/public-api/src/config.ts
Adds VITE_SEI_NODE_URL, VITE_FEATURE_SEI, VITE_FEATURE_DEBRIDGE_SWAP, VITE_DEBRIDGE_API_URL and validators/defaults.
CSP Headers
headers/csps/chains/sei.ts, headers/csps/debridge.ts, headers/csps/index.ts
New CSP modules for Sei and Debridge added and registered.
CAIP, Types & Constants
packages/types/src/base.ts, packages/caip/src/constants.ts, packages/types/src/zerion.ts
Adds KnownChainIds.SeiMainnet, seiChainId/seiAssetId and related mappings.
EVM Adapters & Types
packages/chain-adapters/src/evm/EvmBaseAdapter.ts, packages/chain-adapters/src/evm/sei/*, packages/chain-adapters/src/evm/SecondClassEvmAdapter.ts, packages/chain-adapters/src/types.ts, packages/chain-adapters/src/evm/index.ts
Introduces SeiChainAdapter, evmChainIds updates, supportsSei checks, chain-switch metadata, wrapped native mapping, and type mappings.
Blockchain Clients
packages/contracts/src/ethersProviderSingleton.ts, packages/contracts/src/viemClient.ts
Wires VITE_SEI_NODE_URL into ethers/viem clients and registers viem Sei client.
HDWallet capability flags & guards
packages/hdwallet-core/src/*, packages/hdwallet-*/src/*
Adds _supportsSei flags across wallet implementations and supportsSei type guard; updates ETHWallet interface.
Asset catalog & helpers
packages/utils/src/assetData/baseAssets.ts, getBaseAsset.ts, chainIdToFeeAssetId.ts, getAssetNamespaceFromChainId.ts, getChainShortName.ts, getNativeFeeAssetReference.ts, packages/utils/src/assetData/*
Adds SEI base asset and maps for base asset lookup, fee asset, namespace, short name, and asset generation support.
Asset generation scripts
scripts/generateAssetData/*, scripts/generateAssetData/sei/index.ts
Adds Coingecko fetch and asset merging for Sei into asset generation pipeline.
Debridge swapper implementation
packages/swapper/src/types.ts, packages/swapper/src/constants.ts, packages/swapper/src/index.ts, packages/swapper/src/swappers/DebridgeSwapper/*
Adds Debridge to SwapperName/SwapperConfig, implements debridgeSwapper, API endpoints, service client, constants, fetch utilities, types, getTrade (quote/rate), unsigned tx builders, fee estimation, and status checks against Debridge stats API.
Relay Swapper & Registry
packages/swapper/src/swappers/RelaySwapper/*, packages/swapper/src/constants.ts
Maps Sei for RelaySwapper and registers Debridge in swappers registry with default slippage and auto-slippage support.
App feature flags, state & preferences
src/state/slices/preferencesSlice/preferencesSlice.ts, src/state/helpers.ts, src/test/mocks/store.ts
Adds Sei and DebridgeSwap feature flags and gates Debridge enablement behind flags/cross-account support.
Runtime gating & plugin
src/constants/chains.ts, src/context/PluginProvider/PluginProvider.tsx, src/plugins/sei/index.tsx, src/plugins/activePlugins.ts
Gates Sei behind feature flag; adds Sei plugin registering Sei chain adapter using VITE_SEI_NODE_URL and dynamic token discovery via asset service.
Wallet & account integration
src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts, src/lib/account/evm.ts, src/state/slices/portfolioSlice/utils/index.ts, src/context/WalletProvider/WalletConnectV2/config.ts
Wires supportsSei into wallet support checks, skips Sei for unsupported wallets, adds sei to WalletConnectV2 optional chains, and updates portfolio/account labeling.
Asset service & Coingecko
src/lib/asset-service/service/AssetService.ts, src/lib/coingecko/utils.ts, src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx
Hides Sei assets when feature flag disabled; includes seiChainId in Coingecko supported IDs and popular assets when enabled.
UI & UX wiring
src/components/MultiHopTrade/.../useTradeButtonProps.tsx, src/components/.../SwapperIcon/SwapperIcon.tsx, src/pages/Markets/components/MarketsRow.tsx
Propagates debridgeTransactionMetadata into swap metadata, adds Debridge icon, and feature-gates Markets filtering for Sei.
Opportunities & portfolio
src/state/slices/opportunitiesSlice/mappings.ts, src/state/slices/portfolioSlice/utils/index.ts
Adds Sei entry for supported DeFi opportunities and integrates Sei into portfolio utils.

Sequence Diagram(s)

sequenceDiagram
  participant UI as Client(UI)
  participant Swapper as DebridgeSwapper
  participant DebridgeAPI as Debridge API
  participant Adapter as EVM Adapter / Viem
  participant Blockchain as Sei Node

  UI->>Swapper: request getUnsignedEvmTransaction(quote, from, stepIndex)
  Swapper->>DebridgeAPI: GET/POST create-tx or single-chain endpoint (VITE_DEBRIDGE_API_URL)
  DebridgeAPI-->>Swapper: tx metadata + gas hints
  Swapper->>Adapter: assertGetEvmChainAdapter -> getFeeData / build custom tx
  Adapter->>Blockchain: on-chain fee estimation / chain data
  Blockchain-->>Adapter: gas/fee data
  Adapter-->>Swapper: unsigned EVM tx (with EIP-1559 fields if supported)
  Swapper-->>UI: unsigned transaction + metadata
Loading
sequenceDiagram
  participant Poller as UI / Background
  participant Swapper as DebridgeSwapper
  participant Adapter as EVM Adapter
  participant DebridgeStats as Debridge Stats API

  Poller->>Swapper: checkTradeStatus(txHash, chainId, address, swap)
  Swapper->>Adapter: checkEvmSwapStatus(txHash) (same-chain source)
  Adapter-->>Swapper: receipt / on-chain status
  alt cross-chain & on-chain step done
    Swapper->>DebridgeStats: query order IDs / order status
    DebridgeStats-->>Swapper: order status (Created/Fulfilled/Cancelled)
    Swapper-->>Poller: mapped TxStatus (Pending/Confirmed/Failed) + messages
  else unable to map
    Swapper-->>Poller: Unknown / Pending
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • NeOMakinG

Poem

🐇 I nibble RPC URLs and hop through flags,
I stitch deBridge orders and tidy the tags.
New chains I learn, new swaps I sing,
Tokens parade—and adapters spring!
Hooray — Sei and bridges, let the swap bells ring!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly summarizes the main changes: integrating Sei EVM chain and deBridge swapper with cross-chain and same-chain swap support, which aligns with the comprehensive changeset across multiple files and packages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/integrate-debridge-swapper

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@NeOMakinG NeOMakinG changed the title feat: integrate deBridge DLN swapper for cross-chain bridging feat: integrate deBridge DLN swapper for cross-chain bridging and SEI Feb 18, 2026
@NeOMakinG NeOMakinG changed the base branch from feat/integrate-sei-relay to develop February 19, 2026 08:47
@NeOMakinG NeOMakinG changed the title feat: integrate deBridge DLN swapper for cross-chain bridging and SEI feat: integrate SEI and deBridge DLN swapper for cross-chain bridging and SEI Feb 19, 2026
@NeOMakinG NeOMakinG changed the title feat: integrate SEI and deBridge DLN swapper for cross-chain bridging and SEI feat: integrate SEI chain and deBridge swapper (cross-chain + same-chain) Feb 19, 2026
@NeOMakinG NeOMakinG marked this pull request as ready for review February 20, 2026 15:04
@NeOMakinG NeOMakinG requested a review from a team as a code owner February 20, 2026 15:04
@NeOMakinG NeOMakinG force-pushed the feat/integrate-debridge-swapper branch from d47e273 to 4267156 Compare February 20, 2026 16:10
Copy link
Contributor

@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 (7)
src/plugins/activePlugins.ts (1)

61-62: Minor: sei and scroll are swapped relative to alphabetical order

scroll sorts before sei (comparing 'c' < 'e'), but the array has them reversed. The imports (lines 25–26) are already in the correct order.

♻️ Proposed fix
-  sei,
   scroll,
+  sei,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/plugins/activePlugins.ts` around lines 61 - 62, The array of plugin
identifiers in activePlugins.ts has 'sei' and 'scroll' out of alphabetical
order; swap their positions so 'scroll' comes before 'sei' to match the import
order and alphabetical sorting rule — update the list where the identifiers
appear (the array containing sei and scroll) so it reads scroll, sei.
src/plugins/sei/index.tsx (1)

22-36: fromAssetId called twice per asset — once in filter, once in map.

Each asset calls fromAssetId in the filter (line 26) and again in the map (line 31) to extract assetReference. A single pass (e.g., reduce or flatMap) would avoid the redundant parse.

♻️ Suggested single-pass approach
-                  return assetService.assets
-                    .filter(asset => {
-                      const { chainId, assetNamespace } = fromAssetId(asset.assetId)
-                      return chainId === seiChainId && assetNamespace === 'erc20'
-                    })
-                    .map(asset => ({
-                      assetId: asset.assetId,
-                      contractAddress: fromAssetId(asset.assetId).assetReference,
-                      symbol: asset.symbol,
-                      name: asset.name,
-                      precision: asset.precision,
-                    }))
+                  return assetService.assets.reduce<Array<{ assetId: string; contractAddress: string; symbol: string; name: string; precision: number }>>((acc, asset) => {
+                    const { chainId, assetNamespace, assetReference } = fromAssetId(asset.assetId)
+                    if (chainId === seiChainId && assetNamespace === 'erc20') {
+                      acc.push({
+                        assetId: asset.assetId,
+                        contractAddress: assetReference,
+                        symbol: asset.symbol,
+                        name: asset.name,
+                        precision: asset.precision,
+                      })
+                    }
+                    return acc
+                  }, [])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/plugins/sei/index.tsx` around lines 22 - 36, getKnownTokens calls
fromAssetId twice per asset (once in the filter and again in the map); update
getKnownTokens to call fromAssetId only once per asset by performing a single
pass: iterate assetService.assets and for each asset call
fromAssetId(asset.assetId) once, check chainId/assetNamespace on the parsed
result, and if it matches push/return the object using parsed.assetReference for
contractAddress (preserve symbol/name/precision). This can be implemented with a
single reduce/map that stores the parsed result per asset and avoids the
duplicate fromAssetId calls.
packages/swapper/src/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.ts (1)

12-30: Missing code in makeSwapErrorRight — use TradeQuoteError enum.

Both validation error paths omit the code property. As per coding guidelines, swapper errors should always include a TradeQuoteError enum code for internationalization and structured error handling.

♻️ Add error codes
       Err(
         makeSwapErrorRight({
           message: 'sendAddress is required',
+          code: TradeQuoteError.InternalError,
         }),
       ),
       Err(
         makeSwapErrorRight({
           message: 'receiveAddress is required',
+          code: TradeQuoteError.InternalError,
         }),
       ),

As per coding guidelines: ALWAYS use makeSwapErrorRight for swapper errors with TradeQuoteError enum for error codes and provide detailed error information.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swapper/src/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.ts`
around lines 12 - 30, The validation branches returning Err(...) for missing
addresses must include a TradeQuoteError code; update both checks (the
sendAddress and receiveAddress guards in getTradeQuote) to call
makeSwapErrorRight with a code property set to the appropriate enum value (e.g.,
TradeQuoteError.MissingSendAddress and TradeQuoteError.MissingReceiveAddress)
alongside the message so the returned error uses the TradeQuoteError enum for
structured handling.
packages/swapper/src/swappers/DebridgeSwapper/utils/getTrade.ts (1)

138-146: Redundant buyDebridgeChainId validation — already checked at lines 78–87.

The early-exit block at lines 78–87 already returns Err(UnsupportedChain) when chainIdToDebridgeChainId[buyAsset.chainId] is undefined (for the cross-chain path). Lines 138–146 repeat the same check, which can never fail at that point. This is dead code that adds noise.

♻️ Suggested simplification
-  const buyDebridgeChainId = chainIdToDebridgeChainId[buyAsset.chainId]
-  if (buyDebridgeChainId === undefined) {
-    return Err(
-      makeSwapErrorRight({
-        message: `Buy asset chain '${buyAsset.chainId}' not supported by deBridge`,
-        code: TradeQuoteError.UnsupportedChain,
-      }),
-    )
-  }
+  // buyDebridgeChainId was already validated above (lines 78–87)
+  const buyDebridgeChainId = chainIdToDebridgeChainId[buyAsset.chainId]!
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swapper/src/swappers/DebridgeSwapper/utils/getTrade.ts` around lines
138 - 146, The second validation of buyDebridgeChainId is redundant because
chainIdToDebridgeChainId[buyAsset.chainId] was already checked and
early-returned with Err(UnsupportedChain) for the cross-chain path earlier in
getTrade; remove the dead block that re-checks buyDebridgeChainId (the const
buyDebridgeChainId = ... and the subsequent if returning Err) so the function
does not duplicate the UnsupportedChain guard and to keep logic concise.
packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts (1)

144-144: Reassigning the destructured txHash parameter — prefer a new const.

Line 144 rebinds the destructured parameter txHash, which violates the "avoid let assignments — prefer const" guideline. The mutation also makes it harder to trace which hash is being used at each point in the function.

♻️ Proposed fix
-      txHash = sourceTxStatus.buyTxHash ?? txHash
+      const resolvedTxHash = sourceTxStatus.buyTxHash ?? txHash

     const maybeOrderIdsResponse = await debridgeService.get<DebridgeOrderIdsResponse>(
-      `${DEBRIDGE_STATS_API_URL}/api/Transaction/${txHash}/orderIds`,
+      `${DEBRIDGE_STATS_API_URL}/api/Transaction/${resolvedTxHash}/orderIds`,
     )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts` at line 144, The
code reassigns the destructured parameter txHash (txHash =
sourceTxStatus.buyTxHash ?? txHash); instead leave the parameter immutable and
create a new const (e.g., const resolvedTxHash = sourceTxStatus.buyTxHash ??
txHash) and then use resolvedTxHash in subsequent logic; update any references
that relied on the reassigned txHash to use the new const, keeping
sourceTxStatus and the original txHash parameter untouched.
src/lib/utils/sei.ts (1)

30-59: getSeiTransactionStatus should use the available viem client instead of a raw fetch.

viemClientByChainId[KnownChainIds.SeiMainnet] (viemSeiClient) is already available in @shapeshiftoss/contracts. The same-chain path in DebridgeSwapper/endpoints.ts already uses viemClient.getTransactionReceipt for Sei. Using viem here keeps the two receipt-check paths consistent and removes the hand-rolled JSON-RPC body, the '0x1'/'0x0' string comparison, and the missing request timeout.

♻️ Suggested refactor
+import { viemClientByChainId } from '@shapeshiftoss/contracts'
+import { KnownChainIds } from '@shapeshiftoss/types'
 import type { EvmChainAdapter } from '@shapeshiftoss/chain-adapters'
 import { TxStatus } from '@shapeshiftoss/unchained-client'
+import type { Hex } from 'viem'

-export const getSeiTransactionStatus = async (txHash: string): Promise<TxStatus> => {
-  const rpcUrl = getConfig().VITE_SEI_NODE_URL
+export const getSeiTransactionStatus = async (txHash: string): Promise<TxStatus> => {
+  const viemClient = viemClientByChainId[KnownChainIds.SeiMainnet]
+  if (!viemClient) return TxStatus.Unknown
   try {
-    const response = await fetch(rpcUrl, { ... })
-    if (!response.ok) return TxStatus.Unknown
-    const data = await response.json()
-    const receipt = data?.result
-    if (!receipt) return TxStatus.Pending
-    if (receipt.status === '0x1') return TxStatus.Confirmed
-    if (receipt.status === '0x0') return TxStatus.Failed
-    return TxStatus.Unknown
+    const receipt = await viemClient.getTransactionReceipt({ hash: txHash as Hex })
+    return receipt.status === 'success' ? TxStatus.Confirmed : TxStatus.Failed
   } catch (error) {
-    console.error('Error fetching Sei transaction status:', error)
+    // tx not yet mined — treat as pending
     return TxStatus.Unknown
   }
 }

Additionally, console.error on line 57 should use the project's structured logger per the coding guidelines.

packages/swapper/src/constants.ts (1)

142-198: isAutoSlippageSupportedBySwapper and getDefaultSlippageDecimalPercentageForSwapper are inconsistent for Debridge.

Every other auto-slippage swapper (Jupiter, Relay, Across) throws in getDefaultSlippageDecimalPercentageForSwapper, while Debridge returns '0.03'. This hybrid behaviour exists because same-chain Debridge swaps use explicit slippage (3%) while cross-chain uses dstChainTokenOutAmount: 'auto'. However, isAutoSlippageSupportedBySwapper is chain-mode-agnostic, so UI code that calls isAutoSlippageSupportedBySwapper(SwapperName.Debridge) === true may skip slippage UI for same-chain swaps where a concrete 3% default is actually meaningful.

Consider either:

  • Keeping both functions consistent by moving DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE out of this function and using it only inside getSameChainTrade, OR
  • Documenting the intentional hybrid behaviour with an inline comment.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swapper/src/constants.ts` around lines 142 - 198, The two functions
are inconsistent for Debridge:
isAutoSlippageSupportedBySwapper(SwapperName.Debridge) returns true but
getDefaultSlippageDecimalPercentageForSwapper currently returns
DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE; make them consistent by removing
Debridge’s special-case return from
getDefaultSlippageDecimalPercentageForSwapper (throw like Jupiter/Relay/Across)
and move DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE usage into the same-chain
flow (e.g., getSameChainTrade) so same-chain Debridge trades still use the 3%
constant while global auto-slippage stays “unsupported” by the default-provider;
update imports/usages accordingly (symbols:
DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE,
getDefaultSlippageDecimalPercentageForSwapper, isAutoSlippageSupportedBySwapper,
getSameChainTrade).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@headers/csps/debridge.ts`:
- Around line 3-5: Replace the hardcoded origins in the exported csp object with
a dynamic value loaded via Vite's loadEnv similar to across.ts: create a mode
value (using process.env.MODE or NODE_ENV or 'development'), call loadEnv(mode,
process.cwd(), '') to get env, and set 'connect-src' to use
env.VITE_DEBRIDGE_API_URL (append a trailing slash when present) alongside the
existing 'https://stats-api.dln.trade/' entry; update the exported const csp in
debridge.ts to reference that env value instead of the fixed URL.

In `@packages/chain-adapters/src/evm/sei/SeiChainAdapter.ts`:
- Around line 18-20: The isSeiChainAdapter function currently calls (adapter as
ChainAdapter).getType() and will throw if adapter is null/undefined; update
isSeiChainAdapter to first guard against falsy values (e.g., if (!adapter)
return false) and also verify the adapter exposes a callable getType (e.g.,
typeof (adapter as any).getType === "function") before calling it, then compare
the returned value to KnownChainIds.SeiMainnet; reference the isSeiChainAdapter
function and KnownChainIds.SeiMainnet when making this change.

In `@packages/swapper/src/swappers/DebridgeSwapper/constant.ts`:
- Around line 1-39: Move the current constant.ts contents into a new file at
utils/constants.ts within the DebridgeSwapper folder and delete the original
constant.ts; ensure all exports remain identical (chainIdToDebridgeChainId,
debridgeChainIdToChainId, DEBRIDGE_SUPPORTED_CHAIN_IDS,
DEFAULT_DEBRIDGE_TOKEN_ADDRESS, DEFAULT_DEBRIDGE_USER_ADDRESS) and update any
import sites to import from "…/utils/constants" instead of "./constant" so the
swapper follows the required SwapperName/utils/constants.ts convention.

In `@packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts`:
- Around line 107-114: checkTradeStatus currently ignores the passed-in config
and hardcodes the DLN order status base URL; destructure config (or
VITE_DEBRIDGE_API_URL) from the CheckTradeStatusInput in the checkTradeStatus
signature and use config.VITE_DEBRIDGE_API_URL when building the order status
URL instead of "https://dln.debridge.finance"; leave DEBRIDGE_STATS_API_URL
hardcoded as-is. Update the URL construction/usage inside the checkTradeStatus
function (where the order status fetch is done) to reference the config value so
non-production environments honor VITE_DEBRIDGE_API_URL.

In `@packages/swapper/src/swappers/DebridgeSwapper/utils/getTrade.ts`:
- Around line 182-217: The buyAmountBeforeFeesCryptoBaseUnit calculation
erroneously converts and adds a sell-side DLN protocol fee (protocolFeeAmount
using sellChainFeeAssetDecimals) to a buy-side amount, causing a
currency/precision mismatch; update the logic in the
buyAmountBeforeFeesCryptoBaseUnit block (and the analogous same-chain block) to
not add the converted fee—simply return buyAmountAfterFeesCryptoBaseUnit when a
DlnProtocolFee is present (i.e., remove the fee conversion/addition using
convertPrecision, BigAmount.fromBaseUnit, and related deps.assetsById precision
handling) so the net destination amount remains correct.

In `@packages/swapper/src/swappers/DebridgeSwapper/utils/types.ts`:
- Around line 176-178: The current type guard isDebridgeError is too broad
because it treats any object with a 'message' property (including native Errors)
as a DebridgeError; update the guard to check only for Debridge-specific fields
(e.g., 'errorCode' or 'errorId') and/or a combination that cannot be present on
native Error objects so it reliably narrows to DebridgeError. Locate the
isDebridgeError function in types.ts and replace the condition ("'message' in
error" or loose object checks) with checks like typeof error === 'object' &&
error !== null && ('errorCode' in error || 'errorId' in error) (or similar
unique-key checks) so consumers using isDebridgeError won't misclassify generic
Errors.

---

Nitpick comments:
In `@packages/swapper/src/constants.ts`:
- Around line 142-198: The two functions are inconsistent for Debridge:
isAutoSlippageSupportedBySwapper(SwapperName.Debridge) returns true but
getDefaultSlippageDecimalPercentageForSwapper currently returns
DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE; make them consistent by removing
Debridge’s special-case return from
getDefaultSlippageDecimalPercentageForSwapper (throw like Jupiter/Relay/Across)
and move DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE usage into the same-chain
flow (e.g., getSameChainTrade) so same-chain Debridge trades still use the 3%
constant while global auto-slippage stays “unsupported” by the default-provider;
update imports/usages accordingly (symbols:
DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE,
getDefaultSlippageDecimalPercentageForSwapper, isAutoSlippageSupportedBySwapper,
getSameChainTrade).

In `@packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts`:
- Line 144: The code reassigns the destructured parameter txHash (txHash =
sourceTxStatus.buyTxHash ?? txHash); instead leave the parameter immutable and
create a new const (e.g., const resolvedTxHash = sourceTxStatus.buyTxHash ??
txHash) and then use resolvedTxHash in subsequent logic; update any references
that relied on the reassigned txHash to use the new const, keeping
sourceTxStatus and the original txHash parameter untouched.

In
`@packages/swapper/src/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.ts`:
- Around line 12-30: The validation branches returning Err(...) for missing
addresses must include a TradeQuoteError code; update both checks (the
sendAddress and receiveAddress guards in getTradeQuote) to call
makeSwapErrorRight with a code property set to the appropriate enum value (e.g.,
TradeQuoteError.MissingSendAddress and TradeQuoteError.MissingReceiveAddress)
alongside the message so the returned error uses the TradeQuoteError enum for
structured handling.

In `@packages/swapper/src/swappers/DebridgeSwapper/utils/getTrade.ts`:
- Around line 138-146: The second validation of buyDebridgeChainId is redundant
because chainIdToDebridgeChainId[buyAsset.chainId] was already checked and
early-returned with Err(UnsupportedChain) for the cross-chain path earlier in
getTrade; remove the dead block that re-checks buyDebridgeChainId (the const
buyDebridgeChainId = ... and the subsequent if returning Err) so the function
does not duplicate the UnsupportedChain guard and to keep logic concise.

In `@src/plugins/activePlugins.ts`:
- Around line 61-62: The array of plugin identifiers in activePlugins.ts has
'sei' and 'scroll' out of alphabetical order; swap their positions so 'scroll'
comes before 'sei' to match the import order and alphabetical sorting rule —
update the list where the identifiers appear (the array containing sei and
scroll) so it reads scroll, sei.

In `@src/plugins/sei/index.tsx`:
- Around line 22-36: getKnownTokens calls fromAssetId twice per asset (once in
the filter and again in the map); update getKnownTokens to call fromAssetId only
once per asset by performing a single pass: iterate assetService.assets and for
each asset call fromAssetId(asset.assetId) once, check chainId/assetNamespace on
the parsed result, and if it matches push/return the object using
parsed.assetReference for contractAddress (preserve symbol/name/precision). This
can be implemented with a single reduce/map that stores the parsed result per
asset and avoids the duplicate fromAssetId calls.

@premiumjibles premiumjibles self-requested a review February 23, 2026 00:13
Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/context/WalletProvider/WalletConnectV2/config.ts (1)

54-66: ⚠️ Potential issue | 🟠 Major

Add Sei RPC mapping in WalletConnect provider config.

Sei is added as an optional chain, but walletConnectV2ProviderConfig.rpcMap doesn’t include an RPC URL for CHAIN_REFERENCE.SeiMainnet. This can break chain switching or provider initialization for Sei because WalletConnect won’t know which RPC to use. Please add the VITE_SEI_NODE_URL config entry and map it in rpcMap.

✅ Proposed fix
 const {
   VITE_WALLET_CONNECT_WALLET_PROJECT_ID,
   VITE_AVALANCHE_NODE_URL,
   VITE_OPTIMISM_NODE_URL,
   VITE_BNBSMARTCHAIN_NODE_URL,
   VITE_POLYGON_NODE_URL,
   VITE_GNOSIS_NODE_URL,
   VITE_ETHEREUM_NODE_URL,
   VITE_ARBITRUM_NODE_URL,
   VITE_BASE_NODE_URL,
   VITE_INK_NODE_URL,
   VITE_FLOWEVM_NODE_URL,
+  VITE_SEI_NODE_URL,
 } = getConfig()

   rpcMap: {
     [CHAIN_REFERENCE.AvalancheCChain]: VITE_AVALANCHE_NODE_URL,
     [CHAIN_REFERENCE.OptimismMainnet]: VITE_OPTIMISM_NODE_URL,
     [CHAIN_REFERENCE.BnbSmartChainMainnet]: VITE_BNBSMARTCHAIN_NODE_URL,
     [CHAIN_REFERENCE.PolygonMainnet]: VITE_POLYGON_NODE_URL,
     [CHAIN_REFERENCE.GnosisMainnet]: VITE_GNOSIS_NODE_URL,
     [CHAIN_REFERENCE.EthereumMainnet]: VITE_ETHEREUM_NODE_URL,
     [CHAIN_REFERENCE.ArbitrumMainnet]: VITE_ARBITRUM_NODE_URL,
     [CHAIN_REFERENCE.BaseMainnet]: VITE_BASE_NODE_URL,
     [CHAIN_REFERENCE.InkMainnet]: VITE_INK_NODE_URL,
     [CHAIN_REFERENCE.FlowEvmMainnet]: VITE_FLOWEVM_NODE_URL,
+    [CHAIN_REFERENCE.SeiMainnet]: VITE_SEI_NODE_URL,
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/context/WalletProvider/WalletConnectV2/config.ts` around lines 54 - 66,
walletConnectV2OptionalChains includes the Sei chain but
walletConnectV2ProviderConfig.rpcMap is missing an RPC entry for
CHAIN_REFERENCE.SeiMainnet; add a new VITE_SEI_NODE_URL env config and include
its URL in walletConnectV2ProviderConfig.rpcMap keyed by
CHAIN_REFERENCE.SeiMainnet so WalletConnect can resolve the correct RPC for Sei
during provider initialization and chain switching (update the config where
walletConnectV2ProviderConfig and rpcMap are defined).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/utils/src/assetData/baseAssets.ts`:
- Around line 604-605: Replace the main icon URL for the CoinGecko image id
28205 so it uses the /large/ variant instead of /small/ (i.e. change the string
'https://assets.coingecko.com/coins/images/28205/small/Sei_Logo_-_Transparent.png'
used for the icon field to use '/large/'); leave the networkIcon value as-is
(keep the /small/ variant).
- Line 604: The SEI asset entry currently sets icon to the CoinGecko /small/
path which is low-res; update the asset's main icon URL (the property named
"icon" for the SEI entry referencing "Sei_Logo") to use the higher-resolution
CoinGecko /large/ path while leaving the "networkIcon" property on the same SEI
entry pointing to the /small/ path unchanged; ensure you only change the main
icon string for the SEI asset in baseAssets.ts.

---

Outside diff comments:
In `@src/context/WalletProvider/WalletConnectV2/config.ts`:
- Around line 54-66: walletConnectV2OptionalChains includes the Sei chain but
walletConnectV2ProviderConfig.rpcMap is missing an RPC entry for
CHAIN_REFERENCE.SeiMainnet; add a new VITE_SEI_NODE_URL env config and include
its URL in walletConnectV2ProviderConfig.rpcMap keyed by
CHAIN_REFERENCE.SeiMainnet so WalletConnect can resolve the correct RPC for Sei
during provider initialization and chain switching (update the config where
walletConnectV2ProviderConfig and rpcMap are defined).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4267156 and 4cc3314.

⛔ Files ignored due to path filters (10)
  • packages/caip/src/adapters/coingecko/generated/index.ts is excluded by !**/generated/**
  • public/generated/asset-manifest.json is excluded by !**/generated/**
  • public/generated/asset-manifest.json.br is excluded by !**/generated/**
  • public/generated/asset-manifest.json.gz is excluded by !**/*.gz, !**/generated/**
  • public/generated/generatedAssetData.json is excluded by !**/generated/**
  • public/generated/generatedAssetData.json.br is excluded by !**/generated/**
  • public/generated/generatedAssetData.json.gz is excluded by !**/*.gz, !**/generated/**
  • public/generated/relatedAssetIndex.json is excluded by !**/generated/**
  • public/generated/relatedAssetIndex.json.br is excluded by !**/generated/**
  • public/generated/relatedAssetIndex.json.gz is excluded by !**/*.gz, !**/generated/**
📒 Files selected for processing (50)
  • .env
  • .env.development
  • headers/csps/debridge.ts
  • headers/csps/index.ts
  • packages/caip/src/adapters/coingecko/index.test.ts
  • packages/caip/src/adapters/coingecko/index.ts
  • packages/caip/src/constants.ts
  • packages/chain-adapters/src/evm/EvmBaseAdapter.ts
  • packages/chain-adapters/src/evm/SecondClassEvmAdapter.ts
  • packages/chain-adapters/src/evm/index.ts
  • packages/chain-adapters/src/types.ts
  • packages/contracts/src/ethersProviderSingleton.ts
  • packages/contracts/src/viemClient.ts
  • packages/hdwallet-coinbase/src/coinbase.ts
  • packages/hdwallet-core/src/ethereum.ts
  • packages/hdwallet-core/src/wallet.ts
  • packages/hdwallet-gridplus/src/gridplus.ts
  • packages/hdwallet-keepkey/src/keepkey.ts
  • packages/hdwallet-ledger/src/ledger.ts
  • packages/hdwallet-metamask-multichain/src/shapeshift-multichain.ts
  • packages/hdwallet-native/src/ethereum.ts
  • packages/hdwallet-phantom/src/phantom.ts
  • packages/hdwallet-trezor/src/trezor.ts
  • packages/hdwallet-vultisig/src/vultisig.ts
  • packages/hdwallet-walletconnectv2/src/walletconnectV2.ts
  • packages/public-api/src/config.ts
  • packages/swapper/src/swappers/RelaySwapper/constant.ts
  • packages/swapper/src/swappers/RelaySwapper/utils/relayTokenToAssetId.ts
  • packages/types/src/base.ts
  • packages/types/src/zerion.ts
  • packages/utils/src/assetData/baseAssets.ts
  • packages/utils/src/assetData/getBaseAsset.ts
  • packages/utils/src/chainIdToFeeAssetId.ts
  • packages/utils/src/getAssetNamespaceFromChainId.ts
  • packages/utils/src/getChainShortName.ts
  • packages/utils/src/getNativeFeeAssetReference.ts
  • scripts/generateAssetData/coingecko.ts
  • scripts/generateAssetData/generateAssetData.ts
  • src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx
  • src/config.ts
  • src/constants/chains.ts
  • src/context/PluginProvider/PluginProvider.tsx
  • src/context/WalletProvider/WalletConnectV2/config.ts
  • src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx
  • src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts
  • src/lib/account/evm.ts
  • src/lib/asset-service/service/AssetService.ts
  • src/lib/coingecko/utils.ts
  • src/pages/Markets/components/MarketsRow.tsx
  • src/plugins/activePlugins.ts
🚧 Files skipped from review as they are similar to previous changes (32)
  • packages/chain-adapters/src/evm/index.ts
  • src/lib/asset-service/service/AssetService.ts
  • src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx
  • packages/types/src/base.ts
  • packages/swapper/src/swappers/RelaySwapper/utils/relayTokenToAssetId.ts
  • packages/hdwallet-coinbase/src/coinbase.ts
  • packages/hdwallet-core/src/ethereum.ts
  • src/context/PluginProvider/PluginProvider.tsx
  • src/lib/coingecko/utils.ts
  • packages/hdwallet-metamask-multichain/src/shapeshift-multichain.ts
  • packages/hdwallet-ledger/src/ledger.ts
  • packages/hdwallet-core/src/wallet.ts
  • packages/chain-adapters/src/evm/EvmBaseAdapter.ts
  • src/config.ts
  • src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx
  • packages/caip/src/constants.ts
  • packages/hdwallet-gridplus/src/gridplus.ts
  • packages/utils/src/getNativeFeeAssetReference.ts
  • src/pages/Markets/components/MarketsRow.tsx
  • packages/swapper/src/swappers/RelaySwapper/constant.ts
  • packages/utils/src/getAssetNamespaceFromChainId.ts
  • packages/contracts/src/ethersProviderSingleton.ts
  • scripts/generateAssetData/generateAssetData.ts
  • packages/caip/src/adapters/coingecko/index.ts
  • headers/csps/debridge.ts
  • packages/chain-adapters/src/types.ts
  • src/constants/chains.ts
  • headers/csps/index.ts
  • packages/hdwallet-phantom/src/phantom.ts
  • packages/hdwallet-keepkey/src/keepkey.ts
  • scripts/generateAssetData/coingecko.ts
  • src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts

@gomesalexandre gomesalexandre changed the title feat: integrate SEI chain and deBridge swapper (cross-chain + same-chain) feat: integrate sei evm chain and debridge swapper (cross-chain + same-chain) Feb 24, 2026
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Conceptually looking very sane after salvaging and regenerating ! Will give a runtime pass in a few.

gomesalexandre and others added 2 commits February 24, 2026 13:34
- cross-chain buyAmountBeforeFees: use buyAmountAfterFees as-is (DlnProtocolFee
  is sell-chain native, cannot add to buy amount without exchange rate)
- same-chain buyAmountBeforeFees: protocolFee is in tokenOut (buy asset) units,
  remove broken convertPrecision that was treating it as 18-dec ETH
- same-chain feeData.protocolFees: key by buyAsset.assetId with buy asset info,
  not sell chain fee asset (protocolFee is tokenOut-denominated per api)
- checkTradeStatus: use config.VITE_DEBRIDGE_API_URL for order status endpoint
  (same pattern as Relay/Across), extract resolvedTxHash to avoid param mutation
- rename seiChain -> sei in baseAssets.ts, getBaseAsset.ts, generate scripts
- fix sei icon from /small/ to /large/ (13KB vs 1.3KB - renders non-blurry)
- delete src/lib/utils/sei.ts - sei is standard evm, default case in subscriber handles it
- remove getSeiTransactionStatus import and case from useSendActionSubscriber
- regen sei assets with fixed icon url

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

Choose a reason for hiding this comment

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

done, deleted in 2341454 - SEI is standard EVM, the default case in useSendActionSubscriber handles it via the adapter generically

Copy link
Contributor

@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 (1)
packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts (1)

134-148: Avoid let resolvedTxHash; extract a resolver for const‑only flow.

Style guidelines prefer avoiding let. Consider extracting the EVM confirmation/txHash resolution into a helper returning either a TradeStatus (early return) or a resolved hash, so the remainder can operate on const.

As per coding guidelines: Avoid let variable assignments - prefer const with inline IIFE switch statements or extract to functions for conditional logic.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts` around lines 134
- 148, The current flow mutates resolvedTxHash with let; extract the EVM
confirmation/hash resolution into a helper (e.g., resolveEvmTxHash or
getResolvedTxHash) that accepts (txHash, chainId, address,
assertGetEvmChainAdapter, fetchIsSmartContractAddressQuery) and inside calls
isEvmChainId and checkEvmSwapStatus; have the helper return either a
TradeStatus/TxStatus object (when source status !== TxStatus.Confirmed) to allow
an immediate return, or a string resolved hash (buyTxHash ?? txHash); then in
the caller use a const for the returned value and branch: if the helper returned
a TradeStatus return it, otherwise set a const resolvedTxHash to the returned
string and continue. This removes the let and keeps logic in a
single-responsibility function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts`:
- Around line 118-132: The same‑chain branch in isSameChainSwap is
reimplementing EVM receipt logic instead of reusing the shared utility; replace
the custom viem getTransactionReceipt block with a call to checkEvmSwapStatus,
passing the txHash and chainId (and any required context such as
viemClientByChainId or provider map) and return its result; ensure you import
checkEvmSwapStatus and preserve the current return shape (buyTxHash, status,
message) and the fallback behavior when no viem client exists by delegating that
handling to or preserving it around checkEvmSwapStatus.

In `@packages/swapper/src/swappers/DebridgeSwapper/utils/getTrade.ts`:
- Around line 57-99: The recipientAddress can be undefined for quotes
(input.quoteOrRate !== 'rate') and the deBridge API is invoked before explicit
validation; add an early validation in getTrade (before building
recipientAddress / before any deBridge API call) that returns an Err via
makeSwapErrorRight when input.quoteOrRate !== 'rate' and input.receiveAddress is
falsy, with a clear message like "Missing receiveAddress for quote" and an
appropriate error code (e.g., TradeQuoteError.Validation) to keep error
reporting deterministic; reference recipientAddress and
input.quoteOrRate/input.receiveAddress when adding this check.

---

Nitpick comments:
In `@packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts`:
- Around line 134-148: The current flow mutates resolvedTxHash with let; extract
the EVM confirmation/hash resolution into a helper (e.g., resolveEvmTxHash or
getResolvedTxHash) that accepts (txHash, chainId, address,
assertGetEvmChainAdapter, fetchIsSmartContractAddressQuery) and inside calls
isEvmChainId and checkEvmSwapStatus; have the helper return either a
TradeStatus/TxStatus object (when source status !== TxStatus.Confirmed) to allow
an immediate return, or a string resolved hash (buyTxHash ?? txHash); then in
the caller use a const for the returned value and branch: if the helper returned
a TradeStatus return it, otherwise set a const resolvedTxHash to the returned
string and continue. This removes the let and keeps logic in a
single-responsibility function.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc3314 and 2341454.

⛔ Files ignored due to path filters (6)
  • public/generated/asset-manifest.json is excluded by !**/generated/**
  • public/generated/asset-manifest.json.br is excluded by !**/generated/**
  • public/generated/asset-manifest.json.gz is excluded by !**/*.gz, !**/generated/**
  • public/generated/generatedAssetData.json is excluded by !**/generated/**
  • public/generated/generatedAssetData.json.br is excluded by !**/generated/**
  • public/generated/generatedAssetData.json.gz is excluded by !**/*.gz, !**/generated/**
📒 Files selected for processing (6)
  • packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts
  • packages/swapper/src/swappers/DebridgeSwapper/utils/getTrade.ts
  • packages/utils/src/assetData/baseAssets.ts
  • packages/utils/src/assetData/getBaseAsset.ts
  • scripts/generateAssetData/coingecko.ts
  • scripts/generateAssetData/sei/index.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • scripts/generateAssetData/sei/index.ts
  • scripts/generateAssetData/coingecko.ts
  • packages/utils/src/assetData/getBaseAsset.ts
  • packages/utils/src/assetData/baseAssets.ts

gomesalexandre and others added 2 commits February 24, 2026 13:47
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

@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: 4

🧹 Nitpick comments (1)
packages/caip/src/constants.ts (1)

42-42: Align new constants with UPPER_SNAKE_CASE naming rule.

seiAssetId and seiChainId are camelCase constants. If renaming across the public API is too disruptive for this PR, please consider a follow‑up standardization plan or compatibility aliases so new additions don’t drift further from the guideline.
As per coding guidelines: Use UPPER_SNAKE_CASE for constants and configuration values with descriptive names.

Also applies to: 123-123

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/caip/src/constants.ts` at line 42, Rename the newly added camelCase
constants to follow UPPER_SNAKE_CASE (e.g., SEI_ASSET_ID and SEI_CHAIN_ID) to
comply with the project's constant naming guideline; update all references to
seiAssetId and seiChainId in the codebase (exports, imports, tests, and public
API surfaces) or provide backwards-compatible aliases that re-export the new
names (e.g., export const seiAssetId = SEI_ASSET_ID) if renaming the public API
in this PR is unacceptable, and ensure types (AssetId) and any documentation are
updated to use the new identifiers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/caip/src/constants.ts`:
- Line 195: Remove the inline doc comment added after the SeiMainnet entry in
the constants mapping: keep the existing key/value pair SeiMainnet: '1329' but
delete the trailing comment "// https://docs.sei.io" so the line contains only
the value assignment; do not add any other comments or changes to surrounding
entries.
- Around line 309-310: The FEE_ASSET_IDS list is missing the Sei fee asset,
causing fee resolution/estimation to fail for Sei; update the FEE_ASSET_IDS
array to include seiAssetId alongside existing entries (e.g., add seiAssetId
near CHAIN_REFERENCE.SeiMainnet/CHAIN_REFERENCE.CeloMainnet entries) so
fee-asset resolution and fee estimation for Sei transactions work correctly,
ensuring you reference the existing seiAssetId constant and the FEE_ASSET_IDS
symbol when making the change.

In `@packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts`:
- Around line 142-176: The error branches for deBridge API calls silently ignore
failures; add console.error logs before each early return: when
maybeOrderIdsResponse.isErr() log the error with resolvedTxHash and chainId (and
include maybeOrderIdsResponse.unwrapErr() or the error object) and when
maybeStatusResponse.isErr() log the error with resolvedTxHash, orderId and
chainId (and include maybeStatusResponse.unwrapErr()); update the branches
around debridgeService.get calls that produce maybeOrderIdsResponse and
maybeStatusResponse to follow the logging pattern used in
SunioSwapper/StonfiSwapper.
- Around line 17-104: The catch blocks in getEvmTransactionFees and
getUnsignedEvmTransaction are swallowing exceptions; change both catches to
capture the error (catch (error)) and emit structured logs before falling back:
call a logger (e.g., logger.error) or console.error with metadata { error,
chainId: sellAsset.chainId, stepIndex, to, value, data, gasLimitFromApi } and a
short message indicating gas estimation failed for evm.getFees; ensure you
reference evm.getFees, adapter.getGasFeeData, getEvmTransactionFees and
getUnsignedEvmTransaction so the logs provide context, and only then proceed
with the existing fallback logic.

---

Nitpick comments:
In `@packages/caip/src/constants.ts`:
- Line 42: Rename the newly added camelCase constants to follow UPPER_SNAKE_CASE
(e.g., SEI_ASSET_ID and SEI_CHAIN_ID) to comply with the project's constant
naming guideline; update all references to seiAssetId and seiChainId in the
codebase (exports, imports, tests, and public API surfaces) or provide
backwards-compatible aliases that re-export the new names (e.g., export const
seiAssetId = SEI_ASSET_ID) if renaming the public API in this PR is
unacceptable, and ensure types (AssetId) and any documentation are updated to
use the new identifiers.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3845aaf and 5d91547.

📒 Files selected for processing (2)
  • packages/caip/src/constants.ts
  • packages/swapper/src/swappers/DebridgeSwapper/endpoints.ts

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Happy on almost all counts but:

  • Simulation and Tx failing (Rabby)
Image
  • Same old econd-class Tx history upsertion/action center execution price sad for cross-chain swaps to SEI

https://jam.dev/c/e2435dca-b18b-4bd2-a4c0-2e283e86c0be

Will fix both and we're gucci

gomesalexandre and others added 9 commits February 24, 2026 15:05
Same rpc limitation as flow evm/blast/zksync/celo - use wrapped native
withdrawal event fallback for tx history parsing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fixFee and prependedOperatingExpenseCost are baked into tx.value by
deBridge, making the wallet think it needs way more native than the sell
amount alone. Surface them as a protocol fee with requiresBalance: true
so balance checks account for them.

Drops the broken DlnProtocolFee entry (was ETH assetId key with USDC
amount - negligible ~$0.00076 anyway).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
deBridge API returns conservative gasLimits (1.6-2.3M gas). At high
gas prices (660 gwei on Polygon) this causes tx fees to exceed MetaMask's
1 ETH cap. Use eth_estimateGas result with a 1.2x buffer instead;
fall back to API value only when estimation fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- add seiAssetId to FEE_ASSET_IDS (missing, causing fee resolution to fail)
- drop trailing url comment on SeiMainnet constant entry
- add console.error to debridge catch blocks and status api failures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
auto slippage from deBridge resolves to ~1% which is too tight for
chains like SEI's AlgebraPool (4-5% price impact even for small trades).
Default to 5% to avoid "Return amount is not enough" reverts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DebridgeOrderStatus had no fulfillment tx hash. When order is confirmed,
fetch /api/Orders/{orderId} from stats-api.dln.trade to get
fulfilledDstEventMetadata.transactionHash, surfaced as buyTxHash
so parseTx runs for SEI destination tx and execution price shows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
stats-api.dln.trade/api/Orders returns transactionHash as a
DebridgeHashObject {stringValue, bytesValue, bytesArrayValue} not
a plain string. Was storing the full object as buyTxHash, causing
txHashFilter.toLowerCase crash in selectors and invalid
eth_getTransactionByHash params.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gomesalexandre
gomesalexandre previously approved these changes Feb 24, 2026
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Disregard derp bot dupes

gomesalexandre
gomesalexandre previously approved these changes Feb 24, 2026
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Disregard derp bot dupes

@gomesalexandre gomesalexandre enabled auto-merge (squash) February 24, 2026 15:06
@gomesalexandre gomesalexandre dismissed stale reviews from themself February 24, 2026 15:08

disregard the double-review i'm a derp bot

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

hey @NeOMakinG, picking up from where you left off - summary of what landed after fc60407ebd:

chain integration

  • merge develop + full sei integration (4cc3314da1)
  • debridge fee math fix, sei icon, rm custom tx status (2341454adf)
  • sei chain adapter null guard + debridge error type guard (3845aaf941)
  • same-chain status via checkEvmSwapStatus (55cd0e1eef)
  • celo to VALID_CHAIN_IDS (5d91547042)

sei parseTx / second-class tx history

  • skip debug_traceTransaction for sei (69c035b018) - same rpc limitation as blast/zkSync/flow. WSEI burn event detection now works as fallback -> execution price now shows in tx history

debridge gas + fee fixes

  • surface fixFee + prependedOperatingExpenseCost as protocol fee with requiresBalance: true for cross-chain (51ad24f37b)
  • eth_estimateGas * 1.2 buffer instead of inflated api gas limit (feb9bed30a) - was causing "fee exceeds cap" on polygon
  • seiAssetId added to FEE_ASSET_IDS (was missing, would've broken fee resolution)
  • debridge error logging improvements (e75cceb3af)

same-chain sei fix

  • default slippage to 5% instead of auto (e4011f80ff) - sei's algebrapool has ~4-5% price impact, auto resolves to ~1% so swap always reverted. same-chain sei swaps now work

cross-chain buyTxHash + app crash fix

  • fetch fulfilledDstEventMetadata.transactionHash from stats-api.dln.trade/api/Orders/{orderId} on confirmation (2f3816359a) so parseTx runs for the sei destination tx
  • 0099ec0071 <- this one was crashing the app: stats-api returns all hashes as {stringValue, bytesValue, bytesArrayValue} objects, not plain strings. was storing the full object as buyTxHash -> txHashFilter.toLowerCase is not a function in selectors. now extracts .stringValue. execution price shows

tl;dr ser the receipts are right there, no excuses: https://jam.dev/c/8da29a16-761c-4fdd-b3ec-ef9dcec17694

@gomesalexandre gomesalexandre merged commit c257772 into develop Feb 24, 2026
5 checks passed
@gomesalexandre gomesalexandre deleted the feat/integrate-debridge-swapper branch February 24, 2026 15:16
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.

3 participants