Skip to content

Commit

Permalink
feat: cash valuation method (#1638)
Browse files Browse the repository at this point in the history
* feat: cash valuation method

* fix: introduced newline
  • Loading branch information
mustermeiszer authored Dec 1, 2023
1 parent b8cefb4 commit 7eaa21f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pallets/loans/docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ package valuation {
enum ValuationMethod {
DiscountedCashFlows: DiscountedCashFlows
OutstandingDebt
OutstandingDebt,
Cash
}
ValuationMethod *--> DiscountedCashFlows
Expand Down
2 changes: 1 addition & 1 deletion pallets/loans/src/entities/pricing/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<T: Config> InternalActivePricing<T> {
origination_date,
)?)
}
ValuationMethod::OutstandingDebt => Ok(debt),
ValuationMethod::OutstandingDebt | ValuationMethod::Cash => Ok(debt),
}
}

Expand Down
6 changes: 5 additions & 1 deletion pallets/loans/src/types/valuation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ pub enum ValuationMethod<Rate> {
DiscountedCashFlow(DiscountedCashFlow<Rate>),
/// Outstanding debt valuation
OutstandingDebt,
/// Equal to OutstandingDebt but signals
/// that the given loan is i.e. an account
/// holding cash
Cash,
}

impl<Rate> ValuationMethod<Rate>
Expand All @@ -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,
}
}
}

0 comments on commit 7eaa21f

Please sign in to comment.