GNSStaking
Staking contract for GNS token to earn in multiple reward tokens from fees generated on gTrade.
gns
contract IERC20 gnsdai
contract IERC20 daiaccDaiPerToken
uint128 accDaiPerTokengnsBalance
uint128 gnsBalancestakers
mapping(address => struct IGNSStaking.Staker) stakersunlockManagers
mapping(address => bool) unlockManagersrewardTokens
address[] rewardTokensrewardTokenState
mapping(address => struct IGNSStaking.RewardState) rewardTokenStateuserTokenRewards
mapping(address => mapping(address => struct IGNSStaking.RewardInfo)) userTokenRewardsuserTokenUnlockRewards
mapping(address => mapping(address => mapping(uint256 => struct IGNSStaking.RewardInfo))) userTokenUnlockRewardsstakerInfos
mapping(address => struct IGNSStaking.StakerInfo) stakerInfosconstructor
constructor() publicinitialize
function initialize(address _owner, contract IERC20 _gns, contract IERC20 _dai) externalSets owner and initializes dai and gns state variables
initializeV2
function initializeV2() externalAdd 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 onlyAuthorizedUnlockManager(address _staker, bool _revocable)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 onlyRewardToken(address _token)Modifier to reject any _token not configured as a reward token
notInCooldown
modifier notInCooldown()Modifier to ensure operation is not performed before cooldown period has expired
setUnlockManager
function setUnlockManager(address _manager, bool _authorized) external_Sets whether _manager is _authorized to create vests for other users.
Emits {UnlockManagerUpdated}_
addRewardToken
function addRewardToken(address _token) external_Forwards call to {addRewardToken}. Only callable by owner.
setDelegatee
function setDelegatee(address _token, address _delegatee) externalAttempts to set the delegatee of _token to _delegatee. _token must be a valid reward token.
unlockedGns
function unlockedGns(struct IGNSStaking.UnlockSchedule _schedule, uint48 _timestamp) public pure returns (uint128)Returns the unlocked GNS tokens amount of _schedule at _timestamp. Includes already claimed GNS tokens.
releasableGns
function releasableGns(struct IGNSStaking.UnlockSchedule _schedule, uint48 _timestamp) public pure returns (uint128)Returns the releasable GNS tokens amount (1e18 precision) of _schedule at _timestamp. Doesn't include already claimed GNS tokens.
owner
function owner() public view returns (address)Returns the owner of the contract.
isRewardToken
function isRewardToken(address _token) public view returns (bool)Returns whether _token is a listed reward token.
distributeReward
function distributeReward(address _token, uint256 _amountToken) external_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
function harvestToken(address _token) public returns (uint128)Harvests the caller's regular pending _token rewards. _token must be a valid reward token.
harvestTokenFromUnlock
function harvestTokenFromUnlock(address _token, uint256[] _ids) public returns (uint128)Harvests the caller's pending _token rewards for vests _ids. _token must be a valid reward token.
harvestTokenAll
function harvestTokenAll(address _token, uint256[] _ids) public returns (uint128)Harvests the caller's regular pending _token rewards and pending rewards for vests _ids.
harvestTokens
function harvestTokens() publicHarvests the caller's regular pending rewards for all supported reward tokens.
harvestTokensFromUnlock
function harvestTokensFromUnlock(uint256[] _ids) publicHarvests the caller's pending rewards of vests _ids for all supported reward tokens.
harvestTokensAll
function harvestTokensAll(uint256[] _ids) publicHarvests the caller's regular pending rewards and pending rewards of vests _ids for all supported reward tokens.
compoundGnsRewards
function compoundGnsRewards(uint256[] _ids) externalHarvests the caller's GNS pending rewards and then stakes them
harvestDai
function harvestDai() publicHarvests caller's old regular dai rewards.
harvestDaiFromUnlock
function harvestDaiFromUnlock(uint256[] _ids) publicHarvests caller's old dai rewards for vests _ids.
harvestDaiAll
function harvestDaiAll(uint256[] _ids) publicHarvests caller's old regular dai rewards and old dai rewards of vests _ids.
harvestAll
function harvestAll(uint256[] _ids) externalHarvests the caller's regular pending rewards and pending rewards for vests _ids for all supported reward tokens (+ old DAI rewards).
stakeGns
function stakeGns(uint128 _amountGns) public_Stakes non-vested _amountGns from caller.
Emits {GnsStaked}_
unstakeGns
function unstakeGns(uint128 _amountGns) external_Unstakes non-vested _amountGns from caller.
Emits {GnsUnstaked}_
claimUnlockedGns
function claimUnlockedGns(uint256[] _ids) externalClaims caller's unlocked GNS from vests _ids.
createUnlockSchedule
function createUnlockSchedule(struct IGNSStaking.UnlockScheduleInput _schedule, address _staker) external_Creates vest for _staker given _schedule input parameters. Restricted with onlyAuthorizedUnlockManager access control.
Emits {UnlockScheduled}_
revokeUnlockSchedule
function revokeUnlockSchedule(address _staker, uint256 _id) external_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
function pendingRewardToken(address _staker, address _token) public view returns (uint128)Returns the pending _token rewards (precision depends on token) for _staker.
pendingRewardTokens
function pendingRewardTokens(address _staker) external view returns (uint128[] pendingTokens)Returns an array of _staker's pending rewards (precision depends on token) for all supported tokens.
pendingRewardTokensFromUnlocks
function pendingRewardTokensFromUnlocks(address _staker, uint256[] _ids) external view returns (uint128[] pendingTokens)Returns an array of _staker's pending rewards (precision depends on token) from vests _ids for all supported tokens.
pendingRewardDai
function pendingRewardDai(address _staker) external view returns (uint128)Returns _staker's pending old dai rewards (1e18 precision).
pendingRewardDaiFromUnlocks
function pendingRewardDaiFromUnlocks(address _staker, uint256[] _ids) external view returns (uint128 pending)Returns _staker's pending old dai rewards (1e18 precision) from vests _ids.
totalGnsStaked
function totalGnsStaked(address _staker) external view returns (uint128)Returns _staker's total non-vested and vested GNS staked (1e18 precision)
getUnlockSchedules
function getUnlockSchedules(address _staker) external view returns (struct IGNSStaking.UnlockSchedule[])Returns all _staker's vests.
getUnlockSchedules
function getUnlockSchedules(address _staker, uint256 _index) external view returns (struct IGNSStaking.UnlockSchedule)Returns _staker's vest at _index'
getRewardTokens
function getRewardTokens() external view returns (address[])Returns the address of all supported reward tokens
Was this helpful?