Contracts
PricingEngine
USD-to-PRIV conversion engine with quote system, slippage protection, daily limits, and USDC integration.
Overview
PricingEngine enables users to interact with the protocol using USD (USDC) while settlement happens in PRIV. It provides a quote system with guaranteed rates, slippage protection, and circuit breakers via per-transaction and daily conversion limits.
| Property | Value |
|---|---|
| Contract | PricingEngine |
| Address (Base Sepolia) | 0xBf339D842873c39263DF32c016D19190E9c3AC7e |
| Quote Validity | 5 minutes (1 min -- 1 hour configurable) |
| Default Slippage | 1% (0.1% -- 10% configurable) |
| Max Single Conversion | $100,000 |
| Daily Limit | $1,000,000 |
| Pool Fee | 0.3% (Uniswap V3 standard) |
| Network | Base (Chain ID: 8453) |
Conversion Flow
User requests quote --> Engine queries PriceOracle --> Quote with guaranteed rate
| |
v v
User approves USDC ----------------------------------> Execute quote or direct convert
| |
v v
USDC transferred to treasury <---- PRIV delivered to user (or burned)Two Paths
- Quote-based -- Call
createQuote(usdAmount)to lock a rate, thenexecuteQuote(quoteId, minPrivAmount)within the validity window. - Direct -- Call
convertUsdToPriv(usdAmount, minPrivAmount)for atomic conversion in a single transaction.
Both paths enforce daily limits and per-transaction caps.
Key Functions
getQuote
Preview a conversion with slippage applied. Returns a deterministic quote ID, expected PRIV amount, rate, and expiration.
function getQuote(uint256 usdAmount, uint256 slippageBps)
external view returns (uint256 quoteId, uint256 privAmount, uint256 rate, uint256 expiresAt)convertUsdToPriv
Atomic USD-to-PRIV conversion. Requires prior USDC approval.
function convertUsdToPriv(uint256 usdAmount, uint256 minPrivAmount)
external returns (uint256 privReceived)convertAndSend
Same as convertUsdToPriv but delivers PRIV to a specified recipient address.
function convertAndSend(uint256 usdAmount, uint256 minPrivAmount, address recipient)
external returns (uint256 privReceived)getLimits
Returns current conversion limits and daily usage.
function getLimits() external view returns (uint256 maxSingle, uint256 dailyLimit, uint256 dailyUsed)Admin Functions
| Function | Description |
|---|---|
setLimits(uint256, uint256) | Update per-transaction and daily caps |
setQuoteValidity(uint256) | Adjust quote expiration window (1 min -- 1 hour) |
setSlippageTolerance(uint256) | Default slippage tolerance (10--1000 bps) |
setPriceOracle(address) | Swap underlying price oracle |
setSwapConfig(address, uint24) | Configure DEX router and pool fee |
setTreasury(address) | Update treasury recipient for USDC |
setBurnOnConversion(bool) | Toggle burn vs treasury delivery for converted PRIV |
rescueTokens(address, uint256) | Recover stuck tokens |
pause() / unpause() | Circuit breaker |
Security
- Slippage protection: Every conversion checks
minPrivAmountagainst actual output. - Daily reset: Conversion tracking resets automatically each UTC day.
- Reentrancy guard: All mutative conversion functions use
nonReentrant. - Quote expiration: Stale quotes cannot be executed after the validity window.
- Oracle dependency: Uses PriceOracle with its own staleness and deviation checks.