Algebra Integral Overview
  • Intro
  • Audits
  • Integration of Algebra Integral protocol
    • Specification and API of contracts
      • Algebra Pool
      • Algebra Factory
      • Swap Router
      • Nonfungible Position Manager
      • Quoter
      • QuoterV2
      • TickLens
    • Interaction with pools
      • Getting data from pools
    • Subgraphs and analytics
      • Examples of queries
    • Technical guides
      • Intro
      • Swaps
        • Single swaps
        • Multihop swaps
      • Providing liquidity
        • Setting up your contract
        • Mint a new position
        • Collect fees
        • Decrease liquidity
        • Increase liquidity
        • Final contract
      • Flashloans
        • Setting up your contract
        • Calling flash
        • Flash callback
        • Final contract
    • Migration from UniswapV3
  • Core logic
    • Pool overview
    • Swap calculation
    • Liquidity and positions
    • Ticks
      • Ticks search tree
    • Reserves
    • Flash
    • Plugins
    • AlgebraFactory and roles
  • Plugins
    • Intro
  • Changes after V1
Powered by GitBook
On this page
  1. Integration of Algebra Integral protocol
  2. Technical guides
  3. Providing liquidity

Increase liquidity

PreviousDecrease liquidityNextFinal contract

Last updated 1 year ago

  • Before getting into this section, take a closer look at the to make sure that all the previous steps are completed correctly.

  • The example below implies that the contract already has custody of the NFT.

  • Remember that we cannot change the boundaries of a given liquidity position using the Algebra protocol; the increaseLiquidity function can just increase the liquidity of a position.

  • In production, amount0Min and amount1Min should be adjusted to create slippage protections.

    /// @notice Increases liquidity in the current range
    /// @dev Pool must be initialized already to add liquidity
    /// @param tokenId The id of the erc721 token
    /// @param amount0 The amount to add of token0
    /// @param amount1 The amount to add of token1
    function increaseLiquidityCurrentRange(
        uint256 tokenId,
        uint256 amountAdd0,
        uint256 amountAdd1
    )
        external
        returns (
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        )
    {
        INonfungiblePositionManager.IncreaseLiquidityParams memory params =
            INonfungiblePositionManager.IncreaseLiquidityParams({
                tokenId: tokenId,
                amount0Desired: amountAdd0,
                amount1Desired: amountAdd1,
                amount0Min: 0,
                amount1Min: 0,
                deadline: block.timestamp
            });

        (liquidity, amount0, amount1) = nonfungiblePositionManager.increaseLiquidity(params);
    }
first guide