|
| 1 | +# Capacity Pallet |
| 2 | + |
| 3 | +The Capacity Pallet manages the staking and balances for Capacity, an alternative payment system on Frequency. |
| 4 | + |
| 5 | +## Summary |
| 6 | + |
| 7 | +Capacity is an alternative to paying with tokens for a limited set of calls. |
| 8 | +These Capacity eligible extrinsics are noted in each pallet's documentation with "Capacity" in the Payment column of the extrinsics section. |
| 9 | +Tokens can be staked to generate Capacity for a targeted Provider. |
| 10 | +The generated Capacity renews each [Epoch](#capacity-epoch). |
| 11 | +[Learn more about Capacity](https://docs.frequency.xyz/Tokenomics/ProviderIncentives.html#capacity-model). |
| 12 | + |
| 13 | +### Staking & Unstaking |
| 14 | +Currently, the token to Capacity ratio is 50:1. |
| 15 | +For example, for a 5 token stake, a Provider would receive 0.1 Capacity. |
| 16 | +Staking and unstaking affect available Capacity immediately. |
| 17 | + |
| 18 | +### Capacity Epoch |
| 19 | + |
| 20 | +A Capacity Epoch is a period consisting of a specific number of blocks, during which a Provider's utilization of network Capacity is capped at the amount of generated Capacity targeted to that Provider. |
| 21 | +At the start of each new Epoch, the available Capacity is renewed for each Provider, regardless of how much they consumed in the prior Epoch. |
| 22 | +The duration of a Capacity Epoch is determined by Governance, and is currently set to 7200 blocks. |
| 23 | +With the current average block time of approximately 12 seconds, one Capacity Epoch lasts around 24 hours on Mainnet. |
| 24 | + |
| 25 | +### Thaw Period |
| 26 | + |
| 27 | +After unstaking, the tokens will still be frozen for a set amount of time before they are unencumbered and able to be transferred. |
| 28 | +The `UnstakingThawPeriod` constant defines the number of Epochs that must pass before the tokens may be reclaimed for any use via `withdrawUnstaked()`. |
| 29 | +Currently it is set to 30 Epochs or ~30 days after unstaking. |
| 30 | + |
| 31 | +### Actions |
| 32 | + |
| 33 | +The Capacity Pallet provides for: |
| 34 | + |
| 35 | +- Staking to receive Capacity |
| 36 | +- Unstaking & Thaw Period |
| 37 | +- Capacity Epoch management |
| 38 | + |
| 39 | +## Interactions |
| 40 | + |
| 41 | +### Extrinsics |
| 42 | + |
| 43 | +| Name/Description | Caller | Payment | Key Events | Runtime Added | |
| 44 | +| -------------------------------- | ------------- | ------- | ------------------------------------------------------------------------------------------------------------- | ------------- | |
| 45 | +| `stake`<br />Lock tokens to grant Capacity to a Provider | Token Account | Tokens | [`Staked`](https://frequency-chain.github.io/frequency/pallet_capacity/pallet/enum.Event.html#variant.Staked) | 1 | |
| 46 | +| `unstake`<br />Begin the process of unlocking tokens by unstaking currently staked tokens | Token Account | Tokens | [`UnStaked`](https://frequency-chain.github.io/frequency/pallet_capacity/pallet/enum.Event.html#variant.UnStaked) | 1 | |
| 47 | +| `withdraw_unstaked`<br />Complete the process of unlocking tokens staked by releasing locks on expired unlock chunks | Token Account | Tokens | [`StakeWithdrawn`](https://frequency-chain.github.io/frequency/pallet_capacity/pallet/enum.Event.html#variant.StakeWithdrawn) | 1 | |
| 48 | + |
| 49 | +See [Rust Docs](https://frequency-chain.github.io/frequency/pallet_capacity/pallet/struct.Pallet.html) for more details. |
| 50 | + |
| 51 | +### State Queries |
| 52 | + |
| 53 | +| Name | Description | Query | Runtime Added | |
| 54 | +| --------- | ------------------- | ------------------------ | ------------- | |
| 55 | +| Get Capacity Ledger | Returns the Capacity balance details for a Provider's MSA Id | `capacityLedger` | 1 | |
| 56 | +| Get Current Epoch | Returns the current Capacity Epoch number | `currentEpoch` | 1 | |
| 57 | +| Get Current Epoch Info | Returns information about the current Capacity Epoch such as the starting block number | `currentEpochInfo` | 1 | |
| 58 | +| Get Staking Account Ledger | Returns information about an account's current staking details | `stakingAccountLedger` | 1 | |
| 59 | +| Staking Target Ledger | Returns information about an account's current staking details for a specific target Provider MSA Id | `stakingTargetLedger` | 1 | |
| 60 | +| Get Unstake Information | Returns the information about an account's current unstaking details and the unlocking chunks | `unstakeUnlocks` | 1 | |
| 61 | + |
| 62 | + |
| 63 | +See the [Rust Docs](https://frequency-chain.github.io/frequency/pallet_capacity/pallet/storage_types/index.html) for additional state queries and details. |
0 commit comments