diff --git a/pallets/pool-fees/src/lib.rs b/pallets/pool-fees/src/lib.rs index 0a9a554416..5e1f4f2c0f 100644 --- a/pallets/pool-fees/src/lib.rs +++ b/pallets/pool-fees/src/lib.rs @@ -211,6 +211,7 @@ pub mod pallet { /// /// Lifetime of a storage entry: Forever, inherited from pool lifetime. #[pallet::storage] + #[pallet::getter(fn portfolio_valuation)] pub(crate) type PortfolioValuation = StorageMap< _, Blake2_128Concat, diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 13b36f9310..36849be304 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -139,12 +139,21 @@ where { let mut pool = pallet_pool_system::Pool::::get(pool_id) .ok_or(pallet_pool_system::Error::::NoSuchPool)?; - let (nav_loans, _) = - pallet_loans::Pallet::::update_portfolio_valuation_for_pool(pool_id, price_input)?; - let (nav_fees, _) = pallet_pool_fees::Pallet::::update_portfolio_valuation_for_pool( + + let prev_nav_loans = pallet_loans::Pallet::::portfolio_valuation(pool_id).value(); + let nav_loans = + pallet_loans::Pallet::::update_portfolio_valuation_for_pool(pool_id, price_input) + .map(|(nav_loans, _)| nav_loans) + .unwrap_or(prev_nav_loans); + + let prev_fees_loans = pallet_pool_fees::Pallet::::portfolio_valuation(pool_id).value(); + let nav_fees = pallet_pool_fees::Pallet::::update_portfolio_valuation_for_pool( pool_id, &mut pool.reserve.total, - )?; + ) + .map(|(nav_fees, _)| nav_fees) + .unwrap_or(prev_fees_loans); + let nav = Nav::new(nav_loans, nav_fees); let total = nav .total(pool.reserve.total)