# LP Oracle

{% hint style="info" %}
**Source:** `src/fira_bonding/oracles/LpOracleLib.sol`
{% endhint %}

## Overview

LP token pricing is more complex than BT/CT because LP represents a share of a pool with two assets (BT + FW) in varying proportions.

## Pricing method

The library simulates a hypothetical rebalancing trade:

1. Compute the market's current `rateScalar` and `rateAnchor`
2. Compute `cParam = exp(rateScalar × (rateOracle - rateAnchor))` — where the pool "should" be according to the oracle
3. Calculate the hypothetical trade size to move the pool to the oracle-implied proportion
4. Sum total asset value after the trade: FW reserves (in asset terms) plus BT reserves, adjusted by post-trade rates
5. Divide by total LP supply

The hypothetical trade rate is the average of the oracle TWAP rate and the last trade rate, dampening the impact of stale oracle data.

### Post-expiry

LP pricing simplifies: 1 BT = 1 asset, so `LP value = (totalBt + fwToAsset(totalFw)) / totalLp`.
