Skip to content

Validator calls reference

devintegral3 edited this page Mar 5, 2020 · 13 revisions

Validator calls

Create validator

Create a new validator (staker)

Minimum stake is 3175000 FTM

sfc.createStake([], {from:`address`, value: web3.toWei(`amount`, "ftm")})

Checks

  • Stake amount is greater or equal to sfc.minStake()
  • This address isn't a staker
  • This address isn't a delegator

Increase validator stake

Increase stake by amount of sent FTM.

The new stake will be applied in next epoch.

sfc.increaseStake({from:`address`, value: web3.toWei(`amount`, "ftm")})

Checks

  • Amount is greater or equal to sfc.minStakeIncrease()
  • Staker exists
  • Staker is active: staker isn't a cheater, isn't pruned for being offline, didn't prepare to withdraw

Request to fully withdraw validator stake

Put in a request to withdraw stake, can then call withdrawStake() function after enough seconds and epochs have passed.

Note that it's not possible to call this function until all the rewards are claimed (rewards may be claimed even if they're locked).

Pay attention that stashed rewards will be burned within this call.

After calling this function, validators won't be a validator in next epoch.

This call doesn't affect already earned rewards by delegators and staker.

sfc.prepareToWithdrawStake({from: `address`})

Checks

  • Staker must exist
  • All staker rewards are claimed
  • Staker isn't deactivated (i.e. didn't prepare to withdraw)

Request to partially withdraw validator stake

Put in a request to partially withdraw stake. After a number of seconds and epochs have passed since calling the function below, you will be able to call withdrawByRequest() successfully.

Note that it's not possible to call this function until all the rewards are claimed (rewards may be claimed even if they're locked).

Pay attention that proportional part of stashed rewards will be burned within this call.

request ID is any number which wasn't used by validator before. Remember this number, it'll be needed to finalize withdrawal. Use 0 if not sure.

Validator cannot leave less stake than minStake() or less than delegations amount * 15.0.

This call doesn't affect already earned rewards by delegators.

The validator's stake will be decreased in next epoch by amount.

sfc.prepareToWithdrawStakePartial(`request ID`, web3.toWei(`amount to withdraw`, "ftm"), {from: `address`})

Checks

  • Staker must exist
  • All staker rewards are claimed
  • Staker isn't deactivated (i.e. didn't prepare to withdraw)
  • request ID isn't occupied by another request
  • amount to withdraw >= minStakeDecrease()
  • left amount >= minStake()
  • left amount >= delegations amount * 15.0

Fully withdraw stake

After enough seconds and epochs have passed since calling PreparedToWithdrawStake(), validator can call this function successfully.

If staker is a cheater (i.e. doublesigned in DAG), then staker will be erased, but delegated stake won't be withdrawn (i.e. will be slashed).

sfc.withdrawStake({from: `address`})

Checks

  • Passed at least sfc.stakeLockPeriodTime() seconds since prepareToWithdrawStake was called
  • Passed at least sfc.stakeLockPeriodEpochs() epochs since prepareToWithdrawStake was called

Partially withdraw stake

Finalize withdrawal request. Erases staker object and withdraws stake, transfers stake to account address.

Note that a number of seconds and epochs must elaspe since prepareToWithdrawStakePartial call.

If staker is a cheater (i.e. doublesigned in DAG), then object will be erased, but stake won't be withdrawn (i.e. will be slashed).

sfc.withdrawByRequest(`request ID`, {from: `address`})

Checks

  • Passed at least sfc.stakeLockPeriodTime() seconds since prepareToWithdrawStakePartial
  • Passed at least sfc.stakeLockPeriodEpochs() epochs since prepareToWithdrawStakePartial
Clone this wiki locally