Oracle

Uniswap v4 pools have no built-in price history, and a hook is fixed when a pool is created, so Korax cannot add one to a launched coin's pool. Korax keeps its own observation log in KoraxOracle.

How an observation is recorded

  • poke(poolId) reads the pool's current tick from the PoolManager.
  • At most one observation every 15 seconds per pool.
  • The recorded tick may move at most 50 ticks per second elapsed (about 0.5% per second), with the elapsed time counted up to 60 seconds. A spot that jumped further is recorded at the clamp, and the record catches up on the next observations.
  • Observations go into a 64 slot ring with a running tick cumulative, like a Uniswap v3 oracle.

Anyone can poke. Every open, close and liquidation pokes the pools it uses before trading. The keeper pokes every market with open positions each minute.

The price Korax uses

The 5 minute time-weighted average tick of the recorded series. The coin's USD price is the coin/HYPE average times the HYPE/USDC average, both from pools on Elysium. Health, caps and liquidations read this price.

Why it resists one large swap

A trader who pushes a pool's spot far for one block gets at most one observation recorded, moved by at most 0.5% per second since the last one, and that observation weighs a few seconds in a 300 second average. Holding the spot away for minutes costs pool fees on every swap and leaves the move open to anyone trading it back.

Depth reading

The cap on size reads safeLiquidity: the lower of the pool's live liquidity and a slow figure that follows increases over 30 minutes and decreases at once. Liquidity added and removed around one open does not raise that coin's caps.

Execution bands

Opens need the spot within 5% of the oracle before trading. Each swap must then fill within the oracle price plus the pool fees plus 0.30% plus a band: 10% on opens, 15% on liquidations.