Skip to content

Delegation calls reference

Egor Lysenko edited this page Aug 1, 2022 · 2 revisions

Delegation calls

Delegate

Delegate an amount of FTM to a validator.

Can be used to create a new delegation or increase an existing delegation.

The delegated stake is always unlocked unless locked explicitly with lockStake.

sfcc.delegate(validatorID, {from: "0xAddress", value: web3.toWei("amount", "ftm")})

Checks

  • Validator must exist
  • Validator is active
  • Amount is greater than zero
  • Validator's stake is less or equal to 16.0 * validator's self-stake

Undelegate

Put in a request to withdraw an amount of delegated stake.

After a number of seconds and epochs have passed since calling the function below (called withdrawal period), you will be able to call withdraw successfully.

requestID is any number which isn't occupied by an existing withdrawal request for this delegation.

sfcc.undelegate(validatorID, requestID, web3.toWei("amount", "ftm"), {from: "0xAddress"})

Checks

  • Amount is greater than zero
  • Delegation's unlocked stake is greater or equal to the amount to undelegate
  • requestID isn't occupied by an existing withdrawal request for this delegation
  • If called for validator's self-delegation, then the following stays true after the operation: either validator's stake is less or equal to 16.0 * validator's self-stake or the self-stake is 0

Withdrawal period in seconds and epochs can be retrieved via

sfcc.withdrawalPeriodTime()
sfcc.withdrawalPeriodEpochs()

Withdraw

Finalize withdrawal request.

Erases request object and withdraws requested stake, transfers requested stake to account address.

Note that a number of seconds and epochs must elapse since undelegate call (called withdrawal period).

If validator is a cheater (i.e. double-signed), then the stake may be fully or partially slashed according to validator's slashingRefundRatio.

sfcc.withdraw(validatorID, requestID, {from: "0xAddress"})

Checks

  • Withdrawal request with given address, validator ID and requestID exists
  • At least sfcc.withdrawalPeriodTime() seconds passed since undelegate call
  • At least sfcc.withdrawalPeriodEpochs() epochs passed since undelegate call
  • Non-slashed part of stake is above zero