For the complete documentation index, see llms.txt. This page is also available as Markdown.

Error Codes

Generated from packages/hardhat/contracts/lib/Errors.sol — that file is the source of truth. If a code here disagrees with the contract, the contract wins.

/**
 * @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
    error E152(); // Non-standard fee token: amount received != amount requested
    error E153(); // Market creation deadline passed
    error E154(); // Live creation fee token differs from expectedFeeToken
    error E155(); // Live creation fee exceeds maxFeeAmount

    // ========== 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
    error E417(); // Profit-vest cap is active on a full last-LP exit of an idle pool: wait for vest to expire or do a partial withdrawal that leaves shares outstanding
    error E418(); // Withdraw slippage: shares to redeem above maxSharesToRedeem
    error E419(); // Outstanding early-exit vesting on a full last-LP exit of an idle pool: wait for it to drip in, or do a partial withdrawal that leaves shares outstanding

    // ========== SETTLEMENT INDEX ERRORS (450-469) ==========
    error E450(); // No snapshot at/after expiry and the settlement grace period has not elapsed: call updateMarketRateIndex while the oracle is healthy, then retry. After expiry + Admin.settlementGracePeriodSec, settlement proceeds permissionlessly at the extrapolated last-known index (emits ExpiryIndexExtrapolated)
    error E451(); // Insufficient gas to adjudicate the dead-oracle settlement fallback: retry with more gas (prevents gas starvation from forcing extrapolated settlement)

    // ========== 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)
    error E512(); // Negative base rate not allowed on a Cumulative reference oracle (floating leg cannot go negative, fixed leg would be mispriced / one-sided). Enforced at entry (full-term quote) and on every remaining-tenor consumer: MtM/virtual share price and early-exit/NAV settlement
    error E513(); // Total tokens pulled exceeds maxTotalIn (slippage protection)

    // ========== 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
    error E613(); // Fixed-slot base oracle quote attestation invalid for the market's convention (Cumulative requires isCompoundedTenorQuote() == true; Spot conventions forbid it)
    error E614(); // Floating-slot base oracle must not attest a compounded-equivalent tenor quote (and must attest explicitly on Cumulative markets)
    error E615(); // Paired base-rate oracles must derive from one shared observation ring: if either advertises baseRateRing(), both must resolve to the same non-zero ring (independent-ring inversion guard)

    // ========== VALIDATION ERRORS (700-799) ==========
    error E702(); // Trade size exceeds available liquidity
    error E703(); // numBuckets must be between 1 and MAX_NUM_BUCKETS (181)
    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 E725(); // Spot rate magnitude out of range: reading exceeds MAX_RATE_WAD before rate*time accumulation
    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 fine (DoS): bucketInterval * MAX_ACTIVE_WINDOWS must be >= swapTerm
    error E730(); // Internal invariant: sub-bucket id absent from the occupancy set during virtual settlement
}

Last updated