feat: integrate custom off-ramp API for USDC withdrawals#286
Open
ShantelPeters wants to merge 2 commits intodavedumto:mainfrom
Open
feat: integrate custom off-ramp API for USDC withdrawals#286ShantelPeters wants to merge 2 commits intodavedumto:mainfrom
ShantelPeters wants to merge 2 commits intodavedumto:mainfrom
Conversation
|
Someone is attempting to deploy a commit to the david's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@ShantelPeters Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
this description is vague, please do a proper pull request description |
Author
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR integrates a new Custom Off-ramp API for processing USDC withdrawals to Nigerian bank accounts, transitioning away from the legacy Yellow Card integration. It implements secure payload signing, updates the main withdrawal route to enforce USDC deduction before initiation, and introduces comprehensive unit tests to ensure stability.
🔑 Key Changes
Environment config (.env.example): Replaced YELLOW_CARD variables with new OFFRAMP_API_* credentials (key, secret, URL).
Core Integration (
lib/offramp.ts
): Created the initiateOfframp client method. It signs the request timestamp and JSON payload using an HMAC-SHA256 signature to prevent unauthorized or replay attacks.
Withdrawal Route (
app/api/withdrawals/route.ts
):
Integrated the new initiateOfframp method.
Plumbed a deductStellarUSDC step that deducts USDC from the user's non-custodial Stellar wallet before pinging the off-ramp API.
Implemented robust error catching and fallback responses (returns 400 or 500 appropriately).
Test Coverage (
tests/withdrawals.test.ts
):
Added new test suites mimicking successful and failed API states using vitest.
Scenarios covered: successful withdrawal, insufficient balance, invalid bank account, and 500 API availability failures.
CLOSES #280