GNSStaking
Staking contract for GNS token to earn in multiple reward tokens from fees generated on gTrade.
gns
dai
accDaiPerToken
gnsBalance
stakers
unlockManagers
rewardTokens
rewardTokenState
userTokenRewards
userTokenUnlockRewards
stakerInfos
constructor
initialize
Sets owner
and initializes dai
and gns
state variables
initializeV2
Add dai
as a reward token (old stakers.debtDai, unlockSchedules.debtDai and accDaiPerToken are deprecacted now) Necessary to call right after contract is updated because otherwise distributeRewardDai() reverts.
onlyAuthorizedUnlockManager
Modifier used for vest creation access control. Users can create non-revocable vests for themselves only, owner
and unlockManagers
can create both types for anyone.
onlyRewardToken
Modifier to reject any _token
not configured as a reward token
notInCooldown
Modifier to ensure operation is not performed before cooldown period has expired
setUnlockManager
_Sets whether _manager
is _authorized
to create vests for other users.
Emits {UnlockManagerUpdated}_
addRewardToken
_Forwards call to {addRewardToken}. Only callable by owner
.
setDelegatee
Attempts to set the delegatee of _token
to _delegatee
. _token
must be a valid reward token.
unlockedGns
Returns the unlocked GNS tokens amount of _schedule
at _timestamp
. Includes already claimed GNS tokens.
releasableGns
Returns the releasable GNS tokens amount (1e18 precision) of _schedule
at _timestamp
. Doesn't include already claimed GNS tokens.
owner
Returns the owner of the contract.
isRewardToken
Returns whether _token
is a listed reward token.
distributeReward
_Transfers _amountToken
of _token
(valid reward token) from caller to this contract and updates accRewardPerGns
.
Note: accRewardPerGns
is normalized to 1e18 for all reward tokens (even those with less than 18 decimals)
Emits {RewardDistributed}_
harvestToken
Harvests the caller's regular pending _token
rewards. _token
must be a valid reward token.
harvestTokenFromUnlock
Harvests the caller's pending _token
rewards for vests _ids
. _token
must be a valid reward token.
harvestTokenAll
Harvests the caller's regular pending _token
rewards and pending rewards for vests _ids
.
harvestTokens
Harvests the caller's regular pending rewards for all supported reward tokens.
harvestTokensFromUnlock
Harvests the caller's pending rewards of vests _ids
for all supported reward tokens.
harvestTokensAll
Harvests the caller's regular pending rewards and pending rewards of vests _ids
for all supported reward tokens.
compoundGnsRewards
Harvests the caller's GNS pending rewards and then stakes them
harvestDai
Harvests caller's old regular dai rewards.
harvestDaiFromUnlock
Harvests caller's old dai rewards for vests _ids
.
harvestDaiAll
Harvests caller's old regular dai rewards and old dai rewards of vests _ids
.
harvestAll
Harvests the caller's regular pending rewards and pending rewards for vests _ids
for all supported reward tokens (+ old DAI rewards).
stakeGns
_Stakes non-vested _amountGns
from caller.
Emits {GnsStaked}_
unstakeGns
_Unstakes non-vested _amountGns
from caller.
Emits {GnsUnstaked}_
claimUnlockedGns
Claims caller's unlocked GNS from vests _ids
.
createUnlockSchedule
_Creates vest for _staker
given _schedule
input parameters. Restricted with onlyAuthorizedUnlockManager access control.
Emits {UnlockScheduled}_
revokeUnlockSchedule
_Revokes vest _id
for _staker
. Sends the unlocked GNS to _staker
and sends the remaining locked GNS to owner
. Only callable by owner
.
Emits {UnlockScheduleRevoked}_
pendingRewardToken
Returns the pending _token
rewards (precision depends on token) for _staker
.
pendingRewardTokens
Returns an array of _staker
's pending rewards (precision depends on token) for all supported tokens.
pendingRewardTokensFromUnlocks
Returns an array of _staker
's pending rewards (precision depends on token) from vests _ids
for all supported tokens.
pendingRewardDai
Returns _staker
's pending old dai rewards (1e18 precision).
pendingRewardDaiFromUnlocks
Returns _staker
's pending old dai rewards (1e18 precision) from vests _ids
.
totalGnsStaked
Returns _staker's
total non-vested and vested GNS staked (1e18 precision)
getUnlockSchedules
Returns all _staker's
vests.
getUnlockSchedules
Returns _staker's
vest at _index'
getRewardTokens
Returns the address of all supported reward tokens