apps icon indicating copy to clipboard operation
apps copied to clipboard

Add cashflow section to asset detail page

Open mustermeiszer opened this issue 1 year ago • 2 comments

Goal

Query the Centrifuge chain to know what kind of cash flows the chain is expecting on a certain asset and when it is expecting them. Then visualize these cashflows in a bar graph

Design

Design: https://www.figma.com/design/cn5CiQsuVDOmieszqcneX2/Pool-management?node-id=2408-14869&t=5FOUxemgdNB7UiqR-4

image

Open Questions

  • What do do if NO cashflow is expected?

Technical

  • It IS possible to get an empty Array as a return value - in these cases the chain is not expecting any cashflows
  • It IS possible to get a SINGLE item as a return value - in theses cases the chain is ONLY expecting this cashflow

How to query the chain

  • Query all available assets of a pool (if needed): await api.call.loansApi.portfolio(PoolId)
  • Query the cashflows of the individual:await api.call.loansApi.expectedCashflows(PoolId, LoanId)

NOTE: If the given PoolId or LoanId DOES NOT exist the chain will return a success but containing null.

Datastructures

  • NOTE: All BigInt here are the Balance-type defined somewhere in the apps repository. This is a 6-decimal USDC value for almost ALL cases. Check with @onnovisser or @sophialittlejohn for how they parse that on a per pool basis.

expectedCashflows

The call to the chain will return an Array of the following type

class CashflowPayment {
   when: number,
   principal: BigInt,
   interest: BigInt,
}

portfolio

The call to the chain will return an Array of the following type [LoanId, ActiveLoanInfo]

class ActiveLoanInfo {
   active_loan: ActiveLoan,
   /// Present value of the loan
   present_value: BigInt,
   /// Current outstanding principal of this loan
   outstanding_principal: BigInt,
   /// Current outstanding interest of this loan
   outstanding_interest: BigInt,
   /// Current price for external loans
   /// - If oracle set, then the price is the one coming from the oracle,
   /// - If not set, then the price is a linear accrual using the latest
   ///   settlement price.
   current_price: Option<Price>, 
}
  • NOTE: Price is a 18-decimal BigInt
  • NOTE: ActiveLoan and also the ActiveLoanInfo types SHOULD already be defined in the apps repo. See here.

mustermeiszer avatar Jun 21 '24 15:06 mustermeiszer

Superseeds https://github.com/centrifuge/apps/issues/2225

mustermeiszer avatar Jun 21 '24 15:06 mustermeiszer

@onnovisser is the return behaviour of the runtime api calls correctly described - i.e. does it return null?

mustermeiszer avatar Jun 21 '24 15:06 mustermeiszer

Didn't implement backedn feature. Closing

mustermeiszer avatar Feb 18 '25 13:02 mustermeiszer