From 7eaa21f593715ebd3701aaf8e59c6a0046741bb4 Mon Sep 17 00:00:00 2001 From: Frederik Gartenmeister Date: Fri, 1 Dec 2023 10:21:34 +0100 Subject: [PATCH] feat: cash valuation method (#1638) * feat: cash valuation method * fix: introduced newline --- pallets/loans/docs/types.md | 3 ++- pallets/loans/src/entities/pricing/internal.rs | 2 +- pallets/loans/src/types/valuation.rs | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pallets/loans/docs/types.md b/pallets/loans/docs/types.md index ee5ef6bc33..3ae87a7ded 100644 --- a/pallets/loans/docs/types.md +++ b/pallets/loans/docs/types.md @@ -86,7 +86,8 @@ package valuation { enum ValuationMethod { DiscountedCashFlows: DiscountedCashFlows - OutstandingDebt + OutstandingDebt, + Cash } ValuationMethod *--> DiscountedCashFlows diff --git a/pallets/loans/src/entities/pricing/internal.rs b/pallets/loans/src/entities/pricing/internal.rs index af78ce7c09..f5e78c53fb 100644 --- a/pallets/loans/src/entities/pricing/internal.rs +++ b/pallets/loans/src/entities/pricing/internal.rs @@ -99,7 +99,7 @@ impl InternalActivePricing { origination_date, )?) } - ValuationMethod::OutstandingDebt => Ok(debt), + ValuationMethod::OutstandingDebt | ValuationMethod::Cash => Ok(debt), } } diff --git a/pallets/loans/src/types/valuation.rs b/pallets/loans/src/types/valuation.rs index b53ac6222c..63d2de67ec 100644 --- a/pallets/loans/src/types/valuation.rs +++ b/pallets/loans/src/types/valuation.rs @@ -106,6 +106,10 @@ pub enum ValuationMethod { DiscountedCashFlow(DiscountedCashFlow), /// Outstanding debt valuation OutstandingDebt, + /// Equal to OutstandingDebt but signals + /// that the given loan is i.e. an account + /// holding cash + Cash, } impl ValuationMethod @@ -115,7 +119,7 @@ where pub fn is_valid(&self) -> bool { match self { ValuationMethod::DiscountedCashFlow(dcf) => dcf.discount_rate.per_year() <= One::one(), - ValuationMethod::OutstandingDebt => true, + ValuationMethod::OutstandingDebt | ValuationMethod::Cash => true, } } }