Advanced price discovery system using decimal-aware calculations and dynamic weighting to provide accurate, manipulation-resistant token pricing.
Decimal-Aware Pricing:
• Proper Conversion: Atomic reserves converted to decimal values
• Accurate Ratios: Exchange rates calculated with correct decimals
• Cross-Pool Consistency: Unified decimal handling across all pools
Dynamic Path Weighting:
• Base Score: Path reliability × confidence (min 1%)
• Length Penalty: 10% reduction per additional hop
• Liquidity Boost: Up to 2x multiplier based on minimum pool size
• Recency Factor: Age penalty for stale pool data
Price Discovery Process:
1. Path Discovery: Find all viable routes to sBTC
2. Decimal Calculation: Compute exchange rates with proper decimals
3. Outlier Filtering: Remove prices >50% from median
4. Weighted Average: Combine paths by dynamic weights
5. Confidence Scoring: Based on consistency, liquidity, and path count
Special Handling:
• Stablecoin Anchoring: USD-pegged tokens use $1.00 reference
• sBTC Oracle: Direct Bitcoin price feed integration
• Pool Skipping: Stablecoin/stablecoin pairs bypass constant product
Recent improvements include fixing decimal conversion bugs that were causing 100x price inflation and implementing proper atomic-to-decimal reserve calculations.