@@ -39,13 +39,14 @@ impl<T: Config> Pallet<T> {
3939 log:: debug!( "Subnets to emit to: {subnets_to_emit_to:?}" ) ;
4040
4141 // --- 2. Get sum of tao reserves ( in a later version we will switch to prices. )
42- let mut total_moving_prices = U96F32 :: saturating_from_num ( 0.0 ) ;
42+ let mut acc_total_moving_prices = U96F32 :: saturating_from_num ( 0.0 ) ;
4343 // Only get price EMA for subnets that we emit to.
4444 for netuid_i in subnets_to_emit_to. iter ( ) {
4545 // Get and update the moving price of each subnet adding the total together.
46- total_moving_prices =
47- total_moving_prices . saturating_add ( Self :: get_moving_alpha_price ( * netuid_i) ) ;
46+ acc_total_moving_prices =
47+ acc_total_moving_prices . saturating_add ( Self :: get_moving_alpha_price ( * netuid_i) ) ;
4848 }
49+ let total_moving_prices = acc_total_moving_prices;
4950 log:: debug!( "total_moving_prices: {total_moving_prices:?}" ) ;
5051
5152 // --- 3. Get subnet terms (tao_in, alpha_in, and alpha_out)
@@ -183,21 +184,22 @@ impl<T: Config> Pallet<T> {
183184 } ) ;
184185 }
185186
187+ // Get total TAO on root.
188+ let root_tao: U96F32 = asfloat ! ( SubnetTAO :: <T >:: get( NetUid :: ROOT ) ) ;
189+ log:: debug!( "root_tao: {root_tao:?}" ) ;
190+ // Get tao_weight
191+ let tao_weight: U96F32 = root_tao. saturating_mul ( Self :: get_tao_weight ( ) ) ;
192+ log:: debug!( "tao_weight: {tao_weight:?}" ) ;
193+
186194 // --- 6. Seperate out root dividends in alpha and sell them into tao.
187195 // Then accumulate those dividends for later.
188196 for netuid_i in subnets_to_emit_to. iter ( ) {
189197 // Get remaining alpha out.
190198 let alpha_out_i: U96F32 = * alpha_out. get ( netuid_i) . unwrap_or ( & asfloat ! ( 0.0 ) ) ;
191199 log:: debug!( "alpha_out_i: {alpha_out_i:?}" ) ;
192- // Get total TAO on root.
193- let root_tao: U96F32 = asfloat ! ( SubnetTAO :: <T >:: get( NetUid :: ROOT ) ) ;
194- log:: debug!( "root_tao: {root_tao:?}" ) ;
195200 // Get total ALPHA on subnet.
196201 let alpha_issuance: U96F32 = asfloat ! ( Self :: get_alpha_issuance( * netuid_i) ) ;
197202 log:: debug!( "alpha_issuance: {alpha_issuance:?}" ) ;
198- // Get tao_weight
199- let tao_weight: U96F32 = root_tao. saturating_mul ( Self :: get_tao_weight ( ) ) ;
200- log:: debug!( "tao_weight: {tao_weight:?}" ) ;
201203 // Get root proportional dividends.
202204 let root_proportion: U96F32 = tao_weight
203205 . checked_div ( tao_weight. saturating_add ( alpha_issuance) )
@@ -239,14 +241,14 @@ impl<T: Config> Pallet<T> {
239241 } ) ;
240242 }
241243
242- // --- 7 Update moving prices after using them in the emission calculation.
244+ // --- 7. Update moving prices after using them in the emission calculation.
243245 // Only update price EMA for subnets that we emit to.
244246 for netuid_i in subnets_to_emit_to. iter ( ) {
245247 // Update moving prices after using them above.
246248 Self :: update_moving_price ( * netuid_i) ;
247249 }
248250
249- // --- 7 . Drain pending emission through the subnet based on tempo.
251+ // --- 8 . Drain pending emission through the subnet based on tempo.
250252 // Run the epoch for *all* subnets, even if we don't emit anything.
251253 for & netuid in subnets. iter ( ) {
252254 // Reveal matured weights.
0 commit comments