StakeManager
Contents
Globals
validatorId
uint256
validators
mapping(address => struct Validator)
unstakeId
uint256
unstakeQueue
mapping(uint256 => struct Unstake)
totalLockedAmount
uint256
activeValidators
struct ActiveValidator[]
proposer
address
Modifiers
onlyRouterOrFeePool
No description
Declaration:
Functions
constructor
No description
Declaration:
Modifiers:
Only
indexedValidatorsLength
Get the indexed validators length.
Declaration:
Modifiers: No modifiers
indexedValidatorsExists
Determine whether the index validator exists by id.
Declaration:
Modifiers: No modifiers
Args:
id
uint256
The validator id
indexedValidatorsByIndex
Get indexed validator address by index.
Declaration:
Modifiers: No modifiers
Args:
index
uint256
The validator index
indexedValidatorsById
Get indexed validator address by id.
Declaration:
Modifiers: No modifiers
Args:
id
uint256
The validator id
getVotingPowerByIndex
Get the voting power by validator index, if index is out of range or validator doesn't exist, return 0.
Declaration:
Modifiers: No modifiers
Args:
index
uint256
The validator index
getVotingPowerById
Get the voting power by validator id, if doesn't exist, return 0.
Declaration:
Modifiers: No modifiers
Args:
id
uint256
The validator id
getVotingPowerByAddress
Get the voting power by validator address, if the validator doesn't exist, return 0.
Declaration:
Modifiers: No modifiers
Args:
validator
address
Validator address
getTotalLockedAmountAndValidatorCount
Get the total locked amount and the validator count, but no including the excludes
.
Declaration:
Modifiers: No modifiers
Args:
excludes
address[]
Excluded addresses
activeValidatorsLength
Get the active validators list length.
Declaration:
Modifiers: No modifiers
estimateSharesToAmount
Estimate how much GXC should be stake, if user wants to get the number of shares, Or estimate how much GXC can be obtained, if user unstake the amount of GXC.
Declaration:
Modifiers: No modifiers
Args:
validator
address
Validator address
shares
uint256
Number of shares
estimateAmountToShares
Estimate how much shares should be unstake, if user wants to get the amount of GXC. Or estimate how much shares can be obtained, if user stake the amount of GXC. If the validator doesn't exist, return 0.
Declaration:
Modifiers: No modifiers
Args:
validator
address
Validator address
amount
uint256
Number of GXC
estimateUnstakeAmount
Estimate how much GXC can be claim, if unstake the number of shares(when unstake timeout). If the validator doesn't exist, return 0.
Declaration:
Modifiers: No modifiers
Args:
validator
address
Validator address
shares
uint256
Number of shares
receive
No description
Declaration:
Modifiers: No modifiers
stake
Stake for validator and mint share token to to
address. It will emit Stake
event.
Declaration:
Modifiers:
nonReentrant
Args:
validator
address
Validator address
to
address
Receiver address
startUnstake
Start unstake shares for validator. Stake manager will burn the shares immediately, but return GXC to to
address after config.unstakeDelay
. It will emit StartUnstake
event.
Declaration:
Modifiers:
nonReentrant
Args:
validator
address
Validator address
to
address payable
Receiver address
shares
uint256
Number of shares to be burned
Returns:
Unstake
id(if amount is zero, return MAX_UINT256)
### startClaim
Start claim validator reward.
Stake manager will claim GXC from validator reward manager immediately, but return GXC to to
address after config.unstakeDelay
.
It will emit StartUnstake
event.
Declaration:
Modifiers:
nonReentrant
Args:
to
address payable
Receiver address
amount
uint256
Number of GXC
Returns:
Unstake
id
### setCommissionRate
Set validator commission rate.
Declaration:
Modifiers:
nonReentrant
Args:
rate
uint256
New commission rate
unstake
Unstake by id, return unstake amount.
Declaration:
Modifiers:
nonReentrant
Args:
id
uint256
Unstake id
removeIndexedValidator
Remove the validator from indexedValidators
if the voting power is less than minIndexVotingPower
This can be called by anyone.
Declaration:
Modifiers:
nonReentrant
Args:
validator
address
Validator address
addIndexedValidator
Add the validator to indexedValidators
if the voting power is greater than minIndexVotingPower
This can be called by anyone.
Declaration:
Modifiers:
nonReentrant
Args:
validator
address
Validator address
reward
Reward validator, only can be called by system caller
Declaration:
Modifiers:
nonReentrant
onlyRouterOrFeePool
Args:
validator
address
Validator address
slash
Slash validator, only can be called by system caller
Declaration:
Modifiers:
nonReentrant
onlyRouter
Args:
validator
address
Validator address
reason
uint8
Slash reason
onAfterBlock
After block callback, it will be called by system caller after each block is processed
Declaration:
Modifiers:
nonReentrant
onlyRouter
Args:
_proposer
address
Proposer address
acValidators
address[]
Active validators list
priorities
int256[]
Priority list of active validators
Events
Reward
Emitted when a validator gets a reward NOTE: this event is never shown in the block, because the reward
function is only called by the system caller
Params:
validator
address
✅
Validator address
value
uint256
✅
Reward amount
### Slash
Emitted when a validator is slashed
NOTE: this event is never shown in the block,
Params:
validator
address
✅
Validator address
value
uint256
✅
Slashed amount
### Stake
Emitted when the user stakes
Params:
validator
address
✅
Validator address
value
uint256
✅
Stake value
to
address
Receiver address
shares
uint256
Number of shares minted
### StartUnstake
Emitted when the user starts unstake
Params:
id
uint256
✅
Unique unstake id
validator
address
✅
Validator address
value
uint256
✅
Stake value
to
address
Receiver address
unstakeShares
uint256
Number of unstake shares to be burned
timestamp
uint256
Release timestamp
### DoUnstake
Emitted when stake manager unstake
Params:
id
uint256
✅
Unique unstake id
validator
address
✅
Validator address
to
address
Receiver address
amount
uint256
GXC Released
### SetCommissionRate
Emitted when validator set commission rate
Params:
validator
address
✅
Validator address
rate
uint256
✅
New commission rate
timestamp
uint256
✅
Update timestamp
### IndexedValidator
Emitted when a new validator is indexed
Params:
validator
address
✅
Validator address
votingPower
uint256
✅
Validator voting power
### UnindexedValidator
Emitted when a new validator is unindexed
Params:
validator
address
✅
Validator address
Last updated