Withdrawals

/**
        @notice Sovereign ALM function to withdraw reserves from `pool`.
        @param _amount0 Amount of token0 to withdraw.
        @param _amount1 Amount of token1 to withdraw.
        @param _recipient Address of recipient.
        @param _expectedSqrtSpotPriceLowerX96 Minimum expected sqrt spot price, to mitigate against its manipulation.
        @param _expectedSqrtSpotPriceUpperX96 Maximum expected sqrt spot price, to mitigate against its manipulation.
        @dev Only callable by `liquidityProvider`.
        @dev It assumes that `liquidityProvider` implements sufficient internal protection against
             sandwich attacks or other types of spot price manipulation attacks. 
     */
    function withdrawLiquidity(
        uint256 _amount0,
        uint256 _amount1,
        address _recipient,
        uint160 _expectedSqrtSpotPriceLowerX96,
        uint160 _expectedSqrtSpotPriceUpperX96
    ) external onlyLiquidityProvider
  • Only liquidityProvider can withdraw from HOT, which then calls the withdrawLiquidity function in pool

  • The withdrawLiquidity function offers some degree of protection against spot price manipulation attacks:

    • liquidityProvider can pass the expected lower and upper bounds of sqrt spot price. If sqrt spot price is beyond these, the transaction reverts.

  • WARNING: It assumes that liquidityProvider is a contract that takes sufficient precautions to correctly tokenise liquidity shares (if applicable), prevent sandwich attacks and/or protections against AMM spot price manipulation, or other applicable protections such as timelocks.

Setting Price Bounds

/**
        @notice Sets the AMM position's square-root upper and lower price bounds.
        @param _sqrtPriceLowX96 New square-root lower price bound.
        @param _sqrtPriceHighX96 New square-root upper price bound.
        @param _expectedSqrtSpotPriceLowerX96 Lower limit for expected spot price (inclusive).
        @param _expectedSqrtSpotPriceUpperX96 Upper limit for expected spot price (inclusive).
        @dev Can be used to utilize disproportionate token liquidity by tuning price bounds offchain.
        @dev Only callable by `liquidityProvider`.
        @dev It assumes that `liquidityProvider` implements a timelock when calling this function.
        @dev It assumes that `liquidityProvider` implements sufficient internal protection against
             sandwich attacks, slippage checks or other types of spot price manipulation.
     */
    function setPriceBounds(
        uint160 _sqrtPriceLowX96,
        uint160 _sqrtPriceHighX96,
        uint160 _expectedSqrtSpotPriceLowerX96,
        uint160 _expectedSqrtSpotPriceUpperX96
    ) external poolNonReentrant onlyLiquidityProvider

The liquidityProvider role can manage the lower and upper bound of the liquidity position using the setPriceBounds function, to provide a concentrated liquidity experience for its users.

Note: Although we assume that the LPs trust the liquidityProvider when they deposit their funds, the liquidity provider can additionally add a small timelock to the setPriceBounds function call, to prevent attack vectors, where a malicious liquidityProvider concentrates liquidity at a bad spot price. WARNING: liquidityProvider is expected to have appropriate internal protections against any kind of spot price manipulation attack, or other common attack vectors. ( More on this in the threats and roles document )

Last updated