From b623e3516d59e14f1979ff0da5572d87dd771884 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Tue, 12 Nov 2024 12:40:20 +0200 Subject: [PATCH] fix: FeesTreasuryProportion is only applied to substrate based tx only --- runtime/moonbase/src/lib.rs | 12 ++++++++---- runtime/moonbeam/src/lib.rs | 12 ++++++++---- runtime/moonriver/src/lib.rs | 12 ++++++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index be2fd23073..7c699860f6 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -364,9 +364,9 @@ where mut fees_then_tips: impl Iterator>>, ) { if let Some(fees) = fees_then_tips.next() { - let treasury_perbill = + let treasury_proportion = runtime_params::dynamic_params::runtime_config::FeesTreasuryProportion::get(); - let treasury_part = treasury_perbill.deconstruct(); + let treasury_part = treasury_proportion.deconstruct(); let burn_part = Perbill::one().deconstruct() - treasury_part; let (_, to_treasury) = fees.ration(burn_part, treasury_part); // Balances pallet automatically burns dropped Credits by decreasing @@ -378,7 +378,7 @@ where // handle tip if there is one if let Some(tip) = fees_then_tips.next() { // for now we use the same burn/treasury strategy used for regular fees - let (_, to_treasury) = tip.ration(80, 20); + let (_, to_treasury) = tip.ration(burn_part, treasury_part); ResolveTo::, pallet_balances::Pallet>::on_unbalanced( to_treasury, ); @@ -391,7 +391,11 @@ where fn on_nonzero_unbalanced(amount: Credit>) { // Balances pallet automatically burns dropped Credits by decreasing // total_supply accordingly - let (_, to_treasury) = amount.ration(80, 20); + let treasury_proportion = + runtime_params::dynamic_params::runtime_config::FeesTreasuryProportion::get(); + let treasury_part = treasury_proportion.deconstruct(); + let burn_part = Perbill::one().deconstruct() - treasury_part; + let (_, to_treasury) = amount.ration(burn_part, treasury_part); ResolveTo::, pallet_balances::Pallet>::on_unbalanced(to_treasury); } } diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index a8ca7810a8..91635966c5 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -352,9 +352,9 @@ where mut fees_then_tips: impl Iterator>>, ) { if let Some(fees) = fees_then_tips.next() { - let treasury_perbill = + let treasury_proportion = runtime_params::dynamic_params::runtime_config::FeesTreasuryProportion::get(); - let treasury_part = treasury_perbill.deconstruct(); + let treasury_part = treasury_proportion.deconstruct(); let burn_part = Perbill::one().deconstruct() - treasury_part; let (_, to_treasury) = fees.ration(burn_part, treasury_part); // Balances pallet automatically burns dropped Credits by decreasing @@ -366,7 +366,7 @@ where // handle tip if there is one if let Some(tip) = fees_then_tips.next() { // for now we use the same burn/treasury strategy used for regular fees - let (_, to_treasury) = tip.ration(80, 20); + let (_, to_treasury) = tip.ration(burn_part, treasury_part); ResolveTo::, pallet_balances::Pallet>::on_unbalanced( to_treasury, ); @@ -379,7 +379,11 @@ where fn on_nonzero_unbalanced(amount: Credit>) { // Balances pallet automatically burns dropped Credits by decreasing // total_supply accordingly - let (_, to_treasury) = amount.ration(80, 20); + let treasury_proportion = + runtime_params::dynamic_params::runtime_config::FeesTreasuryProportion::get(); + let treasury_part = treasury_proportion.deconstruct(); + let burn_part = Perbill::one().deconstruct() - treasury_part; + let (_, to_treasury) = amount.ration(burn_part, treasury_part); ResolveTo::, pallet_balances::Pallet>::on_unbalanced(to_treasury); } } diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index ad68874966..bd9776892e 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -354,9 +354,9 @@ where mut fees_then_tips: impl Iterator>>, ) { if let Some(fees) = fees_then_tips.next() { - let treasury_perbill = + let treasury_proportion = runtime_params::dynamic_params::runtime_config::FeesTreasuryProportion::get(); - let treasury_part = treasury_perbill.deconstruct(); + let treasury_part = treasury_proportion.deconstruct(); let burn_part = Perbill::one().deconstruct() - treasury_part; let (_, to_treasury) = fees.ration(burn_part, treasury_part); // Balances pallet automatically burns dropped Credits by decreasing @@ -368,7 +368,7 @@ where // handle tip if there is one if let Some(tip) = fees_then_tips.next() { // for now we use the same burn/treasury strategy used for regular fees - let (_, to_treasury) = tip.ration(80, 20); + let (_, to_treasury) = tip.ration(burn_part, treasury_part); ResolveTo::, pallet_balances::Pallet>::on_unbalanced( to_treasury, ); @@ -381,7 +381,11 @@ where fn on_nonzero_unbalanced(amount: Credit>) { // Balances pallet automatically burns dropped Credits by decreasing // total_supply accordingly - let (_, to_treasury) = amount.ration(80, 20); + let treasury_proportion = + runtime_params::dynamic_params::runtime_config::FeesTreasuryProportion::get(); + let treasury_part = treasury_proportion.deconstruct(); + let burn_part = Perbill::one().deconstruct() - treasury_part; + let (_, to_treasury) = amount.ration(burn_part, treasury_part); ResolveTo::, pallet_balances::Pallet>::on_unbalanced(to_treasury); } }