@@ -30,24 +30,10 @@ impl<T: Config> Pallet<T> {
3030 . filter ( |netuid| * netuid != NetUid :: ROOT )
3131 . collect ( ) ;
3232 log:: debug!( "All subnet netuids: {subnets:?}" ) ;
33- // Filter out subnets with no first emission block number.
34- let subnets_to_emit_to: Vec < NetUid > = subnets
35- . clone ( )
36- . into_iter ( )
37- . filter ( |netuid| FirstEmissionBlockNumber :: < T > :: get ( * netuid) . is_some ( ) )
38- . collect ( ) ;
39- log:: debug!( "Subnets to emit to: {subnets_to_emit_to:?}" ) ;
4033
41- // --- 2. Get sum of tao reserves ( in a later version we will switch to prices. )
42- let mut acc_total_moving_prices = U96F32 :: saturating_from_num ( 0.0 ) ;
43- // Only get price EMA for subnets that we emit to.
44- for netuid_i in subnets_to_emit_to. iter ( ) {
45- // Get and update the moving price of each subnet adding the total together.
46- acc_total_moving_prices =
47- acc_total_moving_prices. saturating_add ( Self :: get_moving_alpha_price ( * netuid_i) ) ;
48- }
49- let total_moving_prices = acc_total_moving_prices;
50- log:: debug!( "total_moving_prices: {total_moving_prices:?}" ) ;
34+ // 2. Get subnets to emit to and emissions
35+ let subnet_emissions = Self :: get_subnet_block_emissions ( & subnets, block_emission) ;
36+ let subnets_to_emit_to: Vec < NetUid > = subnet_emissions. keys ( ) . copied ( ) . collect ( ) ;
5137
5238 // --- 3. Get subnet terms (tao_in, alpha_in, and alpha_out)
5339 // Computation is described in detail in the dtao whitepaper.
@@ -60,14 +46,11 @@ impl<T: Config> Pallet<T> {
6046 // Get subnet price.
6147 let price_i = T :: SwapInterface :: current_alpha_price ( ( * netuid_i) . into ( ) ) ;
6248 log:: debug!( "price_i: {price_i:?}" ) ;
63- // Get subnet TAO.
64- let moving_price_i: U96F32 = Self :: get_moving_alpha_price ( * netuid_i) ;
65- log:: debug!( "moving_price_i: {moving_price_i:?}" ) ;
6649 // Emission is price over total.
67- let default_tao_in_i: U96F32 = block_emission
68- . saturating_mul ( moving_price_i )
69- . checked_div ( total_moving_prices )
70- . unwrap_or ( asfloat ! ( 0.0 ) ) ;
50+ let default_tao_in_i: U96F32 = subnet_emissions
51+ . get ( netuid_i )
52+ . copied ( )
53+ . unwrap_or ( asfloat ! ( 0 ) ) ;
7154 log:: debug!( "default_tao_in_i: {default_tao_in_i:?}" ) ;
7255 // Get alpha_emission total
7356 let alpha_emission_i: U96F32 = asfloat ! (
0 commit comments