Staking provides immunity from Vesting - bug or feature?

Hey there, happy Friday!

We’ve been testing staking and vesting combination and found one side-effect:

  1. Alice has 2000 balance locked in staking, and 1 balance transferrabe
  2. Bob sends a vested transfer to Alice for 1000 amount. Bob’s intention is that Alice keeps this amount for a year before she can sell it on the exchange (that’s what vesting is for, correct?)
  3. Because 2000 that is locked in staking is greater than 1000 in vesting, 1000 remains transferrable.
  4. Alice can transfer 1000 to the exchange immediately.

Is that intentional design?

@gz1 Reserved tokens overlay, so another way to look at this structure is this:

Alice Before Transfer:

  • Free: 1
  • Locked Max; 2000
    • Staking: 2000
  • Total Balance 2001

After Transfer:

  • Free: 1001
  • Locked Max: 2000
    • Staking: 2000
    • Vesting: 1000
  • Total Balance 3001

So the 1000 is still vesting, but it doesn’t matter which 1000 tokens it is. The requirement is that Alice has a lock on 2000 tokens (2000 for staking and 1000 of those same 2000 for vesting). If Alice unstakes, then the 1000 vesting lock would still be there. It would look like this:

After Unstaking:

  • Free: 2001
  • Locked Max: 1000
    • Vesting: 1000
  • Total Balance 3001

See LockableCurrency and pallet_balances - Rust for more details.

Thanks for your response, Will!

I understand the mechanics of how locks overlay, but I am trying to look at this from the standpoint of use cases. In this particular one Bob’s intention is to send Alice 1000 and have it locked for a year on Alice’s wallet, so that she can’t transfer them to an exchange and sell immediately.

But in fact Alice can take advantage of this design:

  • Keep her 3000 staked for a year and receive staking rewards (let’s say, it was her intention anyway)
  • Sell 1000 immediately

Seems like a bit unfair privilege to stakers who receive their staking bonuses AND can sell unvested funds.