PageSourceSearch

https://docs.pendle.finance/assets/js/8f18d939.7a4c250b.js

js pendle.finance collected 2026-10-02 16:18:25 UTC 23,773 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkpendle_documentation=self.webpackChunkpendle_documentation||[]).push([[2895],{8453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>c});var r=t(6540);const d={},s=r.createContext(d);function i(e){const n=r.useContext(s);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:i(e.components),r.createElement(s.Provider,{value:n},e.children)}},9264:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>r,toc:()=>h});const r=JSON.parse('{"id":"Contracts/RouterStatic/ApiReference/MintRedeemFunctions","title":"Mint & Redeem Simulation Functions","description":"These functions come from the IPActionMintRedeemStatic facet. They simulate every mint and redeem operation supported by the live Router, plus two view helpers for reading the current PY index.","source":"@site/docs/pendle-dev-docs/Contracts/RouterStatic/ApiReference/MintRedeemFunctions.md","sourceDirName":"Contracts/RouterStatic/ApiReference","slug":"/Contracts/RouterStatic/ApiReference/MintRedeemFunctions","permalink":"/pendle-v2-dev/Contracts/RouterStatic/ApiReference/MintRedeemFunctions","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{"hide_table_of_contents":true},"sidebar":"pendleDevSidebar","previous":{"title":"Liquidity Functions","permalink":"/pendle-v2-dev/Contracts/RouterStatic/ApiReference/LiquidityFunctions"},"next":{"title":"PYLp Oracle","permalink":"/pendle-v2-dev/Contracts/Oracle/PYLpOracle"}}');var d=t(4848),s=t(8453);const i={hide_table_of_contents:!0},c="Mint & Redeem Simulation Functions",l={},h=[{value:"SY Mint / Redeem",id:"sy-mint--redeem",level:2},{value:"mintSyFromTokenStatic",id:"mintsyfromtokenstatic",level:3},{value:"getAmountTokenToMintSy",id:"getamounttokentomintsy",level:3},{value:"redeemSyToTokenStatic",id:"redeemsytotokenstatic",level:3},{value:"PY Mint / Redeem",id:"py-mint--redeem",level:2},{value:"mintPyFromSyStatic",id:"mintpyfromsystatic",level:3},{value:"mintPyFromTokenStatic",id:"mintpyfromtokenstatic",level:3},{value:"redeemPyToSyStatic",id:"redeempytosystatic",level:3},{value:"redeemPyToTokenStatic",id:"redeempytotokenstatic",level:3},{value:"PY Index Views",id:"py-index-views",level:2},{value:"pyIndexCurrentViewMarket",id:"pyindexcurrentviewmarket",level:3},{value:"pyIndexCurrentViewYt",id:"pyindexcurrentviewyt",level:3},{value:"Examples",id:"examples",level:2},{value:"Mint PT & YT from token \u2014 simulate then execute",id:"mint-pt--yt-from-token--simulate-then-execute",level:3},{value:"Redeem PT & YT to token \u2014 simulate then execute",id:"redeem-pt--yt-to-token--simulate-then-execute",level:3},{value:"Determine how much token to spend for a target SY amount",id:"determine-how-much-token-to-spend-for-a-target-sy-amount",level:3},{value:"Use pyIndex to value a PT/YT position",id:"use-pyindex-to-value-a-ptyt-position",level:3}];function o(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,s.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.header,{children:(0,d.jsx)(n.h1,{id:"mint--redeem-simulation-functions",children:"Mint & Redeem Simulation Functions"})}),"\n",(0,d.jsxs)(n.p,{children:["These functions come from the ",(0,d.jsx)(n.code,{children:"IPActionMintRedeemStatic"})," facet. They simulate every mint and redeem operation supported by the live Router, plus two view helpers for reading the current PY index."]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h2,{id:"sy-mint--redeem",children:"SY Mint / Redeem"}),"\n",(0,d.jsx)(n.h3,{id:"mintsyfromtokenstatic",children:"mintSyFromTokenStatic"}),"\n",(0,d.jsx)(n.p,{children:"Simulates minting SY from an input token."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function mintSyFromTokenStatic(address SY, address tokenIn, uint256 netTokenIn)\n    external\n    view\n    returns (uint256 netSyOut)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"SY"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"SY contract address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"tokenIn"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"Input token address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netTokenIn"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Exact token amount to mint with"})]})]})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netSyOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"SY received"})]})})]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h3,{id:"getamounttokentomintsy",children:"getAmountTokenToMintSy"}),"\n",(0,d.jsxs)(n.p,{children:["Inverse of ",(0,d.jsx)(n.code,{children:"mintSyFromTokenStatic"})," \u2014 returns how many tokens are required to mint a target amount of SY."]}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function getAmountTokenToMintSy(address SY, address tokenIn, uint256 netSyOut)\n    external\n    view\n    returns (uint256 netTokenIn)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"SY"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"SY contract address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"tokenIn"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"Input token address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netSyOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Target SY amount to receive"})]})]})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netTokenIn"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsxs)(n.td,{children:["Token amount required to mint ",(0,d.jsx)(n.code,{children:"netSyOut"})," SY"]})]})})]}),"\n",(0,d.jsxs)(n.p,{children:[(0,d.jsx)(n.strong,{children:"Use Case"}),'\nUseful for constructing "exact SY out" flows \u2014 e.g. when you need a precise SY amount before adding dual-sided liquidity.']}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h3,{id:"redeemsytotokenstatic",children:"redeemSyToTokenStatic"}),"\n",(0,d.jsx)(n.p,{children:"Simulates redeeming SY for an output token."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function redeemSyToTokenStatic(address SY, address tokenOut, uint256 netSyIn)\n    external\n    view\n    returns (uint256 netTokenOut)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"SY"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"SY contract address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"tokenOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"Desired output token address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netSyIn"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"SY amount to redeem"})]})]})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netTokenOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Token received"})]})})]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h2,{id:"py-mint--redeem",children:"PY Mint / Redeem"}),"\n",(0,d.jsx)(n.h3,{id:"mintpyfromsystatic",children:"mintPyFromSyStatic"}),"\n",(0,d.jsx)(n.p,{children:"Simulates minting PT and YT from SY."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function mintPyFromSyStatic(address YT, uint256 netSyToMint)\n    external\n    view\n    returns (uint256 netPYOut)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"YT"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"YT contract address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netSyToMint"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"SY amount to mint from"})]})]})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netPYOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"PT and YT received (equal amounts of each)"})]})})]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h3,{id:"mintpyfromtokenstatic",children:"mintPyFromTokenStatic"}),"\n",(0,d.jsx)(n.p,{children:"Simulates minting PT and YT directly from an input token (token \u2192 SY \u2192 PT+YT)."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function mintPyFromTokenStatic(address YT, address tokenIn, uint256 netTokenIn)\n    external\n    view\n    returns (uint256 netPyOut)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"YT"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"YT contract address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"tokenIn"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"Input token address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netTokenIn"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Token amount to mint from"})]})]})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netPyOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"PT and YT received"})]})})]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h3,{id:"redeempytosystatic",children:"redeemPyToSyStatic"}),"\n",(0,d.jsx)(n.p,{children:"Simulates redeeming PT and YT back to SY. Equal amounts of PT and YT must be provided."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function redeemPyToSyStatic(address YT, uint256 netPYToRedeem)\n    external\n    view\n    returns (uint256 netSyOut)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"YT"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"YT contract address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netPYToRedeem"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Amount of PT (and YT) to redeem"})]})]})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netSyOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"SY received"})]})})]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h3,{id:"redeempytotokenstatic",children:"redeemPyToTokenStatic"}),"\n",(0,d.jsx)(n.p,{children:"Simulates redeeming PT and YT directly to an output token (PT+YT \u2192 SY \u2192 token)."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function redeemPyToTokenStatic(address YT, uint256 netPYToRedeem, address tokenOut)\n    external\n    view\n    returns (uint256 netTokenOut)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"YT"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"YT contract address"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netPYToRedeem"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Amount of PT (and YT) to redeem"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"tokenOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"Desired output token address"})]})]})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"netTokenOut"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{child
1ren:"Token received"})]})})]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h2,{id:"py-index-views",children:"PY Index Views"}),"\n",(0,d.jsxs)(n.p,{children:["The PY index is the exchange rate between SY and PT/YT. It is used internally to price minting and redemption. These helpers let you read it without triggering a state-write (unlike the real ",(0,d.jsx)(n.code,{children:"pyIndexCurrent"})," which may update the index on-chain)."]}),"\n",(0,d.jsx)(n.h3,{id:"pyindexcurrentviewmarket",children:"pyIndexCurrentViewMarket"}),"\n",(0,d.jsx)(n.p,{children:"Returns the current PY index for a market without writing state."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function pyIndexCurrentViewMarket(address market) external view returns (uint256)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"market"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"Pendle market address"})]})})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Current PY index (18 decimals)"})]})})]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h3,{id:"pyindexcurrentviewyt",children:"pyIndexCurrentViewYt"}),"\n",(0,d.jsx)(n.p,{children:"Returns the current PY index for a given YT without writing state."}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-solidity",children:"function pyIndexCurrentViewYt(address yt) external view returns (uint256)\n"})}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Name"}),(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"yt"}),(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"address"})}),(0,d.jsx)(n.td,{children:"YT contract address"})]})})]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"Return Values"})}),"\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"Type"}),(0,d.jsx)(n.th,{children:"Description"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"uint256"})}),(0,d.jsx)(n.td,{children:"Current PY index (18 decimals)"})]})})]}),"\n",(0,d.jsxs)(n.p,{children:[(0,d.jsx)(n.strong,{children:"Use Case"}),"\nUse either index view to manually calculate the SY \u2194 PT/YT conversion rate. For example, ",(0,d.jsx)(n.code,{children:"netSyOut = netPYToRedeem * pyIndex / 1e18"}),"."]}),"\n",(0,d.jsx)(n.hr,{}),"\n",(0,d.jsx)(n.h2,{id:"examples",children:"Examples"}),"\n",(0,d.jsx)(n.admonition,{title:"Recommended: Use the Pendle API",type:"tip",children:(0,d.jsxs)(n.p,{children:["The examples below show direct RouterStatic usage. For most integrations, the ",(0,d.jsx)(n.a,{href:"../../../Backend/HostedSdk",children:"Pendle Hosted SDK / API"})," is the better choice \u2014 it handles approximation, limit-order filling, and zap routing automatically."]})}),"\n",(0,d.jsx)(n.h3,{id:"mint-pt--yt-from-token--simulate-then-execute",children:"Mint PT & YT from token \u2014 simulate then execute"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-typescript",children:'const tokenIn  = WSTETH_ADDRESS;\nconst amountIn = ethers.parseEther("1");\n\n// 1. Simulate\nconst netPyOut = await routerStatic.mintPyFromTokenStatic(YT_ADDRESS, tokenIn, amountIn);\n\nconsole.log(`Expected PT+YT out: ${ethers.formatEther(netPyOut)} each`);\n\n// 2. Execute\nawait IERC20(tokenIn).approve(ROUTER_ADDRESS, amountIn);\nawait router.mintPyFromToken(\n    signer.address,\n    YT_ADDRESS,\n    (netPyOut * 995n) / 1000n,  // minPyOut (0.5% slippage)\n    createTokenInputStruct(tokenIn, amountIn)\n);\n'})}),"\n",(0,d.jsx)(n.h3,{id:"redeem-pt--yt-to-token--simulate-then-execute",children:"Redeem PT & YT to token \u2014 simulate then execute"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-typescript",children:'const tokenOut = WSTETH_ADDRESS;\nconst pyAmount = ethers.parseEther("1");\n\n// 1. Simulate\nconst netTokenOut = await routerStatic.redeemPyToTokenStatic(YT_ADDRESS, pyAmount, tokenOut);\n\nconsole.log(`Expected token out: ${ethers.formatEther(netTokenOut)}`);\n\n// 2. Execute (both PT and YT must be approved in equal amounts)\nawait IERC20(PT_ADDRESS).approve(ROUTER_ADDRESS, pyAmount);\nawait IERC20(YT_ADDRESS).approve(ROUTER_ADDRESS, pyAmount);\nawait router.redeemPyToToken(\n    signer.address,\n    YT_ADDRESS,\n    pyAmount,\n    createTokenOutputStruct(tokenOut, (netTokenOut * 995n) / 1000n)\n);\n'})}),"\n",(0,d.jsx)(n.h3,{id:"determine-how-much-token-to-spend-for-a-target-sy-amount",children:"Determine how much token to 
1spend for a target SY amount"}),"\n",(0,d.jsxs)(n.p,{children:["Use ",(0,d.jsx)(n.code,{children:"getAmountTokenToMintSy"})," when you have a downstream requirement for a fixed SY quantity (e.g. dual-asset liquidity add)."]}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-typescript",children:'const targetSyOut = ethers.parseEther("1.5");\n\n// 1. How many tokens do I need?\nconst netTokenIn = await routerStatic.getAmountTokenToMintSy(SY_ADDRESS, WSTETH_ADDRESS, targetSyOut);\n\nconsole.log(`Need ${ethers.formatEther(netTokenIn)} wstETH to mint ${ethers.formatEther(targetSyOut)} SY`);\n\n// Sanity-check by simulating the forward direction\nconst syOutCheck = await routerStatic.mintSyFromTokenStatic(SY_ADDRESS, WSTETH_ADDRESS, netTokenIn);\nconsole.log(`Forward check: ${ethers.formatEther(syOutCheck)} SY`); // should \u2248 targetSyOut\n\n// 2. Execute\nawait IERC20(WSTETH_ADDRESS).approve(ROUTER_ADDRESS, netTokenIn);\nawait router.mintSyFromToken(\n    signer.address,\n    SY_ADDRESS,\n    (targetSyOut * 995n) / 1000n,           // minSyOut\n    createTokenInputStruct(WSTETH_ADDRESS, netTokenIn)\n);\n'})}),"\n",(0,d.jsx)(n.h3,{id:"use-pyindex-to-value-a-ptyt-position",children:"Use pyIndex to value a PT/YT position"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-typescript",children:'// Read current PY index (no state write)\nconst pyIndex = await routerStatic.pyIndexCurrentViewMarket(MARKET_ADDRESS);\n// pyIndex is an 18-decimal exchange rate: 1 SY = pyIndex PY units\n\n// Value 100 PT in SY terms\nconst ptBalance = ethers.parseEther("100");\nconst syValue = (ptBalance * ethers.parseEther("1")) / pyIndex;\nconsole.log(`100 PT \u2248 ${ethers.formatEther(syValue)} SY at current index`);\n'})})]})}function a(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(o,{...e})}):o(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.