Skip to main content

Principal Token (PT) Trading Functions

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

Token to PT Trading

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

swapExactTokenForPt

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

function swapExactTokenForPt(
address receiver,
address market,
uint256 minPtOut,
ApproxParams calldata guessPtOut,
TokenInput calldata input,
LimitOrderData calldata limit
) external payable returns (uint256 netPtOut, uint256 netSyFee, uint256 netSyInterm)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive PT tokens
marketaddressPendle market address
minPtOutuint256Minimum PT tokens to receive
guessPtOutApproxParamsApproximation parameters
inputTokenInputToken input configuration
limitLimitOrderDataLimit order configuration

Return Values

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

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

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

swapExactSyForPt

Swaps an exact amount of SY tokens for PT tokens.

function swapExactSyForPt(
address receiver,
address market,
uint256 exactSyIn,
uint256 minPtOut,
ApproxParams calldata guessPtOut,
LimitOrderData calldata limit
) external returns (uint256 netPtOut, uint256 netSyFee)

Input Parameters

NameTypeDescription
receiveraddressAddress to receive PT tokens
marketaddressPendle market address
exactSyInuint256Exact amount of SY tokens to swap
minPtOutuint256Minimum PT tokens to receive
guessPtOutApproxParamsApproximation parameters
limitLimitOrderDataLimit order configuration

Return Values

NameTypeDescription
netPtOutuint256PT tokens received
netSyFeeuint256Trading fees paid in SY

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

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

PT to Token Trading

swapExactPtForToken

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

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

Input Parameters

NameTypeDescription
receiveraddressAddress to receive tokens
marketaddressPendle market address
exactPtInuint256Exact amount of PT 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 PT tokens to receive tokens. The function swaps PT for SY (first filling available limit orders, then using the AMM), then converts SY to your desired token.

swapExactPtForSy

Swaps an exact amount of PT tokens for SY tokens.

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

Input Parameters

NameTypeDescription
receiveraddressAddress to receive SY tokens
marketaddressPendle market address
exactPtInuint256Exact amount of PT 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 PT tokens to receive SY tokens.

Integration Examples

Buying PT-sUSDe with USDe

// Swap 1000 USDe for PT-sUSDe tokens
router.swapExactTokenForPt(
msg.sender,
PT_SUSDE_MARKET_ADDRESS,
minPtOut,
createDefaultApproxParams(),
createTokenInputSimple(USDE_ADDRESS, 1000e18),
createEmptyLimitOrderData()
);

Selling PT-sUSDe for USDe

// Swap PT-sUSDe tokens for USDe
router.swapExactPtForToken(
msg.sender,
PT_SUSDE_MARKET_ADDRESS,
ptAmount,
createTokenOutputSimple(USDE_ADDRESS, minUsdeOut),
createEmptyLimitOrderData()
);

Direct SY to PT Trading

// Swap SY tokens directly for PT tokens
router.swapExactSyForPt(
msg.sender,
MARKET_ADDRESS,
syAmount,
minPtOut,
createDefaultApproxParams(),
createEmptyLimitOrderData()
);