You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to allocate a fraction of genesis tokens to collators over a 2 year period as well as define a mechanism for inflationary rewards once this amount of tokens runs out.
We’d like to target 1-5% inflation for
collators
treasury
Desired Outcome
Every block payout
The pallet account will receive an amount of tokens at genesis
These tokens will be distributed at configured RewardAmount to the collators (block author)
Once the genesis amount of tokens are depleted, the pallet will create new tokens
New amount of tokens created every block according to inflation rate
Create a new pallet reward-handler. The pallet will
implement OnUnbalanced to accept the block_reward + tips
calculate the amount of tokens to transfer based on inflation rate
transfer block_reward + tips + new_tokens to block_author every block (or part to treasury)
Pallet Config
/// The pallet's configuration trait.pubtraitConfig: frame_system::Config + pallet_balances::Config + pallet_treasury::Config{/// The overarching event type.typeEvent:From<Event<Self>> + IsType<<Selfas frame_system::Config>::Event>;/// The amount of tokens to mint every blocktypeRewardAmount:Get<Self::Balance>;/// PalletAccounttypePalletAccount:Get<Self::AccountId>;}
OnUnbalanced Handler
pubstructDealWithFees<R>(sp_std::marker::PhantomData<R>);impl<R>OnUnbalanced<NegativeImbalance<R>>forDealWithFees<R>{fnon_unbalanceds<B>(mutfees_then_tips:implIterator<Item = NegativeImbalance<R>>){ifletSome(fees) = fees_then_tips.next(){// for fees, 80% to treasury, 20% to author// We could also make this configurableletmut split = fees.ration(80,20);ifletSome(tips) = fees_then_tips.next(){// for tips, if any, 100% to author
tips.merge_into(&mut split.1);}// try to pay the collator reward amount from the pallet accountifBalances::can_transfer(){let block_author_reward = split.1 + Balances::withdraw(PalletAccount::get())}// if cannot pay from pallet account then add inlfation amountelse{// create new tokensBalances::issue(T::RewardAmount::get())let block_author_reward = split.1 + T::RewardAmount::get();}
<Treasury<R>asOnUnbalanced<_>>::on_unbalanced(split.0);
<ToAuthor<R>asOnUnbalanced<_>>::on_unbalanced(block_author_reward);}}}
Inflationary rewards
We want to allocate a fraction of genesis tokens to collators over a 2 year period as well as define a mechanism for inflationary rewards once this amount of tokens runs out.
We’d like to target 1-5% inflation for
Desired Outcome
RewardAmount
to the collators (block author)Docs
The text was updated successfully, but these errors were encountered: