An expiry futures market works just like a perpetual market with two differences:

Lifecycle of an expiry futures market

1. Creating time expiry future (TEF) markets

An expiry futures market can be created the same way as a perpetual market. This is done via governance using ExpiryFuturesMarketLaunchProposal. An insurance fund for the market must already have been created beforehand. Currently one insurance fund per TEF market is required and upon expiry insurance fund holders can withdraw their funds.

Explanations for parameters of the market launch proposal can be found here. There is one additional parameter for expiry markets: the Expiry field which is the UNIX timestamp at which all positions will be settled.

TODO: Oracle considerations. Note that even though TEF has no funding rate, the oracle price is still used for liquidations. And just using a normal mark price for the underlying as oracle may not be good enough and cause too many liquidations. What can we do?

2. Trading on expiry future markets

Trades occur exactly the same way as they do on perpetual markets. Funds are managed in user subaccounts. When a trader has open orders, part of his funds will be locked in the order. When a new position is created, his subaccount funds are used for posting margin into the isolated margined position.

Unlike perpetual markets, there are no hourly funding payments, and it is rather expected that the TEF contract price may differ from the index price (i.e. the market may experience contango or backwardation). However as the market approaches expiry, the contract price will naturally converge to the the underlying index price.

3. Liquidation of expiry future markets

Just like perpetual markets, a position in an expiry future market can be liquidated and the entire market itself can undergo global settlements with socialized loss. Socialized loss occurs when a position has negative equity (is beyond bankruptcy) and the insurance fund is insufficient to cover the debt.

Under normal scenarios though, TEF markets should not experience global settlements/socialized losses.

4. Settlement of expiry future markets

30 minutes before the expiry date, the current cumulative mark price is recorded. Then once the expiry time has passed, the now current cumulative mark price is used to calculate the settlement price: