Skip to main content

IPendleRouter

imports IWETH, IPendleData, IPendleMarketFactory, PendleStructs

Source: IPendleRouter.sol


REFERENCE

Events

MarketCreated

Emitted when a market for a future yield token and an ERC20 token is created.


event MarketCreated(
bytes32 marketFactoryId,
address indexed xyt,
address indexed token,
address indexed market
);
ParameterTypeDescription
marketFactoryIdbytes32Market factory ID in bytes
xytaddressThe address of the tokenized future yield token as the base asset.
tokenaddressThe address of an ERC20 token as the quote asset.
marketaddressThe address of the newly created market.

Signature: 0xb18af3690cc6a832c9b2e802aab7a21111f4cfca5c2e4fcf614f6ea55b405f4a


SwapEvent

Emitted when a swap happens on the market.


event SwapEvent(
address indexed trader,
address inToken,
address outToken,
uint256 exactIn,
uint256 exactOut,
address market
);
ParameterTypeDescription
traderindexed addressThe address of msg.sender.
inTokenaddressThe input token.
outTokenaddressThe output token.
exactInuint256The exact amount being traded.
exactOutuint256The exact amount received.
marketaddressThe market address.

Signature: 0xf5fd10e802251a919c2bfd2cfc15e2526d3864c819e2b4dc346ca1ade0f51658


Join

Emitted when user adds liquidity.


event Join(
address indexed sender,
uint256 token0Amount,
uint256 token1Amount,
address market,
uint256 exactOutLp
);
ParameterTypeDescription
senderindexed addressThe user who added liquidity.
token0Amountuint256The amount of token0 (xyt) provided by user.
token1Amountuint256The amount of token1 provided by user.
marketaddressThe market address.
exactOutLpaddressThe exact LP minted.

Signature: 0xe37fea01e65dea7d589abafc4bd0d5282a09ddce3e9ea971ed3399d776a1a296


Exit

Emitted when user removes liquidity.


event Exit(
address indexed sender,
uint256 token0Amount,
uint256 token1Amount,
address market,
uint256 exactInLp
);
ParameterTypeDescription
senderaddressThe user who removed liquidity.
token0Amountuint256The amount of token0 (xyt) returned to the user.
token1Amountuint256The amount of token1 returned to the user.
marketaddressThe market address.
exactOutLpaddressThe exact LP removed.

Signature: 0x3af46289ed754c6821a8849534b8412a33bcd8387cb986f39e7e9937fb251cde


General Functions

data

Gets a reference to the PendleData contract.


function data() external view returns (IPendleData);

Returns:
IPendleData — Returns the data contract reference.


weth

Gets a reference of the WETH9 token contract address.


function weth() external view returns (IWETH);

Returns:
IWETH — WETH token reference.


Forge Functions

newYieldContracts

Tokenizes the yield-bearing asset into YT and OT.


function newYieldContracts(
bytes32 forgeId,
address underlyingAsset,
uint256 expiry
) external returns (address ot, address xyt);
ParameterTypeDescription
forgeIdbytes32The forge ID in bytes.
underlyingAssetaddressThe address of the underlying token.
expiryuint256The expiry of the yield contract in epoch time.

Returns:
ot — address of the OT token created.
xyt — address of the YT token created.


redeemAfterExpiry

Redeems the underlying asset after the yield contract expiry by burning OT and YT.


function redeemAfterExpiry(
bytes32 forgeId,
address underlyingAsset,
uint256 expiry
) external returns (uint256 redeemedAmount);
ParameterTypeDescription
forgeIdbytes32The forge ID in bytes.
underlyingAssetaddressThe address of the underlying token.
expiryuint256The expiry of the yield contract in epoch time.

Returns:
redeemedAmount — amount that was redeemed.


redeemDueInterests

Redeems the user's due interests earned from the yield protocols.


function redeemDueInterests(
bytes32 forgeId,
address underlyingAsset,
uint256 expiry,
address user
) external returns (uint256 interests);
ParameterTypeDescription
forgeIdbytes32The forge ID in bytes.
underlyingAssetaddressThe address of the underlying token.
expiryuint256The expiry of the yield contract in epoch time.
useraddressThe address of the user.

Returns:
interests — amount of due interests that was redeemed.


redeemUnderlying

Redeems the underlying asset by burning OT and YT.


function redeemUnderlying(
bytes32 forgeId,
address underlyingAsset,
uint256 expiry,
uint256 amountToRedeem
) external returns (uint256 redeemedAmount);
ParameterTypeDescription
forgeIdbytes32The forge ID in bytes.
underlyingAssetaddressThe address of the underlying token.
expiryuint256The expiry of the yield contract in epoch time.
amountToRedeemuint256The amount of the underlying asset to redeem.

Returns:
redeemedAmount — amount that was redeemed.


renewYield

Renews this yield contract by burning the old OT and YT tokens, while mining new OT and YT tokens without having to remove his underlying asset.


function renewYield(
bytes32 forgeId,
uint256 oldExpiry,
address underlyingAsset,
uint256 newExpiry,
uint256 renewalRate
)
external
returns (
uint256 redeemedAmount,
uint256 amountRenewed,
address ot,
address xyt,
uint256 amountTokenMinted
);
ParameterTypeDescription
forgeIdbytes32The forge ID in bytes.
oldExpiryuint256The old expiry of the yield contract in epoch time.
underlyingAssetaddressThe address of the underlying token.
newExpiryuint256The new expiry of the yield contract in epoch time.
renewalRateuint256The rate to be used for the new yield contract.

Returns:
redeemedAmount — amount that was redeemed.
amountRenewed — amount that was renewed.
ot — address of the new OT token.
xyt — address of the new YT token.
amountTokenMinted — amount of LP tokens minted.


tokenizeYield

Tokenize the underlying asset into OT and YT for a yield contract.


function tokenizeYield(
bytes32 forgeId,
address underlyingAsset,
uint256 expiry,
uint256 amountToTokenize,
address to
)
external
returns (
address ot,
address xyt,
uint256 amountTokenMinted
);
ParameterTypeDescription
forgeIdbytes32The forge ID in bytes.
underlyingAssetaddressThe address of the underlying token.
expiryuint256The expiry of the yield contract in epoch time.
amountToTokenizeuint256Amount of underlying asset to tokenize.
toaddressThe address to send the OT and YT to.

Returns:
ot — address of the new OT token.
xyt — address of the new YT token.
amountTokenMinted — amount of LP tokens minted.


Market Functions

addMarketLiquidityDual

Add both YT and Token liquidity into the market.


function addMarketLiquidityDual(
bytes32 marketFactoryId,
address xyt,
address token,
uint256 desiredXytAmount,
uint256 desiredTokenAmount,
uint256 xytMinAmount,
uint256 tokenMinAmount
)
external
payable
returns (
uint256 amountXytUsed,
uint256 amountTokenUsed,
uint256 lpOut
);
ParameterTypeDescription
marketFactoryIdbytes32The market factory ID in bytes.
xytaddressThe address of the YT token.
tokenaddressThe address of the quote token.
desiredXytAmountuint256Amount of YT to add liquidity to the market.
desiredTokenAmountuint256Amount of quote tokens to add liquidity to the market.
xytMinAmountuint256The minimum expected amount of YT to add liquidity to the market.
tokenMinAmountuint256The minimum expected amount of quote tokens to add liquidity to the market.

Returns:
amountXytUsed — amount of YT liquidity added to the market.
amountTokenUsed — amount of quote tokens liquidity added to the market.
lpOut — amount of LP tokens minted.


addMarketLiquiditySingle

Add either YT or Token liquidity into the market.


function addMarketLiquiditySingle(
bytes32 marketFactoryId,
address xyt,
address token,
bool forXyt,
uint256 exactInAsset,
uint256 minOutLp
) external payable returns (uint256 exactOutLp);
ParameterTypeDescription
marketFactoryIdbytes32The market factory ID in bytes.
xytaddressThe address of the YT token.
tokenaddressThe address of the quote token.
forXytbooltrue if adding liquidity to YT, otherwise false.
exactInAssetuint256Amount of YT or quote tokens to add liquidity to the market.
minOutLpuint256The minimum amount of LP tokens to be minted.

Returns:
exactOutLp — amount of LP tokens minted.


removeMarketLiquidityDual

Remove both YT and Token liquidity from the market.


function removeMarketLiquidityDual(
bytes32 marketFactoryId,
address xyt,
address token,
uint256 exactInLp,
uint256 minOutXyt,
uint256 minOutToken
) external returns (uint256 exactOutXyt, uint256 exactOutToken);
ParameterTypeDescription
marketFactoryIdbytes32The market factory ID in bytes.
xytaddressThe address of the YT token.
tokenaddressThe address of the quote token.
exactInLpuint256The exact amount of LP tokens provided to redeem YT and quote tokens.
minOutXytuint256The minimum expected amount of YT redeemed from the market.
minOutTokenuint256The minimum expected amount of quote tokens redeemed from the market.

Returns:
exactOutXyt — the exact amount of YT redeemed from the market.
exactOutToken — the exact amount of quote tokens redeemed from the market.


removeMarketLiquiditySingle

Remove either YT or Token liquidity from the market.


function removeMarketLiquiditySingle(
bytes32 marketFactoryId,
address xyt,
address token,
bool forXyt,
uint256 exactInLp,
uint256 minOutAsset
) external returns (uint256 exactOutXyt, uint256 exactOutToken);
ParameterTypeDescription
marketFactoryIdbytes32The market factory ID in bytes.
xytaddressThe address of the YT token.
tokenaddressThe address of the quote token.
forXytbooltrue if removing liquidity to YT, otherwise false.
exactInLpuint256Amount of exact LP tokens used to redeem YT and quote tokens.
minOutAssetuint256The minimum amount of either YT ro quote tokens to be redeemed.

Returns:
exactOutXyt — the exact amount of YT redeemed from the market.
exactOutToken — the exact amount of quote tokens redeemed from the market.


createMarket

Creates a market given a protocol ID, future yield token, and an ERC20 token.


function createMarket(
bytes32 marketFactoryId,
address xyt,
address token
) external returns (address market);
ParameterTypeDescription
marketFactoryIdbytes32The market factory ID in bytes.
xytaddressThe address of the YT token.
tokenaddressThe address of the quote token.

Returns:
market — address of the newly created market.


bootstrapMarket

Bootstrap initial liquidity in the newly created market.


function bootstrapMarket(
bytes32 marketFactoryId,
address xyt,
address token,
uint256 initialXytLiquidity,
uint256 initialTokenLiquidity
) external payable;
ParameterTypeDescription
marketFactoryIdbytes32The market factory ID in bytes.
xytaddressThe address of the YT token.
tokenaddressThe address of the quote token.
initialXytLiquidityuint256Initial YT liquidity in the market.
initialTokenLiquidityuint256Initial token liquidity in the market.

Returns:
ot — address of the new OT token.
xyt — address of the new YT token.
amountTokenMinted — amount of LP tokens minted.


swapExactIn

Trades an exact amount of source assets into destination assets.


function swapExactIn(
address tokenIn,
address tokenOut,
uint256 inTotalAmount,
uint256 minOutTotalAmount,
bytes32 marketFactoryId
) external payable returns (uint256 outTotalAmount);
ParameterTypeDescription
tokenInaddressThe address of the source asset to trade.
tokenOutaddressThe address of the destination asset to trade.
inTotalAmountuint256The exact amount of source assets to trade.
minOutTotalAmountuint256The minimum output amount resulting from the trade.
marketFactoryIdbytes32The market factory in bytes.

Returns:
outTotalAmount — the total output amount resulting from the trade.


swapExactOut

Tokenize the underlying asset into OT and YT for a yield contract.


function swapExactOut(
address tokenIn,
address tokenOut,
uint256 outTotalAmount,
uint256 maxInTotalAmount,
bytes32 marketFactoryId
) external payable returns (uint256 inTotalAmount);
ParameterTypeDescription
tokenInaddressThe address of the source asset to trade.
tokenOutaddressThe address of the destination asset to trade.
outTotalAmountuint256The exact amount of destination assets desired to use in the trade.
maxInTotalAmountuint256The maximum input amount allowed to use in the trade.
marketFactoryIdbytes32The market factory in bytes.

Returns:
inTotalAmount — the total input amount used in the trade.


redeemLpInterests

Redeem the LP interests generated from the market LP tokens.


function redeemLpInterests(address market, address user) external returns (uint256 interests);
ParameterTypeDescription
marketaddressThe address of the market.
useraddressThe address of the user.

Returns:
interests — amount of interests redeemed.