LP Oracle
LpOracleLib computes TWAP-based LP token prices by simulating a hypothetical rebalancing trade at the oracle-implied rate.
Last updated
LpOracleLib computes TWAP-based LP token prices by simulating a hypothetical rebalancing trade at the oracle-implied rate.
Source: src/fira_bonding/oracles/LpOracleLib.sol
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.
The library simulates a hypothetical rebalancing trade:
Compute the market's current rateScalar and rateAnchor
Compute cParam = exp(rateScalar × (rateOracle - rateAnchor)) — where the pool "should" be according to the oracle
Calculate the hypothetical trade size to move the pool to the oracle-implied proportion
Sum total asset value after the trade: FW reserves (in asset terms) plus BT reserves, adjusted by post-trade rates
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.
LP pricing simplifies: 1 BT = 1 asset, so LP value = (totalBt + fwToAsset(totalFw)) / totalLp.
Last updated