Can bets settle after deadline?

All bets must have, among other parameters;

deadline (integer): The time at which the bet should be decided/settled, in Unix time (seconds since epoch).

expiration (integer): The number of blocks after which the bet expires if it remains unmatched.

From the docs. I can add that two bets must have identical deadlines to match. If the operator has not settled the bet within 2016 blocks (~14 days) after the deadline, the bet will expire and escrow returned.

The expiration is the number of blocks a bet stays open (can be matched). It’s comparable to an order on the DEX.

My question; if the deadline is reached before a bet expires, can it still be matched? The deadline is a timestamp while the expiry is a block height number. Moreover, timestamps do not have to be in order.

A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours. "Network-adjusted time" is the median of the timestamps returned by all nodes connected to you. As a result, block timestamps are not exactly accurate, and **they do not even need to be in order**. Block times are accurate only to within an hour or two.

The reason I’m asking is a hypothetical lottery where at 4pm every Friday a winner is drawn. The timestamp is easy to set. It’s the upcoming Friday at 4pm (converted to UTC). However, you do not want a potential open bet to expire after that. Since you don’t know how many blocks there are until then, nor when your tx will be included, you’ll have to err a lot on the short end when selecting number of blocks to expiry. In a lottery with fixed odds especially, you’d want the expiry to be as late as possible. More open bets are also essential to add liquidity to the market.