Pricing Model
DSwap uses an oracle-based pricing model with dynamic fee structures and advanced risk management to ensure protocol stability while providing accurate, real-time pricing for synthetic assets.
Oracle-Based Pricing
Price Sources
DSwap integrates multiple oracle providers for robust price feeds:
Primary Sources:
Chainlink: Decentralized oracle network with proven reliability
Pyth Network: High-frequency price updates for real-time trading
Price Feed Structure:
struct PriceData {
int256 price; // Asset price in USD (8 decimals)
uint256 timestamp; // Last update timestamp
bool valid; // Price validity flag
}Price Validation
All prices undergo validation before use:
function getValidatedPrice(bytes32 assetId) external view returns (uint256) {
(int256 price, uint256 timestamp, bool valid) = oracle.getPrice(assetId);
require(valid, "Invalid price feed");
require(price > 0, "Price must be positive");
require(timestamp > block.timestamp - MAX_PRICE_AGE, "Price too stale");
return uint256(price);
}Pricing Mechanics
Mint Pricing (DUSD → Synthetic)
When minting synthetic assets from DUSD:
Example:
Burn Pricing (Synthetic → DUSD)
When burning synthetic assets for DUSD with dynamic fees:
Example:
Swap Pricing (Synthetic ↔ Synthetic)
Direct swaps between synthetic assets:
Example:
Dynamic Fee System
Risk-Based Fee Structure
Different operations pose different risks to protocol solvency:
Mint Synthetic
Low
0.3% flat
Converts DUSD to position
Swap Synthetic
Low
0.3% flat
Position reallocation only
Burn Synthetic
High
0.3-2% dynamic
Creates new DUSD supply
Dynamic Burn Fee Calculation
Fee Schedule
0.1
0.47%
Very healthy
0.3
0.81%
Healthy
0.6
1.32%
Moderate stress
0.9
1.83%
High stress
1.0
BLOCKED
Critical (prevented by hard cap)
Stress Ratio Calculation
Protocol Solvency Protection
Hard Invariant Enforcement
Dynamic Backing Calculation
Real-Time Monitoring
Settlement Lock Impact on Pricing
MEV Protection Mechanism
Price Stability Benefits
Prevents Sandwich Attacks: Cannot immediately reverse trades
Reduces Arbitrage Pressure: 1-minute cooldown dampens rapid exploitation
Oracle Price Stabilization: Allows prices to settle between operations
User Experience Considerations
Price Feed Management
Oracle Integration
Multi-Source Aggregation
Price Precision and Calculations
Decimal Handling
All prices use 8 decimal precision (matching Chainlink standard):
Rounding Protection
Real-Time Price Updates
Price Freshness Requirements
Maximum allowed price age varies by asset type:
Equities: 1 hour (during market hours), 24 hours (market closed)
Commodities: 30 minutes
Crypto: 5 minutes
Indices: 15 minutes
Update Mechanisms
Market Hours Handling
Trading Hours Integration
After-Hours Pricing
Crypto Assets: 24/7 pricing available
Equity Assets: Last market price used when closed
Commodity Assets: Futures pricing may continue
Index Assets: Calculated from component prices
Price Deviation Protection
Circuit Breakers
Volatility Adjustments
Integration Examples
Price Display Component
Dynamic Fee Calculator
Protocol Health Monitor
Risk Management
Oracle Failure Handling
Price Manipulation Protection
Multiple validation layers prevent manipulation:
Multi-source aggregation: Median of multiple oracles
Deviation limits: Maximum allowed price changes
Time-weighted averages: Smooth out temporary spikes
Circuit breakers: Halt trading during anomalies
Settlement locks: Prevent rapid arbitrage cycles
Performance Optimization
Gas-Efficient Price Queries
Caching Strategies
Last updated