Pricing of LPs

Everlong uses a fair-pricing oracle to compute unmanipulatable prices for LP positions. We price each of the three ALM LP buckets (wide / base / limit) independently, then use those component prices to compute the vault’s effective LP value. The canonical on-chain implementation for Everlong’s vault feed is AlphaProVaultFeed.sol (attached. below).

Why “fair pricing”

Naïve LP pricing (reading getReserves() and multiplying by on-chain spot) is vulnerable to short-term manipulation (flash loans, sandwiching) because both reserves and AMM spot prices can be temporarily skewed. The fair pricing approach prevents such attacks by combining: (a) externally-sourced, robust asset prices (“fair asset prices”) and (b) fair reserves inferred from pool invariants rather than the raw, manipulable instantaneous reserves. This idea is the same approach used and explained by Alpha (Alpha Homora v2) under the name Fair LP Price. More information here

Core formula For a 2-token constant-product pool, the fair LP price per LP token reduces to:

where:

PLP  =  2r0r1p0p1totalSupplyP_{LP} \;=\; 2 \cdot \frac{\sqrt{r_0 \cdot r_1} \cdot \sqrt{p_0 \cdot p_1}}{\mathrm{totalSupply}}
  • rir_i ​= observed pool reserve of token iii ( K=r0r1K =r_0 \cdot r_1 )

  • pip_i​​= fair price of token iii (from secure price feeds), and

  • totalSupply = current LP token supply.

This is algebraically equivalent to using K\sqrt{K}(reserve product) and the geometric mean of fair prices to produce a reserve estimate that lines up with fair prices, making the LP price resistant to flash-reserve manipulations.

How Everlong applies fair pricing

  1. Fair asset prices - Everlong pulls robust price references (on-chain oracles / aggregated off-chain feeds such as Chainlink or equivalent) for each token in the pool. These are the pip_i inputs. Use of a decentralised, well-audited feed reduces the risk of price manipulation.

  2. Pool invariant (K) from on-chain state - we read the pool state to get the current reserves and compute K=r0r1K=r_ 0 ​ ⋅r _1 ​. We do not trust the raw per-token reserve split when deriving an LP price; instead we derive fair reserves consistent with the fair price ratio.

  3. Infer fair reserves - using the fair price ratio P=p0/p1P=p_0/p_1 and KK, compute the fair reserves as K/P\sqrt{K/P}​ and KP\sqrt{K\cdot P} This gives reserves that are consistent with fair asset prices rather than transient spot prices.

  4. Compute LP price per token - apply the fair-LP formula (above) and adjust for decimals/supply units. The result is a fair, manipulation-resistant USD (or stable-unit) price for the LP token.

Pseudocode (.sol file below)

Last updated