# GET /v1/xrpl/metrics/peg

How far a registry stablecoin trades from its peg on the XRP Ledger DEX: the deviation of each price route, their median and a status.

## Purpose

Prices `asset`, an XRPL stablecoin of the registry that `/v1/xrpl/stablecoin/{asset}` checks (RLUSD, USDC or EURØP), in `against`, a USD stablecoin of the registry other than `asset`. Without `against` the route uses the peg default: the other USD registry coin for a USD asset (USDC for RLUSD, RLUSD for USDC) and RLUSD for an EUR asset. Any other `asset` or `against` answers 400 naming that field, with no ledger read. `asset` and `against` are answered as `CODE.issuer` with the 40-hex code. `expected` is the price on peg: `1` for a USD asset, and for an EUR asset the stored ECB reference rate in USD per EUR, the latest on or before the answer's UTC date. The routes come from the validated ledger only: `clob_direct` is the mid of the direct order book (base `asset`, quote `against`), `amm_direct` the fee-free spot of the direct AMM pool (a frozen or empty pool counts as no pool), and `via_xrp` the mid of XRP in `against` divided by the mid of XRP in `asset`. `routes` lists only the available ones, each with its `observed` price and its `deviation_bps` = (observed / expected − 1) × 10000. The headline `deviation_bps` is the median of the unrounded route deviations (the mean of the two middle values for an even count), rounded half-up to 2 decimals. `status` is decided on that reported headline: `on_peg` when |deviation_bps| ≤ 50, `drifting` when 50 < |deviation_bps| ≤ 200, `off_peg` when |deviation_bps| > 200, and `unknown` without a route (`routes` is then empty and `deviation_bps` `null`). `depth_at_peg_50` is the funded quantity of `asset` on both sides of the direct book priced in the closed interval [expected × (1 − 0.005), expected × (1 + 0.005)], that is within 50 bps of `expected`, bounds included. `reference` is the ECB rate an EUR asset is measured against (`rate_date`, `usd_per_eur`, `age_days` and `source`), and `null` for a USD asset; an EUR asset without a stored rate gives `expected`, every `deviation_bps`, `depth_at_peg_50` and `reference` `null` and `status` `unknown`. `baseline` compares the direct book (base `asset`, quote `against`) with its stored 7-day series: 15-minute snapshots of the books of the registry stablecoins paired with XRP and with each other, read from one dedicated upstream, each orientation stored on its own (depth in its base); every pair this route accepts is in that list, in its own order. Its seven figures, in this order, are `spread_bps`, `depth_bid_10`, `depth_ask_10`, `depth_bid_50`, `depth_ask_50`, `depth_bid_100` and `depth_ask_100`, each with its stored `points` in the window of the 672 15-minute slots ending at the latest recorded slot, `gaps` (672 − points, the slots with no stored point), `median` and `zscore` = (live − mean) / population standard deviation of the stored values, rounded half-up to 2 decimals (`null` when that deviation is 0), where live is the same statistic of the direct book read here: its spread / mid × 10000, not rounded to 2 decimals, and the funded base quantity of its bids and of its asks priced within 10, 50 and 100 bps of its mid, bounds included, as `/v1/xrpl/metrics/pressure` computes them (around the mid, not around `expected`). A one-sided direct book has no live figure: every `zscore` is `null` and the medians are kept. A figure with fewer than 288 stored slots (3 days) is warming up: its `median` and `zscore` are `null` and `reasons` contains `warming_up`; `baseline` is `null` while every figure warms up. Every pair has `baseline: null` with `not_tracked` while the book series is not tracked; a stored series that cannot be read, or that lacks a figure, gives `baseline: null` with `baseline_unavailable`; every other field is still served and never depends on the baseline. `reasons` holds only the baseline reasons: at most one of `warming_up`, `not_tracked` and `baseline_unavailable`, and is empty when none applies. The books are read at depth 100 (the same cached books as `/v1/xrpl/orderbook`) and the pool through the same cache entry as `/v1/xrpl/amm/{a}/{b}`; `meta` reports the lowest ledger, the oldest read and the worst cache state of these reads, the ECB rate and the stored series not included; the 7-day summary of the stored series is computed once per 15-minute slot, from the 672 slots ending at the latest recorded slot, and cached until that slot ends (a request made before the current slot is recorded gets the previous slot's summary). An AMM read that fails for another reason than a missing pool fails the answer as a failed book read does (503 `upstream-unavailable` when no node can serve it). The deviations, the status and the z-scores are defined computations over the ledger and the stored series, not advice. Bps fields are decimal strings rounded half-up to 2 decimals; prices, quantities and medians are decimal strings, and z-scores decimal strings rounded half-up to 2 decimals. An answer is fresh for 4 seconds, the shortest policy of its reads.

## When to use

To check, from the XRP Ledger's own order books and AMM pools, how far a registry stablecoin trades from its peg against another registry coin, and how much funded depth sits near the peg.

## When not to use

To check that an issued currency is the canonical registry coin, or to read its issuer posture (use `/v1/xrpl/stablecoin/{asset}`); for an asset outside the registry, which this route refuses, read its order book (`/v1/xrpl/orderbook`) or its AMM pool (`/v1/xrpl/amm/{a}/{b}`).

## Parameters

| Name | In | Required | Description | Constraints | Example |
|---|---|---|---|---|---|
| `asset` | query | yes | XRPL stablecoin of the registry whose peg is measured, by its canonical code and issuer. `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | A stablecoin of the registry (see `/v1/xrpl/stablecoin/{asset}`); any other asset is rejected with 400. `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | `524C555344000000000000000000000000000000.rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De` |
| `against` | query | no | USD stablecoin of the registry the asset is priced in; omit it for the peg default. `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | A USD stablecoin of the registry other than `asset`; any other asset is rejected with 400. `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | `5553444300000000000000000000000000000000.rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE` |

## Request example

```sh
curl -s "https://api.criptonlabs.com/v1/xrpl/metrics/peg?asset=524C555344000000000000000000000000000000.rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De"
```

## Response example (200)

```json
{
  "asset": "524C555344000000000000000000000000000000.rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De",
  "against": "5553444300000000000000000000000000000000.rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE",
  "expected": "1",
  "routes": [
    {
      "route": "clob_direct",
      "observed": "1.000217499999568048",
      "deviation_bps": "2.17"
    },
    {
      "route": "amm_direct",
      "observed": "1.000088622560840421",
      "deviation_bps": "0.89"
    },
    {
      "route": "via_xrp",
      "observed": "1.000367272706878199",
      "deviation_bps": "3.67"
    }
  ],
  "deviation_bps": "2.17",
  "status": "on_peg",
  "depth_at_peg_50": "1059091.370861481120472",
  "reference": null,
  "baseline": null,
  "reasons": [
    "not_tracked"
  ],
  "meta": {
    "ledger_index": 108267510,
    "as_of": "2026-11-11T20:23:03.000Z",
    "age_seconds": 0,
    "cache": "miss",
    "stale": false
  }
}
```

## Errors

- 400 [invalid-parameters](https://api.criptonlabs.com/errors/invalid-parameters.md)
- 400 [bad-request](https://api.criptonlabs.com/errors/bad-request.md)
- 429 [rate-limited](https://api.criptonlabs.com/errors/rate-limited.md)
- 503 [upstream-unavailable](https://api.criptonlabs.com/errors/upstream-unavailable.md)

## Caching

Fresh for 4 seconds; on upstream failure the last good value is served for up to 30 seconds (`meta.stale` is `true`), then the service answers 503. See the [freshness guide](https://api.criptonlabs.com/docs/guides/freshness.md).

## Rate limit

Tier `expensive`. See the [rate-limits guide](https://api.criptonlabs.com/docs/guides/rate-limits.md).

## MCP tool

The MCP tool `xrpl_metrics_peg` returns the same data. See the [MCP quickstart](https://api.criptonlabs.com/docs/guides/mcp-quickstart.md).
