LP Oracle
LpOracleLib computes TWAP-based LP token prices by simulating a hypothetical rebalancing trade at the oracle-implied rate.
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:
Compute the market's current
rateScalarandrateAnchorCompute
cParam = exp(rateScalar × (rateOracle - rateAnchor))— where the pool "should" be according to the oracleCalculate 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.
Post-expiry
LP pricing simplifies: 1 BT = 1 asset, so LP value = (totalBt + fwToAsset(totalFw)) / totalLp.
Last updated