End-to-End Examples

Complete Trading Scenarios

Walk through complete examples showing how different actors interact with the UFX protocol, from successful trades to error handling and recovery.

9 Complete Scenarios
Success Cases + Error Handling
Real Transaction Flows + Troubleshooting

Select a Scenario

SCENARIO 1

Complete Trading Lifecycle (Success Case)

Alice (investor) wants to sell 10,000 shares of TechFund. Bob (market maker) provides a quote, Alice accepts, and the trade settles successfully.

Initial State

TechFund Configuration:
• Current NAV: $15.00 per share
• Pricing Bounds: ±2% ($14.70 - $15.30)
• Fee Cap: 0.50% (50 bps)
• Status: Active
Alice's Position:
• Holds: 10,000 TechFund tokens
• Has: Valid KYC Level 2 credential
Bob's Position:
• Holds: 200,000 USDC
• Has: MARKET_MAKER_ROLE + Valid KYC

Step-by-Step Flow

Step 1: Oracle Publishes NAV
NavOracleModule.publishNav(
fundId: "fund-tech-001",
navPerShare: $15.00
)
✓ NAV stored with current timestamp
Step 2: Alice Creates RFQ
RFQEngineModule.createRFQ(
fundId: "fund-tech-001",
paymentToken: USDC,
quantity: 10,000 shares,
expectedPrice: $15.00,
expiry: 24 hours
)
Validation:
✓ Fund status is Active
✓ USDC is whitelisted
✓ Price within NAV bounds ($14.70-$15.30)
✓ Alice has valid KYC
✓ RFQ ID: rfq-001 created (Status: Open)
Step 3: Bob Submits Quote
RFQEngineModule.submitQuote(
rfqId: "rfq-001",
price: $14.90,
quantity: 10,000 shares,
feeBps: 30 (0.30%),
validUntil: 1 hour
)
Quote Details:
• Total Payment: 10,000 × $14.90 = $149,000
• Fee (0.30%): $447
• Alice Receives: $148,553
• Bob Pays: $149,000
✓ Quote ID: quote-001 created
Step 4: Alice Accepts Quote
RFQEngineModule.acceptQuote("rfq-001", "quote-001")
Validation:
✓ Quote still valid (not expired)
✓ RFQ still open
✓ Compliance rechecked
✓ RFQ status: Filled
✓ Escrow automatically initiated
Step 5: Settlement Execution
1. Alice approves 10,000 TechFund tokens
2. Bob approves $149,000 USDC
SettlementModule.settleEscrow("escrow-001")
Execution:
• Protocol fee: $149 accrued
• Issuer fee: $298 accrued
• Transfer: 10,000 tokens (Alice → Bob)
• Transfer: $148,553 USDC (Bob → Alice)
• Compliance exposure updated
• Registry update queued
✓ Settlement complete!
Step 6: Registry Reconciliation
Transfer Agent monitors RegistryUpdateEnqueued event
Updates off-chain cap table:
• Remove 10,000 shares from Alice
• Add 10,000 shares to Bob
TransferAgentModule.markRegistryUpdateProcessed("update-001")
✓ Registry synchronized

Final Balances

ALICE
TechFund: 10,000 → 0
USDC: $0 → $148,553
BOB
TechFund: 0 → 10,000
USDC: $200,000 → $51,000
FEES
Protocol: $149 USDC
Issuer: $298 USDC