@@ -44,12 +44,13 @@ impl<T: Config> Pallet<T> {
44
44
log:: debug!( "All subnet netuids: {:?}" , subnets) ;
45
45
46
46
// --- 2. Get sum of tao reserves ( in a later version we will switch to prices. )
47
- let mut tao_sum : I96F32 = I96F32 :: from_num ( 0.0 ) ;
47
+ let mut total_moving_prices : I96F32 = I96F32 :: from_num ( 0.0 ) ;
48
48
for netuid_i in subnets. iter ( ) {
49
- // Get and add subnet TAO in reserve.
50
- tao_sum = tao_sum. saturating_add ( asfloat ! ( SubnetTAO :: <T >:: get( netuid_i) ) ) ;
49
+ // Get and update the moving price of each subnet adding the total together.
50
+ Self :: update_moving_price ( * netuid_i ) ;
51
+ total_moving_prices = total_moving_prices. saturating_add ( Self :: get_moving_alpha_price ( * netuid_i ) ) ;
51
52
}
52
- log:: debug!( "tao_sum : {:?}" , tao_sum ) ;
53
+ log:: debug!( "total_moving_prices : {:?}" , total_moving_prices ) ;
53
54
54
55
// --- 3. Get subnet terms (tao_in, alpha_in, and alpha_out)
55
56
// Computation is described in detail in the dtao whitepaper.
@@ -61,10 +62,10 @@ impl<T: Config> Pallet<T> {
61
62
let price_i: I96F32 = Self :: get_alpha_price ( * netuid_i) ;
62
63
log:: debug!( "price_i: {:?}" , price_i) ;
63
64
// Get subnet TAO.
64
- let subnet_tao_i : I96F32 = asfloat ! ( SubnetTAO :: < T > :: get ( netuid_i) ) ;
65
- log:: debug!( "subnet_tao_i : {:?}" , subnet_tao_i ) ;
65
+ let moving_price_i : I96F32 = Self :: get_moving_alpha_price ( * netuid_i ) ;
66
+ log:: debug!( "moving_price_i : {:?}" , moving_price_i ) ;
66
67
// Emission is price over total.
67
- let tao_in_i: I96F32 = block_emission. saturating_mul ( subnet_tao_i ) . checked_div ( tao_sum ) . unwrap_or ( asfloat ! ( 0.0 ) ) ;
68
+ let mut tao_in_i: I96F32 = block_emission. saturating_mul ( moving_price_i ) . checked_div ( total_moving_prices ) . unwrap_or ( asfloat ! ( 0.0 ) ) ;
68
69
log:: debug!( "tao_in_i: {:?}" , tao_in_i) ;
69
70
// Get alpha_emission total
70
71
let alpha_emission_i: I96F32 = asfloat ! ( Self :: get_block_emission_for_issuance( Self :: get_alpha_issuance( * netuid_i) ) . unwrap_or( 0 ) ) ;
@@ -75,8 +76,8 @@ impl<T: Config> Pallet<T> {
75
76
// Get alpha_out.
76
77
let alpha_out_i = alpha_emission_i;
77
78
// Only emit TAO if the subnetwork allows registration.
78
- if !Self :: get_network_registration_allowed ( * netuid )
79
- && Self :: get_network_pow_registration_allowed ( * netuid )
79
+ if !Self :: get_network_registration_allowed ( * netuid_i )
80
+ && Self :: get_network_pow_registration_allowed ( * netuid_i )
80
81
{
81
82
tao_in_i = asfloat ! ( 0.0 ) ;
82
83
}
0 commit comments