跳转至主要内容

APY 计算

本文档包含用于计算 Pendle 市场 APY 的公式。

以主网市场 0x107a2e3cd2bb9a32b9ee2e4d51143149f8367eba 为示例。

变量说明

变量名说明
market\text{market}0x107a2e3cd2bb9a32b9ee2e4d51143149f8367eba
sy\text{sy}0xC4ed348c56223C5953939e932E315F9d72Cd83fF
lpPriceUsd\text{lpPriceUsd}LP 代币的 USD 价格
syPriceUsd\text{syPriceUsd}SY 代币的 USD 价格
pendlePriceUSD\text{pendlePriceUSD}PENDLE 代币的 USD 价格
duration\text{duration}用于计算 APY 的时间间隔。例如 duration=7\text{duration}=7 表示基于过去 7 天的数据计算 APY。系统默认使用 7 天。
syIndex\text{syIndex}SY 代币的当前指数,可从 SY 合约的 exchangeRate 函数读取
prevSyIndex\text{prevSyIndex}duration\text{duration} 天前的 syIndex\text{syIndex}
yearsToExpiry\text{yearsToExpiry}市场到期的年数

底层 APY

underlyingApy=underlyingInterestApy+underlyingRewardApr\text{underlyingApy} = \text{underlyingInterestApy} + \text{underlyingRewardApr}

underlyingApy\text{underlyingApy} 由两部分组成,各自计算方法如下:

底层利息 APY(UnderlyingInterestApy)

interestMultiple=syIndexprevSyIndex\text{interestMultiple} = \dfrac{\text{syIndex}}{\text{prevSyIndex}}

underlyingInterestApy=interestMultiple365days1\text{underlyingInterestApy} = \text{interestMultiple}^{\frac{365}{\text{days}}} - 1

  • 说明:
    • underlyingInterestApy\text{underlyingInterestApy} 估算 SY 代币底层协议利息的当前 APY。利息 = 以底层资产计价的收益,默认自动复利。
    • 此公式取过去 7 天的历史 APY,并外推为年化收益率。

底层奖励 APR(UnderlyingRewardApr)

  • 对于每种奖励代币:

    • prevRewardIndex=\text{prevRewardIndex} = duration\text{duration} 天前的 rewardIndex\text{rewardIndex}

    • dailyRewardPerSy=rewardIndexprevRewardIndexdays\text{dailyRewardPerSy} = \dfrac{\text{rewardIndex} - \text{prevRewardIndex}}{\text{days}}

    • dailyRewardYield=dailyRewardPerSyrewardPricesyPrice\text{dailyRewardYield} = \text{dailyRewardPerSy} * \dfrac{\text{rewardPrice}}{\text{syPrice}}

    • tokenRewardApr=dailyRewardYield×365\text{tokenRewardApr} = \text{dailyRewardYield} \times 365

  • underlyingRewardApr=tokenRewardApr\text{underlyingRewardApr} = \sum \text{tokenRewardApr}

  • 说明:

    • underlyingRewardApr\text{underlyingRewardApr} 估算 SY 代币底层协议奖励的当前 APR。奖励 = 以奖励代币计价的收益,默认不自动复利。
    • 此公式取过去 7 天的历史奖励速率,并外推为年化收益率。
    • 每种奖励代币有独立的奖励速率,对应独立的 APR,求和得到所有奖励代币的总 APR。

隐含 APY(impliedAPY)

apy=elnImpliedYield1\text{apy} = e^{\text{lnImpliedYield}} - 1

  • lnImpliedYield\text{lnImpliedYield} 可从市场合约的 readState 函数读取,请注意需除以 1e18 进行缩放。

兑换手续费 APY(SwapFeeApy)

SwapFeeApy

swapFeeApy\text{swapFeeApy} 是 LP 持有者从池子兑换手续费中获得的 APY。

poolValue=lpPriceUsdtotalSupply\text{poolValue} = \text{lpPriceUsd} * \text{totalSupply}

swapFeeForLpHolder=explicitSwapFee20%+implicitSwapFee\text{swapFeeForLpHolder} = \text{explicitSwapFee} * 20\% + \text{implicitSwapFee}

swapFeeRateForLpHolder=swapFeeForLpHoldersyPriceUsdpoolValue\text{swapFeeRateForLpHolder} = \dfrac{\text{swapFeeForLpHolder} * \text{syPriceUsd}}{\text{poolValue}}

swapFeeApy=(1+swapFeeRateForLpHolder)365durations1\text{swapFeeApy} = (1 + \text{swapFeeRateForLpHolder})^\frac{{365}}{\text{durations}} - 1

  • 说明:
    • LP 持有者获得显式兑换手续费的 20% 和全部隐式兑换手续费
    • swapFeeRateForLpHolder\text{swapFeeRateForLpHolder} 是 LP 持有者以 USD 计算获得的手续费比率,再外推得到 swapFeeApyswapFeeApy

做多收益 APY(longYieldApy):

interestReturns=(1+underlyingInterestApy)yearsToExpiry1\text{interestReturns} = (1+\text{underlyingInterestApy})^{\text{yearsToExpiry}} - 1 rewardsReturns=underlyingRewardApyyearsToExpiry\text{rewardsReturns} = \text{underlyingRewardApy} * \text{yearsToExpiry}

ytReturns=interestReturns+rewardsReturns\text{ytReturns} = \text{interestReturns} + \text{rewardsReturns} ytReturnsAfterFee=holdYtReturns×95%\text{ytReturnsAfterFee} = \text{holdYtReturns} \times 95\%

longYieldApy=ytReturnsAfterFeeytPriceInAsset1yearsToExpiry1\text{longYieldApy}=\dfrac{\text{ytReturnsAfterFee}}{\text{ytPriceInAsset}}^{\frac{1}{\text{yearsToExpiry}}}-1

  • 说明:
    • interestReturns\text{interestReturns}
      • 持有 1 个 YT 从现在到到期日,以会计资产计价的利息收益
    • rewardsReturns\text{rewardsReturns}
      • 持有 1 个 YT 从现在到到期日,以会计资产计价的奖励收益
    • ytReturnsAfterFee\text{ytReturnsAfterFee}
      • YT 收益收取 5% 手续费,因此需乘以 95%
    • longYieldApy\text{longYieldApy}
      • 即今日买入 YT 并持有至到期日、假设底层 APY 保持不变的 APY。可能为负(若 YT 收益总和低于 YT 购买价格)
      • ytPriceInAsset\text{ytPriceInAsset} 出发,经过 yearsToExpiry\text{yearsToExpiry} 年后得回 ytReturnsWithFee\text{ytReturnsWithFee},再换算为年化即得 APY

effectiveImpliedApy\text{effectiveImpliedApy}(实际隐含 APY)

实际隐含 APY 是基于用户实际兑换汇率计算的 APY。

计算 effectiveImpliedApy\text{effectiveImpliedApy} 需要获取 ptExchangeRate\text{ptExchangeRate}:即 1 个底层资产可兑换的 PT 数量。

共有三种兑换类型:

  • PT ↔ YT 以外的任意代币
  • YT ↔ PT 以外的任意代币
  • PT ↔ YT

每种类型计算 ptExchangeRateptExchangeRate 的方式不同:

PT ↔ 任意代币

  • underlying\text{underlying}:以底层代币计价的输入/输出代币数量
  • ptAmount\text{ptAmount}:PT 输入/输出数量

ptExchangeRate=ptAmountunderlying\text{ptExchangeRate} = \dfrac{\text{ptAmount}}{\text{underlying}}

YT ↔ 任意代币

  • ytAmount\text{ytAmount}:YT 输入/输出数量

ptExchangeRate=11underlyingytAmount\text{ptExchangeRate} = \dfrac{1}{1 - \dfrac{\text{underlying}}{\text{ytAmount}}}

PT ↔ YT

ptExchangeRate=1+ptAmountytAmount\text{ptExchangeRate} = 1 + \dfrac{\text{ptAmount}}{\text{ytAmount}}

ptExchangeRate\text{ptExchangeRate} 可按如下公式计算 effectiveImpliedApy:

effectiveImpliedApy=ptExchangeRate365daysToExpiry1\text{effectiveImpliedApy} = \text{ptExchangeRate}^{\frac{365}{\text{daysToExpiry}}} - 1