Skip to content

Validator calls reference

quan8 edited this page Sep 11, 2020 · 13 revisions

Validator calls

Create validator

Create a new validator (staker)

Minimum stake is 3175000 FTM

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

Checks

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

Increase validator stake

Not availible since sfc2.0.2-rc2.

Request to partially withdraw validator stake

To partially withdraw stake. This function can only be called after 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, due to penalty for early withdrawal.

After calling partially withdrawing stake for a number of seconds and epochs, you will be able to call withdrawByRequest() successfully.

request ID is any number which wasn't used by this validator previously. 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.

sfcc.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

Partially withdraw stake

To finalize withdrawal request, wait for number of seconds and epochs must elaps since prepareToWithdrawStakePartial call. Erases request object and withdraws requested stake, transfers requested stake to account address.

If staker is a cheater (i.e. double-signed), then object will be erased, but stake won't be withdrawn (i.e. will be slashed).

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

Checks

  • Passed at least sfcc.stakeLockPeriodTime() seconds since prepareToWithdrawStakePartial
  • Passed at least sfcc.stakeLockPeriodEpochs() epochs since prepareToWithdrawStakePartial

Fully withdraw stake

Validator can call prepareToWithdrawStake to prepare to withdraw their stake fully. It only applies if the stake is not locked (lockup has expired), or validator is offline.

sfcc.prepareToWithdrawStake({from: address})

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

If staker is a cheater (i.e. double-signed), then staker will be erased, but delegated stake won't be withdrawn (i.e. will be slashed).

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

Checks

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

Lock up stake

Reward for a non-locked stake is 30% (base rate) of the full reward for a locked stake. It is impossible to withdraw stake until lockup period has expired.

sfcc.lockUpStake(`lockup duration`, {from: `address`})

lockup duration is lockup duration in seconds. Must be >= 14 days, <= 365 days.

Checks

  • lockup duration >= 14 days
  • lockup duration <= 365 days
Clone this wiki locally