Skip to content

Conversation

luchobonatti
Copy link
Member

Add Remove Liquidity Support (buildRemoveLiquidityCallData)

Overview

This PR adds support for building calldata to remove liquidity from Uniswap V4 positions. Developers can now easily generate calldata and value for partial or full liquidity removal, with slippage and deadline controls, ready to be sent to the PositionManager contract.

Changes

  • Added buildRemoveLiquidityCallData utility for preparing calldata to remove liquidity from a position.
  • Added comprehensive unit tests for buildRemoveLiquidityCallData.
  • Updated the README with usage instructions and parameter documentation for removing liquidity.

Technical Details

  • buildRemoveLiquidityCallData:
    • Accepts liquidityPercentage (in BPS), tokenId, optional slippageTolerance, and optional deadline.
    • Fetches position data and builds calldata using the Uniswap V4 SDK.
    • Handles default and custom deadlines.
    • Throws clear errors if the position is not found or if the SDK fails.
  • README:
    • Documents the new function with a usage example.
    • Clarifies BPS usage for all percentage-based parameters.

Testing

Added test suite:

  • buildRemoveLiquidityCallData.test.ts covering:
    • 100% liquidity removal
    • Custom slippage tolerance
    • Error when position is not found
    • Error propagation from the Uniswap SDK

Usage Example

const { calldata, value } = await uniDevKit.buildRemoveLiquidityCallData({
  liquidityPercentage: 10_000, // 100%
  tokenId: '123',
  slippageTolerance: 50, // 0.5%
  deadline: '1700000000'
});

const tx = await sendTransaction({
  to: uniDevKit.getContractAddress('positionManager'),
  data: calldata,
  value
});

@luchobonatti luchobonatti self-assigned this Jun 11, 2025
@luchobonatti luchobonatti force-pushed the feat/removeLiquidity branch from 536f60f to 9716913 Compare June 11, 2025 20:00
@luchobonatti luchobonatti merged commit f09a982 into main Jun 11, 2025
1 check passed
@luchobonatti luchobonatti changed the title Feat/remove liquidity feat: Remove liquidity Jun 11, 2025
@luchobonatti luchobonatti deleted the feat/removeLiquidity branch June 11, 2025 20:17
Copy link

🎉 This PR is included in version 1.0.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant