Bitmap Nonce Instructions
This page is intended as instructions for a Liquidity Manager to construct valid nonce values compatible with the HOT bitmap. Full documentation for the HOT Nonce Bitmap can be found here: HOT Quote replay protection.
The HOT contract has a bitmap of 56 nonces. The signer keeps track of all signed quotes that have not yet expired or landed onchain, these quotes are considered “active”.
A nonce assigned to an “active” quote is considered “taken”, all other nonces are “free”.
When a new solver quote request comes in through the API, the signer has to do the following things:
Identify a “free” nonce.
Set the
expected
flag to the current value of the bit currently present at the selected nonce index. For example, if the current Nonce Bitmap looks like the Old Bitmap shown above, then If nonce = 0, expectedFlag = 1 If nonce = 1, expectedFlag = 0 If nonce = 2, expectedFlag = 1, and so on.
When the HOT quote is processed, the bit present at the specified nonce index is checked against the expected flag. If the values are the same, the quote is valid and the swap is processed. After processing the swap, the bit on the specified nonce index is flipped to prevent a replay attack. The next time this nonce is used, the expected flag must correspond to the newly flipped bit value.
Note: When assigning a nonce that is already assigned to another “active” quote, there is a possibility that one of these quotes can be replayed onchain. It is important for a HOT Signer to make sure that the nonce they are including in a new quote is “free”.
Last updated