Overview

This issue has been discovered during development of FIP-21 Staking and requires a consideration and decision on best path forward.

The Issue

Requirements

Staking requirements state that:

7 day lock technical approach

The technical approach to deliver the 7 day unstake lock is to rely on FIP-6 functionality which is defined by:

When user unstakes an amount the FIP-6 locks are supposed to be adjusted to insert a new unlock period. To continue the above example, if the user of the above account staked 100 tokens and now unstakes 10, their FIP-6 locks would be adapted as follows:

However FIP-6 percent precision is decimals, so each period will have to be rounded as follows:

Which when added equal to 100.001%

We initially thought this could be solved by adjusting the “slack” of Period 0 in the above example like this:

However, after additional consideration this approach appears undesirable because:

Solutions

#

Solution

Description

Tech difficulty

Hack vs. right way

1

Leave as is

User will get behavior described above, but an argument could be made that most users will not be affected in a meaningful way.

Future uses of locks for other purposes may run into the same issue.

2

The right thing to do

Re-architect the FIP-6 locks to operate on SUFs and not percentages. This removes the precision issue from the chain altogether and makes locks more flexible for potential future uses.

3

Implement staking limits

  • Do not allow staking on accounts with Mainnet locks or FIP-6 locks, which are now only possible on new accounts.

  • Do not allow unstaking of partial amounts. The user can add staked amounts, but when they unstake, they have to unstake everything that was stake. Example:

    • Allowed:

      • Stake 100

      • Stake 200

      • Stake 300

      • Unstake 600

    • Not allowed

      • Stake 100

      • Stake 200

      • Stake 300

      • Unstake 300

4

Remove unstake 7-day lock

When unstaking, the user will immediately receive 100% of what they wanted to unstake.

2021-06-01 Discussion

During a discussion with Luke Stokes Eric Butz Ed Rotthoff Pawel Mastalerz a decision was made to proceed with Option #2: