本文档包含用于计算 Pendle 市场 APY 的公式。
以主网市场 0x107a2e3cd2bb9a32b9ee2e4d51143149f8367eba 为示例。
变量说明
| 变量名 | 说明 |
|---|
| market | 0x107a2e3cd2bb9a32b9ee2e4d51143149f8367eba |
| sy | 0xC4ed348c56223C5953939e932E315F9d72Cd83fF |
| lpPriceUsd | LP 代币的 USD 价格 |
| syPriceUsd | SY 代币的 USD 价格 |
| pendlePriceUSD | PENDLE 代币的 USD 价格 |
| duration | 用于计算 APY 的时间间隔。例如 duration=7 表示基于过去 7 天的数据计算 APY。系统默认使用 7 天。 |
| syIndex | SY 代币的当前指数,可从 SY 合约的 exchangeRate 函数读取 |
| prevSyIndex | duration 天前的 syIndex |
| yearsToExpiry | 市场到期的年数 |
底层 APY
underlyingApy=underlyingInterestApy+underlyingRewardApr
underlyingApy 由两部分组成,各自计算方法如下:
底层利息 APY(UnderlyingInterestApy)
interestMultiple=prevSyIndexsyIndex
underlyingInterestApy=interestMultipledays365−1
- 说明:
- underlyingInterestApy 估算 SY 代币底层协议利息的当前 APY。利息 = 以底层资产计价的收益,默认自动复利。
- 此公式取过去 7 天的历史 APY,并外推为年化收益率。
底层奖励 APR(UnderlyingRewardApr)
隐含 APY(impliedAPY)
apy=elnImpliedYield−1
- lnImpliedYield 可从市场合约的 readState 函数读取,请注意需除以 1e18 进行缩放。
兑换手续费 APY(SwapFeeApy)
SwapFeeApy
swapFeeApy 是 LP 持有者从池子兑换手续费中获得的 APY。
poolValue=lpPriceUsd∗totalSupply
swapFeeForLpHolder=explicitSwapFee∗20%+implicitSwapFee
swapFeeRateForLpHolder=poolValueswapFeeForLpHolder∗syPriceUsd
swapFeeApy=(1+swapFeeRateForLpHolder)durations365−1
- 说明:
- LP 持有者获得显式兑换手续费的 20% 和全部隐式兑换手续费
- swapFeeRateForLpHolder 是 LP 持有者以 USD 计算获得的手续费比率,再外推得到 swapFeeApy
做多收益 APY(longYieldApy):
interestReturns=(1+underlyingInterestApy)yearsToExpiry−1
rewardsReturns=underlyingRewardApy∗yearsToExpiry
ytReturns=interestReturns+rewardsReturns
ytReturnsAfterFee=holdYtReturns×95%
longYieldApy=ytPriceInAssetytReturnsAfterFeeyearsToExpiry1−1
- 说明:
- interestReturns:
- 持有 1 个 YT 从现在到到期日,以会计资产计价的利息收益
- rewardsReturns:
- 持有 1 个 YT 从现在到到期日,以会计资产计价的奖励收益
- ytReturnsAfterFee:
- longYieldApy:
- 即今日买入 YT 并持有至到期日、假设底层 APY 保持不变的 APY。可能为负(若 YT 收益总和低于 YT 购买价格)
- 从 ytPriceInAsset 出发,经过 yearsToExpiry 年后得回 ytReturnsWithFee,再换算为年化即得 APY
effectiveImpliedApy(实际隐含 APY)
实际隐含 APY 是基于用户实际兑换汇率计算的 APY。
计算 effectiveImpliedApy 需要获取 ptExchangeRate:即 1 个底层资产可兑换的 PT 数量。
共有三种兑换类型:
- PT ↔ YT 以外的任意代币
- YT ↔ PT 以外的任意代币
- PT ↔ YT
每种类型计算 ptExchangeRate 的方式不同:
PT ↔ 任意代币
- underlying:以底层代币计价的输入/输出代币数量
- ptAmount:PT 输入/输出数量
ptExchangeRate=underlyingptAmount
YT ↔ 任意代币
- ytAmount:YT 输入/输出数量
ptExchangeRate=1−ytAmountunderlying1
PT ↔ YT
ptExchangeRate=1+ytAmountptAmount
由 ptExchangeRate 可按如下公式计算 effectiveImpliedApy:
effectiveImpliedApy=ptExchangeRatedaysToExpiry365−1