Skip to content

Commit

Permalink
Remove dead duplicated fee-handler code + increase system fee to 2+2%
Browse files Browse the repository at this point in the history
  • Loading branch information
olanod committed Feb 15, 2024
1 parent 8cb01dc commit ac58bf4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 47 deletions.
44 changes: 1 addition & 43 deletions runtime/kreivo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use frame_support::{
ord_parameter_types, parameter_types,
traits::{
fungible::HoldConsideration,
fungibles,
tokens::{PayFromAccount, UnityAssetBalanceConversion},
AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, LinearStoragePrice,
NeverEnsureOrigin, TransformOrigin,
Expand Down Expand Up @@ -625,13 +626,6 @@ impl pallet_preimage::Config for Runtime {
>;
}

parameter_types! {
pub const MaxRemarkLength: u8 = 50;
pub const IncentivePercentage: Percent = Percent::from_percent(INCENTIVE_PERCENTAGE);
pub const PaymentPalletId: PalletId = PalletId(*b"payments");

}

ord_parameter_types! {
pub const RootAccount: AccountId32 = AccountId32::new(
[
Expand All @@ -654,42 +648,6 @@ impl super::BenchmarkHelper<AccountId, AssetId, Balance> for BenchmarkHelper {
}
}

pub struct KreivoFeeHandler;

const MANDATORY_FEE: bool = true;
pub const SYSTEM_FEE: u8 = 1;
pub const SYSTEM_FEE_PERCENTAGE: Percent = Percent::from_percent(SYSTEM_FEE);
pub const INCENTIVE_PERCENTAGE: u8 = 10;

impl FeeHandler<Runtime> for KreivoFeeHandler {
fn apply_fees(
_asset: &AssetIdOf<Runtime>,
_sender: &AccountId,
_beneficiary: &AccountId,
amount: &Balance,
_remark: Option<&[u8]>,
) -> Fees<Runtime> {
let sender_fee: Vec<(AccountId, Balance, bool)> = vec![(
RootAccount::get(),
SYSTEM_FEE_PERCENTAGE.mul_floor(*amount),
MANDATORY_FEE,
)];
let beneficiary_fee: Vec<(AccountId, Balance, bool)> = vec![(
RootAccount::get(),
SYSTEM_FEE_PERCENTAGE.mul_floor(*amount),
MANDATORY_FEE,
)];

let sender_pays: FeeDetails<Runtime> = BoundedVec::try_from(sender_fee).unwrap();
let beneficiary_pays: FeeDetails<Runtime> = BoundedVec::try_from(beneficiary_fee).unwrap();

Fees {
sender_pays,
beneficiary_pays,
}
}
}

#[cfg(feature = "runtime-benchmarks")]
pub struct AssetRegistryBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
Expand Down
9 changes: 5 additions & 4 deletions runtime/kreivo/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ impl pallet_payments::BenchmarkHelper<AccountId, AssetIdForTrustBackedAssets, Ba
pub struct KreivoFeeHandler;

const MANDATORY_FEE: bool = true;
pub const SYSTEM_FEE: u8 = 1;
pub const SYSTEM_FEE: u8 = 2;
pub const SYSTEM_FEE_PERCENTAGE: Percent = Percent::from_percent(SYSTEM_FEE);
pub const INCENTIVE_PERCENTAGE: u8 = 10;

impl FeeHandler<Runtime> for KreivoFeeHandler {
fn apply_fees(
_asset: &AssetIdOf<Runtime>,
asset: &AssetIdOf<Runtime>,
_sender: &AccountId,
_beneficiary: &AccountId,
amount: &Balance,
_remark: Option<&[u8]>,
) -> Fees<Runtime> {
let min = <Assets as fungibles::Inspect<AccountId>>::minimum_balance(*asset);
let sender_fee: Vec<(AccountId, Balance, bool)> = vec![(
TreasuryAccount::get(),
SYSTEM_FEE_PERCENTAGE.mul_floor(*amount),
min.max(SYSTEM_FEE_PERCENTAGE.mul_floor(*amount)),
MANDATORY_FEE,
)];
let beneficiary_fee: Vec<(AccountId, Balance, bool)> = vec![(
TreasuryAccount::get(),
SYSTEM_FEE_PERCENTAGE.mul_floor(*amount),
min.max(SYSTEM_FEE_PERCENTAGE.mul_floor(*amount)),
MANDATORY_FEE,
)];

Expand Down

0 comments on commit ac58bf4

Please sign in to comment.