Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ApyUSDRateView

Git Source

Inherits: EInvalidAddress

Title: ApyUSDRateView

View contract that computes the current APY for an ApyUSD vault from its total assets and the vesting contract's yield rate (unvested amount per vesting period remaining).

Vault is set at deployment. Yield per second = unvestedAmount() / vestingPeriodRemaining(). Returns 0 when totalAssets is zero, vesting is not set, or vesting period remaining is zero. Values returned by apr() and apy() are approximations and may include rounding errors due to integer division and fixed-point math.

State Variables

SECONDS_PER_YEAR

Seconds per year (365.25 days) for annualizing the yield rate

uint256 public constant SECONDS_PER_YEAR = 31_557_600

vault

The ApyUSD vault address this view reads from

address public immutable vault

Functions

constructor

Sets the vault address at deployment

constructor(address vault_) ;

Parameters

NameTypeDescription
vault_addressAddress of the ApyUSD vault (must not be zero)

annualizedYield

Returns the annualized yield (unvested per second × SECONDS_PER_YEAR)

function annualizedYield() public view returns (uint256 annualYield);

Returns

NameTypeDescription
annualYielduint256Annualized yield in asset units, or 0 if no vesting or zero period remaining

apr

Returns the current APR as an 18-decimal fraction (e.g. 0.05e18 = 5%)

Approximate; rounding may occur in annualizedYield and in the division by totalAssets.

function apr() public view returns (uint256 annualRate);

Returns

NameTypeDescription
annualRateuint256APR or 0 when totalAssets is zero, vesting is not set, or period remaining is zero

apy

Returns the current APY as an 18-decimal fraction (e.g. 0.05e18 = 5%)

Assumes the annual rate is compounded monthly based on monthly dividend yields. Approximate; rounding may occur in apr(), in base computation, and in rpow.

function apy() public view returns (uint256 annualYield);

Returns

NameTypeDescription
annualYielduint256APY or 0 when annualRate is zero