Skip to main content

Misc Functions

This document covers core functions for SY/PY operations, reward claiming, exit strategies, and utility functions in Pendle Router.

SY Operations

mintSyFromToken

Mints SY tokens from any supported tokens.

function mintSyFromToken(
address receiver,
address SY,
uint256 minSyOut,
TokenInput calldata input
) external payable returns (uint256 netSyOut)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive SY tokens
SYaddressSY token contract address
minSyOutuint256Minimum SY tokens to receive
inputTokenInputToken input configuration

Return Values

NameTypeDescription
netSyOutuint256SY tokens received

Use Case Convert any supported token into SY tokens, which are standardized yield-bearing tokens used throughout the Pendle ecosystem.

redeemSyToToken

Redeems SY tokens back to any supported tokens.

function redeemSyToToken(
address receiver,
address SY,
uint256 netSyIn,
TokenOutput calldata output
) external returns (uint256 netTokenOut)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
SYaddressSY token contract address
netSyInuint256Amount of SY tokens to redeem
outputTokenOutputToken output configuration

Return Values

NameTypeDescription
netTokenOutuint256Tokens received

Use Case Convert SY tokens back to tokens when you want.

Principal/Yield Token Operations

mintPyFromToken

Mints PT and YT tokens (collectively called PY) from any supported tokens.

function mintPyFromToken(
address receiver,
address YT,
uint256 minPyOut,
TokenInput calldata input
) external payable returns (uint256 netPyOut, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive PT and YT tokens
YTaddressYT token contract address
minPyOutuint256Minimum PY tokens to mint
inputTokenInputToken input configuration

Return Values

NameTypeDescription
netPyOutuint256PT and YT tokens minted (equal amounts)
netSyIntermuint256SY tokens generated as intermediate step

Use Case Split any supported token into separate principal and yield components.

redeemPyToToken

Redeems equal amounts of PT and YT tokens back to any supported tokens.

function redeemPyToToken(
address receiver,
address YT,
uint256 netPyIn,
TokenOutput calldata output
) external returns (uint256 netTokenOut, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
YTaddressYT token contract address
netPyInuint256Amount of PT+YT pairs to redeem
outputTokenOutputToken output configuration

Return Values

NameTypeDescription
netTokenOutuint256Tokens received
netSyIntermuint256SY tokens generated as intermediate step

Use Case Recombine PT and YT tokens back into any supported token. Requires holding equal amounts of both PT and YT.

mintPyFromSy

Mints PT and YT tokens directly from SY tokens.

function mintPyFromSy(
address receiver,
address YT,
uint256 netSyIn,
uint256 minPyOut
) external returns (uint256 netPyOut)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive PT and YT tokens
YTaddressYT token contract address
netSyInuint256Amount of SY tokens to use
minPyOutuint256Minimum PY tokens to mint

Return Values

NameTypeDescription
netPyOutuint256PT and YT tokens minted (equal amounts)

Use Case Efficient splitting of SY tokens into PT and YT when you already have SY tokens.

redeemPyToSy

Redeems equal amounts of PT and YT tokens back to SY tokens.

function redeemPyToSy(
address receiver,
address YT,
uint256 netPyIn,
uint256 minSyOut
) external returns (uint256 netSyOut)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive SY tokens
YTaddressYT token contract address
netPyInuint256Amount of PT+YT pairs to redeem
minSyOutuint256Minimum SY tokens to receive

Return Values

NameTypeDescription
netSyOutuint256SY tokens received

Use Case Recombine PT and YT tokens into SY tokens for further operations within Pendle ecosystem.

Reward Functions

redeemDueInterestAndRewards

Claims all pending rewards and interest from SY tokens, YT tokens, and LP positions.

function redeemDueInterestAndRewards(
address user,
address[] calldata sys,
address[] calldata yts,
address[] calldata markets
) external

Input Parameters

NameTypeDescription
useraddressAddress to receive rewards
sysaddress[]Array of SY token addresses
ytsaddress[]Array of YT token addresses
marketsaddress[]Array of market addresses

Use Case Batch claim all rewards across multiple positions. This is the most gas-efficient way to claim rewards from multiple sources.

redeemDueInterestAndRewardsV2

Advanced reward claiming with token swapping capabilities.

function redeemDueInterestAndRewardsV2(
IStandardizedYield[] calldata SYs,
RedeemYtIncomeToTokenStruct[] calldata YTs,
IPMarket[] calldata markets,
IPSwapAggregator pendleSwap,
SwapDataExtra[] calldata swaps
) external returns (uint256[] memory netOutFromSwaps, uint256[] memory netInterests)

Input Parameters

NameTypeDescription
SYsIStandardizedYield[]Array of SY contracts
YTsRedeemYtIncomeToTokenStruct[]YT redemption configurations
marketsIPMarket[]Array of market contracts
pendleSwapIPSwapAggregatorSwap aggregator for token conversions
swapsSwapDataExtra[]Swap configurations

Return Values

NameTypeDescription
netOutFromSwapsuint256[]Tokens received from swaps
netInterestsuint256[]Interest tokens received

Use Case Advanced reward claiming that can automatically swap reward tokens to desired tokens. Useful for complex strategies and automated systems.

Token Swapping

swapTokensToTokens

Performs multiple token-to-token swaps using external aggregators.

function swapTokensToTokens(
IPSwapAggregator pendleSwap,
SwapDataExtra[] calldata swaps,
uint256[] calldata netSwaps
) external payable returns (uint256[] memory netOutFromSwaps)

Input Parameters

NameTypeDescription
pendleSwapIPSwapAggregatorSwap aggregator contract
swapsSwapDataExtra[]Array of swap configurations
netSwapsuint256[]Array of input amounts for each swap

Return Values

NameTypeDescription
netOutFromSwapsuint256[]Output amounts from each swap

Use Case Batch multiple token swaps for gas efficiency.

swapTokenToTokenViaSy

Swaps tokens using SY as an intermediate step.

function swapTokenToTokenViaSy(
address receiver,
address SY,
TokenInput calldata input,
address tokenRedeemSy,
uint256 minTokenOut
) external payable returns (uint256 netTokenOut, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive output tokens
SYaddressSY token contract address
inputTokenInputInput token configuration
tokenRedeemSyaddressOutput token address
minTokenOutuint256Minimum output tokens to receive

Return Values

NameTypeDescription
netTokenOutuint256Output tokens received
netSyIntermuint256SY tokens used as intermediate

Use Case Swap between tokens that both support the same SY token, often providing better rates than external DEXes.

Exit Strategies

exitPreExpToToken

Comprehensive position exit before market expiry, converting everything to a single token.

function exitPreExpToToken(
address receiver,
address market,
uint256 netPtIn,
uint256 netYtIn,
uint256 netLpIn,
TokenOutput calldata output,
LimitOrderData calldata limit
) external returns (uint256 totalTokenOut, ExitPreExpReturnParams memory params)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
marketaddressPendle market address
netPtInuint256Amount of PT tokens to exit
netYtInuint256Amount of YT tokens to exit
netLpInuint256Amount of LP tokens to exit
outputTokenOutputOutput token configuration
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
totalTokenOutuint256Total tokens received
paramsExitPreExpReturnParamsDetailed breakdown of exit operations

Use Case Complete portfolio liquidation before expiry. Optimally combines PT+YT pairs and swaps remaining tokens.

exitPreExpToSy

Comprehensive position exit before market expiry, converting everything to SY tokens.

function exitPreExpToSy(
address receiver,
address market,
uint256 netPtIn,
uint256 netYtIn,
uint256 netLpIn,
uint256 minSyOut,
LimitOrderData calldata limit
) external returns (ExitPreExpReturnParams memory params)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive SY tokens
marketaddressPendle market address
netPtInuint256Amount of PT tokens to exit
netYtInuint256Amount of YT tokens to exit
netLpInuint256Amount of LP tokens to exit
minSyOutuint256Minimum SY tokens to receive
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
paramsExitPreExpReturnParamsDetailed breakdown of exit operations

Use Case Portfolio liquidation to SY tokens, useful when you want to stay within Pendle ecosystem or perform further operations.

exitPostExpToToken

Position exit after market expiry, when PT tokens can be redeemed 1:1.

function exitPostExpToToken(
address receiver,
address market,
uint256 netPtIn,
uint256 netLpIn,
TokenOutput calldata output
) external returns (uint256 totalTokenOut, ExitPostExpReturnParams memory params)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
marketaddressPendle market address
netPtInuint256Amount of PT tokens to redeem
netLpInuint256Amount of LP tokens to exit
outputTokenOutputOutput token configuration

Return Values

NameTypeDescription
totalTokenOutuint256Total tokens received
paramsExitPostExpReturnParamsBreakdown of redemption operations

Use Case Clean exit after maturity when PT tokens are worth face value. Much simpler than pre-expiry exits.

exitPostExpToSy

Position exit after market expiry, converting to SY tokens.

function exitPostExpToSy(
address receiver,
address market,
uint256 netPtIn,
uint256 netLpIn,
uint256 minSyOut
) external returns (ExitPostExpReturnParams memory params)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive SY tokens
marketaddressPendle market address
netPtInuint256Amount of PT tokens to redeem
netLpInuint256Amount of LP tokens to exit
minSyOutuint256Minimum SY tokens to receive

Return Values

NameTypeDescription
paramsExitPostExpReturnParamsBreakdown of redemption operations

Use Case Post-expiry exit to SY tokens, maintaining position within Pendle ecosystem.

Utility Functions

boostMarkets

Triggers market updates to refresh boost multipliers.

function boostMarkets(address[] memory markets) external

Input Parameters

NameTypeDescription
marketsaddress[]Array of market addresses to boost

Use Case Refresh boost calculations for multiple markets in a single transaction.

multicall

Executes multiple function calls in a single transaction.

function multicall(Call3[] calldata calls) external payable returns (Result[] memory res)

Input Parameters

NameTypeDescription
callsCall3[]Array of function calls to execute

Return Values

NameTypeDescription
resResult[]Results from each function call

Use Case Batch multiple operations for gas efficiency and atomic execution.

simulate

Simulates function execution without state changes.

function simulate(address target, bytes calldata data) external payable

Input Parameters

NameTypeDescription
targetaddressContract address to simulate
databytesEncoded function call data

Use Case Test function execution and get return values without actually executing the transaction.

Integration Examples

Basic SY Operations

// Mint SY-sUSDe from USDe
router.mintSyFromToken(
msg.sender,
SY_USDE_ADDRESS,
minSyOut,
createTokenInputSimple(USDE_ADDRESS, 1000e18)
);

// Redeem SY-sUSDe back to USDE
router.redeemSyToToken(
msg.sender,
SY_USDE_ADDRESS,
syAmount,
createTokenOutputSimple(USDE_ADDRESS, minUsdeOut)
);

Reward Claiming

// Claim all rewards
address[] memory sys = new address[](1);
address[] memory yts = new address[](1);
address[] memory markets = new address[](1);
sys[0] = SY_ADDRESS;
yts[0] = YT_ADDRESS;
markets[0] = MARKET_ADDRESS;

router.redeemDueInterestAndRewards(msg.sender, sys, yts, markets);

Complete Position Exit

// Exit all positions before expiry
router.exitPreExpToToken(
msg.sender,
MARKET_ADDRESS,
ptAmount,
ytAmount,
lpAmount,
createTokenOutputSimple(USDC_ADDRESS, minUsdcOut),
createEmptyLimitOrderData()
);