POST
/
api
/
algebra
/
interactions
/
increase
curl --request POST \
  --url https://public-beam-backend-mainnet.codemelt.codes/api/algebra/interactions/increase \
  --header 'Content-Type: application/json' \
  --data '{
  "liquidityPercent": 123,
  "tokenId": 123,
  "recipient": "<string>",
  "tokenAId": 123,
  "tokenBId": 123,
  "networkName": "<string>",
  "liquidity": "<string>",
  "tickLower": 123,
  "tickUpper": 123,
  "amountA": 123,
  "amountB": 123
}'
{
  "message": "<string>",
  "data": null,
  "status": "<any>"
}

Increase Liquidity

This endpoint provides functionality for increasing liquidity to existing Algebra positions. It supports both single-token and balanced liquidity additions to existing positions.

Using the SDK

import api, { IConnection } from "codemelt-retro-api-sdk"
import { ChangeLiquidityDTO } from 'codemelt-retro-api-sdk/structures/ChangeLiquidityDTO'

const connection: IConnection = {
  host: '<enter your host url here>',
  headers: {
    'x-api-key': '<enter your api key here>'
  }
}

const networkName = 'Zeta Mainnet'
const input: ChangeLiquidityDTO = {
  tickLower: Number(position.tickRange.lower),
  tickUpper: Number(position.tickRange.upper),
  networkName: networkName,
  tokenId: Number(position.tokenId),
  amountA: Number(firstTokenAmount),
  amountB: Number(secondTokenAmount),
  tokenAId: tokenA.id,
  tokenBId: tokenB.id,
  liquidity: position.liquidity,
  recipient: signer.address,
  liquidityPercent: 0
}

const resp = await api.functional.api.algebra.interactions.increase.increaseLiquidity(
  connection,
  input
)

Security Considerations

  1. Slippage Protection

    • Default slippage tolerance for non-meme pools is 2%
    • Default slippage tolerance for meme pools is 10%
    • Slippage is calculated based on the current position’s price range
  2. Position Validation

    • Position must exist and belong to the recipient
    • Position must not be closed
    • Current price must be within the position’s range for balanced adds
    • Single-sided adds are possible when price is outside range

Best Practices

  1. Timing Considerations
    • Check if current price is within range
    • Consider increasing when:
      • Position is generating good fees
      • Price is centered in range
      • Market volatility matches position range

Common Errors and Solutions

  1. Price Out of Range

    // Check if price is in range before increasing
    if (currentPrice < position.tickLower || currentPrice > position.tickUpper) {
      console.warn('Price out of range, consider single-sided add')
    }
    
  2. Invalid Position ID

    // Verify position ownership
      const resp = await api.algebra.pool.manual.getUserPools(
       connection,
       signer.address,
       networkName
     )
    
     resp.data.data.positions.find(elm => elm.tokenId === desiredTokenId)
    

Body

application/json
liquidityPercent
number
required
tokenId
number
required
recipient
string
required
tokenAId
number
required
tokenBId
number
required
networkName
string
required
liquidity
string
required
tickLower
number
required
tickUpper
number
required
amountA
number
required
amountB
number
required

Response

201 - application/json
message
string
required
data
null
required
status
any
required