DSwap enables spot trading of synthetic assets using DUSD as the base currency. The system uses oracle-based pricing with enhanced multi-layer security architecture, dynamic fee structures, and mathematical solvency guarantees for maximum protocol security.
Overview
DSwap provides:
Virtual synthetic asset positions (no ERC20 tokens)
Mathematical solvency guarantees through hard invariants
Fee distribution: 1.5 DUSD to insurance fund, 1.5 DUSD to fee recipient
Net amount: 997 DUSD
xAAPL amount: 997 ÷ 150 = 6.64 xAAPL
Burn 1000 DUSD from user
SynthManager tracks 6.64 xAAPL virtual position
Settlement lock: 1 minute (no transfers/swaps)
Enhanced Burn Flow with Insurance Support
User has 6.64 xAAPL virtual position (after settlement lock expires)
Cooldown Check: Verify mint cooldown period has passed
Oracle provides AAPL price ($160)
Value: 6.64 × 160 = 1,062 DUSD
Stress Calculation: Current stress ratio = 0.98 (98% of max borrowable)
Dynamic Fee: 0.4% = 4.25 DUSD (normal zone linear escalation)
Global Solvency Check: Verify hard invariants
Insurance Fund Check: Stress < 100%, normal minting
Net amount: 1,058 DUSD
Mint 1,058 DUSD to user
Fee distribution: 2.125 DUSD to insurance fund, 2.125 DUSD to fee recipient
Settlement lock: 1 minute (new lock period)
Risk Classification Matrix
Operation
Risk Level
Fee Structure
Insurance Support
Mint Synthetic
Low
Base fee (0.3%)
No
Swap Synthetic
Low
Base fee (0.3%)
No
Burn Synthetic
High
Dynamic (0.3-5%)
Yes (danger zone)
Stress Response System
Stress Level
Range
Fee Rate
Insurance
Operations
Healthy
0-95%
0.3%
Inactive
Full
Normal
95-100%
0.3-0.5%
Inactive
Full
Danger
100-105%
0.5-5%
Active
Restricted
Blocked
>105%
N/A
N/A
Halted
Virtual Asset Architecture
SyntheticToken (Clone Implementation)
File:src/tokens/SyntheticToken.sol
Minimal ERC20 implementation designed for cloning:
SynthManager (Clone Factory)
File:src/tokens/SynthManager.sol
Factory and registry for synthetic tokens:
Supported Assets (Virtual Positions)
Equities (Primary Focus)
xAAPL: Apple Inc. (virtual position)
xTSLA: Tesla Inc. (virtual position)
xMSFT: Microsoft Corp. (virtual position)
xAMZN: Amazon.com Inc. (virtual position)
xGOOGL: Alphabet Inc. (virtual position)
Commodities
xGOLD: Gold futures (virtual position)
xSILVER: Silver futures (virtual position)
xOIL: Crude Oil futures (virtual position)
xCOPPER: Copper futures (virtual position)
Indices
xSP500: S&P 500 Index (virtual position)
xNASDAQ: NASDAQ Composite (virtual position)
xDOW: Dow Jones Industrial Average (virtual position)
Crypto (Synthetic Versions)
xBTC: Synthetic Bitcoin (virtual position)
xETH: Synthetic Ethereum (virtual position)
Note: All assets are virtual positions tracked in SynthManager, not ERC20 tokens. This eliminates deployment costs and enables instant asset addition with 97.5% gas savings.
Integration
Smart Contract Integration
Benefits
For Traders
Access to global markets 24/7
Zero slippage oracle-based pricing
Mathematical solvency guarantees
Enhanced MEV protection
Dynamic fees reflect system health
For the Protocol
Mathematical impossibility of insolvency
Self-balancing through dynamic fees and insurance
Scalable virtual asset system
Comprehensive risk management
Revenue generation through fee distribution
Key Insight: The enhanced DSwap system provides mathematical guarantees of protocol solvency through hard invariants while maintaining economic incentives through dynamic fees and insurance fund support. Only burning synthetics creates solvency risk by minting new DUSD, hence the sophisticated multi-layer security architecture.
// Mint xAAPL using DUSD (creates virtual position)
await swapRouter.mintSynthetic(
keccak256("xAAPL"), // Asset ID
parseEther("1000"), // 1000 DUSD
parseEther("6.6") // Min 6.6 xAAPL at $150/share
)
// Result: Virtual xAAPL position tracked in SynthManager
// Burn xAAPL for DUSD (subject to dynamic burn fee)
await swapRouter.burnSynthetic(
keccak256("xAAPL"), // Asset ID
parseEther("6.6"), // 6.6 xAAPL virtual position
parseEther("980") // Min 980 DUSD (after dynamic fee)
)
// Note: Dynamic fee ranges from 0.3% to 5% based on stress ratio
// Swap xAAPL to xTSLA (both virtual positions)
await swapRouter.swapSynthetic(
keccak256("xAAPL"), // From asset
keccak256("xTSLA"), // To asset
parseEther("6.6"), // 6.6 xAAPL
parseEther("4.9") // Min 4.9 xTSLA
)
// Note: 0.3% base fee, no DUSD intermediate step