BC Oracle

BCOracleLib computes TWAP-based prices for Bond Tokens and Coupon Tokens from the FiraMarket's implied rate observations.

circle-info

Source: src/fira_bonding/oracles/BCOracleLib.sol, src/fira_bonding/oracles/BCLpOracle.sol

BCOracleLib

BT pricing

Pre-expiry, BT price is derived from the TWAP ln(impliedRate):

btToAssetRate = 1 / exp(lnImpliedRate × timeToExpiry / YEAR)

This is the present value of 1 unit of underlying, discounted at the TWAP implied rate. Post-expiry, BT is worth exactly 1 asset unit.

CT pricing

CT value is 1 - btToAssetRate. Since BT + CT = 1 asset unit by construction, CT captures the remainder.

FW solvency adjustment

If the FW exchange rate drops below the BC index, the FW wrapper is insolvent. In this case, BT and CT rates are scaled down by fwIndex / bcIndex, preventing the oracle from reporting prices that assume full solvency.

TWAP calculation

getMarketLnImpliedRate(market, duration) queries two cumulative observations, takes the difference, and divides by duration for a manipulation-resistant time-weighted average.

BCLpOracle

A convenience contract wrapping both BCOracleLib and LpOracleLib as external view functions. Deployed once per chain to save bytecode in contracts that need oracle prices.

Provides getOracleState(market, duration) to check whether a market has enough observation cardinality for the requested TWAP window and whether the oldest observation is old enough.

Last updated