Skip to content

Lockup calls reference

Egor Lysenko edited this page Mar 18, 2024 · 6 revisions

Stake lockup calls

Lock up stake

Reward for a non-locked stake is 30% (base rate) of the full reward for a locked stake.

Note that validator's stake must be locked up before validator's delegations can lock their stake. The specified lockup period of a delegation must not exceed validator's current lockup period plus 30 days.

Delegation can be locked partially according to the specified amount.

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

lockupDuration proportionally increases lockup rate for rewards. For 14 days, rewards are 30%+2.684931% of the total reward rate. For 365 days, rewards are 30%+70% of the total reward rate.

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

Checks

  • Amount is smaller or equal to unlocked stake
  • Previous lockup period (if any) must end before the new period starts.
  • lockupDuration >= 14 days
  • lockupDuration <= 365 days
  • Validator's lockup period must end after delegation's lockup period will expire
  • Validator is active

Re-lock stake

Extend lockup period or increase lockup stake amount.

If user is already lockup up, the call will create a new lockup entry with parameters: lockedStake=prevLockedStake+amount and lockup duration=newLockupDuration.

The call adds an entry about the previous lockup period for accurate unlocking penalty calculation. For this reason, the number of non-expired lockup periods is limited (see Checks below or https://github.com/Fantom-foundation/opera-sfc/pull/67).

Example:

  1. Alice had locked up 10 FTM for 3 months a month ago, and she has to wait 2 months until lockup expiration
  2. She called relockStake(validatorID, 4 months, 5 FTM)
  3. As a result, now she has 15 FTM as locked up, and she has to wait 4 months until lockup expiration (2 months longer, despite new lockup duration being only 1 month longer)
sfcc.relockStake(validatorID, newLockupDuration, web3.toWei("amount", "ftm"), {from: "0xAddress"})

Checks

  • Amount is smaller or equal to unlocked stake
  • lockupDuration >= previous lockupDuration (if locked up). Note that previous lockupDuration is not locked time remaining but lockup duration of existing lockup.
  • lockupDuration >= 14 days
  • lockupDuration <= 365 days
  • Validator's lockup period must end not earlier than delegation's lockup period will expire
  • Validator is active
  • Number of ongoing relocks cannot exceed 30
  • Either number of ongoing relocks doesn't exceed 3, or lockup amount is increased by 1%, or passed 14 days since previous relocking

Unlock stake prematurely

Unlock the stake before lockup duration has elapsed.

The following penalty will be withheld from the unlocked amount:

  • (base rate = 30%)/2 + lockup rate of rewards received for epochs during the lockup period, excluding previous expired periods if position has been relocked
sfcc.unlockStake(validatorID, web3.toWei("amount", "ftm"), {from: "0xAddress"})

Checks

  • Amount is greater than zero
  • Amount is smaller or equal to locked stake
  • Delegation is locked up (fully or partially)