Skip to main content

CreatorOracle

Price oracle for creator tokens using Uniswap V4 TWAP.

Purpose

The CreatorOracle:

  • Tracks real-time share token price
  • Provides TWAP for manipulation resistance
  • Used for vault accounting and lottery prize valuations

Key Functions

Price Queries

// Get creator token price in USD
function getCreatorPrice() external view returns (int256 price, uint256 timestamp);

// Get ETH price in USD
function getEthPrice() external view returns (int256 price, uint256 timestamp);

// Get creator token price in ETH (TWAP)
function getCreatorEthTWAP(uint32 duration) external view returns (uint256 price);

// Check if price is fresh
function isPriceFresh() external view returns (bool);

TWAP Configuration

ParameterDefaultDescription
Duration30 minutesTWAP observation period
Staleness threshold2 hoursMax age before price is stale

Usage in System

Lottery Manager

Uses oracle to calculate USD value of trades:

uint256 swapValueUSD = _calculateTokenUSD(creatorCoin, tokenIn, amountIn);

GaugeController

Uses oracle for slippage protection on WETH swaps:

uint256 minAmountOut = _calculateMinOutput(wethAmount);

Price Sources

The oracle aggregates from:

  • Uniswap V4 pool TWAP
  • Chainlink price feeds (ETH/USD)