✨ server: add evm network support for bridge onramp#951
Conversation
🦋 Changeset detectedLatest commit: 7093014 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds EVM (BASE) support to the bridge onramp: introduces an EVM network enum and evm payment rail, expands /quote request/response schemas to accept EVM networks and include EVM deposit addresses, threads evmNetwork through deposit lookup/creation and liquidation handling, updates tests, and adds a changeset. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant API as API (/quote)
participant Bridge as Bridge utils
participant DB as DB / Liquidation store
Client->>API: GET /quote?provider=bridge¤cy=USDC&network=BASE
API->>Bridge: resolve provider & request deposit details (evmNetwork=BASE)
Bridge->>DB: lookup liquidation address (chain="evm", network=BASE)
alt liquidation exists
DB-->>Bridge: return liquidation address (Address)
Bridge-->>API: return depositInfo { displayName, address, fee, estimatedProcessingTime }
API-->>Client: 200 { depositInfo }
else none found
Bridge->>DB: create liquidation address for evm (network=BASE)
DB-->>Bridge: new liquidation address
Bridge-->>API: return depositInfo (with new address)
API-->>Client: 200 { depositInfo }
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces support for EVM networks, specifically the BASE network, for the Bridge onramp provider. Key changes include updating API validators and schemas to support the new network, extending bridge utilities to handle EVM liquidation addresses, and adding relevant test cases. I have no feedback to provide.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #951 +/- ##
==========================================
+ Coverage 72.73% 72.95% +0.21%
==========================================
Files 229 229
Lines 8572 8671 +99
Branches 2781 2836 +55
==========================================
+ Hits 6235 6326 +91
Misses 2103 2103
- Partials 234 242 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
server/utils/ramps/bridge.ts (1)
855-869: 🧹 Nitpick | 🔵 TrivialRedundant
"evm"in picklist.
CryptoPaymentRail(line 510) already includes"evm", so spreading it and appending"evm"again creates a duplicate. The schemas work correctly, but the duplication is misleading.🔧 Proposed fix
const CreateLiquidationAddress = object({ currency: picklist(["usdc", "usdt"]), - chain: picklist([...CryptoPaymentRail, "evm"]), + chain: picklist(CryptoPaymentRail), destination_payment_rail: picklist(BridgeChain), destination_currency: picklist(["usdc"]), destination_address: Address, }); const LiquidationAddress = object({ id: string(), currency: picklist(["usdc", "usdt", "any"]), - chain: picklist([...CryptoPaymentRail, "evm"]), + chain: picklist(CryptoPaymentRail), address: string(), destination_address: string(), });
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 941559ec-be2b-4d00-b1d6-ae3ef62fbebe
📒 Files selected for processing (5)
.changeset/bright-evm-arrive.mdserver/api/ramp.tsserver/test/api/ramp.test.tsserver/test/utils/bridge.test.tsserver/utils/ramps/bridge.ts
1b06371 to
c4899b8
Compare
a52283e to
2f52e56
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
server/utils/ramps/bridge.ts (1)
446-466:⚠️ Potential issue | 🟠 MajorMake EVM liquidation-address reuse network-aware.
Lines 446-466 reuse an existing address by
chain === "evm"andcurrencyonly, then relabel it with whatevernetworkthe caller requested. That is fine for BASE-only today, but it will silently return the wrong address as soon asEVMNetworkhas more than one entry. Please key reuse on the actual EVM network as well, or guard this path so a generic"evm"address cannot be presented as multiple networks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8acf8f86-5cb2-4a06-b936-eb056da1b805
📒 Files selected for processing (6)
.changeset/bright-evm-arrive.mdserver/api/ramp.tsserver/test/api/ramp.test.tsserver/test/utils/bridge.test.tsserver/utils/ramps/bridge.tsserver/utils/ramps/manteca.ts
closes #962
Summary by CodeRabbit