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

# Simulate a depeg's cross-protocol liquidation cascade (advisory)



## OpenAPI

````yaml https://api.pegana.xyz/openapi.json get /v1/assets/{symbol}/simulate-depeg
openapi: 3.1.0
info:
  title: Pegana API
  description: >-
    The peg-risk oracle for Solana. Read real-time peg state, history, alerts,
    and delivery health across 26 active mainnet assets spanning 6 classes —
    LSTs, fiat / CDP / delta-neutral / yield-bearing / FX stables, and a
    leveraged synthetic. Some assets are flagged `monitoring_only` (beta): their
    alerts are live but the calibration is provisional. Public read endpoints
    require no API key but ARE rate-limited per IP (300/min global, 10/min on
    /v1/audit.csv); exceeding the limit returns 429 with a Retry-After header.
    User-scoped /v1/me/* routes require a JWT obtained via Telegram Login. Every
    state transition emits a public receipt at /v1/audit/{id} with the
    methodology version, frozen inputs, and an on-chain SPL Memo commit (SAS
    deferred per ADR-0004 — SPL Memo gives 90% of the value). EVERY error
    response across the API is JSON — the envelope is `{error, message, asset?}`
    (the `ApiError` schema); branch on the stable `error` code, never on
    `message`. Malformed request bodies surface as `{error:"invalid_body"}`. Any
    endpoint may also return 500 `{error:"internal"}` on an unexpected server
    error. Value conventions: monetary and ratio amounts are exact decimal
    STRINGS (parse with a decimal library, never a float) with trailing zeros
    trimmed; USD aggregate fields (e.g. `market_cap`, `loop_exposure_usd`,
    `liquidatable_usd`) are rounded to the cent while price/discount signal
    fields keep full precision. All timestamps are RFC3339 UTC with millisecond
    precision and a `Z` suffix (`2026-07-24T15:33:14.545Z`).
  contact:
    name: Rafael Souza
    email: rafael@pegana.xyz
  license:
    name: MIT
    identifier: MIT
  version: 0.1.0
servers:
  - url: https://api.pegana.xyz
    description: Production
security: []
tags:
  - name: Health
    description: Liveness and readiness probes
  - name: Assets
    description: Public read access to asset state, history, and metadata
  - name: Alerts
    description: Global feed of state transitions
  - name: Stats
    description: Aggregate counters and delivery health
  - name: Auth
    description: Telegram Login Widget → JWT
  - name: Me
    description: Authenticated user profile and preferences
  - name: Subscriptions
    description: User alert subscriptions
  - name: Webhooks
    description: User-managed Ed25519-signed webhooks
  - name: WebSocket
    description: Live state stream
  - name: audit
    description: >-
      Public receipts for alerts — methodology version, inputs frozen, replay
      bundles. All endpoints public, no auth, cacheable. ADR-0006 four-state
      response on /v1/audit/:id (200/202/404/410); ADR-0014 bounds (90-day max,
      100-row max, 50k-row cap).
  - name: methodology
    description: >-
      Public lifecycle status of the active methodology — version + status
      (active/deprecated/broken) + optional fix_url when broken. Consumed by
      web/app/api/methodology to power the home-page trust strip.
  - name: peg
    description: >-
      Mint-keyed peg-signal feed for tokens.xyz / aggregator consumption.
      Public, no auth, cacheable. Honest beta status via `calibration` +
      `monitoring_only`; freshness via `as_of` + `stale`.
paths:
  /v1/assets/{symbol}/simulate-depeg:
    get:
      tags:
        - Assets
      summary: Simulate a depeg's cross-protocol liquidation cascade (advisory)
      operationId: asset_simulate_depeg
      parameters:
        - name: symbol
          in: path
          description: Asset symbol — case-insensitive.
          required: true
          schema:
            type: string
        - name: shock_bps
          in: query
          description: Collateral shock in bps. Must be one of {100, 250, 500, 1000, 2000}.
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: Cascade estimate for the shock
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimulateDepegResponse'
        '400':
          description: shock_bps not in {100,250,500,1000,2000}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: Asset symbol unknown or inactive
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
components:
  schemas:
    SimulateDepegResponse:
      type: object
      required:
        - asset
        - shock_bps
        - loop_exposure_usd
        - liquidatable_usd
        - positions_affected
        - coverage
        - by_protocol
        - model_note
      properties:
        as_of:
          type:
            - string
            - 'null'
        asset:
          type: string
        by_protocol:
          type: array
          items:
            $ref: '#/components/schemas/SimulateByProtocol'
        coverage:
          type: string
          description: >-
            `full` | `partial` | `unknown`. `partial` whenever risky bands were

            k-floor-dropped or dominance-suppressed (the honest ADR-0036
            posture).
        liquidatable_usd:
          type: string
          description: >-
            Collateral (USD) in bands that cross their liquidation threshold at
            this shock.
        loop_exposure_usd:
          type: string
          description: >-
            Total leveraged collateral across protocols (context, from
            loop-exposure).
        model_note:
          type: string
          description: ADR-0036 inv.9 — advisory model estimate, not a verifiable receipt.
        positions_affected:
          type: string
          description: >-
            Bucketed range of affected positions (ADR-0036 inv.8 — never a raw
            count).
        shock_bps:
          type: integer
          format: int32
    ApiError:
      type: object
      required:
        - error
        - message
      properties:
        asset:
          type:
            - string
            - 'null'
          description: The offending asset symbol, present only for asset-scoped errors.
        error:
          type: string
          description: Stable, machine-readable code. Branch on this, never on `message`.
        message:
          type: string
          description: >-
            Human-readable explanation. NOT stable — for humans/logs; do not
            parse.
    SimulateByProtocol:
      type: object
      required:
        - protocol
        - liquidatable_usd
        - positions_affected
      properties:
        liquidatable_usd:
          type: string
        positions_affected:
          type: string
        protocol:
          type: string

````