Matching rules
The engine runs one sequencer per market. These are the rules it applies, and the contract checks the outcome of each one.
Priority and price
Orders match by price, then by arrival. A fill prints at the maker's price, so a taker never pays worse than the resting order it hit. The engine numbers every command it accepts; that number is the sequence in the public log.
Time in force
| tif | On arrival | Contract check |
|---|---|---|
| 0 GTC | Matches what crosses, rests the remainder. | May be maker or taker. |
| 1 IOC | Matches what crosses, cancels the remainder. | Never a maker. |
| 2 ALO | Cancelled whole if it would cross; otherwise rests. | Never a taker. |
Reduce-only orders may only shrink a position; the exchange enforces it per fill.
Self-trade prevention
When an incoming order would match a resting order of the same trader, the resting order is cancelled and matching continues. The contract also refuses any fill where one trader is on both sides.
Funding
Funding runs hourly. Anyone may call updateFunding(id) once an hour has passed. The formula is Hyperliquid's:
rate per 8h = premium + clamp(0.01% - premium, -0.05%, +0.05%)
paid hourly = rate / 8, capped at 4% an hour
premium = size-weighted (fill price - mark) / mark over the hour's settled fillsThe premium is accumulated on chain from settled fills, so nobody submits it. Longs pay shorts when the rate is positive.