Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ pub mod pallet {
}
#[pallet::type_value]
/// Default value for zero.
pub fn DefaultZeroU128<T: Config>() -> u128 {
0
}
#[pallet::type_value]
/// Default value for zero.
pub fn DefaultZeroU16<T: Config>() -> u16 {
0
}
Expand Down Expand Up @@ -907,7 +912,7 @@ pub mod pallet {
pub type DynamicBlock<T> = StorageValue<_, u64, ValueQuery>;
#[pallet::storage] // --- MAP ( netuid ) --> total_volume | The total amount of TAO bought and sold since the start of the network.
pub type SubnetVolume<T: Config> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultZeroU64<T>>;
StorageMap<_, Identity, u16, u128, ValueQuery, DefaultZeroU128<T>>;
#[pallet::storage] // --- MAP ( netuid ) --> tao_in_subnet | Returns the amount of TAO in the subnet.
pub type SubnetTAO<T: Config> =
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultZeroU64<T>>;
Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/rpc_info/dynamic_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use codec::Compact;
use frame_support::pallet_prelude::{Decode, Encode};
use subtensor_macros::freeze_struct;

#[freeze_struct("1be5a1e26a82082f")]
#[freeze_struct("a5cdc80d655398e9")]
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
pub struct DynamicInfo<T: Config> {
netuid: Compact<u16>,
Expand All @@ -24,7 +24,7 @@ pub struct DynamicInfo<T: Config> {
tao_in_emission: Compact<u64>,
pending_alpha_emission: Compact<u64>,
pending_root_emission: Compact<u64>,
subnet_volume: Compact<u64>,
subnet_volume: Compact<u128>,
network_registered_at: Compact<u64>,
subnet_identity: Option<SubnetIdentity>,
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/rpc_info/metagraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use frame_support::pallet_prelude::{Decode, Encode};
use substrate_fixed::types::I64F64;
use subtensor_macros::freeze_struct;

#[freeze_struct("fa24d156067e5eb9")]
#[freeze_struct("7c5fe907490c5d5e")]
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
pub struct Metagraph<T: Config> {
// Subnet index
Expand Down Expand Up @@ -38,7 +38,7 @@ pub struct Metagraph<T: Config> {
tao_in_emission: Compact<u64>, // amount of tao injected per block
pending_alpha_emission: Compact<u64>, // pending alpha to be distributed
pending_root_emission: Compact<u64>, // panding tao for root divs to be distributed
subnet_volume: Compact<u64>, // volume of the subnet in TAO
subnet_volume: Compact<u128>, // volume of the subnet in TAO

// Hparams for epoch
rho: Compact<u16>, // subnet rho param
Expand Down
8 changes: 4 additions & 4 deletions pallets/subtensor/src/staking/stake_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ impl<T: Config> Pallet<T> {
TotalStake::<T>::mutate(|total| {
*total = total.saturating_add(tao);
});
// Step 8. Decrease Alpha reserves.
// Step 8. Increase total subnet TAO volume.
SubnetVolume::<T>::mutate(netuid, |total| {
*total = total.saturating_add(tao);
*total = total.saturating_add(tao.into());
});
// Step 9. Return the alpha received.
alpha
Expand Down Expand Up @@ -589,9 +589,9 @@ impl<T: Config> Pallet<T> {
TotalStake::<T>::mutate(|total| {
*total = total.saturating_sub(tao);
});
// Step 8. Decrease Alpha reserves.
// Step 8. Increase total subnet TAO volume.
SubnetVolume::<T>::mutate(netuid, |total| {
*total = total.saturating_add(tao);
*total = total.saturating_add(tao.into());
});
// Step 9. Return the tao received.
tao
Expand Down
Loading