Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ junit.xml
.yarnrc.yml

docker-compose.local.yml

# Planning scratch files
findings.md
progress.md
task_plan.md
1 change: 1 addition & 0 deletions dev/config/base-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ bridge:
dwIDAQAB
-----END PUBLIC KEY-----
transfer: "<replace>"
external_account: "<replace>"
timestampSkewMs: 300000

# See Foreign Exchange Rates: https://www.firstglobal-bank.com/
Expand Down
4 changes: 2 additions & 2 deletions docs/bridge-integration/API.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bridge.xyz GraphQL API Reference

All Bridge-related operations require the user to be authenticated and have an **Account Level 2** or higher.
All Bridge-related operations require the user to be authenticated and have an **Account Level 1** or higher.

## Mutations

Expand Down Expand Up @@ -193,7 +193,7 @@ query BridgeWithdrawals {
| Code | Description |
| --- | --- |
| `BRIDGE_DISABLED` | Bridge integration is disabled in configuration. |
| `BRIDGE_ACCOUNT_LEVEL_ERROR` | User account level is below 2. |
| `BRIDGE_ACCOUNT_LEVEL_ERROR` | User account level is below 1. |
| `BRIDGE_KYC_PENDING` | Operation requires approved KYC, but it is still pending. |
| `BRIDGE_KYC_REJECTED` | KYC was rejected. |
| `BRIDGE_CUSTOMER_NOT_FOUND` | Bridge customer record not found for the user. |
14 changes: 7 additions & 7 deletions docs/bridge-integration/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## System Overview

The Bridge.xyz integration enables USD on-ramp and off-ramp functionality for Flash users. It allows users to convert between USD (via bank transfers) and USDT (on the Tron network), which is then integrated into the Flash ecosystem via IBEX.
The Bridge.xyz integration enables USD on-ramp and off-ramp functionality for Flash users. It allows users to convert between USD (via bank transfers) and USDT (Ethereum), which is then integrated into the Flash ecosystem via IBEX.

## Component Architecture

The integration consists of three main components:

1. **Flash Backend**: The core service that orchestrates the flow between users, Bridge.xyz, and IBEX. It exposes a GraphQL API for the mobile app and handles webhooks from Bridge.xyz.
2. **Bridge.xyz API**: An external service that provides virtual bank accounts, KYC processing, and USD/USDT conversion.
3. **IBEX**: An external service used by Flash to manage Bitcoin and Lightning wallets, and in this context, to provide Tron USDT receive addresses and handle USDT deposits.
3. **IBEX**: An external service used by Flash to manage Bitcoin and Lightning wallets, and in this context, to provide USDT receive addresses and handle USDT deposits.

### Component Diagram

Expand All @@ -29,7 +29,7 @@ The integration consists of three main components:
| USD/USDT | USDT
v v
+----------------------------+
| Tron Network |
| Ethereum Network |
+----------------------------+
```

Expand All @@ -38,16 +38,16 @@ The integration consists of three main components:
### On-Ramp (USD -> USDT)

1. **KYC**: User initiates KYC via Flash, which creates a Bridge customer and returns a KYC link (Persona).
2. **Virtual Account**: Once KYC is approved, Flash creates a Tron USDT address via IBEX and a Bridge virtual account pointing to that address.
2. **Virtual Account**: Once KYC is approved, Flash creates a Bridge virtual account for receiving USD deposits.
3. **Deposit**: User sends USD to the virtual account.
4. **Conversion**: Bridge converts USD to USDT and sends it to the Tron address.
4. **Conversion**: Bridge converts USD to USDT and sends it to the user's on-chain address.
5. **Credit**: IBEX detects the USDT deposit and notifies Flash via webhook, which credits the user's wallet.

### Off-Ramp (USDT -> USD)

1. **Link Bank**: User links an external bank account via Bridge's hosted UI.
2. **Withdrawal**: User initiates a withdrawal in Flash.
3. **Transfer**: Flash creates a Bridge transfer from the user's Tron address to the linked bank account.
3. **Transfer**: Flash initiates a Bridge transfer from the user's Bridge balance to the linked external bank account.
4. **Conversion**: Bridge converts USDT to USD and sends it to the bank via ACH.

## Technology Stack
Expand All @@ -60,7 +60,7 @@ The integration consists of three main components:

## Security Model

- **Account Level**: Bridge functionality is restricted to users with Account Level 2 or higher.
- **Account Level**: Bridge functionality is restricted to users with Account Level 1 or higher.
- **KYC**: All users must pass Bridge's KYC process (powered by Persona).
- **Webhook Verification**: All incoming webhooks from Bridge.xyz are verified using asymmetric RSA-SHA256 signatures.
- **Idempotency**: All critical API calls to Bridge include an `Idempotency-Key` to prevent duplicate transactions.
Expand Down
10 changes: 5 additions & 5 deletions docs/bridge-integration/FLOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ User Flash App Flash Backend Bridge.xyz
| (Persona Flow) | | | |
| | | 7. kyc.approved | |
| | |<--------------------| |
| | | 8. Create Tron Addr | |
| | | 8. Create USDT Addr | |
| | |---------------------------------------->|
| | | 9. Create Virt Acc | |
| | |-------------------->| |
Expand All @@ -51,12 +51,12 @@ User Flash App Flash Backend Bridge.xyz
5. **Redirect**: App opens the KYC link (Persona).
6. **Verification**: User completes identity verification.
7. **KYC Webhook**: Bridge sends `kyc.approved` webhook to Flash.
8. **Tron Address**: Flash requests a unique Tron USDT receive address from IBEX.
9. **Virtual Account**: Flash creates a Bridge virtual account linked to the Tron address.
8. **USDT Address**: Flash requests a unique USDT receive address from IBEX.
9. **Virtual Account**: Flash creates a Bridge virtual account linked to the receive address.
10. **Display Details**: User sees bank name, routing number, and account number in the app.
11. **Bank Transfer**: User initiates a transfer from their banking app.
12. **Conversion**: Bridge receives USD and converts it to USDT.
13. **Settlement**: Bridge sends USDT to the user's Tron address.
13. **Settlement**: Bridge sends USDT to the user's on-chain address.
14. **IBEX Webhook**: IBEX detects the incoming USDT and notifies Flash.
15. **Credit**: Flash credits the user's USDT wallet and sends a push notification.

Expand Down Expand Up @@ -120,7 +120,7 @@ User Flash App Flash Backend Bridge.xyz
6. **Verification Webhook**: Bridge notifies Flash when the external account is verified.
7. **Initiate Withdrawal**: User enters amount and selects the linked bank account.
8. **GraphQL Mutation**: App calls `bridgeInitiateWithdrawal`.
9. **Bridge Transfer**: Flash creates a transfer in Bridge from the user's Tron address to the external account.
9. **Bridge Transfer**: Flash initiates a Bridge transfer from the user's Bridge balance to the external account.
10. **Confirmation**: App shows the withdrawal as "Pending".
11. **Conversion**: Bridge converts USDT from the user's balance to USD.
12. **ACH Transfer**: Bridge sends USD to the user's bank via ACH.
Expand Down
2 changes: 1 addition & 1 deletion docs/bridge-integration/WEBHOOKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Sent when a user's KYC application is rejected.
### Deposit Events

#### `deposit.completed`
Sent when a USD deposit to a virtual account is successfully converted to USDT and sent to the destination Tron address.
Sent when a USD deposit to a virtual account is successfully converted to USDT and sent to the user's on-chain address.
- **Action**: This event is primarily for tracking. The actual crediting of the user's wallet is handled by the IBEX webhook when the USDT arrives.

### Transfer Events
Expand Down
Loading