Prices API
Use the Prices API to display token prices, chart collateral price history and estimate the fiat value of a position. Each observation carries currency and source information so that an application can keep a valuation tied to its inputs.
These display prices are not a uniform protocol oracle and do not set a position's challenge price. For the canonical share token's reference prices, use FCS. FPS price routes here report the underlying FPS token, not an FCS market price.
Endpoints
/prices/ticker/:ticker
{chf, usd} numbers for a ticker
/prices/list
Array of token metadata and price observations
/prices/mapping
Lowercase address -> price observation
/prices/erc20/mint
ZCHF metadata
/prices/erc20/fps
Legacy FPS metadata
/prices/erc20/collateral
Collateral metadata
/prices/owner/:address/valueLocked
Year-keyed values in raw ZCHF strings; use the Positions API for current positions
/prices/marketChart
Market-data prices, market_caps, total_volumes series
/prices/history/list
Available collateral histories keyed by address
/prices/history/:address
Available history for a token
/prices/history/ratio
collateralRatioByFreeFloat and collateralRatioBySupply series
Currencies, units and freshness
A mapping observation contains chainId, address, name, symbol, decimals, price.chf, price.usd, source and timestamp. Prices are already scaled fiat values per whole token. timestamp is Unix milliseconds, unlike transfer and savings timestamps. Sources include defillama, thegraph, custom and null.
A record with a null source, timestamp zero or zero price may represent unavailable data. Reject missing/stale prices for a valuation rather than substitute zero or silently select another currency. Define a freshness threshold for the application. Preserve the quoted currency and source with each displayed value. A ticker alone is not a unique chain/token identity.
Look up a price and build a chart
For a quick ticker display, request /prices/ticker/:ticker, for example:
Read chf or usd according to the display currency. For portfolio work, fetch /prices/mapping instead, select the lowercase collateral address and verify the observation's chain ID and decimals against the position.
To chart one collateral, request /prices/history/:address. Read its CHF prices, convert millisecond timestamp keys to dates and sort the observations chronologically. Use /prices/history/list when the view needs several collateral histories. Keep gaps visible; observations need not arrive at regular intervals.
The separate /prices/marketChart route provides prices, market_caps and total_volumes series. Its schema does not specify the quote currency, so confirm the feed's denomination before labelling the chart.
Aggregate collateral ratios
Use /prices/history/ratio to plot the collateralRatioBySupply and collateralRatioByFreeFloat series separately. The names distinguish total supply from free float, but the schema does not specify the full numerator or free-float exclusions. Confirm those inputs before comparing the series to an external ratio. With the same numerator, a smaller free-float denominator yields a larger ratio; it is not inherently a more conservative measure against the same threshold.
These series do not define universal “healthy” bands or a protocol liquidation threshold. State the valuation assumptions and denominator whenever displaying a ratio. The protocol's challenge mechanism is separate from an off-chain portfolio estimate.
Indicative position valuation
Fetch the owner's positions from /positions/owners and price observations from /prices/mapping. Match lowercase owner keys and collateral addresses, and use each token's decimals. Both sides of a ratio must use the same currency: collateral units times CHF per token divided by ZCHF debt times CHF per ZCHF. An assumption of one CHF per ZCHF is explicit parity valuation, not an observed exchange price.
The example below returns a rational pair of BigInt values for an indicative ratio. It keeps raw balances exact and uses the decimal values already returned by the price API; it cannot restore precision the server has discarded. It treats zero debt as a separate state and rejects missing or stale prices. The caller supplies chain ID, the ZCHF contract address, valuation time, freshness limit and an explicit CHF-per-ZCHF quote (or parity assumption).
ratioDecimal truncates to six decimal places for display. The numerator and denominator preserve the exact ratio of the supplied decimal inputs. The caller can fetch both maps with the shared GET helper, then use priceMap[position.collateral.toLowerCase()]. An unsupported chain or missing observation is an error, not a zero valuation.
Last updated
Was this helpful?