LogoLogo
User DocsDeveloper DocsHow-To Guides
  • ➡️Start Here
  • 🚧Disclaimer
  • User Docs
    • Introduction
    • Fund Overview
    • zVLT
    • Tranches
    • ZVE Token
  • How-To Guides
    • Complete KYC/KYB
    • Mint Tranche Tokens
    • Stake Tranche Tokens
  • Developer Docs
    • Contract Addresses
    • Core Contracts
      • ZivoeDAO.sol
      • ZivoeGlobals.sol
      • ZivoeGovernorV2.sol
      • ZivoeITO.sol
      • ZivoeLocker.sol
      • ZivoeMath.sol
      • ZivoeRewards.sol
      • ZivoeRewardsVesting.sol
      • ZivoeToken.sol
      • ZivoeTranches.sol
      • ZivoeTrancheToken.sol
      • ZivoeYDL.sol
      • ZivoeVault.sol
      • ZivoeRouter.sol
    • Lockers
      • OCC_Modular.sol
      • OCE_ZVE.sol
      • OCL_ZVE.sol
      • OCR_Modular.sol
      • OCT_DAO.sol
      • OCT_Convert.sol
      • OCT_YDL.sol
      • OCT_ZVL.sol
      • OCY_Convex_A.sol
      • OCY_Convex_B.sol
      • OCY_Convex_C.sol
      • OCY_OUSD.sol
      • ZivoeSwapper.sol
  • Official Links
    • Audits
    • Website
    • Twitter
    • Telegram
    • Blog
  • Terms
    • Terms Of Use / Privacy Policy
    • Reg S Compliance
Powered by GitBook

Zivoe Finance - Official Documentation

On this page
  • Introduction
  • Sections
  • Read Functions
  • Write Functions
  • Events
  1. Developer Docs
  2. Core Contracts

ZivoeRewardsVesting.sol

Vesting $ZVE Linearly

PreviousZivoeRewards.solNextZivoeToken.sol

Last updated 11 months ago

Introduction

This contract facilitates staking and yield distribution, as well as vesting tokens.

This contract has the following responsibilities:

  • Allows creation of vesting schedules (and revocation) for "vestingToken".

  • Allows unstaking of vested tokens.

  • Allows claiming yield distributed / "deposited" to this contract.

  • Allows multiple assets to be added as "rewardToken" for distributions (except for "vestingToken").

  • Vests rewardTokens linearly overtime to stakers.

State Variables

Type
Name
Description

address

GBL

The ZivoeGlobals contract.

address

vestingToken

The token vesting, in this case Zivoe ($ZVE).

address[]

rewardTokens

Array of ERC20 tokens distributed as rewards (if present).

uint256

vestingTokenAllocated

The amount of vestingToken currently allocated.

uint256

_totalSupply

Total supply of (non-transferrable) LP tokens for reards contract.

rewardData

Contains rewards information for each rewardToken.

mapping(address => bool)

vestingScheduleSet

Tracks if a wallet has been assigned a schedule.

vestingScheduleOf

Tracks the vesting schedule of accounts.

mapping(address => mapping(address => (uint256))

accountRewardPerTokenPaid

The order is account -> rewardAsset -> amount.

mapping(address => mapping(address => (uint256))

rewards

The order is account -> rewardAsset -> amount.

mapping(address => uint256)

_balances

Contains LP token balance of each account (is 1:1 ratio with amount deposited).

IERC20

stakingToken

IERC20 wrapper for the stakingToken (deposited to receive LP tokens).

Reward

This struct stores information for reward tokens.

Type
Name
Description

uint256

rewardsDuration

How long rewards take to vest, e.g. 30 days.

uint256

periodFinish

When current rewards will finish vesting.

uint256

rewardRate

Rewards emitted per second.

uint256

lastUpdateTime

Last time this data struct was updated.

uint256

rewardPerTokenStored

Last snapshot of rewardPerToken taken.

VestingSchedule

This struct stores information for vesting schedules.

Type
Name
Description

uint256

start

The block.timestamp at which tokens will start vesting.

uint256

cliff

The block.timestamp at which tokens are first claimable.

uint256

end

The block.timestamp at which tokens will stop vesting (finished).

uint256

totalVesting

The total amount to vest.

uint256

totalWithdrawn

The total amount withdrawn so far.

uint256

vestingPerSecond

The amount of vestingToken that vests per second.

bool

revokable

Whether or not this vesting schedule can be revoked.

Sections

Read Functions

  • balanceOf() - Returns the amount of tokens owned by "account", received when depositing via stake().

  • getRewardForDuration() - Returns the total amount of rewards being distributed to everyone for current rewardsDuration.

  • totalSupply() - Returns the amount of tokens in existence; these are minted and burned when depositing or withdrawing.

  • viewAccountRewardPerTokenPaid() - Returns the last snapshot of rewardPerTokenStored taken for a reward asset.

  • viewRewards() - Returns the rewards earned of a specific rewardToken for an address.

  • viewSchedule() - Provides information for a vesting schedule. See VestingSchedule

  • amountWithdrawable() - Returns the amount of $ZVE tokens a user can withdraw.

  • earned() - Provides information on the rewards available for claim.

  • lastTimeRewardApplicable() - Helper function for assessing distribution timelines.

  • rewardPerToken() - Cumulative amount of rewards distributed per LP token.

Write Functions

  • addReward() - Adds a new asset as a reward to this contract.

  • depositReward() - Deposits a reward to this contract for distribution.

  • fullWithdraw() - Simultaneously calls withdraw() and getRewards() for convenience.

  • createVestingSchedule() - Sets the vestingSchedule for an account.

  • revokeVestingSchedule() - Ends vesting schedule for a given account (if revokable).

  • getRewards() - Claim rewards for all possible _rewardTokens.

  • withdraw() - Withdraws the specified amount of stakingToken from this contract.

Events

  • RewardAdded()

  • RewardDeposited()

  • RewardDistributed()

  • Staked()

  • VestingScheduleCreated()

  • VestingScheduleRevoked()

  • Withdrawn()

Read Functions

balanceOf()

Returns the amount of tokens owned by "account", received when depositing via stake().

function balanceOf(
    address account
) external view returns (uint256 amount);
Type
Name
Description

address

account

The account to view information of.

Returns

Type
Name
Description

uint256

amount

The amount of tokens owned by "account".

getRewardForDuration()

Returns the total amount of rewards being distributed to everyone for current rewardsDuration.

function getRewardForDuration(
    address _rewardsToken
) external view returns (uint256 amount);
Type
Name
Description

address

_rewardsToken

The asset that's being distributed.

Returns

Type
Name
Description

uint256

amount

The amount of rewards being distributed.

totalSupply()

Returns the amount of tokens in existence; these are minted and burned when depositing or withdrawing.

function totalSupply() external view returns (uint256 amount);

Returns

Type
Name
Description

uint256

amount

The amount of tokens in existence.

viewAccountRewardPerTokenPaid()

Returns the last snapshot of rewardPerTokenStored taken for a reward asset.

function viewAccountRewardPerTokenPaid(
    address account, 
    address rewardAsset
) external view returns (uint256 amount);
Type
Name
Description

address

account

The account to view information of.

address

rewardAsset

The reward token for which we want to return the rewardPerTokenstored.

Returns

Type
Name
Description

uint256

amount

The latest up-to-date value of rewardPerTokenStored.

viewRewards()

Returns the rewards earned of a specific rewardToken for an address.

function viewRewards(
    address account,
    address rewardAsset
) external view returns (uint256 amount);
Type
Name
Description

address

account

The account to view information of.

address

rewardAsset

The asset earned as a reward.

Returns

Type
Name
Description

uint256

amount

The amount of rewards earned.

viewSchedule()

Provides information for a vesting schedule. See VestingSchedule

function viewSchedule(address account) external view returns (
    uint256 start, 
    uint256 cliff, 
    uint256 end, 
    uint256 totalVesting, 
    uint256 totalWithdrawn, 
    uint256 vestingPerSecond, 
    bool revokable
);
Type
Name
Description

address

account

The account to view information of.

Returns

Type
Name
Description

uint256

start

The block.timestamp at which tokens will start vesting.

uint256

cliff

The block.timestamp at which tokens are first claimable.

uint256

end

The block.timestamp at which tokens will stop vesting (finished).

uint256

totalVesting

The total amount to vest.

uint256

totalWithdrawn

The total amount withdrawn so far.

uint256

vestingPerSecond

The amount of vestingToken that vests per second.

bool

revokable

Whether or not this vesting schedule can be revoked.

amountWithdrawable()

Returns the amount of $ZVE tokens a user can withdraw.

function amountWithdrawable(
    address account
) public view returns (uint256 amount);
Type
Name
Description

address

account

The account to be withdrawn from.

Returns

Type
Name
Description

uint256

amount

Withdrawable amount of $ZVE tokens.

earned()

Provides information on the rewards available for claim.

function earned(
    address account, 
    address _rewardsToken
) public view returns (uint256 amount);
Type
Name
Description

address

account

The account to view information of.

address

_rewardsToken

The asset that's being distributed.

Returns

Type
Name
Description

uint256

amount

The amount of rewards earned.

lastTimeRewardApplicable()

Helper function for assessing distribution timelines.

function lastTimeRewardApplicable(
    address _rewardsToken
) public view returns (uint256 timestamp); 
Type
Name
Description

address

_rewardsToken

The asset that's being distributed.

Returns

Type
Name
Description

uint256

timestamp

The most recent time (in UNIX format) at which rewards are available for distribution.

rewardPerToken()

Cumulative amount of rewards distributed per LP token.

function rewardPerToken(
    address _rewardsToken
) public view returns (uint256 amount);
Type
Name
Description

address

_rewardsToken

The asset that's being distributed.

Returns

Type
Name
Description

uint256

amount

The cumulative amount of rewards distributed per LP token.

Write Functions

addReward()

Adds a new asset as a reward to this contract.

function addReward(
    address _rewardsToken, 
    uint256 _rewardsDuration
) external;
Type
Name
Description

address

_rewardsToken

The asset that's being distributed

uint256

_rewardsDuration

How long rewards take to vest, e.g. 30 days (denoted in seconds).

Emits the RewardAdded() event

depositReward()

Deposits a reward to this contract for distribution.

function depositReward(
    address _rewardsToken, 
    uint256 reward
) external updateReward(address(0)) nonReentrant;
Type
Name
Description

address

_rewardsToken

The asset that's being distributed.

uint256

reward

The amount of the _rewardsToken to deposit.

Emits the RewardDeposited() event

fullWithdraw()

Simultaneously calls withdraw() and getRewards() for convenience.

function fullWithdraw() external;

Emits the Withdrawn() and RewardDistributed() event(s)

createVestingSchedule()

Sets the vestingSchedule for an account.

function createVestingSchedule(
    address account,
    uint256 daysToCliff, 
    uint256 daysToVest, 
    uint256 amountToVest, 
    bool revokable
) external onlyZVLorITO;
Type
Name
Description

address

account

The account vesting $ZVE

uint256

daysToCliff

The number of days before vesting is claimable (a.k.a. cliff period).

uint256

daysToVest

The number of days for the entire vesting period, from beginning to end.

uint256

amountToVest

The amount of tokens being vested.

bool

revokable

If the vested amount can be revoked.

Emits the VestingScheduleCreated() and Staked() event

revokeVestingSchedule()

Ends vesting schedule for a given account (if revokable).

function revokeVestingSchedule(
    address account
) external updateReward(account) onlyZVLOrITO nonReentrant;
Type
Name
Description

address

account

The acount to revoke a vesting schedule for.

Emits the VestingScheduleRevoked() event

getRewards()

Claim rewards for all possible _rewardTokens.

function getRewards() public updateReward(_msgSender());

Emits the RewardDistributed() event

withdraw()

Withdraws the specified amount of stakingToken from this contract.

function withdraw(uint256 amount) public nonReentrant updateReward(_msgSender());
Type
Name
Description

uint256

amount

The amount of the _rewardsToken to withdraw.

Emits the Withdrawn() event

Events

RewardAdded()

Emitted during addReward()

event RewardAdded(address indexed reward);
Type
Indexed
Name
Description

address

True

reward

The asset that's being distributed.

RewardDeposited()

Emitted during depositReward()

event RewardDeposited(
    address indexed reward, 
    uint256 amount, 
    address indexed depositor
);
Type
Indexed
Name
Description

address

True

reward

The asset that's being deposited.

uint256

False

amount

The amount deposited.

address

True

depositor

The _msgSender() who deposited said reward.

RewardDistributed()

Emitted during ZivoeRewardsVesting.sol

event RewardDistributed(
    address indexed account, 
    address indexed rewardsToken, 
    uint256 reward
);
Type
Indexed
Name
Description

address

True

account

The account receiving a reward.

address

True

rewardsToken

The ERC20 asset distributed as a reward.

uint256

False

reward

The amount of "rewardsToken" distributed.

Staked()

Emitted during createVestingSchedule()

event Staked(address indexed account, uint256 amount);
Type
Indexed
Name
Description

address

True

account

The account staking "stakingToken".

uint256

False

amount

The amount of "stakingToken" staked.

VestingScheduleCreated()

Emitted during createVestingSchedule()

event VestingScheduleCreated(
    address indexed account, 
    uint256 start, 
    uint256 cliff, 
    uint256 end, 
    uint256 totalVesting, 
    uint256 vestingPerSecond, 
    bool revokable
);
Type
Indexed
Name
Description

address

True

account

The account that was given a vesting schedule.

uint256

False

start

The block.timestamp at which tokens will start vesting.

uint256

False

cliff

The block.timestamp at which tokens are first claimable.

uint256

False

end

The block.timestamp at which tokens will stop vesting (finished).

uint256

False

totalVesting

The total amount to vest.

uint256

False

vestingPerSecond

The amount of vestingToken that vests per second.

bool

False

revokable

Whether or not this vesting schedule can be revoked.

VestingScheduleRevoked()

Emitted during revokeVestingSchedule()

event VestingScheduleRevoked(
    address indexed account, 
    uint256 amountRevoked, 
    uint256 cliff, 
    uint256 end, 
    uint256 totalVesting, 
    bool revokable
);
Type
Indexed
Name
Description

address

True

account

The account that was revoked a vesting schedule.

uint256

False

amountRevoked

The amount of tokens revoked.

uint256

False

cliff

The updated value for cliff.

uint256

False

end

The updated value for end.

uint256

False

totalVesting

The total amount to vested (claimable).

bool

False

revokable

The final revokable status of schedule (always false after revocation).

Withdrawn()

Emitted during withdraw()

event Withdrawn(address indexed account, uint256 amount);
Type
Indexed
Name
Description

address

True

account

The account withdrawing "stakingToken".

uint256

False

amount

The amount of "stakingToken" to withdraw.

mapping(address => )

mapping(address => )

Reward
VestingSchedule