EpsStaker allows users to stake EPS in order to receive a portion of the trade fees generated by the Ellipsis platform. It is loosely based on the Synthetix staking rewards contract.
You can view the source code for
EpsStaker on Github.
stakingToken() returns (address)
The address of the token staked within this contract (EPS).
rewardTokens(uint256 i) returns (address)
An array of addresses for reward tokens distributed by the contract. All stakers receive each reward token porportionally to the amount of EPS they have deposited. The exception to this rule is the token at index zero (EPS) which is only distributed based on locked balances.
rewardsDuration() returns (uint256)
The period of time, given in seconds, over which a reward token is released after it is added to the contract. Reward tokens are streamed out linearly to stakers; for example if 100 tokens were added and with a reward duration of 10 days, 10 tokens would be rewarded to stakers each day.
Hardcoded as seven days.
lockDuration() returns (uint256)
The period of time, given in seconds, that locked tokens cannot be withdrawn for, and that vested tokens can only be withdrawn after paying a 50% penalty.
Hardcoded as 13 weeks.
totalSupply() returns (uint256)
The total amount of EPS stored within the contract including locked, staked and vested tokens.
lockedSupply() returns (uint256)
The total locked amount of EPS within the contract.
Within the contract, each user is considered to have three balances:
Vesting (or "earned") EPS, which was minted via
MerkleDistributor. These tokens earn trade fees normally, but the user must pay a 50% penalty to withdraw them within the first 13 weeks of minting.
Staked EPS which was deposited via the
stake function. These tokens earn trade fees normally and can be withdrawn at any time with no penalty.
Locked EPS, also deposited via the
stake function. These tokens cannot be withdrawn for 13 weeks after they are deposited. They earn trade fees normally, and also earn a portion of the penalty fees paid when unlocking vested tokens early.
claimableRewards(address account) returns (RewardData)
Information on the currently claimable rewards for
account. Returns an array of (reward token, claimable amount) for all claimable rewards.
totalBalance(address user) returns (uint256)
The total deposited balance for
user, including locked, vested and staked tokens.
Note that due to token locks and the early-exit penalty, this value may be greater than the withdrawable balance.
unlockedBalance(address user) returns (uint256)
The staked balance of
user. These tokens may be withdrawn at any time without penalty.
earnedBalances(address user) returns (uint256 total, LockedBalance)
Information on the vested balances of
the total vested amount
an array of (amount, unlock time) for each vesting period.
lockedBalances(address user) returns (uint, uint, uint, LockedBalance)
Information on the locked balances of
the total locked balance
the balance within locks that have expired, and which may be withdrawn at any time
the balance within locks that have not yet expired and so cannot be withdrawn
an array of (amount, unlock time) for each locked balance
withdrawableBalance(address user) returns (uint256, uint256)
The current total withdrawable balance for
user including staked and vested tokens, and the penalty amount paid if this balance were withdrawn.
stake(uint256 amount, bool lock)
Stakes EPS within the contract.
amount: The number of tokens to stake.
lock: Indicates if the tokens should be locked for
lockDuration in order to also receive penalty fees.
amount EPS from the contract.
Withdrawals always start with the staked balance (where no fee is applied). Once only vested tokens remain, they are withdrawn starting from the oldest vest period (the tokens which will vest soonest).
Claim all owed reward tokens for the caller.
Withdraw all staked and vested balances for the user and claim any pending rewards.
Withdraw all locked tokens where the lock period has expired.
Note that locked tokens continue to receive a portion of penalty fees once the lock period has passed. There is no need to withdraw and relock.
It is not possible to withdraw a portion of your expired locked tokens.