Skip to content

Commit 135514e

Browse files
committed
update to design doc
1 parent 7a81207 commit 135514e

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

designdocs/capacity_staking_rewards_implementation.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ pub struct StakingAccountDetails {
4343
pub staking_type: StakingType, // NEW
4444
/// staking amounts that have been retargeted are prevented from being retargeted again for the
4545
/// configured Thawing Period number of blocks.
46-
pub stake_change_unlocking: BoundedVec<UnlockChunk<BalanceOf<T>, EraOf<T>>, T::MaxUnlockingChunks> // NEW
46+
pub stake_change_unlocking: BoundedVec<UnlockChunk<BalanceOf<T>, T::RewardEra>, T::MaxUnlockingChunks>, // NEW
47+
/// total staked amounts for each past era, up to StakingRewardsPastErasMax eras.
48+
pub staking_history: BoundedVec<StakingHistory<BalanceOf<T>, T::RewardEra>, T::StakingRewardsPastErasMax>, // NEW
4749
}
50+
51+
pub struct StakingHistory<Balance, RewardEra> {
52+
total_staked: Balance,
53+
reward_era: RewardEra,
54+
}
4855
```
4956

5057
**Unstaking thaw period**
@@ -157,8 +164,15 @@ pub trait Config: frame_system::Config {
157164
### NEW: RewardPoolInfo
158165
This is the necessary information about the reward pool for a given Reward Era and how it's stored.
159166
```rust
160-
pub struct RewardPoolInfo<T: Config> {
167+
pub struct RewardPoolInfo<Balance> {
168+
/// the total staked for rewards in the associated RewardEra
169+
pub total_staked_token: Balance,
170+
/// the reward pool for this era
171+
pub total_reward_pool: Balance,
172+
/// the remaining rewards balance to be claimed
173+
pub unclaimed_balance: Balance,
161174
}
175+
162176
/// Reward Pool history
163177
#[pallet::storage]
164178
#[pallet::getter(fn get_reward_pool_for_era)]
@@ -265,10 +279,22 @@ pub fn change_staking_target(
265279
fn payout_eligible(account_id: AccountIdOf<T>) -> bool;
266280
```
267281

268-
### NEW RPC
282+
### NEW RPCS
269283
There are no custom RPCs for the Capacity pallet, so that work will need to be done first.
270284
```rust
271-
/// RPC access to the pallet function by the same name
272-
pub fn payout_eligible(account_id: AccountId) -> bool;
273-
```
285+
pub struct UnclaimedRewardInfo {
286+
/// The Reward Era for which this reward was earned
287+
reward_era: RewardEra,
288+
/// An ISO8701 string, UTC, estimated using current block time, and the number of blocks between
289+
/// the current block and the block when this era's RewardPoolInfo would be removed from StakingRewardPool history
290+
expires_at: string,
291+
/// The amount staked in this era
292+
staked_amount: BalanceOf<T>,
293+
/// The amount in token of the reward (only if it can be calculated using only on chain data)
294+
earned_amount: BalanceOf<T>
295+
}
274296

297+
/// Check what unclaimed rewards origin has and how long they have left to claim them
298+
/// If no unclaimed rewards, returns empty list.
299+
fn check_for_unclaimed_rewards(origin: OriginFor<T>) -> Vec<UnclaimedRewardInfo>;
300+
```

0 commit comments

Comments
 (0)