Skip to content

Commit d73e559

Browse files
committed
apply tax to coinbase
1 parent 8f4288b commit d73e559

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ impl<T: Config> Pallet<T> {
743743
// Calculate the hotkey's share of the validator emission based on its childkey take
744744
let validating_emission: U96F32 = U96F32::saturating_from_num(dividends);
745745
let mut remaining_emission: U96F32 = validating_emission;
746+
746747
let childkey_take_proportion: U96F32 =
747748
U96F32::saturating_from_num(Self::get_childkey_take(hotkey, netuid))
748749
.safe_div(U96F32::saturating_from_num(u16::MAX));
@@ -826,14 +827,26 @@ impl<T: Config> Pallet<T> {
826827
.saturating_mul(U96F32::saturating_from_num(parent_emission))
827828
};
828829

830+
let childkey_emission_take_tax: U96F32 = child_emission_take
831+
.saturating_mul(U96F32::saturating_from_num(Self::get_childkey_tax_rate()))
832+
.safe_div(U96F32::saturating_from_num(u16::MAX));
833+
834+
let child_emission_take_after_tax: U96F32 =
835+
child_emission_take.saturating_sub(childkey_emission_take_tax);
836+
829837
// Remove the childkey take from the parent's emission.
830838
parent_emission = parent_emission.saturating_sub(child_emission_take);
831839

832840
// Add the childkey take to the total childkey take tracker.
833841
total_child_emission_take =
834-
total_child_emission_take.saturating_add(child_emission_take);
842+
total_child_emission_take.saturating_add(child_emission_take_after_tax);
835843

836-
log::debug!("Child emission take: {child_emission_take:?} for hotkey {hotkey:?}");
844+
log::debug!(
845+
"Child emission take tax: {childkey_emission_take_tax:?} for hotkey {hotkey:?}"
846+
);
847+
log::debug!(
848+
"Child emission take after tax: {child_emission_take_after_tax:?} for hotkey {hotkey:?}"
849+
);
837850
log::debug!("Parent emission: {parent_emission:?} for hotkey {hotkey:?}");
838851
log::debug!("remaining emission: {remaining_emission:?}");
839852

pallets/subtensor/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,9 +1483,9 @@ pub mod pallet {
14831483
StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultImmuneOwnerUidsLimit<T>>;
14841484

14851485
#[pallet::type_value]
1486-
/// Default value for childkey tax rate
1486+
/// Default value for childkey tax rate, 18%
14871487
pub fn DefaultChildkeyTaxRate<T: Config>() -> u16 {
1488-
18
1488+
11_796
14891489
}
14901490
#[pallet::storage]
14911491
pub type ChildkeyTaxRate<T> = StorageValue<_, u16, ValueQuery, DefaultChildkeyTaxRate<T>>;

pallets/subtensor/src/utils/misc.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,6 @@ impl<T: Config> Pallet<T> {
848848
/// - `Ok(())` on success.
849849
/// - `Err(Error::<T>::InvalidValue)` if `childkey_tax_rate` is outside `[0, 100]`.
850850
pub fn set_childkey_tax_rate(childkey_tax_rate: u16) -> DispatchResult {
851-
ensure!(childkey_tax_rate <= 100, Error::<T>::InvalidValue);
852-
853851
ChildkeyTaxRate::<T>::set(childkey_tax_rate);
854852
Ok(())
855853
}

0 commit comments

Comments
 (0)