LP hedge model
The Hedging demo page of the web application shows a mathematical LP model next to a real variance position. This page explains what the model measures and what the hedge does not cover. For the steps, see the Hedging demo.
Sources: web/src/lib/lp-model.ts (LP model), web/src/components/demo/use-lp-hedge.ts and hedge-position.ts (test position), and the root file DEMO.md (demo plan).
The LP position is a test position
The LP position is a calculation in the browser from the oracle price. It does not read reserves or LP shares from a deployed DEX pool. The page labels it DUMMY POOL. The variance hedge is a real position in the market contract.
What the model measures
The model represents concentrated liquidity around a pool entry price. The default inputs are 100,000 USDC of capital and a range of plus or minus 12%.
At each observed oracle price, the model calculates the token holdings and the cash holdings of the position. It also tracks a reference portfolio. The reference holds the prior LP token quantity over each price move, then rebalances without the execution loss of the LP.
This quantity is loss versus rebalancing, or LVR. It is not the same as total LP profit, loss versus the starting cash amount, or loss versus holding the original token balances.
Why the panel shows loss from moves only
An LP also has direction risk, because it holds the token. A normal short perpetual removes that risk. The variance hedge addresses the remaining part, which is the loss from moves. A directional price drop can reduce the LP value even when the variance hedge offsets much of the LVR.
Hedge size
Inside the active range, the model uses:
For 100,000 USDC and a range of plus or minus 12%, the result is 41.0 contracts. The result does not depend on the pool entry price.
Where the hedge size comes from
Inside the range from
The value curve bends down. Its second derivative is:
For a small price move
The loss grows with the squared return
Why the entry price drops out
The model sets the range as
The right side has no price in it. For
This is a local approximation from the curvature of the LP position. It is not a guarantee. The model reports zero exposure outside the range. Range exit, large jumps, the observation cap, funding charges, fees, and limited execution depth affect the result.
How the page matches the two results
A new book position gets funding from the second observation after the fill. A closed position gets funding for one more observation. The page uses these rules to measure the LP loss and the hedge funding over the same observations:
| Event | Rule of the page |
|---|---|
| Hedge order fills | The page stores a test position in the browser, with the block of the fill and the account result before the order. |
| First observation after the fill | This price is the pool entry. The funding position becomes active. |
| Each later observation | One point of the LP loss series and one point of the hedge result series. |
| Hedge closed | The funding position stays for one more observation. |
| First observation after the close | The page ends the test position and keeps the totals. |
The page stores the test position in browser localStorage, for one chain, one market, and one account.
The values on the page
| Tile | Meaning |
|---|---|
| LP loss from moves | The LVR of the model over the counted observations |
| Hedge result after costs | The change of the account result since the hedge order. It includes funding, mark profit and loss, fees, and the spread. |
| Net | Hedge result minus LP loss |
| Coverage | Hedge result divided by LP loss, limited to the range from 0% to 100% |
| Observations | The number of prices in the model path |
The hedge result is the change of the full account result in that market. If the same account makes other trades in that market during the test, those trades change the hedge result.
The panel also shows the initial margin of the hedge. It calculates this value in the browser with a gap limit of 180 seconds, which is the limit of a 60-second market. The contract value can differ by a small amount for a different interval.
What the hedge does not cover
- Directional loss. Use a normal short position for that risk.
- A move above the cap. A log return above 0.05 in one observation receives the payment of 0.05.
- A move that the market misses. A long observation gap skips funding. See Oracle and observations.
- The calm-market cost. In a calm market, the hedge costs more than it pays.
The cost of the hedge
These values are from the demo plan, for 41 contracts at a mark of 1.57:
| Item | Value |
|---|---|
| Fixed charge | About 919 USDC each day, which is 0.92% of the LP capital each day |
| Expected loss from moves at 110% volatility | About 0.71% of the LP capital each day |
| Difference | The premium that the seller receives |
The hedge pays for the part of the loss that was not expected. In the demo, that part is the scripted jump. A real market does not jump at the correct time.
Python scenario results
The file simulation/demo_lp_hedge.py runs the demo price path through the Python simulation engine, with a deep book and the MON rules. Its outputs are:
| Item | USDC |
|---|---|
| LP loss in the 4% fall | -334.75 |
| Hedge funding in the 4% fall | +341.76 |
| LP loss in the 3% rebound | -191.13 |
| Hedge funding in the 3% rebound | +192.19 |
| Total LP loss from moves | -528.98 |
| Total hedge funding, after the charge | +533.09 |
| Trading fees for entry and exit | -6.45 |
| Spread paid for entry and exit | -12.89 |
| Hedge result after all costs | +513.75 |
| Net | -15.23 |
Simulation outputs
These are historical simulation outputs with synthetic prices. The shock inputs are log returns of -0.04 and +0.03. The local chain and the public testnet use different timing and different makers. Do not show the Python totals as measured results of a deployed exchange.
Requirements for a real pool demo
A completed pool demonstration needs actual token transfers, measurable pool reserves, and LP ownership. Use mintable test MON and test USDC for controlled reserve changes. Clearly separate test MON from the native test MON that pays gas.
The pool contract, its deployment command, the swap integration, and the reserve reads of the web application remain open work.