Skip to content

Hedging demo ​

This guide runs one story on the local chain: an LP position loses money when MON moves, and a long variance position offsets part of that loss.

The Hedging demo page of the web application has the LP hedge panel and the shock bar. Read LP hedge model for what the values mean.

Say this in a demonstration

The LP position is a test position. It is a calculation in the browser from the oracle price. It is not a DEX position. The hedge offsets part of the loss from moves. It does not cover directional loss. The oracle price path is scripted.

Before you start ​

You need the local exchange from Run the local exchange: Anvil, the demo loop, the API, and the web application. The shock buttons also work on testnet when the API has SHOCK_ENABLED=true and the testnet operator loop runs. See Run on Monad testnet.

Steps ​

1. Deploy with 10-second observations ​

Stop the demo loop and the API. Delete .local/local-indexer.json. Then run:

sh
LOCAL_OBSERVATION_SECONDS=10 pnpm local:deploy
pnpm demo seed
pnpm demo serve

Start the API again with the command from the local guide.

The default interval is 60 seconds. The demo also works with it, but each step then takes up to 60 seconds.

Limits of a 10-second market

The gap limit is 30 seconds and the mark age limit is 20 seconds. If the demo loop stops for longer, the oracle halts. Then stop the loop and run the keeper recover command, or deploy again.

2. Fund the account ​

Connect the wallet. Deposit 10,000 test USDC in the MON market. Enable a trading session for the MON market.

The 41-contract hedge needs about 4,300 USDC of initial margin.

3. Buy the hedge ​

Open Hedging demo in the top navigation. Keep the inputs:

InputValue
Pool capital100,000 USDC
Price range around entry± 12%
Max buy priceThe mark plus 5% (the default)

The panel shows a hedge size of 41.0 contracts. Select the button Buy 41.0 MON variance · IOC. The session key signs the order, and the relayer submits it.

The panel stores the test position in the browser. The inputs then stay locked.

4. Wait for one observation ​

A new book position gets funding from the second observation after the fill. The first observation after the fill is the pool entry of the panel. Thus the LP loss and the hedge funding cover the same observations.

The panel shows Book position and Funding position. Continue when the funding position shows 41 contracts.

5. Send the shock and the rebound ​

Use the shock bar on the Hedging demo page: select Shock −4%, wait for the applied result, then select Rebound +3%.

Or use a terminal:

sh
pnpm demo shock MON -4
pnpm demo shock MON 3

Each move applies at the next observation. Send the second move after the first one is applied, because a new request for the same market replaces a pending one.

At each of the two observations, the LP loss tile and the hedge result tile change. The makers also raise their quote center after the large move, so the mark rises for a short time.

6. Close the hedge ​

Select Close hedge. The page sends an IOC sell order for the full book position at the mark minus 5%.

The book position goes to zero. The funding position stays open for one more observation, and the exchange keeps the margin for it until then. After that observation, the panel ends the test position and keeps the totals on the screen.

Start a new test position clears the stored position.

What the page shows ​

AreaContent
Shock barThe oracle price, the time to the next observation, and the two shock buttons. It shows only when the API reports shockEnabled.
Left panelThe inputs, the pool entry price, the range, the hedge size, the initial margin, and the action button
Result tilesLP loss from moves, hedge result after costs, net, coverage, and the number of observations
ChartThree lines: LP loss from moves, hedge profit and loss, and net

What moves between shocks ​

Between shocks, the demo loop moves each oracle price with calm noise: a random log return with an annual volatility of 110% for MON and 60% for ETH, limited to 1% for each observation. Thus the LP loss and the hedge funding change by small amounts at each calm observation.

In a calm market, the hedge pays the fixed charge and receives little. This is the cost of the hedge.

Talk track ​

The root file DEMO.md has a six-minute script. Its main lines are:

MomentWhat to say
The terminalThis is an order book for MON volatility. The price is how much MON is expected to move. All orders and matches are on-chain.
Deposit and sessionOne deposit, one signature. After this, no wallet prompts.
The LP panelThis is a test LP position. It loses a small amount each time the price moves, up or down.
The hedge orderThe panel calculated the size. One click, no wallet prompt, filled on-chain.
Calm marketIn a calm market the hedge pays a small charge at each observation. That is the price of the insurance.
The shockMON drops 4%. The LP loses. The hedge pays in the same observation.
The reboundThe price is almost where it started, but the LP lost again. The hedge pays again.
The closeThe position closes at the next observation. The exchange keeps the margin until then.

Numbers in the script

The USDC amounts in DEMO.md are outputs of the Python simulation. Read the amounts of your run from the page. Do not quote the Python totals as measured results.

Risks in a live demonstration ​

RiskPrevention
The demo loop stopsThe book has no live ladder after 30 seconds, and the hedge order does not fill. Start the loop before the demonstration and watch its log.
The mark freezes after a jumpWithdrawals and liquidations wait. Do not show a withdrawal directly after the jump.
The audience thinks the LP position is realThe page labels it DUMMY POOL. Say it also.
The audience thinks all LP losses are coveredUse the words "loss from moves". Say that direction needs a normal short position.
A stored test position from an old chainThe page ignores a stored position with a block above the indexed block. Use Start a new test position or Reset the test position if the totals look wrong.

Deployed on Monad testnet.