LinearVestV0
Inherits: AccessManaged, IVesting
Title: LinearVestV0
Contract that receives yield deposits and vests them linearly over a configurable period
Allows yield distributors to deposit yield, which vests linearly over time. Only vault contract can transfer vested yield. New deposits reset the vesting period. Features:
- Linear vesting over configurable period
- Vesting period resets on new deposits (adds to existing unvested amount)
- Only vault can transfer vested yield
- Access control via AccessManager
State Variables
asset
The asset token (apxUSD) held in vesting
IERC20 public immutable asset
vestingAmount
Total amount currently vesting, including any newlyVestedAmount() that has not yet been accrued to the fullyVestedAmount. This amount is updated on depositYield and setVestingPeriod.
To calculate the current annualizedYield() or apy() use the ApyUSDRateView contract.
uint256 public vestingAmount
fullyVestedAmount
Total amount that has been fully vested but not yet transferred to the beneficiary
uint256 public fullyVestedAmount
lastDepositTimestamp
Timestamp of the last deposit (when vesting period was reset)
uint256 public lastDepositTimestamp
lastTransferTimestamp
Timestamp of the last transfer (when vested yield was transferred to the beneficiary)
uint256 public lastTransferTimestamp
vestingPeriod
Vesting period in seconds
uint256 public vestingPeriod
beneficiary
Beneficiary contract address (authorized for transfers)
address public beneficiary
Functions
onlyBeneficiary
Ensures only vault contract can call transfer functions
This is only applied to the pullVestedYield function, so it is more efficient to inline
modifier onlyBeneficiary() ;
constructor
Initializes the LinearVestV0 contract
constructor(address _asset, address _authority, address _beneficiary, uint256 _vestingPeriod)
AccessManaged(_authority);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the asset token (apxUSD) |
_authority | address | Address of the AccessManager contract |
_beneficiary | address | Address of the beneficiary contract |
_vestingPeriod | uint256 | Initial vesting period in seconds |
vestingPeriodStart
Returns the start of the current vesting period
function vestingPeriodStart() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Start of the current vesting period |
vestingPeriodEnd
Returns the end of the current vesting period
function vestingPeriodEnd() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | End of the current vesting period |
vestingPeriodRemaining
Returns the remaining time in the current vesting period
function vestingPeriodRemaining() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Remaining time in the current vesting period |
vestedAmount
Returns the amount of yield that has vested and is available, including fully vested and newly vested yield.
function vestedAmount() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Amount of vested yield including fully vested and newly vested yield |
newlyVestedAmount
Returns the amount of yield that has been newly vested since the last transfer
function newlyVestedAmount() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Amount of newly vested yield |
unvestedAmount
Returns the amount of yield that is still vesting
function unvestedAmount() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Amount of unvested yield |
depositYield
Deposits yield into the vesting contract
Resets the vesting period, adding vested yield to the fullyVestedAmount and the new deposit amount to the vestingAmount.
function depositYield(uint256 amount) external override restricted;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount of yield to deposit |
pullVestedYield
Transfers all vested yield to the vault
Only callable by vault contract. No-op if no vested yield available.
function pullVestedYield() external override onlyBeneficiary;
setVestingPeriod
Sets the vesting period
Only callable through AccessManager with ADMIN_ROLE
function setVestingPeriod(uint256 newPeriod) external override restricted;
Parameters
| Name | Type | Description |
|---|---|---|
newPeriod | uint256 | New vesting period in seconds |
setBeneficiary
Sets the beneficiary address. This is used when initializing the vesting contract, to set the beneficiary address and when migrating to a new vesting contract.
Only callable through AccessManager with ADMIN_ROLE
function setBeneficiary(address newBeneficiary) external override restricted;
Parameters
| Name | Type | Description |
|---|---|---|
newBeneficiary | address | New beneficiary contract address |