Skip to content

Commit

Permalink
Restore merge removals
Browse files Browse the repository at this point in the history
  • Loading branch information
rakanalh committed Nov 27, 2023
1 parent 7527f72 commit 4f4c28c
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions pallets/ddc-payouts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,55 @@ pub mod pallet {
}
}

fn charge_treasury_fees<T: Config>(
treasury_fee: u128,
vault: &T::AccountId,
treasury_vault: &T::AccountId,
) -> DispatchResult {
let amount_to_deduct = treasury_fee.saturated_into::<BalanceOf<T>>();
<T as pallet::Config>::Currency::transfer(
vault,
treasury_vault,
amount_to_deduct,
ExistenceRequirement::KeepAlive,
)
}

fn charge_cluster_reserve_fees<T: Config>(
cluster_reserve_fee: u128,
vault: &T::AccountId,
reserve_vault: &T::AccountId,
) -> DispatchResult {
let amount_to_deduct = cluster_reserve_fee.saturated_into::<BalanceOf<T>>();
<T as pallet::Config>::Currency::transfer(
vault,
reserve_vault,
amount_to_deduct,
ExistenceRequirement::KeepAlive,
)
}

fn charge_validator_fees<T: Config>(
validators_fee: u128,
vault: &T::AccountId,
) -> DispatchResult {
let amount_to_deduct = validators_fee
.checked_div(T::ValidatorList::count().try_into().unwrap())
.ok_or(Error::<T>::ArithmeticOverflow)?
.saturated_into::<BalanceOf<T>>();

for validator_account_id in T::ValidatorList::iter() {
<T as pallet::Config>::Currency::transfer(
vault,
&validator_account_id,
amount_to_deduct,
ExistenceRequirement::KeepAlive,
)?;
}

Ok(())
}

fn get_node_reward(
node_usage: &NodeUsage,
total_nodes_usage: &NodeUsage,
Expand Down

0 comments on commit 4f4c28c

Please sign in to comment.