Add cashflow section to asset detail page
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
Open Questions
- What do do if NO cashflow is expected?
Technical
- It IS possible to get an empty
Arrayas 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
BigInthere are theBalance-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:
Priceis a 18-decimalBigInt - NOTE:
ActiveLoanand also theActiveLoanInfotypes SHOULD already be defined in the apps repo. See here.
Superseeds https://github.com/centrifuge/apps/issues/2225
@onnovisser is the return behaviour of the runtime api calls correctly described - i.e. does it return null?
Didn't implement backedn feature. Closing