AMM

The AMM

The AMM is a single CPMM range order managed by liquidityProvider. The AMM achieves lower gas execution than traditional concentrated liquidity AMMs through a simpler implementation.

The liquidityProvider can delegate a partial AMM state update to an HOT quote.

Dynamic AMM Swap Fee

HOT Quotes include a parameter feeGrowth . This is the per-second growth, in percentage points per second, of the fee percentage applied to AMM swaps.

AMM swap fee for each input token:

feeBipsToken0=feeMinToken0+feeGrowthE6Token0×(blockTimestamplastProcessedSignatureTimestamp)1000000\mathrm{fee\mathrm{Bips}\mathrm{Token0}} = \mathrm{feeMinToken0} + \mathrm{feeGrowthE6Token0} \times \frac{(\mathrm{blockTimestamp} - \mathrm{lastProcessedSignatureTimestamp})}{1000000}
feeBipsToken1=feeMinToken1+feeGrowthE6Token1×(blockTimestamplastProcessedSignatureTimestamp)1000000\mathrm{fee\mathrm{Bips}\mathrm{Token1}} = \mathrm{feeMinToken1} + \mathrm{feeGrowthE6Token1} \times \frac{(\mathrm{blockTimestamp} - \mathrm{lastProcessedSignatureTimestamp})}{1000000}

Where lastProcessedSignatureTimestamp is the UNIX timestamp at which the previously processed HOT quote has been signed (set off-chain, but validated to be within reasonable bounds by the smart contract).

AMM swap fees are capped at their respective maximum value (feeToken0Max or feeToken1Max).

Dynamic fee preventing stale price arbitrage

The above shows a fee which grows linearly as the last processed AMM state update becomes stale.

feeGrowthInPipsToken{0,1} becomes the expected per-second change in spot price, in percentage points. signer can update this parameter to reflect the current expected volatility of an asset pair across external markets. Therefore the AMM spot price +- fee (or spread) should be sufficient to prevent arbitrage opened up by large block times, which might cause the HOT quotes to land onchain later than expected, and would therefore update the AMM towards a stale price. The higher the value of feeBipsToken{0,1}, the more error tolerance we allow signer to have in its proposed AMM spot price update, although significantly lowering the chances that subsequent AMM swaps will get executed (since at this stage the AMM would be quoting worse prices compared to all over venues).

This dynamic fee also ensures AMM swaps occurring directly after an HOT quote is processed receive a minimum fee. The minimum fee can be reasonably lower than comparable AMMs, because a recently and accurately signed AMM spot price price reduces the probability of stale-price arbitrage.

This dynamic fee allows the pool to protect itself from Top-of-Block arbitrage without applying an explicit lock on permissionless swaps. In practice, the AMM swap fee growth should outpace the divergence between the “true” market price (say, from a CEX) and the AMM’s spot price, to minimize exposure to toxic order flow. It is up to the signer to constantly update these parameters in response to changing market conditions such as volatility. When HOT quotes do not land in the next block, it is still possible to update the AMM spot price, but the fee (spread) that grows over time accounts for the fact that the staleness of AMM spot price grows over time, hence it acts as a counter-measure against latency arbitrage opportunities.

As a protection measure, the smart contract enforces that feeToken0Min and feeToken1Min cannot be below some pre-determined value (minAmmFee). This is a minimum error assumed to the signer’s prices, and the minimum fee reduces the exposure to unwanted arbitrage opportunities right after AMM updates.

Operating without the offchain components

If the offchain API is removed, the pool becomes a low gas single range order AMM (similar to a UniV3 position) with a default maximum fee. This can be useful for long-tail assets which are in the process of bootstrapping sufficient liquidity and volume. Then, as soon as there are two USD-denominated Chainlink price feeds (one for each token in the pool), the HOT mode can be enabled, allowing Solvers and Market Makers to easily list such tokens while benefitting from greater capital efficiency and significantly reduced order-flow toxicity. While the current version of HOT contracts only supports Chainlink price feed as reference onchain oracles, it is possible to integrate other oracles dependencies with minimal smart contract code changes.

Last updated