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

# Error Codes

HalfMoon PMM RFQ may return errors at three different layers:

* HTTP response envelope
* quote-level business fields such as `error_code`
* on-chain revert reasons during execution

***

## HTTP Business Codes

Successful HTTP responses use:

| Code    | Meaning |
| ------- | ------- |
| `10000` | Success |

Common business-level failure codes:

| Code    | Meaning                              |
| ------- | ------------------------------------ |
| `10030` | Insufficient liquidity               |
| `10070` | Invalid credential (API key invalid) |
| `10084` | Signature error                      |
| `10090` | Unsupported chain                    |
| `10091` | Insufficient balance                 |
| `10095` | Invalid parameters                   |
| `20001` | Service error                        |
| `20002` | Service unavailable                  |
| `20003` | Internal service error               |
| `20004` | Resource not found                   |

Example success envelope:

```json
{
  "code": 10000,
  "message": "success",
  "data": {}
}
```

***

## Authentication Errors

Example authentication failure:

```json
{
  "code": 401,
  "message": "missing api key"
}
```

Common reasons include:

* missing `Authorization` header for HTTP requests
* missing `api_key` query parameter or `X-API-Key` header for WebSocket connections
* incorrect API key type
* expired or disabled API key

***

## Single-MM Quote Error Codes

`POST /v1/quote/firmQuote` returns quote-level status in `data.error_code`.

| Value | Meaning                 |
| ----- | ----------------------- |
| `0`   | Success                 |
| `1`   | No liquidity            |
| `2`   | MM timeout              |
| `3`   | MM rejected the request |
| `4`   | Pair not supported      |
| `5`   | Amount too small        |
| `6`   | Internal error          |
| `7`   | Version mismatch        |

***

## WebSocket Error Codes

The orderbook stream may return `QEErrorCode` values:

| Value | Meaning                     |
| ----- | --------------------------- |
| `1`   | Invalid message             |
| `2`   | Unauthorized                |
| `3`   | Rate limit exceeded         |
| `4`   | Unsupported pair            |
| `5`   | Internal error              |
| `6`   | Subscription limit exceeded |

***

## On-Chain Revert Diagnosis

Common on-chain revert reasons in Aggregator Mode:

| Revert Reason        | Meaning                                            | Recommended Action                                       |
| -------------------- | -------------------------------------------------- | -------------------------------------------------------- |
| `QuoteExpired`       | The quote expired before execution                 | Re-request and submit faster                             |
| `InvalidSignature`   | Quote signature verification failed                | Ensure `rfq_quote_data` was decoded and passed unchanged |
| `NonceUsed`          | The quote nonce has already been consumed          | Do not reuse the same quote                              |
| `AmountTooLarge`     | The provided `amountIn` exceeds the quoted maximum | Keep `amountIn <= mmQuote.amountIn`                      |
| `InsufficientOutput` | Effective output is below `amountOutMin`           | Recalculate protection and consider time decay           |

***

## Handling Guidance

* Retry transient service errors with backoff
* Re-check chain, pair, and amount parameters when validation fails
* Re-request quotes when deadlines are short or market conditions have changed
* Treat decoded quote payloads as immutable before on-chain submission
