User Methods

vEPOCH contract user methods

Methods

Add Reward Tokens

function addRewardTokens(uint256 _tokenAmount) external;

Description: Allows anyone to add reward tokens (which will be distributed proportionally)

Inputs:

  • _tokenAmount - The number of reward tokens to deposit

Calculate Rewards Earned

function calculateRewardsEarned(uint256 _depositId) external view returns (uint256);

Description: View function allowing computation of the total number of reward tokens earned for a given deposit ID.

Inputs:

  • _depositId - The deposit ID you wish to query rewards for

Claim Yield

function claimYield(uint256 _depositId) public;

Description: Allows deposit owners to claim reward tokens earned for a single deposit

Inputs:

  • _depositId - The deposit ID you wish to claim rewards/yield for

Claim Yield (multiple)

function claimYield(uint256[] calldata _depositIds) public;

Description: Allows deposit owners to claim reward tokens earned for multiple deposits at once

Inputs:

  • _depositIds - an array of deposit IDs you wish to claim rewards for

Calculate Ve Tokens

function calculateVeTokens(uint256 _tokenAmount, uint256 _duration) public pure returns(uint256);

Description: Returns the veTokens minted for a given tokenAmount and duration

Inputs:

  • _tokenAmount - The number of EPOCH-LP

  • _duration - The duration of the lock in seconds

Note: This function will return values for durations longer than the max deposit duration but this does not mean users can deposit for longer than the max deposit duration.

Deposit

function deposit(
    uint256 _tokenAmount, 
    uint32 _duration, 
    address _behalfOf
) external returns(uint256 _depositCount);

Description: Function used to enter the vEPOCH ecosystem. Allows depositing of EPOCH-LP for a given lock duration.

Inputs:

  • _tokenAmount - The number of EPOCH-LP tokens to deposit (in wei)

  • _duration - The duration to lock these tokens in seconds

  • _behalfOf - The address that will own this deposit

    • DANGER: The depositor will lose all control of vEPOCH and EPOCH-LP if this parameter is set to anything other than the depositor's address.

Withdraw Forfeit

function withdrawForfeit(
    uint256 _depositId, 
    uint256 _depositTokensToRemove
) external;

Description: Allows depositors to exit the system before their lock duration has ended by forfeiting some number of reward tokens. This method allows for partial withdrawals.

Inputs:

  • _depositId - The deposit ID to withdraw from

  • _depositTokenToRemove - The number of EPOCH-LP tokens to remove from the deposit (in wei)

Withdraw

function withdraw(uint256 _depositId, uint256 _tokenAmount) external;

Description: Allows depositors to exit the system after their lock duration has ended. There will be no reward tokens forfeit when using this function. This method allows for partial withdrawals.

Inputs:

  • _depositId - The deposit ID to withdraw from

  • _tokenAmount - The number of EPOCH-LP tokens to remove from the deposit (in wei)

Extend Deposit

function extendDeposit(uint256 _depositId, uint32 _secondsToExtend) external;

Description: Allows depositors to extend their deposit lock duration in exchange for more vEPOCH which increases reward distribution.

Inputs:

  • _depositID - The deposit ID to extend

  • _secondsToExtend - The number of seconds to extend this deposit by

Note: The deposit can never exceed the maximum lock duration.

Transfer Deposit Ownership

function transferDepositOwnership(uint256 _depositId, address _newOwner) external;

Description: Allows depositors to transfer the ownership of their deposit which includes both vEPOCH and the underlying EPOCH-LP that is locked in the contract.

Inputs:

  • _depositId - The deposit ID to transfer

  • _newOwner - The new owner of this deposit

DANGER: Once a deposit has been transferred, there is NO WAY to reverse this. Transferring ownership will irrevocably transfer BOTH vEPOCH and the underlying EPOCH-LP.

State Variables

Deposits

struct Deposit {
    address owner;
    uint32 depositTs;
    uint32 lockDuration;
    uint256 depositTokenBalance;
}
mapping(uint256 => Deposit) public deposits;

Input: Deposit ID

The contract can be queried by deposit ID to determine the owner, deposit timestamp, lock duration and deposit token balance (EPOCH-LP) of a given deposit.

Deposit Count

uint256 public depositCount;

Returns the number of deposits to date. This should be used with "deposits" above to retrieve all deposit data off-chain.

Max Deposit Duration

uint256 public maxDepositDuration = 730 days;

Returns the current maximum deposit duration.

The maximum deposit duration. This was initially set to 730 days but is currently set to 365 days.

Deposit Token

IERC20 public immutable depositToken;

Returns the address for the deposit token.

The deposit token is EPOCH-LP, an 80/20 EPOCH/WETH Balancer WeightedPool token.

Max Deposit Duration Locked

bool public maxDepositDurationLocked;

Returns true or false depending on whether the max deposit duration is locked permanently. If this returns true, the DAO (owner) will not be able to update the maximum deposit duration.

Authorised Locked

bool public authorisedLocked;

Returns true or false depending on whether the authorised feature is locked permanently. If this returns true, the DAO (owner) will not be able to toggle the authorised status of addresses.

Find out more about authorised in the admin methods.

Authorised

mapping(address => bool) public authorised;

Input: address

Returns true or false when provided with an address. This returned state determines whether an address is authorised to transfer vEPOCH.

Reward Token

IERC20Metadata public immutable rewardToken;

Returns the address for the reward token.

The reward token is EPOCH.

Reward Staking Power

mapping(uint256 => uint256) public rewardStakingPower;

Returns the staking power for a given deposit ID.

Input: Deposit ID

The vEPOCH reward distribution mechanism uses this value to determine the proportional share a given deposit should earn when rewards are distributed. Note that addresses do not earn proportionally but instead, deposits earn proportionally. The owner of a given deposit is then allowed to claim these reward tokens.

The returned value from this function is equivalent to the number of vEPOCH tokens minted for a given deposit.

Reward Tokens Claimed

mapping(uint256 => uint256) public rewardTokensClaimed;

This mapping will return the number of reward tokens claimed from each deposit ID.

Input: Deposit ID

This variable is used in the contract to compute the number of reward tokens that must be paid back by a depositor if they wish to withdraw forfeit.

Last updated