Prices API

The Prices API provides access to current and historical price data for all collateral assets in the Frankencoin ecosystem, as well as system-wide collateralization ratios. This is essential for monitoring position health, calculating liquidation thresholds, and displaying accurate financial information.

Overview

The Prices API enables you to:

  • Query current prices for all collateral tokens

  • Access historical price data for charting and analysis

  • Monitor collateralization ratios across the ecosystem

  • Track price feeds for specific collateral assets

  • Analyze price trends over time

Key Concepts

Price Sources

Prices in the Frankencoin ecosystem come from:

  • On-chain oracles (Chainlink, Uniswap TWAP, etc.)

  • Position-specific price feeds set during creation

  • Aggregated market data

All prices are denominated in CHF (Swiss Francs) or ZCHF.

Collateralization Ratios

Two key ratios track ecosystem health:

  • Ratio by Free Float: Collateral value / circulating ZCHF supply

  • Ratio by Total Supply: Collateral value / total ZCHF supply

These ratios indicate how well-backed the ZCHF stablecoin is by collateral.

Main Endpoints

Prices Controller

Current Prices

  • GET /prices/ticker/:ticker - Get price for a specific ticker symbol (e.g., WBTC, WETH, FPS)

  • GET /prices/list - Get all token prices with metadata

  • GET /prices/mapping - Get prices as address-keyed mapping for efficient lookup

Token Information

  • GET /prices/erc20/mint - Get Frankencoin (ZCHF) token information

  • GET /prices/erc20/fps - Get FPS token information

  • GET /prices/erc20/collateral - Get all collateral token information

Owner Analytics

  • GET /prices/owner/:address/valueLocked - Get historical time series of total value locked by owner

Market Data

  • GET /prices/marketChart - Get Frankencoin market chart data from CoinGecko (prices, market caps, volumes)

Prices History Controller

Price History

  • GET /prices/history/list - Complete price history for all collateral types with CHF prices

  • GET /prices/history/:address - Price history for a specific collateral token

The history endpoint for a specific token returns:

  • Token metadata (name, symbol, decimals, address)

  • Current price in CHF

  • Historical prices as a time-series (timestamp β†’ CHF price mapping)

Collateralization Ratios

  • GET /prices/history/ratio - Historical collateralization ratio data

Returns:

  • Current timestamp

  • collateralRatioByFreeFloat: Time series of ratios based on circulating supply

  • collateralRatioBySupply: Time series of ratios based on total supply

Use Cases

Position Health Monitoring

Fetch current prices to calculate if positions are adequately collateralized:

Then compare position collateral value against minted amount.

Quick Price Lookup by Ticker

Get the price of a specific token by its symbol:

Returns price in USD and CHF for WBTC.

Price Charts

Build historical price charts for collateral assets:

This returns WBTC price history that can be charted over time.

System Health Dashboard

Monitor ecosystem-wide collateralization:

Display ratios over time to show protocol health trends.

Liquidation Alerts

Compare current prices against position liquidation thresholds to alert users of risks:

  1. Get current prices: GET /prices/list

  2. Fetch user's positions: GET /positions/owner/:address

  3. Calculate collateralization ratios

  4. Alert if approaching liquidation levels

Multi-Asset Analysis

Compare price performance across different collateral types:

Analyze which collateral types are most stable or volatile.

Token Metadata Lookup

Get ERC20 information for system tokens:

Owner Value Tracking

Track historical value locked by a specific owner across all their positions:

Returns yearly time series of total collateral value.

Market Data Integration

Fetch CoinGecko market data for Frankencoin:

Returns prices, market caps, and trading volumes over time.

Data Structure

Price List Response

Array of price objects with metadata:

Price Mapping Response

Object mapping addresses to price data:

Historical Price Response (Specific Token)

Collateralization Ratio Response

Understanding Collateral Ratios

Healthy Ranges

  • Above 1.5: System is overcollateralized, very healthy

  • 1.2 - 1.5: Normal operating range

  • 1.0 - 1.2: Warning zone, increased risk

  • Below 1.0: Critical, system is undercollateralized

Free Float vs Total Supply

  • By Free Float: More conservative, only counts circulating ZCHF

  • By Supply: Includes all ZCHF, even locked or uncirculated

The free float ratio is typically higher (more conservative) than the total supply ratio.

Notes

Timestamps

  • Historical data uses Unix millisecond timestamps as keys

  • The main timestamp field indicates when data was last updated

Price Precision

  • Prices are in CHF with decimal precision

  • Historical endpoints may have varying time intervals between data points

Performance Considerations

  • Price history objects can be large (hundreds of data points)

  • Consider caching price data with appropriate TTLs (1-5 minutes for current prices, longer for historical)

  • For charting, you may want to downsample historical data client-side

Integration Best Practices

  1. Poll Current Prices: Update every 1-5 minutes for position monitoring

  2. Cache Historical Data: Price history changes infrequently, cache for 15-30 minutes

  3. Handle Missing Data: Not all timestamps will have data, interpolate when necessary for charts

  4. Monitor Ratios: Set up alerts when collateralization ratios drop below thresholds

  5. Validate Addresses: Always validate collateral addresses against the Collateral API before using prices

Example: Building a Position Monitor

Last updated

Was this helpful?