Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.generalmarket.io/llms.txt

Use this file to discover all available pages before exploring further.

Smart Contract Error Codes

The General Market protocol uses custom Solidity errors for gas-efficient reverts. Error codes follow the format E001 through E069+ and are defined in ErrorsLib.sol.
This page documents a representative subset of error codes. For the complete list, see ErrorsLib.sol in the contracts source.

Order Errors (E001 - E010)

Errors raised during order creation, validation, and lifecycle management.
CodeNameDescription
E001Invalid order amountThe order amount is zero or negative.
E002Insufficient collateral balanceThe caller does not have enough collateral escrowed to cover the order amount.
E003Order already existsAn order with the specified ID has already been submitted.
E004Order not foundThe referenced order ID does not exist in storage.
E005Order already batchedThe referenced order has already been included in a batch and cannot be modified.
E006Order already filledThe referenced order has already been fully executed.
E007Order timeoutThe referenced order exceeded the time-to-live window and has expired.
E008Invalid ITP IDThe target ITP does not exist or the ID is malformed.
E009Order amount below minimumThe order amount is below the protocol-defined minimum threshold.
E010Invalid order typeThe order type flag is not a recognized value (e.g., not buy or sell).

Batch Errors (E011 - E020)

Errors raised during batch construction, signature verification, and confirmation.
CodeNameDescription
E011Invalid batchThe batch structure is malformed or contains no orders.
E012Batch already confirmedThe referenced batch has already been confirmed on-chain and cannot be resubmitted.
E013Invalid BLS signatureThe aggregated BLS signature failed verification against the registered public key.
E014Insufficient signaturesThe number of issuer signatures does not meet the required quorum.
E015Batch contains invalid ordersOne or more orders in the batch failed individual validation checks.

ITP Errors (E021 - E030)

Errors raised during ITP creation, configuration, and weight management.
CodeNameDescription
E021ITP not foundThe specified ITP ID does not correspond to any registered Index Tracking Product.
E022ITP pausedThe specified ITP is currently paused and not accepting orders.
E023Invalid ITP weightsITP asset weights must sum to exactly 100% (1e18 in fixed-point).
E024Too many assetsA single ITP cannot contain more than 100 underlying assets.
E025Invalid asset addressOne of the provided asset addresses is the zero address or not a valid token.
E026Duplicate asset in ITPThe same asset address appears more than once in the asset list.

Fill Errors (E031 - E040)

Errors raised when Authorized Participants (APs) report trade fills.
CodeNameDescription
E031Fill price out of toleranceThe reported fill price deviates more than 0.1% from the oracle reference price.
E032Fill amount exceeds orderThe fill amount is greater than the remaining unfilled quantity on the order.
E033Invalid fill reporterThe caller is not a registered AP in the AP registry.

Registry Errors (E041 - E050)

Errors raised by the issuer, collateral, and asset registry contracts.
CodeNameDescription
E041Issuer not registeredThe signing address is not registered in IssuerRegistry.
E042Invalid BLS public keyThe provided BLS public key is malformed or does not lie on the BN254 curve.
E043Collateral not whitelistedThe token address is not in the CollateralRegistry whitelist.
E044Asset pair not registeredThe asset/collateral trading pair is not registered for AP execution.

Governance Errors (E051 - E060)

Errors raised by administrative and governance operations.
CodeNameDescription
E051Not authorizedThe caller does not have the required role or permission.
E052Contract pausedThe target contract is paused and the called function is unavailable.
E053Invalid pause targetThe specified contract address is not a valid pausable target.

Decoding Errors in the Frontend

Custom errors are decoded using the contract ABI. The frontend maps error codes to user-friendly messages:
import { decodeErrorResult } from "viem";
import { indexAbi } from "@/lib/contracts/abi";

try {
  await writeContract(/* ... */);
} catch (err) {
  const decoded = decodeErrorResult({
    abi: indexAbi,
    data: err.data,
  });
  // decoded.errorName → "E002"
  // Map to user message: "Insufficient collateral balance"
}