Skip to main content

Yield Token (YT) Trading Functions

This document covers all functions for trading Yield Tokens (YT) in Pendle markets. YT tokens represent the yield portion of yield-bearing assets and can be traded against other tokens or SY tokens.

Token to YT Trading

Since AMM only supports swaps by exact YT, to swap exact tokens for YT requires binary search approximation to find the correct amount of SY needed to achieve the desired YT output. For best usage, use the SDK for better approximation since running binary search on-chain is costly.

swapExactTokenForYt

Swaps an exact amount of any supported token for YT tokens.

function swapExactTokenForYt(
address receiver,
address market,
uint256 minYtOut,
ApproxParams calldata guessYtOut,
TokenInput calldata input,
LimitOrderData calldata limit
) external payable returns (uint256 netYtOut, uint256 netSyFee, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive YT tokens
marketaddressPendle market address
minYtOutuint256Minimum YT tokens to receive
guessYtOutApproxParamsApproximation parameters
inputTokenInputToken input configuration
limitLimitOrderDataLimit order configuration

Return Values

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

Use Case Most common function for buying YT tokens with any supported token. The function converts your token to SY and then swaps SY for YT, first filling available limit orders, then using the AMM for any remaining amount.

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

swapExactSyForYt

Swaps an exact amount of SY tokens for YT tokens.

function swapExactSyForYt(
address receiver,
address market,
uint256 exactSyIn,
uint256 minYtOut,
ApproxParams calldata guessYtOut,
LimitOrderData calldata limit
) external returns (uint256 netYtOut, uint256 netSyFee)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive YT tokens
marketaddressPendle market address
exactSyInuint256Exact amount of SY tokens to swap
minYtOutuint256Minimum YT tokens to receive
guessYtOutApproxParamsApproximation parameters
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netYtOutuint256YT tokens received
netSyFeeuint256Trading fees paid in SY

Use Case Direct and efficient method when you already have SY tokens and want to buy YT tokens.

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

YT to Token Trading

swapExactYtForToken

Swaps an exact amount of YT tokens for any supported token.

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

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
marketaddressPendle market address
exactYtInuint256Exact amount of YT tokens to swap
outputTokenOutputToken output configuration
limitLimitOrderDataLimit order configuration

Return Values

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

Use Case Most common function for selling YT tokens to receive tokens. The function swaps YT for SY (first filling available limit orders, then using the AMM), then converts SY to your desired token.

swapExactYtForSy

Swaps an exact amount of YT tokens for SY tokens.

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

Input Parameters

NameTypeDescription
receiveraddressAddress to receive SY tokens
marketaddressPendle market address
exactYtInuint256Exact amount of YT tokens to swap
minSyOutuint256Minimum SY tokens to receive
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netSyOutuint256SY tokens received
netSyFeeuint256Trading fees paid in SY

Use Case Direct and efficient method for selling YT tokens to receive SY tokens.

Integration Examples

Buying YT-sUSDe with USDe

// Swap 1000 USDe for YT-sUSDe tokens
router.swapExactTokenForYt(
msg.sender,
PT_SUSDE_MARKET_ADDRESS,
minYtOut,
createDefaultApproxParams(),
createTokenInputSimple(USDE_ADDRESS, 1000e18),
createEmptyLimitOrderData()
);

Selling YT-sUSDe for USDe

// Swap YT-sUSDe tokens for USDe
router.swapExactYtForToken(
msg.sender,
PT_SUSDE_MARKET_ADDRESS,
ytAmount,
createTokenOutputSimple(USDE_ADDRESS, minUsdeOut),
createEmptyLimitOrderData()
);

Direct SY to YT Trading

// Swap SY tokens directly for YT tokens
router.swapExactSyForYt(
msg.sender,
MARKET_ADDRESS,
syAmount,
minYtOut,
createDefaultApproxParams(),
createEmptyLimitOrderData()
);