|
| 1 | +# 📄 Token Locking with Delayed Thaw and Boosting Rewards |
| 2 | + |
| 3 | +## 📚 Context and Scope |
| 4 | + |
| 5 | +This design document introduces a new `pallet-delayed_thaw` to the Frequency runtime. The primary focus is on defining a |
| 6 | +mechanism for locking tokens in a way that is both time-sensitive and event-driven, with immutably defined thawing |
| 7 | +behavior. While this design does not aim to change the Provider Boosting system itself, it leverages that mechanism to |
| 8 | +provide users with an incentive to commit tokens to long-term locks. The `capacity` pallet's Provider Boosting system |
| 9 | +serves as the vehicle for rewarding these users, with minimal changes required to accept staked tokens that are |
| 10 | +simultaneously locked. |
| 11 | + |
| 12 | +## ❗ Problem Statement |
| 13 | +Business needs dictate that users be able to lock tokens subject to a Precipitating Tokenomic Event (PTE), |
| 14 | +following which, tokens would unlock according to pre-set rules. The specifics of the locking/unlocking |
| 15 | +scheme is not supported by the current `time-release` pallet. |
| 16 | + |
| 17 | +Additionally: |
| 18 | +- While the announcement of the PTE would be a Governance action, the subsequent ability to unlock |
| 19 | +portions of the locked tokens over time should not be modifiable, even by Governance |
| 20 | +- Tokens must be locked prior to the PTE as a condition of the PTE; however, if Governance fails |
| 21 | +to act (or the PTE does not happen) by a certain date, there should be a failsafe whereby any |
| 22 | +tokens so locked would automatically be able to be unlocked. |
| 23 | +- Due to the exceesive lock period and delayed thaw, there should be some incentive mechanism for |
| 24 | +users to participate in the extended locking scheme. |
| 25 | +- |
| 26 | +## 🎯 Goals and Non-Goals |
| 27 | + |
| 28 | +### Goals: |
| 29 | + |
| 30 | +- Introduce a new pallet, `pallet-delayed_thaw`, to manage event-driven and schedule-based token unlocking. |
| 31 | +- Enable tokens locked by `pallet-delayed_thaw` to participate in Provider Boosting. |
| 32 | +- Provide separate reward behavior for locked tokens using the `RewardsProvider` trait. |
| 33 | +- Ensure immutability of thawing logic while allowing governance to trigger the precipitating event. |
| 34 | + |
| 35 | +### Non-Goals: |
| 36 | + |
| 37 | +- This proposal does not change or refactor the general mechanics of Provider Boosting. |
| 38 | +- It does not provide a user interface or wallet-level integration. |
| 39 | +- It does not address consolidation or configuration of Provider Boosting parameters. |
| 40 | + |
| 41 | +## ✨ Summary |
| 42 | + |
| 43 | +This document proposes an enhancement to the `Provider Boosting` feature in the `capacity` pallet and the introduction |
| 44 | +of a new `delayed_thaw` pallet to handle token locking logic. The objective is to support tokens locked with specific |
| 45 | +thawing behavior, with such tokens participating in Provider Boosting at a distinct reward rate. |
| 46 | + |
| 47 | +## 📂 `pallet-delayed_thaw` - Token Locking Mechanism |
| 48 | + |
| 49 | +This new pallet manages the locking and gradual thawing of tokens. It does not handle reward logic but contributes to |
| 50 | +reward calculation via a custom implementation of the `RewardsProvider` trait. |
| 51 | + |
| 52 | +### Storage and Constants: |
| 53 | + |
| 54 | +```rust |
| 55 | +#[pallet::storage] |
| 56 | +pub type PrecipitatingEventBlockNumber<T: Config> = StorageValue<_, T::BlockNumber, OptionQuery>; |
| 57 | + |
| 58 | +pub const FAILSAFE_UNLOCK_BLOCK_NUMBER: BlockNumber = < some constant>; |
| 59 | +``` |
| 60 | + |
| 61 | +- `PrecipitatingEventBlockNumber`: Set by governance to signal a precipitating event. |
| 62 | +- `FAILSAFE_UNLOCK_BLOCK_NUMBER`: Ensures unlock safety if governance fails to act. |
| 63 | + |
| 64 | +### Thaw Parameters: |
| 65 | + |
| 66 | +```rust |
| 67 | +pub const THAW_ERA_LENGTH: BlockNumber = < some constant>; |
| 68 | +pub const INITIAL_FREEZE_THAW_ERAS: u32 = < some constant>; |
| 69 | +pub const UNLOCK_THAW_ERAS: u32 = < some constant>; |
| 70 | +``` |
| 71 | + |
| 72 | +**Unlock formula per era:** |
| 73 | + |
| 74 | +```text |
| 75 | +If current_era < INITIAL_FREEZE_THAW_ERAS: |
| 76 | + unlock_ratio = 0 |
| 77 | +Else: |
| 78 | + thaw_era = current_era - INITIAL_FREEZE_THAW_ERAS |
| 79 | + unlock_ratio = 1 / (UNLOCK_THAW_ERAS - min(thaw_era, UNLOCK_THAW_ERAS) + 1) |
| 80 | +``` |
| 81 | + |
| 82 | +### Open Design Question: |
| 83 | + |
| 84 | +> How should we enforce immutability of thaw parameters? |
| 85 | +
|
| 86 | +Options: |
| 87 | + |
| 88 | +- **Hard-code into the pallet**: Ensures absolute immutability. |
| 89 | + - Chain code upgrade would be required to modify thaw parameters |
| 90 | +- **Store with each lock** |
| 91 | + - Thaw modification would require both a chain code update and storage migration |
| 92 | + |
| 93 | +**→ Feedback requested from the blockchain team.** |
| 94 | + |
| 95 | +## 📈 Rewards Integration |
| 96 | + |
| 97 | +### Interaction with Token Locks |
| 98 | + |
| 99 | +The `pallet-delayed_thaw` will define a new `LockReason` for its locking operations. Since the balances pallet supports |
| 100 | +multiple simultaneous locks under different `LockReason`s, tokens locked by `pallet-delayed_thaw` can still be |
| 101 | +independently used for Provider Boosting. This is similar to how tokens locked for governance voting can also be reused |
| 102 | +elsewhere in the runtime, provided the logic permits it. |
| 103 | + |
| 104 | +To support this, the `capacity` pallet may require a minor change to its internal staking logic to accept tokens locked |
| 105 | +under the `delayed_thaw` `LockReason` as valid staking collateral. This ensures seamless participation in boosting |
| 106 | +rewards while maintaining lock-specific thawing behavior. |
| 107 | + |
| 108 | +The rewards system remains in `pallet-capacity`. One change: |
| 109 | + |
| 110 | +- `pallet-delayed_thaw` will implement the `RewardsProvider` trait. |
| 111 | +- Allows for differential reward rate logic for locked tokens. |
| 112 | + |
| 113 | +## 🔐 Governance Integration |
| 114 | + |
| 115 | +- Governance can set `PrecipitatingEventBlockNumber`. |
| 116 | +- No governance control over thaw parameters. |
| 117 | + |
| 118 | +## 🔄 Migration Strategy |
| 119 | + |
| 120 | +- Existing boost types and reward parameters remain unchanged. |
| 121 | +- Integration of `pallet-delayed_thaw` adds new locked-stake source for boosting without altering core logic. |
0 commit comments