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

LinearVestV0

Git Source

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

NameTypeDescription
_assetaddressAddress of the asset token (apxUSD)
_authorityaddressAddress of the AccessManager contract
_beneficiaryaddressAddress of the beneficiary contract
_vestingPerioduint256Initial vesting period in seconds

vestingPeriodStart

Returns the start of the current vesting period

function vestingPeriodStart() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256Start of the current vesting period

vestingPeriodEnd

Returns the end of the current vesting period

function vestingPeriodEnd() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256End of the current vesting period

vestingPeriodRemaining

Returns the remaining time in the current vesting period

function vestingPeriodRemaining() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256Remaining 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

NameTypeDescription
<none>uint256Amount 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

NameTypeDescription
<none>uint256Amount of newly vested yield

unvestedAmount

Returns the amount of yield that is still vesting

function unvestedAmount() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256Amount 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

NameTypeDescription
amountuint256Amount 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

NameTypeDescription
newPerioduint256New 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

NameTypeDescription
newBeneficiaryaddressNew beneficiary contract address