Error Codes
/**
* @title Errors
* @notice Custom error definitions for SwapCore contract
* @dev Using custom errors instead of require strings for gas efficiency
* Error codes are organized by category for easier maintenance
*/
library Errors {
// ========== CONFIGURATION ERRORS (100-199) ==========
error E102(); // Invalid admin address
error E103(); // Invalid address (cannot be zero)
error E150(); // Insufficient ETH for market creation fee
error E151(); // ETH transfer failed
// ========== AUTHORIZATION ERRORS (200-299) ==========
error E201(); // User not whitelisted
error E202(); // Not market owner
error E203(); // Not swap owner
error E205(); // Market LP whitelist not enabled
error E206(); // Not authorized to act on behalf
// ========== MARKET ERRORS (300-399) ==========
error E300(); // Market does not exist
error E301(); // Market already exists
error E304(); // Market terminated
// ========== COLLATERAL ERRORS (400-499) ==========
error E400(); // Invalid amount
error E404(); // Insufficient pool collateral
error E405(); // Insufficient available collateral
error E407(); // No pool shares exist
error E411(); // Supply slippage: shares minted below minSharesOut
error E412(); // Withdraw slippage: collateral received below minCollateralOut
error E413(); // Withdrawal blocked: LP shares still vesting (same block as deposit)
error E414(); // Pool underwater with active swaps: deposits blocked
error E415(); // Expired unsettled swaps exist: settle before depositing/withdrawing
error E416(); // Last share locked: active swaps require at least 1 share outstanding
// ========== DEPOSIT/WITHDRAWAL PAUSE ERRORS (450-469) ==========
error E450(); // No snapshot data for expiry resolution
// ========== SWAP ERRORS (500-599) ==========
error E500(); // Swap does not exist
error E501(); // Swap already settled
error E502(); // Swap is expired
error E503(); // Buyer or LP collateral below minimum threshold
error E506(); // Exit too early
error E507(); // Swap not liquidatable
error E508(); // Insufficient liquidity
error E509(); // Zero notional amount
error E510(); // Swap rate exceeds maxSwapRate (slippage protection)
error E511(); // Markup exceeds maxMarkup (utilizationFee + riskPremium)
// ========== EARLY EXIT ERRORS (550-559) ==========
error E550(); // Early exit not allowed
error E552(); // Early exit slippage: payout below minExitAmount
// ========== ORACLE ERRORS (600-699) ==========
error E600(); // baseSwapRateOracle must implement IBaseRateOracle
error E602(); // riskPremiumOracle must implement IRateOracle
error E603(); // baseSwapRateOracle rate invalid
error E605(); // riskPremiumOracle rate invalid
error E606(); // Oracle returned invalid or zero data
error E607(); // Convention mismatch for already-initialized oracle
error E608(); // Oracle not initialized (call initialize() first)
error E609(); // Invalid oracle address (address zero)
error E610(); // Stale or invalid oracle answer
error E611(); // Invalid base rate oracle
error E612(); // Risk premium cannot be negative
// ========== VALIDATION ERRORS (700-799) ==========
error E702(); // Trade size exceeds available liquidity
error E703(); // numBuckets must be between 1 and 365
error E704(); // bucketInterval must be between 1200 and swapTerm
error E705(); // numBuckets * bucketInterval must be >= swapTerm
error E706(); // totalLiquidity is zero
error E707(); // availableLiquidity exceeds totalLiquidity
error E710(); // Invalid reference rate oracle address
error E711(); // Invalid base swap rate oracle address
error E712(); // Invalid swap token address
error E713(); // Invalid leverage multiplier
error E714(); // Invalid liquidation incentive
error E715(); // Invalid swap term
error E716(); // Kink utilization must be < 100%
error E717(); // Early exit fee must be <= 100%
error E718(); // utilFeeSlopeWad must be <= 1000%
error E719(); // maxKinkFeeWad must be <= 1000%
error E720(); // Invalid rate type
error E721(); // minCollateral must be > 0
error E722(); // Bucket interval must be > 0
error E723(); // Number of buckets must be > 0
error E724(); // SafeCast: uint256 to int256 overflow
error E726(); // Compound exponent overflow: accumulated rate * time exceeds expWad limit
error E728(); // Oracle index at floor: refuse swap entry to prevent corrupted entryFloatingIndex
error E729(); // bucketInterval too coarse: bucketInterval * MIN_BUCKETS_FOR_SAFETY must be <= swapTerm
}
Last updated