ElyPerpsDOCSOpen app

Mark price, TWAP and caps

The oracle

On the first swap of each block, beforeSwap records the pool price as it stood before that swap, so a push inside the block does not count. Each observation moves at most 0.1% from the previous one. The engine marks opens, closes and liquidations on the 60-second TWAP of those observations, 600 blocks.

Grey: a 10% push held 20 seconds. Green: the truncated observations, at most 0.1% per block with a swap. Dashed: the 60 s TWAP the engine marks on.

Fill prices

An open fills at the worse of TWAP and spot for the trader: a long at the higher, a short at the lower. A close fills the same way. If spot and TWAP differ by more than 3%, new opens pause for that market; closes and liquidations continue.

Caps

Depth is the HYPE the pool's active liquidity holds between the price and 20% above it. Open interest per side is capped at 10% of it, at most 25,000 HYPE. One account holds at most 2%. Leverage: 3x under 2,000 HYPE of depth, 5x from 2,000, 10x from 50,000.

OI cap per side50 HYPEsampled: 25
Max per account10 HYPEsampled: 5
Max leverage3xsampled: 2x

What manipulation costs

Moving a 500-HYPE constant-product pool 10% takes about 24 HYPE of buying. Holding it there for a minute against arbitrage, paying the pool fee each time, is what moves the TWAP by the same amount, at 0.1% per block at most. The biggest position the caps allow on that pool is 10 HYPE of notional, so the move earns at most about 1 HYPE. The repository's manipulation test pushes a pool every block for 60 seconds and checks that the capped gain stays under a tenth of the HYPE spent.