HOT Swap

Given a struct hot of type HolverOrderType, an HOT swap involves the following steps:

  1. hot.authorizedSender calls pool the Sovereign Pool containing the HOT Liquidity Module.

  2. pool performs basic validation of input data (see Sovereign Pool Documentation).

  3. pool calls HOT getSwapFeeInBips , which calculates the correct swap fee to charge on this HOT swap. In order to trigger the correct branch in the HOT contract, which is both a Liquidity Module and Swap Fee Module, authorizedSender should pass a non-empty bytes payload as its _externalContext . The authentication of the HOT and the choice of fee path will be performed later.

  4. HOT checks that authorizedSender has chosen the correct Swap Fee Module execution path in step 3. Revert otherwise.

  5. Check that the number of HOT swaps on this block does not exceed the maximum limit. Revert otherwise.

  6. Determine price to be quoted to hot.recipient

  7. Validate that hot AMM fee parameters meet the correct bounds and criteria:

* `feeToken0Min` and `feeToken1Min` cannot be smaller than `minAmmFeeBips`
* All other fee related parameters should be in Bips and consistent with the previously outlined assumptions.
  1. Validate fundamental parameters in the hot struct:

* `hot.authorizedSender` must be `msg.sender` in the pool’s swap function
* `hot.authorizedRecipient` must be `_recipient` in the pool’s swap function
* `_amountIn` requested to the pool’s swap function must not be greater than `hot.amountInMax`, therefore bounding the amount of input token that can be exchanged.
* `hot.expiry` must be less than the maximum (constant) delay set in the `HOT` contract. This is to prevent signed HOT quotes from becoming perpetually valid.
* `hot.signatureTimestamp` must not be greater than `block.timestamp` (since the HOT quote must have been signed in an earlier UNIX timestamp), and also `block.timestamp` must be less or equal than `hot.signatureTimestamp + hot.expiry`
* tokenOut amount quoted in the HOT must not exceed `maxToken{0,1}VolumeToQuote`, depending on which token is the output token.
* `hot.nonce` must have the expected value of `expectedFlag` (either 0 or 1). (See HOT bitmap nonces)
  1. Validate proximity between all square-root prices against the square-root oracle price.

  2. Check that EIP-712 signature of hot is valid and has been signed by signer. Revert otherwise.

  3. Update hybridWriteSlot parameters.

  4. In case the hot meets the criteria to update AMM spot price, AMM’s sqrtSpotPriceX96 gets set to hot.sqrtSpotPriceX96New

  1. Call returns to the pool’s swap function, which proceeds to exchange the correct input and output token amounts, as well as perform all required internal state updates.

Last updated