Skip to content

Commit 6f3ce2c

Browse files
committed
EMA price halving period hyperparameter - in progress
1 parent 3c72232 commit 6f3ce2c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,35 @@ pub mod pallet {
14141414
);
14151415
Ok(())
14161416
}
1417+
1418+
///
1419+
///
1420+
/// # Arguments
1421+
/// * `origin` - The origin of the call, which must be the root account.
1422+
/// * `ema_alpha_period` - Number of blocks for EMA price to halve
1423+
///
1424+
/// # Errors
1425+
/// * `BadOrigin` - If the caller is not the root account.
1426+
///
1427+
/// # Weight
1428+
/// Weight is handled by the `#[pallet::weight]` attribute.
1429+
#[pallet::call_index(65)]
1430+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1431+
pub fn sudo_set_ema_price_halving_period(
1432+
origin: OriginFor<T>,
1433+
netuid: u16,
1434+
ema_halving: u64,
1435+
) -> DispatchResult {
1436+
ensure_root(origin)?;
1437+
pallet_subtensor::EMAPriceHalvingBlocks::<T>::set(netuid, ema_halving);
1438+
1439+
log::debug!(
1440+
"EMAPriceHalvingBlocks( netuid: {:?}, ema_halving: {:?} )",
1441+
netuid,
1442+
ema_halving
1443+
);
1444+
Ok(())
1445+
}
14171446
}
14181447
}
14191448

pallets/subtensor/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,11 @@ pub mod pallet {
396396
0
397397
}
398398
#[pallet::type_value]
399+
/// Default EMA price halving blocks
400+
pub fn DefaultEMAPriceMovingBlocks<T: Config>() -> u64 {
401+
201_600
402+
}
403+
#[pallet::type_value]
399404
/// Default registrations this block.
400405
pub fn DefaultBurn<T: Config>() -> u64 {
401406
T::InitialBurn::get()
@@ -1284,6 +1289,10 @@ pub mod pallet {
12841289
pub type RegistrationsThisBlock<T> =
12851290
StorageMap<_, Identity, u16, u16, ValueQuery, DefaultRegistrationsThisBlock<T>>;
12861291
#[pallet::storage]
1292+
/// --- MAP ( netuid ) --> Halving time of average moving price.
1293+
pub type EMAPriceHalvingBlocks<T> =
1294+
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultEMAPriceMovingBlocks<T>>;
1295+
#[pallet::storage]
12871296
/// --- MAP ( netuid ) --> global_RAO_recycled_for_registration
12881297
pub type RAORecycledForRegistration<T> =
12891298
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultRAORecycledForRegistration<T>>;

0 commit comments

Comments
 (0)