USDX Payments Processing Microservices Architecture

API Gateway
Core Services
Blockchain
Infrastructure

External Layer

External Clients

  • Web & Mobile Apps
  • Fintech Integrations
  • Merchant Systems

Gateway

API Gateway

  • Request Routing
  • OAuth2 Authentication
  • Rate Limiting
  • Webhook Management

Core Services

Authentication Service

  • OAuth2 Token Management
  • Multi-Factor Authentication
  • Session Management
  • Access Token Generation and Validation

Account Management Service

  • User Profile Creation and Management
  • KYC Process Integration
  • External Account Linking
  • Account Status Management

Wallet Service

  • USDX Wallet Creation and Management
  • Balance Tracking and Updates
  • Transaction History Maintenance
  • Wallet Recovery and Backup

Transaction Service

  • USDX Transfers (On/Off Chain)
  • Payment Processing
  • Virtual Account Transactions
  • Transaction Fee Calculation
  • Idempotency Handling

Treasury Service

  • Reserve Management
  • Yield Distribution
  • Cash Flow Management
  • Liquidity Monitoring and Management

Support Services

Compliance Service

  • KYC/AML Checks
  • Regulatory Reporting
  • Geographic Restrictions Enforcement
  • Sanctions Screening

Exchange Rate Service

  • Real-Time Exchange Rate Updates
  • Historical Rate Data Storage and Retrieval
  • Rate Conversion Calculations

Notification Service

  • Transaction Alerts
  • System Updates
  • Compliance Notifications
  • Custom User Notifications

Blockchain Layer

Blockchain Service

  • Network Interactions
  • Smart Contract Management
  • Token Minting/Burning
  • Block Confirmation Monitoring

Infrastructure

Database Service

  • Transaction Ledger Maintenance
  • User Data Storage and Retrieval
  • Audit Trail Logging
  • Data Backup and Recovery

Monitoring & Analytics Service

  • Performance Metrics Collection and Analysis
  • Error Logging and Alerting
  • Business Intelligence Reporting
  • System Health Monitoring

Security Service

  • End-to-End Encryption
  • Fraud Detection Algorithms
  • Access Control Management
  • Security Incident Response

X Protocol

USDX is a permissionless, yield-bearing stablecoin for payments.

Features

  • Access Control
  • Rebasing token mechanism
  • Minting and burning functionality
  • Block/Unblock accounts
  • Pausing emergency stop mechanism
  • Reward multiplier system
  • EIP-2612 permit support
  • OpenZeppelin UUPS upgrade pattern

Use Cases

  • Cash management
  • Yield-bearing collateral
  • Cross-border payments

Token Types

  • USDX: ERC-20, rebasing, yield-bearing collateral
  • wUSDX: ERC-4626, accumulating, DeFi

USDX

Public and External Functions

  • initialize(string memory name_, string memory symbol_, address owner)
  • name()
  • symbol()
  • decimals()
  • convertToShares(uint256 amount)
  • convertToTokens(uint256 shares)
  • totalShares()
  • totalSupply()
  • balanceOf(address account)
  • sharesOf(address account)
  • mint(address to, uint256 amount)
  • burn(address from, uint256 amount)
  • transfer(address to, uint256 amount)
  • blockAccounts(address[] addresses)
  • unblockAccounts(address[] addresses)
  • isBlocked(address account)
  • pause()
  • unpause()
  • setRewardMultiplier(uint256 _rewardMultiplier)
  • addRewardMultiplier(uint256 _rewardMultiplierIncrement)
  • approve(address spender, uint256 amount)
  • allowance(address owner, address spender)
  • transferFrom(address from, address to, uint256 amount)
  • increaseAllowance(address spender, uint256 addedValue)
  • decreaseAllowance(address spender, uint256 subtractedValue)
  • DOMAIN_SEPARATOR()
  • nonces(address owner)
  • permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

Private and Internal Functions

  • _authorizeUpgrade(address newImplementation)
  • _mint(address to, uint256 amount)
  • _burn(address account, uint256 amount)
  • _beforeTokenTransfer(address from, address to, uint256 amount)
  • _afterTokenTransfer(address from, address to, uint256 amount)
  • _transfer(address from, address to, uint256 amount)
  • _blockAccount(address account)
  • _unblockAccount(address account)
  • _setRewardMultiplier(uint256 _rewardMultiplier)
  • _spendAllowance(address owner, address spender, uint256 amount)
  • _useNonce(address owner)
  • _approve(address owner, address spender, uint256 amount)

Events

  • Transfer(from indexed addr, to uint256, amount uint256)
  • RewardMultiplier(uint256 indexed value)
  • Approval(address indexed owner, address indexed spender, uint256 value)
  • AccountBlocked(address indexed addr)
  • AccountUnblocked(address indexed addr)
  • Paused(address account)
  • Unpaused(address account)
  • Upgraded(address indexed implementation)

Roles

  • DEFAULT_ADMIN_ROLE
  • MINTER_ROLE
  • BURNER_ROLE
  • BLOCKLIST_ROLE
  • ORACLE_ROLE
  • UPGRADE_ROLE
  • PAUSE_ROLE

wUSDX

Public and External Functions

  • initialize(IUSDX _USDX, address owner)
  • pause()
  • unpause()
  • paused()
  • DOMAIN_SEPARATOR()
  • nonces(address owner)
  • permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

Private and Internal Functions

  • _beforeTokenTransfer(address from, address to, uint256 amount)
  • _authorizeUpgrade(address newImplementation)
  • _useNonce(address owner)

Events

  • Transfer(from indexed addr, to uint256, amount uint256)
  • Approval(address indexed owner, address indexed spender, uint256 value)
  • Paused(address account)
  • Unpaused(address account)
  • Upgraded(address indexed implementation)

Roles

  • DEFAULT_ADMIN_ROLE
  • UPGRADE_ROLE
  • PAUSE_ROLE

Description

USDX is a stablecoin designed to maintain a 1 USD valuation backed by short-term US Treasury bills. The yield generated by these T-bills is automatically distributed to USDX token holders through rebasing. This feature keeps the price of USDX stable while steadily increasing the balance of USDX for token holders.

X Protocol hosts the primary market that establishes the price peg. KYC-verified users can deposit collateral, either USDC or fiat currency, on our platform. In exchange, they receive USDX and can choose to redeem USDX for collateral or withdraw USDX to any Ethereum address. Since X Protocol offers an exchange rate of one dollar per USDX in both directions, any price movement in the external (secondary) market can be traded in the primary market to re-establish the peg.

USDX is a rebasing ERC-20 token with a set of additional features, including pausing, blocking/unblocking accounts, role-based access control, and upgradability. The contract’s primary objective is to reflect the T-bills’ annual percentage yield (APY) within the token’s value. It achieves this through a reward multiplier rebasing mechanism, where the addRewardMultiplier function is called daily to adjust the reward multiplier, guaranteeing an accurate representation of yield from the underlying assets.

Acknowledging the complexities of handling rebasing tokens in the DeFi ecosystem, the wUSDX contract serves as a wrapped token, simplifying integration while preserving stability. The wUSDX contract is an ERC-4626 token vault, enabling users to deposit USDX in exchange for wUSDX tokens. The USDX tokens are rebasing, whereas the wUSDX tokens are non-rebasing, making wUSDX ideal for seamless integration with protocols in the DeFi ecosystem.

The wUSDX contract incorporates the ERC-2612 permit functionality, allowing the use of signatures to grant token allowances. Additionally, the close relationship between the wUSDX and USDX contracts is also worth noting; the wUSDX contract leverages the account block list from the USDX contract to govern transfers and, specifically, prevent transfers from accounts included in the block list.

Finally, the wUSDX token transfers can be paused in two ways: either by being paused directly from within the wUSDX contract or in the event the USDX contract is paused.

API Endpoints List

Based on openapi.yaml spec

API Services Overview

API request/response schemas

Authentication

POST /auth/token

Request

{
  "client_id": "string",
  "client_secret": "string"
}

Response (200 OK)

{
  "access_token": "string",
  "token_type": "string",
  "expires_in": "integer"
}

Public

GET /public/nav

Response (200 OK)

{
  "navPerToken": "number",
  "timestamp": "string (date-time)"
}

Public

GET /public/yield

Response (200 OK)

{
  "currentAPY": "number",
  "sevenDayYield": "number",
  "lastUpdated": "string (date-time)"
}

Account Management

POST /accounts

Request

{
  "email": "string",
  "name": "string"
}

Response (201 Created)

{
  "accountId": "string",
  "email": "string",
  "name": "string",
  "createdAt": "string (date-time)"
}

Account Management

GET /accounts/{accountId}

Response (200 OK)

{
  "accountId": "string",
  "email": "string",
  "name": "string",
  "createdAt": "string (date-time)"
}

Customer Management

POST /customers

Request

{
  "name": "string",
  "email": "string",
  "phone": "string (optional)"
}

Response (201 Created)

{
  "customerId": "string",
  "name": "string",
  "email": "string",
  "phone": "string",
  "createdAt": "string (date-time)"
}

Customer Management

GET /customers/{customerId}

Response (200 OK)

{
  "customerId": "string",
  "name": "string",
  "email": "string",
  "phone": "string",
  "createdAt": "string (date-time)"
}

Wallet Management

POST /wallets

Request

{
  "accountId": "string"
}

Response (201 Created)

{
  "walletId": "string",
  "accountId": "string",
  "balance": "string",
  "currency": "string"
}

Wallet Management

GET /wallets/{walletId}

Response (200 OK)

{
  "walletId": "string",
  "accountId": "string",
  "balance": "string",
  "currency": "string"
}

External Accounts

POST /external-accounts

Request

{
  "accountId": "string",
  "type": "string (bank|card)",
  "accountNumber": "string",
  "routingNumber": "string (optional)"
}

Response (201 Created)

{
  "externalAccountId": "string",
  "accountId": "string",
  "type": "string",
  "accountNumber": "string",
  "routingNumber": "string"
}

External Accounts

GET /external-accounts/{externalAccountId}

Response (200 OK)

{
  "externalAccountId": "string",
  "accountId": "string",
  "type": "string",
  "accountNumber": "string",
  "routingNumber": "string"
}

Transactions

POST /transactions

Request

{
  "sourceWalletId": "string",
  "destinationWalletId": "string",
  "amount": "string",
  "currency": "string (default: USDX)"
}

Response (201 Created)

{
  "transactionId": "string",
  "sourceWalletId": "string",
  "destinationWalletId": "string",
  "amount": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Transactions

GET /transactions/{transactionId}

Response (200 OK)

{
  "transactionId": "string",
  "sourceWalletId": "string",
  "destinationWalletId": "string",
  "amount": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Payments

POST /payments

Request

{
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "amount": "string",
  "currency": "string",
  "paymentMethod": "string (ACH|wire|SWIFT)",
  "paymentDetails": { ... }
}

Response (201 Created)

{
  "paymentId": "string",
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "amount": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Payments

GET /payments/{paymentId}

Response (200 OK)

{
  "paymentId": "string",
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "amount": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Transfers

POST /transfers

Request

{
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "amount": "string",
  "currency": "string",
  "transferMethod": "string (internal|ACH|wire|SWIFT)",
  "transferDetails": { ... }
}

Response (201 Created)

{
  "transferId": "string",
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "amount": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Transfers

GET /transfers/{transferId}

Response (200 OK)

{
  "transferId": "string",
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "amount": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Virtual Accounts

POST /virtual-accounts

Request

{
  "accountId": "string",
  "currency": "string"
}

Response (201 Created)

{
  "virtualAccountId": "string",
  "accountId": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Virtual Accounts

GET /virtual-accounts/{virtualAccountId}

Response (200 OK)

{
  "virtualAccountId": "string",
  "accountId": "string",
  "currency": "string",
  "status": "string",
  "createdAt": "string (date-time)"
}

Treasury

GET /treasury/assets

Response (200 OK)

{
  "totalAssets": "string",
  "treasuryBillsValue": "string",
  "circulatingUSDX": "string",
  "reserveRatio": "number"
}

Treasury

POST /treasury/rebase

Request

{
  "yieldAmount": "number"
}

Response (200 OK)

{
  "rebaseId": "string",
  "timestamp": "string (date-time)",
  "yieldDistributed": "string",
  "newTotalSupply": "string"
}

Compliance

GET /compliance/attestations

Response (200 OK)

{
  "latestReport": {
    "reportId": "string",
    "reportDate": "string (date)",
    "auditor": "string",
    "reportUrl": "string (uri)"
  },
  "historicalReports": [
    {
      "reportId": "string",
      "reportDate": "string (date)",
      "auditor": "string",
      "reportUrl": "string (uri)"
    }
  ]
}

KYC

POST /kyc/generate-link

Request

{
  "accountId": "string"
}

Response (201 Created)

{
  "kycId": "string",
  "verificationLink": "string (uri)",
  "expiresAt": "string (date-time)"
}

KYC

GET /kyc/status/{kycId}

Response (200 OK)

{
  "kycId": "string",
  "status": "string (pending|in_progress|completed|rejected)",
  "lastUpdated": "string (date-time)"
}

Exchange Rates

GET /exchange-rates

Response (200 OK)

{
  "base": "string",
  "rates": {
    "CURRENCY_CODE": "number"
  },
  "timestamp": "string (date-time)"
}

Fee Management

GET /fees

Response (200 OK)

{
  "transactionFeePercentage": "number",
  "minimumFee": "number",
  "maximumFee": "number",
  "lastUpdated": "string (date-time)"
}

Webhooks

POST /webhooks

Request

{
  "url": "string (uri)",
  "events": ["string"]
}

Response (201 Created)

{
  "webhookId": "string",
  "url": "string (uri)",
  "events": ["string"],
  "createdAt": "string (date-time)"
}

Webhooks

GET /webhooks/{webhookId}

Response (200 OK)

{
  "webhookId": "string",
  "url": "string (uri)",
  "events": ["string"],
  "createdAt": "string (date-time)"
}

Cash Management

GET /cash-management/cash-flow

Response (200 OK)

{
  "startDate": "string (date)",
  "endDate": "string (date)",
  "inflows": "number",
  "outflows": "number",
  "netCashFlow": "number",
  "transactions": [
    {
      "date": "string (date)",
      "type": "string (inflow|outflow)",
      "amount": "number",
      "description": "string"
    }
  ]
}

Cash Management

POST /cash-management/allocate-funds

Request

{
  "allocations": [
    {
      "accountId": "string",
      "amount": "number"
    }
  ]
}

Response (200 OK)

{
  "allocationId": "string",
  "timestamp": "string (date-time)",
  "allocations": [
    {
      "accountId": "string",
      "amount": "number",
      "status": "string (success|failed)"
    }
  ]
}

Cash Management

POST /cash-management/reconcile

Request

{
  "accountId": "string",
  "date": "string (date)"
}

Response (200 OK)

{
  "reconciliationId": "string",
  "accountId": "string",
  "date": "string (date)",
  "balancePerBooks": "number",
  "balancePerBank": "number",
  "discrepancy": "number",
  "status": "string (matched|discrepancy_found)"
}

Auto-Sweep

POST /auto-sweep/rules

Request

{
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "thresholdAmount": "number",
  "thresholdType": "string (minimum|maximum)",
  "frequency": "string (daily|weekly|monthly)"
}

Response (201 Created)

{
  "ruleId": "string",
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "thresholdAmount": "number",
  "thresholdType": "string",
  "frequency": "string",
  "createdAt": "string (date-time)",
  "lastExecuted": "string (date-time)"
}

Auto-Sweep

GET /auto-sweep/rules/{ruleId}

Response (200 OK)

{
  "ruleId": "string",
  "sourceAccountId": "string",
  "destinationAccountId": "string",
  "thresholdAmount": "number",
  "thresholdType": "string",
  "frequency": "string",
  "createdAt": "string (date-time)",
  "lastExecuted": "string (date-time)"
}

Stablecoin Operations

POST /stablecoin/mint

Request

{
  "amount": "string",
  "sourceType": "string (usd_deposit|treasury_bill)",
  "depositId": "string (conditional)",
  "billId": "string (conditional)"
}

Response (201 Created)

{
  "mintId": "string",
  "amount": "string",
  "status": "string (completed|pending|failed)",
  "txHash": "string",
  "timestamp": "string (date-time)"
}

Stablecoin Operations

POST /stablecoin/burn

Request

{
  "amount": "string",
  "destinationType": "string (usd_withdrawal|treasury_bill)",
  "withdrawalAccount": "string (conditional)"
}

Response (200 OK)

{
  "burnId": "string",
  "amount": "string",
  "status": "string (completed|pending|failed)",
  "txHash": "string",
  "timestamp": "string (date-time)"
}