> For the complete documentation index, see [llms.txt](https://docs.kairosswap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kairosswap.com/protocol/error-codes.md).

# Error Codes

```markdown
/**
 * @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

    // ========== 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

    // ========== SETTLEMENT INDEX ERRORS (450-469) ==========
    error E450(); // No snapshot data for expiry resolution: call updateMarketRateIndex while oracle is healthy, then retry

    // ========== 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)
    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

    // ========== 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 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 coarse: bucketInterval * MIN_BUCKETS_FOR_SAFETY must be <= swapTerm
}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kairosswap.com/protocol/error-codes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
