Matching rules

The engine runs one sequencer per market. These are the rules it applies, and the contract checks the outcome of each one.

25.12first in#225.11first in#2#325.10first in#225.08first in#225.07first in#2#325.06first in
Price first, then time. A buy at 25.11 takes the 25.10 queue in arrival order, then the first order at 25.11, and prints at each maker's price.

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

tifOn arrivalContract check
0 GTCMatches what crosses, rests the remainder.May be maker or taker.
1 IOCMatches what crosses, cancels the remainder.Never a maker.
2 ALOCancelled 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 fills

The premium is accumulated on chain from settled fills, so nobody submits it. Longs pay shorts when the rate is positive.