@@ -231,6 +231,10 @@ impl<T: Config> Pallet<T> {
231
231
PendingRootDivs :: < T > :: mutate ( * netuid, |total| {
232
232
* total = total. saturating_add ( root_emission_in_tao) ;
233
233
} ) ;
234
+ // Accumulate alpha that was swapped for the pending root divs.
235
+ PendingAlphaSwapped :: < T > :: mutate ( * netuid, |total| {
236
+ * total = total. saturating_add ( root_emission_in_alpha. to_num :: < u64 > ( ) ) ;
237
+ } ) ;
234
238
// Accumulate alpha emission in pending.
235
239
PendingEmission :: < T > :: mutate ( * netuid, |total| {
236
240
* total = total. saturating_add ( pending_alpha_emission. to_num :: < u64 > ( ) ) ;
@@ -261,10 +265,14 @@ impl<T: Config> Pallet<T> {
261
265
let pending_emission: u64 = PendingEmission :: < T > :: get ( netuid) ;
262
266
PendingEmission :: < T > :: insert ( netuid, 0 ) ;
263
267
264
- // 5.2.2 Get and drain the subnet pending root divs.
268
+ // 5.2.2a Get and drain the subnet pending root divs.
265
269
let pending_root_divs: u64 = PendingRootDivs :: < T > :: get ( netuid) ;
266
270
PendingRootDivs :: < T > :: insert ( netuid, 0 ) ;
267
271
272
+ // 5.2.2b Get this amount as alpha that was swapped for pending root divs.
273
+ let pending_alpha_swapped: u64 = PendingAlphaSwapped :: < T > :: get ( netuid) ;
274
+ PendingAlphaSwapped :: < T > :: insert ( netuid, 0 ) ;
275
+
268
276
// 5.2.3 Get owner cut and drain.
269
277
let owner_cut: u64 = PendingOwnerCut :: < T > :: get ( netuid) ;
270
278
PendingOwnerCut :: < T > :: insert ( netuid, 0 ) ;
@@ -274,6 +282,7 @@ impl<T: Config> Pallet<T> {
274
282
netuid,
275
283
pending_emission,
276
284
pending_root_divs,
285
+ pending_alpha_swapped,
277
286
owner_cut,
278
287
) ;
279
288
} else {
@@ -287,19 +296,24 @@ impl<T: Config> Pallet<T> {
287
296
netuid : u16 ,
288
297
pending_alpha_emission : u64 ,
289
298
pending_root_divs : u64 ,
299
+ pending_alpha_swapped : u64 ,
290
300
owner_cut : u64 ,
291
301
) {
292
302
log:: debug!(
293
- "Draining pending alpha emission for netuid {:?}: {:?}, with pending root divs {:?}, and owner cut {:?}" ,
303
+ "Draining pending alpha emission for netuid {:?}: {:?}, with pending root divs {:?}, pending alpha swapped {:?}, and owner cut {:?}" ,
294
304
netuid,
295
305
pending_alpha_emission,
296
306
pending_root_divs,
307
+ pending_alpha_swapped,
297
308
owner_cut
298
309
) ;
299
310
300
311
// Run the epoch() --> hotkey emission.
301
- let hotkey_emission: Vec < ( T :: AccountId , u64 , u64 ) > =
302
- Self :: epoch ( netuid, pending_alpha_emission) ;
312
+ // Needs to run on the full emission to the subnet.
313
+ let hotkey_emission: Vec < ( T :: AccountId , u64 , u64 ) > = Self :: epoch (
314
+ netuid,
315
+ pending_alpha_emission. saturating_add ( pending_alpha_swapped) ,
316
+ ) ;
303
317
log:: debug!(
304
318
"Hotkey emission for netuid {:?}: {:?}" ,
305
319
netuid,
0 commit comments