ApyUSDRateView
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
| Name | Type | Description |
|---|---|---|
vault_ | address | Address 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
| Name | Type | Description |
|---|---|---|
annualYield | uint256 | Annualized 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
| Name | Type | Description |
|---|---|---|
annualRate | uint256 | APR 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
| Name | Type | Description |
|---|---|---|
annualYield | uint256 | APY or 0 when annualRate is zero |