Algebra Integral
HomepageSocialsIntegrate
  • Overview
    • What is Algebra?
    • Who Are These Docs For
    • Why Concentrated Liquidity & Modularity Matter
    • Partners & Ecosystem
    • Audits & Security
    • Social Media & Communities
  • Introducing Algebra Integral to Founders & Business Teams
    • Overview of Algebra Integral
      • How It Works: Core + Plugins
      • V3 vs. V4: Key Differences
      • Integral vs. Uniswap V4: Key Differences
    • Benefits of Modular Architecture
      • Perks for DEXes
      • Perks for Builders
      • Perks for Users
  • Modularity: Use Cases
  • Plugin Marketplace
  • Algebra Partner Support
  • User Guide Template For DEXes
    • Concentrated Liquidity & Modular Architecture Basics
      • Glossary
      • How Concentrated Liquidity & Modular Architecture Work
      • Benefits of Modular Concentrated Liquidity AMM for Users
        • Perks for Liquidity Providers
        • Perks for Projects
        • Perks for Traders
      • Fee Mechanics
        • Static Fee
        • Dynamic Fee
        • Sliding Fee
        • Dynamic Fee Based on Trading Volume
        • Managed Swap Fee
        • Whitelist Fee Discount
      • Farming
      • Farming FAQ
  • Price Ranges and Liquidity Strategies
    • What Are Price Ranges
    • Basic Price Range Presets
    • Advanced Range Presets
    • How Price Moves Affect Liquidity
    • Impermanent Loss: Concepts & Mitigation
    • Matching Your Liquidity Strategy to Market Moves
    • Swap & LP Strategies with Price Ranges
    • Liquidity Scenarios & Risk Profiles
  • Liquidity Provisioning: Tutorials & FAQs
    • Adding Liquidity
      • Manual Mode
      • Automated Mode
    • Managing & Adjusting Positions
    • How APR is Calculated
    • FAQ for LPs
  • Algebra Integral / Technical Reference
    • Intro
    • Audits
    • Integration Process
      • 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
      • FAQ
    • Core Logic
      • Pool overview
      • Swap calculation
      • Liquidity and positions
      • Ticks
        • Ticks search tree
      • Reserves
      • Flash
      • Plugins
      • AlgebraFactory and roles
    • Plugins
      • Overview
      • Farming
      • Adaptive Fee
      • Sliding Fee
      • Whitelist Discount Fee
      • Safety Switch
      • Position Limit Orders
      • Managed Swap Fee
      • FAQ
    • Guides
      • Plugin Development
      • Plugin Testing
      • Plugin Deployment
    • Changes V1
    • Changes V1.1
    • Changes v1.2
  • Changes v1.2.1
  • Other
    • Archived Documentation
Powered by GitBook
On this page
  1. Algebra Integral / Technical Reference
  2. Integration Process
  3. Technical Guides
  4. Providing liquidity

Increase liquidity

  • Before getting into this section, take a closer look at the first guide 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);
    }
PreviousDecrease liquidityNextFinal Contract