> ## Documentation Index
> Fetch the complete documentation index at: https://xoxno.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Stellar lending errors

> Current error-code groups and common integration handling for Stellar Lending contracts.

Error codes are defined in `common/src/errors.rs`. Clients should match numeric
codes, not variant display text.

## Common Generic Errors

| Code | Name                    | Meaning                                                                        |
| ---- | ----------------------- | ------------------------------------------------------------------------------ |
| `1`  | `AssetNotSupported`     | Asset is not active or not listed for this flow.                               |
| `2`  | `AssetAlreadySupported` | Asset is already listed.                                                       |
| `5`  | `PoolAlreadyDeployed`   | Central pool already exists.                                                   |
| `10` | `InvalidPoolTemplate`   | Pool template hash is invalid.                                                 |
| `12` | `PairNotActive`         | Asset has no active oracle configuration for this operation.                   |
| `13` | `AccountNotInMarket`    | Account is missing, caller is unauthorized, or self-liquidation was attempted. |
| `30` | `PoolNotInitialized`    | Pool or market pool row is missing.                                            |
| `35` | `TokenNotApproved`      | Token was not approved before market creation.                                 |
| `36` | `InvalidPositionLimits` | Position limits are outside allowed bounds.                                    |
| `41` | `InvalidRole`           | Governance role is not recognized.                                             |
| `42` | `BlendPoolNotApproved`  | Blend pool is not on the allow-list.                                           |

## Collateral And Pool Errors

| Code  | Name                        | Meaning                                                |
| ----- | --------------------------- | ------------------------------------------------------ |
| `100` | `InsufficientCollateral`    | LTV gate fails.                                        |
| `101` | `HealthFactorTooHigh`       | Account is not liquidatable.                           |
| `102` | `HealthFactorTooLow`        | Post-operation health factor is below threshold.       |
| `104` | `NotCollateral`             | Spoke asset cannot count as collateral.                |
| `107` | `AssetNotBorrowable`        | Asset is not borrowable in the account's spoke config. |
| `109` | `PositionLimitExceeded`     | Account would exceed position limits.                  |
| `112` | `InsufficientLiquidity`     | Pool `cash` is below required amount.                  |
| `114` | `CannotCleanBadDebt`        | Account is not eligible for bad-debt cleanup.          |
| `126` | `MinBorrowCollateralNotMet` | Collateral floor is not met while debt remains.        |
| `127` | `UtilizationAboveMax`       | Operation would exceed max utilization.                |

## Spoke Errors

| Code  | Name                      | Meaning                                             |
| ----- | ------------------------- | --------------------------------------------------- |
| `300` | `SpokeNotFound`           | Spoke id does not exist.                            |
| `301` | `SpokeDeprecated`         | Spoke has been deprecated.                          |
| `307` | `AssetNotInSpoke`         | Hub asset is not listed on the spoke.               |
| `308` | `AssetAlreadyInSpoke`     | Hub asset already listed on the spoke.              |
| `309` | `SpokeAssetsLimitReached` | Spoke asset count limit reached.                    |
| `310` | `SpokeMismatch`           | Requested spoke does not match the account's spoke. |
| `311` | `SpokeSupplyCapReached`   | Spoke supply cap would be exceeded.                 |
| `312` | `SpokeBorrowCapReached`   | Spoke borrow cap would be exceeded.                 |
| `314` | `SpokeCapBelowUsage`      | Spoke cap would fall below current spoke usage.     |
| `315` | `SpokeAssetPaused`        | Spoke asset is paused for risk-increasing use.      |
| `316` | `SpokeAssetFrozen`        | Spoke asset blocks position increases.              |

## Oracle Errors

| Code  | Name                           | Meaning                                  |
| ----- | ------------------------------ | ---------------------------------------- |
| `201` | `InvalidAggregator`            | Aggregator address is invalid.           |
| `210` | `NoLastPrice`                  | Source has no usable price.              |
| `216` | `OracleNotConfigured`          | Required oracle configuration is absent. |
| `217` | `InvalidPrice`                 | Source returned invalid price.           |
| `219` | `TwapInsufficientObservations` | TWAP history is insufficient.            |
| `223` | `SanityBoundViolated`          | Price is outside sanity bounds.          |

## Flash Loan And Strategy Errors

| Code  | Name                       | Meaning                                                           |
| ----- | -------------------------- | ----------------------------------------------------------------- |
| `400` | `FlashLoanOngoing`         | Reentrant mutator attempted during guarded flow.                  |
| `401` | `FlashloanNotEnabled`      | Hub asset is not flashloanable.                                   |
| `412` | `InvalidFlashloanReceiver` | Receiver is not a deployed WASM contract.                         |
| `500` | `ConvertStepsRequired`     | `multiply` needs `convert_swap` for the supplied initial payment. |

## Integration Handling

* Treat oracle errors as retryable only after source recovery or configuration
  change.
* Treat cap and utilization errors as amount/headroom problems.
* Treat auth and spoke-listing errors as request construction problems.
* Use controller views to preflight, but treat mutation results as authoritative.
