Quote API
Every mint and redemption on a live market carries a price signed by Ported's price service. This page documents the service's endpoints, the signed message, how to check it and how to hand it to the Issuer.
What it serves
The service reads each market on Hyperliquid, turns it into a bid and an ask per pToken, and signs them as an EIP-712 message that the AttestedPriceSource contract on Elysium verifies. It is the price input until Elysium can read Hyperliquid prices natively; then a price source that reads them on-chain replaces it behind the same interface, without touching the Issuer.
- Base URL
https://ported-keeper-production.up.railway.app- Format
- JSON. Every integer (prices, times, blocks) is a decimal string, since most exceed what a JSON number can hold.
- CORS
- Open (
access-control-allow-origin: *), so a browser can call it directly. - Caching
- Responses are sent with
cache-control: no-store. Do not cache them yourself either.
| Endpoint | Purpose |
|---|---|
GET /quote?perp=<perpIndex> | A fresh quote for one market, signed by this attester. |
POST /cosign | Co-signs a quote another registered attester proposed. Only needed when the price source asks for more than one signature. |
GET /health | The service's own status and each market's quote mode. |
GET /quote
One query parameter, perp: the market's Hyperliquid perp index as an integer (10003 for pGOLD). The response holds the quote, who signed it and in which mode.
GET https://ported-keeper-production.up.railway.app/quote?perp=10003
200 OK
{
"quote": {
"token": "0x6a27c2AfE7DB657cABAf82981C125E220313a575",
"bid": "3664943693958750000000",
"ask": "3668610471041250000000",
"issuedAt": "1795986787",
"hlBlock": "1239551737"
},
"signer": "0x…",
"signature": "0x…",
"mode": "normal"
}| Field | Meaning |
|---|---|
quote.token | The pToken priced. The signature covers it, so a quote cannot price another market or another deployment's token. |
quote.bid | What a redemption receives, in USDC per whole token with 18 decimals. 3664943693958750000000 is 3,664.94 USDC. |
quote.ask | What a mint pays, same scale. Never below the bid. |
quote.issuedAt | Unix time, in seconds, at which the price was read. Validity is counted from this moment, not from when the quote was signed or served. |
quote.hlBlock | The Hyperliquid (HyperCore) block the price was read at, for audit trails. Signed, not checked by the contract. |
signer | The attester address that signed. |
signature | 65-byte EIP-712 signature over the quote. |
mode | normal or redeemOnly, described below. |
The bid and ask already include the market's funding to date: they price one token, not one unit of the underlying.
503 {"error":"no fresh price for this market"}
429 {"error":"slow down"}
404 {"error":"not found"}
400 {"error":"bad request"}- 503
- No fresh price for this market right now. Wait a few seconds and ask again. The service also answers 503 with
{"error":"this keeper is not an attester"}if it is not configured to sign. - 429
- Too many requests from your IP. Back off before retrying.
- 404
- Unknown path.
- 400
- Malformed request, such as a body that is not JSON.
Modes, and when there is no quote
| Mode | Quote | What you can do |
|---|---|---|
normal | Bid and ask a spread apart. | Mint and redeem. |
redeemOnly | The ask is set to 100 times the bid. | Redeem. A mint would pay a hundred times the price, so any reasonable minimum makes it revert. |
| no quote (503) | None. | Neither, unless the market is wound down: a settled market redeems at its settlement price with no quote at all. |
A market is redeem-only while it cannot take new exposure: minting is paused or disabled on-chain, the market's account on HyperEVM is paused or not yet set up, or Hyperliquid's open-interest cap for the market is reached. Exits stay open.
A market has no quote while:
- the service's data from HyperEVM or Elysium is stale;
- redemptions are paused on the Issuer;
- the market has no reference price yet, or the price is outside the Issuer's band (a quote the contract would refuse is not signed);
- around the top of each hour, briefly, while Hyperliquid's hourly funding settles, so that no quote signed at the old exposure per token outlives the payment.
GET /health shows each market's current mode, including off for the no-quote state.
Verifying a quote
The Issuer verifies every quote on-chain, so a bad one can cost you a failed transaction but never a bad fill. Checking it before you sign avoids even that, and protects you from a wrong or spoofed endpoint.
- 1Same tokenThe quote's
tokenequalsmarket(perp).token. - 2Sane prices
bidis positive and not aboveask. - 3Recover the signerFrom the EIP-712 digest and the signature; it must match the
signerfield. - 4Registered
isAttester(signer)on the price source returns true. - 5FreshThe latest block's timestamp is at most
issuedAt + maxQuoteAge().
import { getAddress, parseAbi, recoverTypedDataAddress, type Address, type Hex } from "viem"
import { elysium, ISSUER, issuerAbi, publicClient } from "./ported" // see the Integrate page
export const QUOTE_TYPES = {
Quote: [
{ name: "token", type: "address" },
{ name: "bid", type: "uint256" },
{ name: "ask", type: "uint256" },
{ name: "issuedAt", type: "uint64" },
{ name: "hlBlock", type: "uint64" },
],
} as const
export type Quote = { token: Address; bid: bigint; ask: bigint; issuedAt: bigint; hlBlock: bigint }
const priceSourceAbi = parseAbi([
"function isAttester(address) view returns (bool)",
"function threshold() view returns (uint8)",
"function maxQuoteAge() view returns (uint64)",
])
/** JSON (decimal strings) to typed values. */
export const parseQuote = (q: Record<string, string>): Quote => ({
token: getAddress(q.token),
bid: BigInt(q.bid),
ask: BigInt(q.ask),
issuedAt: BigInt(q.issuedAt),
hlBlock: BigInt(q.hlBlock),
})
/** The signer of a quote, if it is a registered attester of the Issuer's price source. */
export async function verifiedSigner(quote: Quote, signature: Hex, expectedToken: Address) {
const priceSource = await publicClient.readContract({ address: ISSUER, abi: issuerAbi, functionName: "priceSource" })
const domain = { name: "Ported Price", version: "2", chainId: elysium.id, verifyingContract: priceSource } as const
if (quote.token !== getAddress(expectedToken)) throw new Error("quote for another token")
if (quote.bid === 0n || quote.bid > quote.ask) throw new Error("bid must be positive and not above the ask")
const [maxAge, block] = await Promise.all([
publicClient.readContract({ address: priceSource, abi: priceSourceAbi, functionName: "maxQuoteAge" }),
publicClient.getBlock(),
])
if (block.timestamp > quote.issuedAt + maxAge) throw new Error("quote already expired")
const signer = await recoverTypedDataAddress({ domain, types: QUOTE_TYPES, primaryType: "Quote", message: quote, signature })
const registered = await publicClient.readContract({
address: priceSource, abi: priceSourceAbi, functionName: "isAttester", args: [signer],
})
if (!registered) throw new Error("not signed by a registered attester")
return signer
}The contract also exposes quoteDigest(quote), which returns the digest it will check, if you want to compare it with your own hashing.
Encoding priceData
The Issuer's mint and redeem take the quote as bytes priceData and pass it to the price source untouched. Its layout is the ABI encoding of the quote struct followed by an array of signatures:
- Signatures go in strictly increasing order of signer address. The contract recovers each one and rejects the data if an address is not greater than the previous one, which also stops one attester from counting twice.
- Every signature must come from a registered attester, and there must be at least
threshold()of them. - Extra valid signatures beyond the threshold are accepted.
import { encodeAbiParameters, type Address, type Hex } from "viem"
import { QUOTE_TYPES, type Quote } from "./verify"
/** abi.encode(Quote, bytes[]): signatures in strictly increasing order of signer address. */
export function encodePriceData(quote: Quote, signed: { signer: Address; signature: Hex }[]): Hex {
const sorted = [...signed].sort((a, b) => (BigInt(a.signer) < BigInt(b.signer) ? -1 : 1))
return encodeAbiParameters(
[{ type: "tuple", components: QUOTE_TYPES.Quote }, { type: "bytes[]" }],
[quote, sorted.map((s) => s.signature)],
)
}To test a priceData without sending a trade, call the price source's quote view. It runs every check the Issuer relies on, except the price band, which lives in the Issuer.
// Ask the price source itself: it returns (bid, ask, issuedAt) or reverts with the reason.
const [bid, ask, issuedAt] = await publicClient.readContract({
address: priceSource,
abi: parseAbi(["function quote(address token, bytes data) view returns (uint256, uint256, uint64)"]),
functionName: "quote",
args: [quote.token, priceData],
})How long a quote lasts
A quote is a free option on the price for as long as it is valid, so the window is short on purpose: long enough for a wallet confirmation, too short for the price to move much past the spread and the fees. Read the current value with maxQuoteAge() on the price source. Because issuedAt is the time the price was read, part of the window has passed by the time you receive the quote.
A valid signature is not the only check. The Issuer also requires the bid, and for a mint the ask, to sit within a band around the market's last accepted price:
For the first market that is 20% plus 5% per minute. The band stops a faulty price, not a real move: on a gap larger than the band, the service stops quoting until the band has widened enough, or until the guardian resets the anchor with a valid quote. Anyone may call pokePrice(perp, priceData) to move the anchor with a quote that a trade would accept.
POST /cosign
The price source accepts a quote only with threshold() signatures from distinct attesters. When that is more than one, a client gathers them in two steps: one attester proposes a quote through GET /quote, and the others co-sign that exact quote, so every signature covers the same bytes.
POST https://<attester>/cosign
content-type: application/json
{
"quote": {
"token": "0x6a27c2AfE7DB657cABAf82981C125E220313a575",
"bid": "3664943693958750000000",
"ask": "3668610471041250000000",
"issuedAt": "1795986787",
"hlBlock": "1239551737"
},
"proposer": { "signer": "0x…", "signature": "0x…" }
}
200 OK
{ "signer": "0x…", "signature": "0x…" }An attester co-signs only if all of these hold, and otherwise answers 409 with the reason in error:
- the proposer is a different, registered attester, and its signature over the quote is valid;
- the quote is not dated in the future and is less than half of maxQuoteAge old;
- the bid is positive and not above the ask;
- the prices are close to the co-signer's own reading of the market: never narrower than its own quote beyond a small tolerance (that would under-price the hedge), and only slightly wider (a wider quote costs only the trader, who is protected by the minimum). A redeem-only quote may have any ask.
The same per-IP request budget applies, and the endpoint answers 503 if the co-signer has no fresh price of its own for the market. Collect the signatures, verify each, sort by signer and encode:
import { getAddress, type Address, type Hex } from "viem"
import { encodePriceData } from "./encode"
import { parseQuote, verifiedSigner } from "./verify"
/**
* Collects a quote signed by `threshold` distinct attesters: one proposes (GET /quote),
* the others co-sign that exact quote (POST /cosign). Every signature is checked.
*/
export async function collectQuote(urls: string[], perp: number, token: Address, threshold: number) {
for (const url of urls) {
let proposal
try {
const r = await fetch(url + "/quote?perp=" + perp, { cache: "no-store", signal: AbortSignal.timeout(4_000) })
if (!r.ok) continue
proposal = await r.json()
} catch {
continue
}
const quote = parseQuote(proposal.quote)
const first = await verifiedSigner(quote, proposal.signature as Hex, token)
if (first !== getAddress(proposal.signer)) continue
const signed = [{ signer: first, signature: proposal.signature as Hex }]
for (const other of urls) {
if (signed.length >= threshold) break
if (other === url) continue
try {
const r = await fetch(other + "/cosign", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ quote: proposal.quote, proposer: { signer: first, signature: proposal.signature } }),
signal: AbortSignal.timeout(4_000),
})
if (!r.ok) continue // 409 carries the reason in body.error
const body = await r.json()
const s = await verifiedSigner(quote, body.signature as Hex, token)
if (!signed.some((x) => x.signer === s)) signed.push({ signer: s, signature: body.signature as Hex })
} catch {
// try the next attester
}
}
if (signed.length >= threshold) return { quote, mode: proposal.mode, priceData: encodePriceData(quote, signed) }
}
throw new Error("could not gather " + threshold + " signatures")
}GET /health
GET https://ported-keeper-production.up.railway.app/health
200 OK
{
"ok": true,
"lastPassAt": "2026-11-30T09:12:04.187Z",
"solvencyFailures": 0,
"markets": { "10003": "normal" }
}- ok
- Whether the service's last full check of every market completed.
- lastPassAt
- When that check finished (ISO 8601, UTC).
- solvencyFailures
- How many checks in a row could not compute the protocol's solvency. Zero is normal.
- markets
- Each perp index and its quote mode:
normal,redeemOnlyoroff.
/health is not counted against the request budget. It is the right endpoint to check before showing a trade form, rather than requesting quotes on a timer.
Rate limits
/quote and /cosign share a request budget per client IP. Past it, the service answers 429 {"error":"slow down"} until the budget refills. Signatures are cached per price, so polling returns the same quote until the price changes and gains nothing.