diff --git a/pallets/universal-dividend/src/compute_claim_uds.rs b/pallets/universal-dividend/src/compute_claim_uds.rs index 5e214b9770db89791226dcc20e46e8847df1ac2e..02b381603eff4f949c941ef37278723d6593d9ee 100644 --- a/pallets/universal-dividend/src/compute_claim_uds.rs +++ b/pallets/universal-dividend/src/compute_claim_uds.rs @@ -26,12 +26,15 @@ pub(super) fn compute_claim_uds<Balance: AtLeast32BitUnsigned>( let mut total_amount = Zero::zero(); let mut total_count = 0; for (ud_index, ud_amount) in past_reevals.rev() { - let count = current_ud_index - core::cmp::max(ud_index, first_ud_index); - total_amount += Balance::from(count) * ud_amount; - total_count += count; if ud_index <= first_ud_index { + let count = current_ud_index - first_ud_index; + total_amount += Balance::from(count) * ud_amount; + total_count += count; break; } else { + let count = current_ud_index - ud_index; + total_amount += Balance::from(count) * ud_amount; + total_count += count; current_ud_index = ud_index; } } diff --git a/runtime/common/src/weights/pallet_universal_dividend.rs b/runtime/common/src/weights/pallet_universal_dividend.rs index 9f196cb7f02e44fa0c782f7a5b7a3af48f0fab0c..9c9efb8f91e8e234a80a53cd082edf33c3668d3c 100644 --- a/runtime/common/src/weights/pallet_universal_dividend.rs +++ b/runtime/common/src/weights/pallet_universal_dividend.rs @@ -76,7 +76,7 @@ impl<T: frame_system::Config> pallet_universal_dividend::WeightInfo for WeightIn fn claim_uds(n: u32) -> Weight { (1_228_876_000 as Weight) // Standard Error: 958_000 - .saturating_add((7_709_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((7_551_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) }