DelegationController

This contract performs all delegation functions including delegation requests, and undelegation, etc.

Delegators and validators may both perform delegations. Validators who perform delegations to themselves are effectively self-delegating or self-bonding.

Undelegation may be requested at any time, but undelegation is only performed at the completion of the current delegation period.

Delegated tokens may be in one of several states:

  • PROPOSED: token holder proposes tokens to delegate to a validator.

  • ACCEPTED: token delegations are accepted by a validator and are locked-by-delegation.

  • CANCELED: token holder cancels delegation proposal. Only allowed before the proposal is accepted by the validator.

  • REJECTED: token proposal expires at the UTC start of the next month.

  • DELEGATED: accepted delegations are delegated at the UTC start of the month.

  • UNDELEGATION_REQUESTED: token holder requests delegations to undelegate from the validator.

  • COMPLETED: undelegation request is completed at the end of the delegation period.

checkDelegationExists checkDelegationExists(uint256 delegationId) modifier

Modifier to make a function callable only if delegation exists.

getAndUpdateDelegatedToValidatorNow getAndUpdateDelegatedToValidatorNow(uint256 validatorId) → uint256 external

Update and return a validator’s delegations.

getAndUpdateDelegatedAmount getAndUpdateDelegatedAmount(address holder) → uint256 external

Update and return the amount delegated.

getAndUpdateEffectiveDelegatedByHolderToValidator getAndUpdateEffectiveDelegatedByHolderToValidator(address holder, uint256 validatorId, uint256 month) → uint256 effectiveDelegated external

Update and return the effective amount delegated (minus slash) for the given month.

delegate delegate(uint256 validatorId, uint256 amount, uint256 delegationPeriod, string info) external

Allows a token holder to create a delegation proposal of an amount and delegationPeriod to a validatorId. Delegation must be accepted by the validator before the UTC start of the month, otherwise the delegation will be rejected.

The token holder may add additional information in each proposal.

Emits a DelegationProposed event.

Requirements:

  • Holder must have sufficient delegatable tokens.

  • Delegation must be above the validator’s minimum delegation amount.

  • Delegation period must be allowed.

  • Validator must be authorized if trusted list is enabled.

  • Validator must be accepting new delegation requests.

getAndUpdateLockedAmount getAndUpdateLockedAmount(address wallet) → uint256 external

getAndUpdateForbiddenForDelegationAmount getAndUpdateForbiddenForDelegationAmount(address wallet) → uint256 external

cancelPendingDelegation cancelPendingDelegation(uint256 delegationId) external

Allows token holder to cancel a delegation proposal.

Requirements:

  • msg.sender must be the token holder of the delegation proposal.

  • Delegation state must be PROPOSED.

acceptPendingDelegation acceptPendingDelegation(uint256 delegationId) external

Allows a validator to accept a proposed delegation. Successful acceptance of delegations transition the tokens from a PROPOSED state to ACCEPTED, and tokens are locked for the remainder of the delegation period.

Emits a DelegationAccepted event.

Requirements:

  • Validator must be recipient of proposal.

  • Delegation state must be PROPOSED.

requestUndelegation requestUndelegation(uint256 delegationId) external

Allows delegator to undelegate a specific delegation.

Emits UndelegationRequested event.

Requirements:

  • msg.sender must be the delegator.

  • Delegation state must be DELEGATED.

confiscate confiscate(uint256 validatorId, uint256 amount) external

Allows Punisher contract to slash an amount of stake from a validator. This slashes an amount of delegations of the validator, which reduces the amount that the validator has staked. This consequence may force the SKALE Manager to reduce the number of nodes a validator is operating so the validator can meet the Minimum Staking Requirement.

Emits a {SlashingEvent}.

See Punisher.

getAndUpdateEffectiveDelegatedToValidator getAndUpdateEffectiveDelegatedToValidator(uint256 validatorId, uint256 month) → uint256 external

Allows Distributor contract to return and update the effective amount delegated (minus slash) to a validator for a given month.

getAndUpdateDelegatedByHolderToValidatorNow getAndUpdateDelegatedByHolderToValidatorNow(address holder, uint256 validatorId) → uint256 external

Return and update the amount delegated to a validator for the current month.

getEffectiveDelegatedValuesByValidator getEffectiveDelegatedValuesByValidator(uint256 validatorId) → uint256[] external

getEffectiveDelegatedToValidator getEffectiveDelegatedToValidator(uint256 validatorId, uint256 month) → uint256 external

getDelegatedToValidator getDelegatedToValidator(uint256 validatorId, uint256 month) → uint256 external

getDelegation getDelegation(uint256 delegationId) → struct DelegationController.Delegation external

Return Delegation struct.

getFirstDelegationMonth getFirstDelegationMonth(address holder, uint256 validatorId) → uint256 external

Returns the first delegation month.

getDelegationsByValidatorLength getDelegationsByValidatorLength(uint256 validatorId) → uint256 external

Returns a validator’s total number of delegations.

getDelegationsByHolderLength getDelegationsByHolderLength(address holder) → uint256 external

Returns a holder’s total number of delegations.

initialize initialize(address contractsAddress) public

processSlashes processSlashes(address holder, uint256 limit) public

Process slashes up to the given limit.

processAllSlashes processAllSlashes(address holder) public

Process all slashes.

getState getState(uint256 delegationId) → enum DelegationController.State state public

Returns the token state of a given delegation.

getLockedInPendingDelegations getLockedInPendingDelegations(address holder) → uint256 public

Returns the amount of tokens in PENDING delegation state.

hasUnprocessedSlashes hasUnprocessedSlashes(address holder) → bool public

Checks whether there are any unprocessed slashes.

DelegationProposed DelegationProposed(uint256 delegationId) event

Emitted when a delegation is proposed to a validator.

DelegationAccepted DelegationAccepted(uint256 delegationId) event

Emitted when a delegation is accepted by a validator.

DelegationRequestCanceledByUser DelegationRequestCanceledByUser(uint256 delegationId) event

Emitted when a delegation is cancelled by the delegator.

UndelegationRequested UndelegationRequested(uint256 delegationId) event

Emitted when a delegation is requested to undelegate.