Bank Integration
NestJS banking API with Currency Cloud, IFX, compliance sync, and native KMS/MPC/CEX/DEX integration.
Bank Integration
The Lux Bank is a NestJS/TypeScript API that handles fiat on/off ramp, payment processing, client management, and regulatory compliance. It natively integrates with KMS, MPC, CEX, and DEX for a unified trading experience.
Architecture
app.lux.financial (Frontend)
|
Bank API (NestJS)
|
+----+----+----+----+
| | | | |
CEX DEX KMS MPC Payment Providers
|
+-----+-----+
| |
CurrencyCloud IFXServices
ComplianceSyncService
Bridges bank compliance data to the CEX engine:
// Auto-sync on account changes
await complianceSyncService.syncAccountToCex(client);
// Sync after risk assessment update
await complianceSyncService.syncRiskAssessmentToCex(client, riskAssessment);Synced fields: jurisdiction, country, client type, KYC level, AML status, accreditation, PEP status, source of funds, adverse media, FATF high-risk, EDD status, tax residency, trading limits.
Auto-sync: Hourly scheduled sync of all accounts via @Cron.
TradingService
Native integration with all trading infrastructure:
// KMS signing
const sig = await tradingService.kmsSign(keyId, payload);
// MPC threshold signing
const sig = await tradingService.mpcSign(walletId, txHash, 'ethereum');
// Smart order router (auto-selects best venue)
const result = await tradingService.submitOrder(accountId, {
symbol: 'BTC-USD',
side: 'buy',
type: 'limit',
quantity: 1.5,
price: 45000,
});
// result.venue = 'cex' | 'dex'
// Force venue
const cexOrder = await tradingService.submitOrder(accountId, order, 'cex');
const dexOrder = await tradingService.submitOrder(accountId, order, 'dex');Smart Order Router
The submitOrder method compares CEX and DEX order books in parallel:
- Buy orders: Routes to venue with lowest ask price
- Sell orders: Routes to venue with highest bid price
- Fallback: Defaults to CEX if only one venue has liquidity
Account Model
The Account entity includes full compliance fields:
// Trading compliance
jurisdiction: string // US, UK, EU, SG, HK, IM, AE, ...
tradingClientType: string // individual, institutional, broker_dealer
kycLevel: number // 0-3
accredited: boolean // SEC accredited investor
professional: boolean // MiFID professional client
// PEP / EDD
pepStatus: string // direct, related, former
pepReviewedAt: Date
sourceOfFunds: string // employment, investments, ...
sofVerified: boolean
adverseMedia: boolean
highRiskCountry: boolean
eddRequired: boolean
taxResidency: string // ISO country codeJurisdiction Inference
The Client entity automatically infers regulatory jurisdiction from country:
- US territories (PR, VI, GU) -> US
- Isle of Man (IM) -> IM (own FSA regime, not UK)
- Crown Dependencies (GG, JE) -> UK (FCA oversight)
- EU member states (27 countries) -> EU
- 30+ additional jurisdictions mapped individually
Payment Providers
| Provider | Use Case |
|---|---|
| Currency Cloud | FX, international payments, multi-currency accounts |
| IFX | Institutional FX, large-value transfers |
| OpenPayd | EU banking, SEPA, card processing |
Configuration
| Env Var | Description |
|---|---|
CEX_BASE_URL | CEX API endpoint (default: http://localhost:8080) |
CEX_API_KEY | Bearer token for CEX auth |
CEX_SYNC_ENABLED | Enable compliance sync (true/false) |
DEX_BASE_URL | DEX RPC endpoint |
DEX_API_KEY | Bearer token for DEX auth |
KMS_BASE_URL | KMS API endpoint |
KMS_API_KEY | Bearer token for KMS auth |
MPC_BASE_URL | MPC API endpoint |
MPC_API_KEY | Bearer token for MPC auth |
Source
- Bank API:
luxfi/bank/app/api/src/ - Trading services:
luxfi/bank/app/api/src/trading/ - Models:
luxfi/bank/pkg/models/src/ - Account entity:
pkg/models/src/users/entities/account.entity.ts - Client entity:
pkg/models/src/clients/entities/client.entity.ts
How is this guide?
Last updated on