Positions

Concentrated liquidity positions define a price range [tickLower, tickUpper] in which your liquidity is active. The SDK provides the Position class and NonfungiblePositionManager for all position operations.


Creating a Position

Use Position.fromAmounts to model a position from desired token amounts. Ticks must be multiples of tickSpacing — use nearestUsableTick to align them.

typescript
import { Position, nearestUsableTick, DEFAULT_TICK_SPACING } from '@hydrexfi/hydrex-sdk';

const position = Position.fromAmounts({
  pool,
  tickLower: nearestUsableTick(tickCurrent - DEFAULT_TICK_SPACING * 10, DEFAULT_TICK_SPACING),
  tickUpper: nearestUsableTick(tickCurrent + DEFAULT_TICK_SPACING * 10, DEFAULT_TICK_SPACING),
  amount0: '1000000',           // desired token0 amount
  amount1: '500000000000000000', // desired token1 amount
  useFullPrecision: true,
});

// Read token amounts at current tick
const { amount0, amount1 } = position.mintAmounts;

Minting a New Position

Call NonfungiblePositionManager.addCallParameters without a tokenId to mint a new NFT position.

typescript
import { 
  NonfungiblePositionManager, 
  Percent, 
  NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
  ChainId 
} from '@hydrexfi/hydrex-sdk';

// Mint a new position
const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, {
  slippageTolerance: new Percent(50, 10_000),
  recipient: '0xYourWallet',
  deadline: Math.floor(Date.now() / 1000) + 1200,
});

// Send tx to NONFUNGIBLE_POSITION_MANAGER_ADDRESSES[ChainId.Base]

Increasing Liquidity

Pass a tokenId to add liquidity to an existing NFT position.

typescript
// Increase liquidity on an existing position (tokenId: '42')
const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, {
  tokenId: '42',
  slippageTolerance: new Percent(50, 10_000),
  deadline: Math.floor(Date.now() / 1000) + 1200,
});

Collecting Fees

Collect accrued trading fees from a position at any time without removing liquidity.

typescript
// Collect accrued fees
const { calldata, value } = NonfungiblePositionManager.collectCallParameters({
  tokenId: '42',
  recipient: '0xYourWallet',
  expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(USDC, '0'),
  expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(WETH, '0'),
});

Removing Liquidity

Remove some or all liquidity. The collectOptions field lets you claim fees in the same transaction.

typescript
// Remove 100% of liquidity + collect fees in one call
const { calldata, value } = NonfungiblePositionManager.removeCallParameters(position, {
  tokenId: '42',
  liquidityPercentage: new Percent(100, 100),
  slippageTolerance: new Percent(50, 10_000),
  deadline: Math.floor(Date.now() / 1000) + 1200,
  collectOptions: {
    expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(USDC, '0'),
    expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(WETH, '0'),
    recipient: '0xYourWallet',
  },
});

Two-step withdrawal

Due to the Uniswap V3 withdrawal pattern, fee collection is a separate step from liquidity removal unless you combine them via collectOptions.
Hydrex

Hydrex is an Omni-Liquidity MetaDEX built on Base for Base, designed to bring new users onchain.

Paragraph

© 2026 Hydrex. All rights reserved.