@@ -39,13 +39,14 @@ impl<T: Config> Pallet<T> {
39
39
log:: debug!( "Subnets to emit to: {subnets_to_emit_to:?}" ) ;
40
40
41
41
// --- 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 ) ;
43
43
// Only get price EMA for subnets that we emit to.
44
44
for netuid_i in subnets_to_emit_to. iter ( ) {
45
45
// 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) ) ;
48
48
}
49
+ let total_moving_prices = acc_total_moving_prices;
49
50
log:: debug!( "total_moving_prices: {total_moving_prices:?}" ) ;
50
51
51
52
// --- 3. Get subnet terms (tao_in, alpha_in, and alpha_out)
@@ -183,21 +184,22 @@ impl<T: Config> Pallet<T> {
183
184
} ) ;
184
185
}
185
186
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
+
186
194
// --- 6. Seperate out root dividends in alpha and sell them into tao.
187
195
// Then accumulate those dividends for later.
188
196
for netuid_i in subnets_to_emit_to. iter ( ) {
189
197
// Get remaining alpha out.
190
198
let alpha_out_i: U96F32 = * alpha_out. get ( netuid_i) . unwrap_or ( & asfloat ! ( 0.0 ) ) ;
191
199
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:?}" ) ;
195
200
// Get total ALPHA on subnet.
196
201
let alpha_issuance: U96F32 = asfloat ! ( Self :: get_alpha_issuance( * netuid_i) ) ;
197
202
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:?}" ) ;
201
203
// Get root proportional dividends.
202
204
let root_proportion: U96F32 = tao_weight
203
205
. checked_div ( tao_weight. saturating_add ( alpha_issuance) )
@@ -239,14 +241,14 @@ impl<T: Config> Pallet<T> {
239
241
} ) ;
240
242
}
241
243
242
- // --- 7 Update moving prices after using them in the emission calculation.
244
+ // --- 7. Update moving prices after using them in the emission calculation.
243
245
// Only update price EMA for subnets that we emit to.
244
246
for netuid_i in subnets_to_emit_to. iter ( ) {
245
247
// Update moving prices after using them above.
246
248
Self :: update_moving_price ( * netuid_i) ;
247
249
}
248
250
249
- // --- 7 . Drain pending emission through the subnet based on tempo.
251
+ // --- 8 . Drain pending emission through the subnet based on tempo.
250
252
// Run the epoch for *all* subnets, even if we don't emit anything.
251
253
for & netuid in subnets. iter ( ) {
252
254
// Reveal matured weights.
0 commit comments