Skip to content

Commit

Permalink
Handle fees from evm transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
NZT48 committed Jul 14, 2023
1 parent 771dc8d commit d0d7cc3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ type NegativeImbalance = <Balances as PalletCurrency<AccountId>>::NegativeImbala

pub struct DealWithFees;
impl OnUnbalanced<NegativeImbalance> for DealWithFees {
// this is called for substrate-based transactions
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
if let Some(mut fees) = fees_then_tips.next() {
if let Some(tips) = fees_then_tips.next() {
Expand All @@ -479,6 +480,20 @@ impl OnUnbalanced<NegativeImbalance> for DealWithFees {
<DkgIncentivesPot as OnUnbalanced<_>>::on_unbalanced(dkg_incentives_fees);
}
}

// this is called from pallet_evm for Ethereum-based transactions
// (technically, it calls on_unbalanced, which calls this when non-zero)
fn on_nonzero_unbalanced(amount: NegativeImbalance) {
let split = amount.ration(60, 40);
let (dkg_incentives_fees, collators_incentives_fees) = split.0.ration(50, 50);
let (future_auctions_fees, treasury_fees) = split.1.ration(75, 25);

Treasury::on_unbalanced(treasury_fees);
<ToStakingPot as OnUnbalanced<_>>::on_unbalanced(collators_incentives_fees);
<FutureAuctionsPot as OnUnbalanced<_>>::on_unbalanced(future_auctions_fees);
<DkgIncentivesPot as OnUnbalanced<_>>::on_unbalanced(dkg_incentives_fees);
}

}

parameter_types! {
Expand Down Expand Up @@ -611,6 +626,11 @@ impl pallet_sudo::Config for Runtime {
type RuntimeCall = RuntimeCall;
}

impl pallet_sudo::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
}

parameter_types! {
pub const MinVestedTransfer: Balance = 15 * OTP;
pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
Expand Down

0 comments on commit d0d7cc3

Please sign in to comment.