{
  "openapi": "3.1.0",
  "info": {
    "title": "Onix.Vault API",
    "version": "1.6.1",
    "description": "Auditable vaults for real-world assets. Create a vault from items a custodian holds (custody derived per vault, the creator paid on chain), trade its token on a Meteora curve and, after graduation, on the pool; play for the items (USDC to custody: 93% stays in the treasury, 5% goes to the creator, 2% to Onix; a burned token shrinks supply); integrate a gacha through reservations. Every state change is anchored to a public transaction: payments are read from the chain before anything leaves custody. The server never holds a user's key and never signs a user's transaction. There is no API key: an integrator names itself in `integrator` on a reservation; limits are per address.\n\n**1.4.0 (4 Oct 2026, security review):** every route that moves value answers `503` while the operator has paused the server or that vault (`GET /v1/health` → `paused`); every route that signs, settles or reads the chain on demand is rate-fenced per address (`429`); an unexpected error answers a generic `500` with a `ref` (never RPC or database text); addresses must be base58 public keys and signatures base58 text (`400`); `slippageBps` is an integer from 1 to 500; a reservation or a play is reached only through its own vault; an `Idempotency-Key` replays only for the same vault and integrator (`409` otherwise); an admission shows its value only once admitted, read from the chain. See `docs/security-review.md`.\n\n**1.5.0:** the first design's redemption door is gone from the contract: no `redemptions` route, no `band` in `stats`, no `redeemPriceUsd` on items. The exit by burning is Play in tokens (`/play`, `/plays`), priced in share of backing.\n\n**1.5.1:** the contract is served by the server itself at `GET /v1/openapi.json`.\n\n**1.6.0 (11 Oct 2026):** every card a vault sells pays the creator 5% and Onix 2%; 93% stays in the treasury. Nothing changes on the wire: the buyer (a player, or an integrator through `reservations`) still pays the full price to the custody wallet, exactly as `paymentTransaction` builds it. The custody pays the two shares in its next fee claim (every 15 minutes, in the same transaction as the trading fees; `server/commissions.js`). The Activity rows of a USDC play and of a gacha sale carry `sale` (the split, its status and the payout signature); `fee-claims` carry `creatorUsd`, `salesOnixUsd`, `salesCount`; `stats.treasury` carries `owedUsd` and `availableUsd`; each vault in `GET /v1/vaults` carries `saleSplit`. Sales made before 11 Oct 2026 are `pre_rule` and owe nothing.\n\n**1.6.1 (15 Oct 2026):** `POST /v1/vaults/create/open` answers `402` when the creator's wallet cannot cover the gas it sends the vault, the deposits and the launch (about 0.12 SOL) — the message carries both numbers; a deposit the chain refuses in simulation is explained in words (the program's own log, or which instruction and why), never as raw JSON."
  },
  "servers": [
    {
      "url": "https://vault.onix.finance"
    }
  ],
  "paths": {
    "/v1/openapi.json": {
      "get": {
        "summary": "This contract, as the running server holds it",
        "responses": {
          "200": {
            "description": "the OpenAPI document"
          }
        }
      }
    },
    "/v1/health": {
      "get": {
        "summary": "What is configured (never a secret)",
        "responses": {
          "200": {
            "description": "ok",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    },
    "/v1/vaults": {
      "get": {
        "summary": "Every vault this server serves, each with its stats",
        "responses": {
          "200": {
            "description": "vaults",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "readAt": {
                      "type": "string"
                    },
                    "vaults": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "vault": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "operator": {
                            "type": "string"
                          },
                          "custodians": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "description": {
                            "type": "string"
                          },
                          "stats": {
                            "$ref": "#/components/schemas/Stats"
                          },
                          "saleSplit": {
                            "type": "object",
                            "description": "where the price of every card sold goes, in percent",
                            "properties": {
                              "creator": {
                                "type": "number"
                              },
                              "onix": {
                                "type": "number"
                              },
                              "treasury": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/vaults/{vault}/stats": {
      "get": {
        "summary": "Backing (index and realisable) and, when a pool exists, price · supply · market cap · graduation progress — read on the server",
        "description": "Backing and the pool are two numbers and are never summed; `pool.ratio` is the only place they meet. `pool` is null and `poolStatus` says why until the curve is launched.",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "responses": {
          "200": {
            "description": "stats",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Stats"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/{vault}/activity": {
      "get": {
        "summary": "The doors that fired, newest first: gacha sales, plays, the creator’s additions, the treasury’s purchases and fee claims (with the sales they paid out), graduation — each with its signatures",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "responses": {
          "200": {
            "description": "activity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "readAt": {
                      "type": "string"
                    },
                    "activity": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "gacha",
                              "admit",
                              "play",
                              "bought",
                              "fees",
                              "graduated"
                            ]
                          },
                          "at": {
                            "type": "integer"
                          },
                          "mint": {
                            "type": "string"
                          },
                          "to": {
                            "type": "string"
                          },
                          "priceUsd": {
                            "type": "number"
                          },
                          "paymentSignature": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "burnSignature": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "deliverySignature": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "reservationId": {
                            "type": "string",
                            "description": "gacha rows: the reservation this sale settled"
                          },
                          "playId": {
                            "type": "string",
                            "description": "play rows"
                          },
                          "sale": {
                            "type": [
                              "object",
                              "null"
                            ],
                            "description": "USDC plays and gacha sales: where the price went (5% creator · 2% Onix · 93% treasury) and whether the custody paid the two shares yet. null for a token play, or a sale made before the rule (pre_rule rows are not joined). Absent on vaults without the ledger.",
                            "properties": {
                              "creatorUsd": {
                                "type": "number"
                              },
                              "onixUsd": {
                                "type": "number"
                              },
                              "treasuryUsd": {
                                "type": "number"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pre_rule",
                                  "owed",
                                  "paying",
                                  "paid"
                                ]
                              },
                              "payoutId": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "description": "the fee claim that carries the two legs"
                              },
                              "payoutSignature": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          },
                          "creatorUsd": {
                            "type": "number",
                            "description": "fees rows: paid to the creator in this claim (the 5% of the sales)"
                          },
                          "salesOnixUsd": {
                            "type": "number",
                            "description": "fees rows: the 2% of the sales, part of onixUsd"
                          },
                          "salesCount": {
                            "type": "integer",
                            "description": "fees rows: sales paid out in this claim"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/wallets/{wallet}/eligible-items": {
      "get": {
        "summary": "What in a wallet could back a vault: items from a registered custodian with a value on chain; the rest listed with the reason",
        "parameters": [
          {
            "name": "wallet",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "eligibility",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallet": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "eligible": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "ineligible": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "mint": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "custodian": {
                            "type": "string",
                            "nullable": true,
                            "description": "the registered custodian holding the item; null for a token nobody registered (its picture is never relayed)"
                          },
                          "imageUrl": {
                            "type": "string",
                            "nullable": true,
                            "description": "only for an item from a registered custodian"
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        }
      }
    },
    "/v1/vaults/{vault}/items": {
      "get": {
        "summary": "Every priced item in the vault wallet, read from the chain",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "responses": {
          "200": {
            "description": "items",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "readAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "itemsAgeMs": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Item"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/{vault}/reservations": {
      "post": {
        "summary": "Reserve an item for a draw; returns the payment transaction to sign",
        "description": "Reserve only when your player has already paid you. The exit price is frozen for the reservation window. The response carries `paymentTransaction` (base64, unsigned, single signer = `integrator`, memo = reservation id): sign it, send it, then settle. Honours `Idempotency-Key`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "replays the same reservation for the same vault and integrator; a key already used by another integrator or vault answers 409"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "mint",
                  "integrator",
                  "winner"
                ],
                "properties": {
                  "mint": {
                    "type": "string"
                  },
                  "integrator": {
                    "type": "string",
                    "description": "the wallet that will pay — a base58 Solana address"
                  },
                  "winner": {
                    "type": "string",
                    "description": "the wallet that receives the item — a base58 Solana address"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "reserved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reservation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        }
      }
    },
    "/v1/vaults/{vault}/reservations/{id}/settle": {
      "post": {
        "summary": "Prove the payment landed; the vault delivers",
        "description": "The vault reads the transaction from the chain and checks: finalized; credits the vault's USDC account with at least the frozen price; memo equals the reservation id. Only then it builds the delivery to `winner`, asserts it has a single unsigned signer (the vault), SIMULATES it, signs, persists the signed transaction and broadcasts. A payment signature settles one reservation, ever. `paymentSignature` must be base58 text (400 otherwise, before the chain is asked). A reservation of another vault answers 404.",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "paymentSignature"
                ],
                "properties": {
                  "paymentSignature": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "settled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reservation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "description": "payment does not cover the reservation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "not found / not finalized yet / already used — retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "reservation expired; refunds are manual in v1",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "description": "paid, but the delivery failed (it is simulated before it is signed; a delivery that would fail on chain is never broadcast). The reservation is `delivery_failed`, keeps the payment, and the operator re-runs the delivery by hand (`scripts/retry-delivery.js`); poll `GET …/reservations/{id}` for `deliverySignature`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/vaults/{vault}/reservations/{id}": {
      "get": {
        "summary": "The trail of one reservation",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "reservation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reservation"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/create/quote": {
      "get": {
        "summary": "What a wallet could open a vault on, and the curve those rules imply",
        "tags": [
          "Create"
        ],
        "parameters": [
          {
            "name": "wallet",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rules",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "JSON of the creator's rules (category, minValueUsd, minGrade, creatorFeePct, gradMult); off-list values are 422"
          }
        ],
        "responses": {
          "200": {
            "description": "items (eligible under the rules), ineligible with reasons, indexUsd, realisableUsd, canCreate, why, sol{have, need, short} (the SOL the wallet holds against what a launch needs, about 0.12), curve{openingMcapUsd, graduationUsd, supply, creatorPct}, rules"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        }
      }
    },
    "/v1/vaults/create/upload": {
      "post": {
        "summary": "The coin image or the banner: raw bytes, typed by the bytes (PNG, JPEG, WebP — never SVG), up to 1 MB, stored under its sha256",
        "tags": [
          "Create"
        ],
        "requestBody": {
          "content": {
            "image/png": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/jpeg": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/webp": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "uploadId, type, bytes, url (a preview at GET /v1/vaults/create/uploads/{id}); orphans are swept after an hour"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "415": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/create/uploads/{id}": {
      "get": {
        "summary": "Preview of an upload before launch (fixed Content-Type, nosniff)",
        "tags": [
          "Create"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "the image"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/create/open": {
      "post": {
        "summary": "Step 1 — open a creation: the custody wallet is derived and the deposit transactions (items + gas → custody) are built for the creator to sign. Nothing of Onix is spent.",
        "tags": [
          "Create"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "owner",
                  "name",
                  "symbol",
                  "mints"
                ],
                "properties": {
                  "owner": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 32
                  },
                  "symbol": {
                    "type": "string",
                    "pattern": "^[A-Z0-9]{2,10}$"
                  },
                  "mints": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "rules": {
                    "type": "object"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "links": {
                    "type": "object",
                    "properties": {
                      "x": {
                        "type": "string"
                      },
                      "site": {
                        "type": "string"
                      }
                    }
                  },
                  "imageId": {
                    "type": "string"
                  },
                  "bannerId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "creationId, custodyWallet, depositTransactions[] (base64, unsigned, single signer = owner), gasSol, items, backing, expiresAt"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "description": "the creator's wallet cannot cover the gas it sends the vault, the deposits and the launch (about 0.12 SOL) — the message says what it holds and what a launch needs; nothing was built"
          },
          "409": {
            "description": "a creation already in flight for this wallet, or the symbol is taken"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/create/deposited": {
      "post": {
        "summary": "Step 2 — the chain shows every item (and the gas) in custody → Onix creates the curve config (simulated first; paid once) → the launch transaction is built for the creator",
        "tags": [
          "Create"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "creationId"
                ],
                "properties": {
                  "creationId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "creationId, pool, baseMint, config, curve, backing, transaction (base64, UNSIGNED), message"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "custody does not hold the items yet / no gas / the program would refuse the config / Onix's config is on the chain but not confirmed yet (retry: it serves when it lands, is replaced when it can no longer land)"
          },
          "410": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        }
      }
    },
    "/v1/vaults/create/submit": {
      "post": {
        "summary": "Step 3 — the creator signed the launch (signTransaction): same content as built (wallet wrappers ignored) → the mint key completes it → broadcast",
        "tags": [
          "Create"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "creationId",
                  "signedTransaction"
                ],
                "properties": {
                  "creationId": {
                    "type": "string"
                  },
                  "signedTransaction": {
                    "type": "string",
                    "description": "base64"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "signature"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "not the transaction that was built, or the creator did not sign"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        }
      }
    },
    "/v1/vaults/create/confirm": {
      "post": {
        "summary": "Step 4 — the pool is on chain → the vault is registered (custody, creator, rules, manifest, image, banner) and served at once",
        "tags": [
          "Create"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "creationId"
                ],
                "properties": {
                  "creationId": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "vault summary"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        }
      }
    },
    "/v1/vaults/create/abandon": {
      "post": {
        "summary": "Before launch: custody returns every item and the gas to the creator (signed by the derived key); strangers cannot",
        "tags": [
          "Create"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "creationId",
                  "owner"
                ],
                "properties": {
                  "creationId": {
                    "type": "string"
                  },
                  "owner": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "returned[] (signatures)"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        }
      }
    },
    "/v1/vaults/create/{creationId}": {
      "get": {
        "summary": "Where a creation stands; while open, what custody still lacks and fresh deposit transactions for exactly that",
        "tags": [
          "Create"
        ],
        "parameters": [
          {
            "name": "creationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "status, symbol, mints, custodyWallet, missingMints, custodySol, depositTransactions?"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        }
      }
    },
    "/token/{mint}.json": {
      "get": {
        "summary": "Token metadata of a created vault (what wallets, Jupiter and Meteora read): name, symbol, description, image, banner, external_url",
        "tags": [
          "Create"
        ],
        "parameters": [
          {
            "name": "mint",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "metadata JSON"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/token/{mint}.png": {
      "get": {
        "summary": "The coin image (and /token/{mint}-banner.png the banner): fixed Content-Type from the bytes, nosniff, cached a day",
        "tags": [
          "Create"
        ],
        "parameters": [
          {
            "name": "mint",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "the image"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/{vault}/play": {
      "get": {
        "summary": "The machines: open (Play opens at graduation) and the bands by custodian value with items, odds, priceUsdc (avg × 1.15) and priceTokens (avg × 1.10 ÷ backing per token — share of backing, never the market price)",
        "tags": [
          "Play"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "the vault's custody wallet"
          }
        ],
        "responses": {
          "200": {
            "description": "open, lockedReason, currencies{usdc, token}, tokenSymbol, bands[{id, label, items, kind: draw|pick|empty, avgIndexUsd, priceUsdc, priceTokens, odds, preview[]}], navPerTokenUsd"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/{vault}/plays": {
      "post": {
        "summary": "Open a play: the commit (sha256 of the server seed) is published and the payment transaction is built for the player — USDC to custody + memo play:<id>, or a burnChecked of the player's own vault tokens + memo. Unsigned, single signer, simulated first.",
        "tags": [
          "Play"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "the vault's custody wallet"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "band",
                  "player",
                  "currency",
                  "clientSeed"
                ],
                "properties": {
                  "band": {
                    "type": "string"
                  },
                  "player": {
                    "type": "string"
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "usdc",
                      "token"
                    ]
                  },
                  "clientSeed": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,32}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "playId, serverSeedHash, band, items, odds, currency, price, unit, memo, paymentTransaction (base64), quoteValidUntil, expiresAt"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "description": "the wallet lacks the funds — nothing was sent"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "Play not open yet (the vault has not graduated), an unpaid play waiting, or token plays closed"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        }
      },
      "get": {
        "summary": "Plays of this vault (paid ones), newest first",
        "tags": [
          "Play"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "the vault's custody wallet"
          }
        ],
        "responses": {
          "200": {
            "description": "plays[]"
          }
        }
      }
    },
    "/v1/vaults/{vault}/plays/{id}/submit": {
      "post": {
        "summary": "The player paid: the signature is recorded (UNIQUE). A sweep waits for finality, reads the payment from the transaction itself, draws, holds the item and delivers from custody.",
        "tags": [
          "Play"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "the vault's custody wallet"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "signature"
                ],
                "properties": {
                  "signature": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "the play"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "already paid / this signature already paid a play"
          },
          "410": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        },
        "description": " `signature` must be base58 text (400 otherwise). A play of another vault answers 404."
      }
    },
    "/v1/vaults/{vault}/plays/{id}": {
      "get": {
        "summary": "The proof: status, commit, server seed (once done), client seed, nonce, digest, index, snapshot (mints sorted), payment and delivery signatures",
        "tags": [
          "Play"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "the vault's custody wallet"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "the play"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/{vault}/trades/quote": {
      "post": {
        "summary": "Quote a buy (USDC → token) or sell (token → USDC) on the live pool",
        "description": "Meteora DBC quote on the current pool state. 409 until the token launches. One door for the token's whole life: while the curve is live the quote is Meteora DBC's (buys fill up to the graduation threshold and return the rest: amountInUsed, amountInLeft, partial); once migrated the same route trades on the graduated DAMM v2 pool (quote.venue = 'pool', priceImpactPct). The server never signs; the transaction is simulated first (402 with the two numbers when the wallet lacks funds).",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "side",
                  "amount"
                ],
                "properties": {
                  "side": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "amount": {
                    "type": "number",
                    "description": "USDC for buy, tokens for sell"
                  },
                  "slippageBps": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500,
                    "default": 100,
                    "description": "how far the price may move before the transaction fails; 1–500 bps"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        }
      }
    },
    "/v1/vaults/{vault}/trades/build": {
      "post": {
        "summary": "Build the swap for the user's wallet to sign — unsigned, single signer = owner, nothing pre-signed",
        "description": "Returns the base64 transaction and the base58 message Phantom's signAndSendTransaction takes. The server never signs trades. One door for the token's whole life: while the curve is live the quote is Meteora DBC's (buys fill up to the graduation threshold and return the rest: amountInUsed, amountInLeft, partial); once migrated the same route trades on the graduated DAMM v2 pool (quote.venue = 'pool', priceImpactPct). The server never signs; the transaction is simulated first (402 with the two numbers when the wallet lacks funds).",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "owner",
                  "side",
                  "amount"
                ],
                "properties": {
                  "owner": {
                    "type": "string"
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "amount": {
                    "type": "number"
                  },
                  "slippageBps": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500,
                    "default": 100,
                    "description": "how far the price may move before the transaction fails; 1–500 bps"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "unsigned swap",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    },
                    "transaction": {
                      "type": "string",
                      "description": "base64, unsigned"
                    },
                    "message": {
                      "type": "string",
                      "description": "base58 serialized message, for signAndSendTransaction"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        }
      }
    },
    "/v1/vaults/{vault}/trades/balances": {
      "get": {
        "summary": "USDC and vault token held by a wallet (what the panel shows as balance and Max)",
        "tags": [
          "Trade"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "wallet",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "wallet, usdc, token"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        }
      }
    },
    "/v1/vaults/{vault}/eligible-items": {
      "get": {
        "summary": "What in a wallet passes THIS vault's rules (custodian, category, minimum value); the rest with the reason",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          },
          {
            "name": "wallet",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "eligibility for this vault"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        }
      }
    },
    "/v1/vaults/{vault}/admissions/build": {
      "post": {
        "summary": "Build the transfer of an eligible item from the owner to the vault — unsigned, single signer = owner",
        "description": "Only the vault's creator, and only an item the creator holds that passes the vault's rules (403 / 404 / 422 otherwise). The answer is the unsigned transfer into custody, single signer = the creator, with the item's custodian value and realisable value. No tokens are owed for an admission: the creator is paid by the 50% allocation, the fee share and 5% of every card sold.",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "owner",
                  "mint"
                ],
                "properties": {
                  "owner": {
                    "type": "string"
                  },
                  "mint": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "the unsigned transfer, with the item's value and realisable value",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mint": {
                      "type": "string"
                    },
                    "valueUsd": {
                      "type": "number"
                    },
                    "realisableUsd": {
                      "type": "number"
                    },
                    "transaction": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        }
      }
    },
    "/v1/vaults/{vault}/admissions": {
      "post": {
        "summary": "Record a sent admission (the signature of the transfer); verified against the chain within a minute",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "mint",
                  "owner",
                  "signature",
                  "valueUsd"
                ],
                "properties": {
                  "mint": {
                    "type": "string"
                  },
                  "owner": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string"
                  },
                  "valueUsd": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "recorded as pending"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "503": {
            "$ref": "#/components/responses/Paused"
          }
        },
        "description": " `mint` and `owner` must be base58 addresses and `signature` base58 text. The admission is admitted only when custody holds the item and the named transfer was signed by the creator; its value is then read from the item (the one sent is never shown); a transfer signed by anyone else is rejected; nothing after an hour expires."
      },
      "get": {
        "summary": "Every admission with its signature and status (pending | admitted)",
        "parameters": [
          {
            "$ref": "#/components/parameters/vault"
          }
        ],
        "responses": {
          "200": {
            "description": "admissions + the vault's rules"
          }
        },
        "description": " Lists pending and admitted admissions; `valueUsd` is null until admitted."
      }
    },
    "/v1/vaults/{vault}/fee-claims": {
      "get": {
        "summary": "Trading fees claimed into the treasury (curve partner fee split 2/3 treasury · 1/3 Onix in the same tx; pool LP fee 100% treasury) and, in the same transaction, the sales paid out: 5% of every card sold to the creator, 2% to Onix",
        "tags": [
          "Treasury"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "claims[]: curveUsd, poolUsd, onixUsd (Onix’s third of the curve fee + its 2% of the sales), treasuryUsd (the custody’s net move; negative when only sales were paid), creatorUsd, salesOnixUsd, salesCount, creatorWallet, solSpentLamports, status, signature, at"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/vaults/{vault}/purchases": {
      "get": {
        "summary": "Items the treasury bought (the restock bot, under the vault's rules)",
        "tags": [
          "Treasury"
        ],
        "parameters": [
          {
            "name": "vault",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "purchases[]: mint, name, priceUsd, insuredUsd, venue, status, signature, at"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "vault": {
        "name": "vault",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "the vault wallet"
      }
    },
    "responses": {
      "Error": {
        "description": "error with the service's status",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Paused": {
        "description": "paused for maintenance — nothing is lost; try again later",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooMany": {
        "description": "rate limit for this address on this kind of request; try again later",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Health": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "vaultWallet": {
            "type": "string"
          },
          "signerConfigured": {
            "type": "boolean"
          },
          "itemsAgeMs": {
            "type": [
              "integer",
              "null"
            ]
          },
          "paused": {
            "type": "object",
            "description": "The emergency stop: while `global` is true, or the vault is listed, every route that moves value answers 503. Nothing is lost; payments already made are processed when it lifts.",
            "properties": {
              "global": {
                "type": "boolean"
              },
              "vaults": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "vault ids or wallets paused one by one"
              }
            }
          }
        }
      },
      "Item": {
        "type": "object",
        "properties": {
          "mint": {
            "type": "string"
          },
          "custodian": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "custodianValueUsd": {
            "type": "number"
          },
          "custodianValueBasis": {
            "type": [
              "string",
              "null"
            ]
          },
          "marketRefUsd": {
            "type": [
              "number",
              "null"
            ]
          },
          "exitPriceUsd": {
            "type": "number",
            "description": "max(custodian value, market reference)"
          },
          "exitPriceBasis": {
            "type": "string",
            "enum": [
              "custodian",
              "market"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "reserved"
            ]
          },
          "reservedUntil": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "Reservation": {
        "type": "object",
        "properties": {
          "reservationId": {
            "type": "string"
          },
          "mint": {
            "type": "string"
          },
          "integrator": {
            "type": "string"
          },
          "winner": {
            "type": "string"
          },
          "exitPriceUsd": {
            "type": "number"
          },
          "status": {
            "type": "string",
            "enum": [
              "reserved",
              "settling",
              "settled",
              "expired",
              "cancelled",
              "delivery_failed"
            ]
          },
          "expiresAt": {
            "type": "integer"
          },
          "payTo": {
            "type": "string"
          },
          "payMint": {
            "type": "string"
          },
          "memo": {
            "type": "string"
          },
          "paymentTransaction": {
            "type": "string",
            "description": "base64, unsigned; present on creation"
          },
          "paymentSignature": {
            "type": [
              "string",
              "null"
            ]
          },
          "deliverySignature": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "integer"
          },
          "ref": {
            "type": "string",
            "description": "only on 500: a reference the operator finds in the server log (the error text itself never leaves the server)"
          }
        }
      },
      "Stats": {
        "type": "object",
        "properties": {
          "readAt": {
            "type": "integer"
          },
          "ageMs": {
            "type": [
              "integer",
              "null"
            ]
          },
          "items": {
            "type": "object",
            "properties": {
              "count": {
                "type": "integer"
              }
            }
          },
          "backing": {
            "type": "object",
            "properties": {
              "indexUsd": {
                "type": "number"
              },
              "realisableUsd": {
                "type": "number"
              },
              "multiplier": {
                "type": "number"
              }
            }
          },
          "poolStatus": {
            "type": "string",
            "description": "not launched | live | migrated | unreadable: <why>"
          },
          "pool": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "address": {
                "type": "string"
              },
              "baseMint": {
                "type": "string"
              },
              "priceUsd": {
                "type": "number"
              },
              "supply": {
                "type": "number"
              },
              "mcapUsd": {
                "type": "number"
              },
              "ratio": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "market cap ÷ realisable backing"
              },
              "graduationUsd": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "graduationProgress": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "partnerFeeClaimableUsd": {
                "type": "number"
              },
              "feesLifetimeUsd": {
                "type": "number"
              },
              "isMigrated": {
                "type": "boolean"
              }
            }
          },
          "treasury": {
            "type": "object",
            "description": "USDC in the custody wallet right now (never part of backing)",
            "properties": {
              "usdc": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "owedUsd": {
                "type": "number",
                "description": "of it, what the cards sold owe the creator and Onix until the next fee claim pays it"
              },
              "availableUsd": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "usdc − owedUsd: what the treasury may spend on the next item"
              }
            }
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "side": {
            "type": "string"
          },
          "amountIn": {
            "type": "number"
          },
          "amountOut": {
            "type": "number"
          },
          "minimumAmountOut": {
            "type": "number"
          },
          "tradingFeeUsd": {
            "type": "number"
          },
          "protocolFeeUsd": {
            "type": "number"
          },
          "slippageBps": {
            "type": "integer"
          },
          "unitIn": {
            "type": "string"
          },
          "unitOut": {
            "type": "string"
          }
        }
      }
    }
  }
}
