Skip to main content

Liquidity Management Functions

This document covers all functions for managing liquidity positions in Pendle markets. These functions allow adding and removing liquidity in various token combinations.

Add Liquidity Functions

addLiquidityDualTokenAndPt

Adds liquidity using a token and PT token in exact amounts.

function addLiquidityDualTokenAndPt(
address receiver,
address market,
TokenInput calldata input,
uint256 netPtDesired,
uint256 minLpOut
) external payable returns (uint256 netLpOut, uint256 netPtUsed, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive LP tokens
marketaddressPendle market address
inputTokenInputToken input configuration
netPtDesireduint256Desired amount of PT tokens to use
minLpOutuint256Minimum LP tokens to receive

Return Values

NameTypeDescription
netLpOutuint256LP tokens received
netPtUseduint256PT tokens actually used
netSyIntermuint256SY tokens generated from input token

Use Case When you have both the underlying token and PT tokens and want to add liquidity using exact amounts of both. The function will mint SY from your token input and combine it with your PT tokens.

addLiquidityDualSyAndPt

Adds liquidity using both SY and PT tokens in exact amounts.

function addLiquidityDualSyAndPt(
address receiver,
address market,
uint256 netSyDesired,
uint256 netPtDesired,
uint256 minLpOut
) external returns (uint256 netLpOut, uint256 netSyUsed, uint256 netPtUsed)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive LP tokens
marketaddressPendle market address
netSyDesireduint256Desired amount of SY tokens to use
netPtDesireduint256Desired amount of PT tokens to use
minLpOutuint256Minimum LP tokens to receive

Return Values

NameTypeDescription
netLpOutuint256LP tokens received
netSyUseduint256SY tokens actually used
netPtUseduint256PT tokens actually used

Use Case When you already have both SY and PT tokens and want to add liquidity directly.

addLiquiditySinglePt

Adds liquidity using only PT tokens by internally swapping some PT for SY.

function addLiquiditySinglePt(
address receiver,
address market,
uint256 netPtIn,
uint256 minLpOut,
ApproxParams calldata guessPtSwapToSy,
LimitOrderData calldata limit
) external returns (uint256 netLpOut, uint256 netSyFee)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive LP tokens
marketaddressPendle market address
netPtInuint256Amount of PT tokens to use
minLpOutuint256Minimum LP tokens to receive
guessPtSwapToSyApproxParamsApproximation parameters
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netLpOutuint256LP tokens received
netSyFeeuint256Trading fees paid in SY

Use Case When you only have PT tokens and want to add liquidity. The function will automatically determine the optimal amount of PT to swap for SY to achieve balanced liquidity provision.

Simple Version Available For basic operations without custom parameters, use addLiquiditySinglePtSimple which automatically handles approximation and skips limit order functionality.

addLiquiditySingleToken

Adds liquidity using any supported token by converting it to SY and PT as needed.

function addLiquiditySingleToken(
address receiver,
address market,
uint256 minLpOut,
ApproxParams calldata guessPtReceivedFromSy,
TokenInput calldata input,
LimitOrderData calldata limit
) external payable returns (uint256 netLpOut, uint256 netSyFee, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive LP tokens
marketaddressPendle market address
minLpOutuint256Minimum LP tokens to receive
guessPtReceivedFromSyApproxParamsApproximation parameters
inputTokenInputToken input configuration
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netLpOutuint256LP tokens received
netSyFeeuint256Trading fees paid in SY
netSyIntermuint256SY tokens generated from input token

Use Case Most convenient method when you have any supported token and want to add liquidity. The function handles all necessary conversions and swaps automatically.

Simple Version Available For basic operations without custom parameters, use addLiquiditySingleTokenSimple which automatically handles approximation and skips limit order functionality.

addLiquiditySingleSy

Adds liquidity using only SY tokens by converting some to PT through market operations.

function addLiquiditySingleSy(
address receiver,
address market,
uint256 netSyIn,
uint256 minLpOut,
ApproxParams calldata guessPtReceivedFromSy,
LimitOrderData calldata limit
) external returns (uint256 netLpOut, uint256 netSyFee)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive LP tokens
marketaddressPendle market address
netSyInuint256Amount of SY tokens to use
minLpOutuint256Minimum LP tokens to receive
guessPtReceivedFromSyApproxParamsApproximation parameters
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netLpOutuint256LP tokens received
netSyFeeuint256Trading fees paid in SY

Use Case When you have SY tokens and want to add liquidity. The function will swap some SY for PT to achieve optimal liquidity provision.

Simple Version Available For basic operations without custom parameters, use addLiquiditySingleSySimple which automatically handles approximation and skips limit order functionality.

addLiquiditySingleTokenKeepYt

Adds liquidity while keeping the generated YT tokens instead of selling them.

function addLiquiditySingleTokenKeepYt(
address receiver,
address market,
uint256 minLpOut,
uint256 minYtOut,
TokenInput calldata input
) external payable returns (uint256 netLpOut, uint256 netYtOut, uint256 netSyMintPy, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive LP and YT tokens
marketaddressPendle market address
minLpOutuint256Minimum LP tokens to receive
minYtOutuint256Minimum YT tokens to receive
inputTokenInputToken input configuration

Return Values

NameTypeDescription
netLpOutuint256LP tokens received
netYtOutuint256YT tokens received
netSyMintPyuint256SY used to mint PT/YT
netSyIntermuint256SY tokens generated from input token

Use Case When you want to add liquidity and also keep YT tokens for yield farming. This strategy avoids price impact since no swapping occurs - the underlying asset is converted to SY, then PT/YT pairs are minted directly. The PT and remaining SY are used for liquidity provision while YT is returned to you.

addLiquiditySingleSyKeepYt

Adds liquidity using SY tokens while keeping the generated YT tokens.

function addLiquiditySingleSyKeepYt(
address receiver,
address market,
uint256 netSyIn,
uint256 minLpOut,
uint256 minYtOut
) external returns (uint256 netLpOut, uint256 netYtOut, uint256 netSyMintPy)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive LP and YT tokens
marketaddressPendle market address
netSyInuint256Amount of SY tokens to use
minLpOutuint256Minimum LP tokens to receive
minYtOutuint256Minimum YT tokens to receive

Return Values

NameTypeDescription
netLpOutuint256LP tokens received
netYtOutuint256YT tokens received
netSyMintPyuint256SY used to mint PT/YT

Use Case When you have SY tokens and want both LP tokens and YT tokens. This method avoids price impact since no swapping occurs - SY is used to mint PT/YT pairs directly, with PT used for liquidity provision and YT returned to you.

Remove Liquidity Functions

removeLiquidityDualTokenAndPt

Removes liquidity and receives both the underlying token and PT tokens.

function removeLiquidityDualTokenAndPt(
address receiver,
address market,
uint256 netLpToRemove,
TokenOutput calldata output,
uint256 minPtOut
) external returns (uint256 netTokenOut, uint256 netPtOut, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
marketaddressPendle market address
netLpToRemoveuint256Amount of LP tokens to burn
outputTokenOutputToken output configuration
minPtOutuint256Minimum PT tokens to receive

Return Values

NameTypeDescription
netTokenOutuint256Amount tokens received
netPtOutuint256PT tokens received
netSyIntermuint256SY tokens converted to underlying

Use Case When you want to exit a liquidity position and receive both the underlying token and PT tokens separately.

removeLiquidityDualSyAndPt

Removes liquidity and receives both SY and PT tokens.

function removeLiquidityDualSyAndPt(
address receiver,
address market,
uint256 netLpToRemove,
uint256 minSyOut,
uint256 minPtOut
) external returns (uint256 netSyOut, uint256 netPtOut)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
marketaddressPendle market address
netLpToRemoveuint256Amount of LP tokens to burn
minSyOutuint256Minimum SY tokens to receive
minPtOutuint256Minimum PT tokens to receive

Return Values

NameTypeDescription
netSyOutuint256SY tokens received
netPtOutuint256PT tokens received

Use Case Most efficient method when you want both SY and PT tokens. No additional conversions are performed.

removeLiquiditySinglePt

Removes liquidity and converts everything to PT tokens.

function removeLiquiditySinglePt(
address receiver,
address market,
uint256 netLpToRemove,
uint256 minPtOut,
ApproxParams calldata guessPtReceivedFromSy,
LimitOrderData calldata limit
) external returns (uint256 netPtOut, uint256 netSyFee)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive PT tokens
marketaddressPendle market address
netLpToRemoveuint256Amount of LP tokens to burn
minPtOutuint256Minimum PT tokens to receive
guessPtReceivedFromSyApproxParamsApproximation parameters
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netPtOutuint256PT tokens received
netSyFeeuint256Trading fees paid in SY

Use Case When you want to exit liquidity and hold only PT tokens, maximizing your PT position.

Simple Version Available For basic operations without custom parameters, use removeLiquiditySinglePtSimple which automatically handles approximation and skips limit order functionality.

removeLiquiditySingleToken

Removes liquidity and converts everything to a specified underlying token.

function removeLiquiditySingleToken(
address receiver,
address market,
uint256 netLpToRemove,
TokenOutput calldata output,
LimitOrderData calldata limit
) external returns (uint256 netTokenOut, uint256 netSyFee, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
marketaddressPendle market address
netLpToRemoveuint256Amount of LP tokens to burn
outputTokenOutputToken output configuration
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netTokenOutuint256Amount tokens received
netSyFeeuint256Trading fees paid in SY
netSyIntermuint256SY tokens before conversion

Use Case Most convenient exit method when you want to receive a specific underlying token. Handles all necessary conversions automatically.

removeLiquiditySingleSy

Removes liquidity and converts everything to SY tokens.

function removeLiquiditySingleSy(
address receiver,
address market,
uint256 netLpToRemove,
uint256 minSyOut,
LimitOrderData calldata limit
) external returns (uint256 netSyOut, uint256 netSyFee)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive SY tokens
marketaddressPendle market address
netLpToRemoveuint256Amount of LP tokens to burn
minSyOutuint256Minimum SY tokens to receive
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netSyOutuint256SY tokens received
netSyFeeuint256Trading fees paid in SY

Use Case When you want to exit liquidity and hold SY tokens, useful for further operations within the Pendle ecosystem.

Integration Examples

Basic Liquidity Addition

// Add liquidity with USDe
router.addLiquiditySingleToken(
msg.sender,
PT_USDE_MARKET_ADDRESS,
minLpOut,
createDefaultApproxParams(),
createTokenInputSimple(USDE_ADDRESS, 1000e18),
createEmptyLimitOrderData()
);

Basic Liquidity Removal

// Remove liquidity to USDe
router.removeLiquiditySingleToken(
msg.sender,
PT_USDE_MARKET_ADDRESS,
lpAmount,
createTokenOutputSimple(USDE_ADDRESS, minUsdeOut),
createEmptyLimitOrderData()
);