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
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.
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
Technical
Array
as a return value - in these cases the chain is not expecting any cashflowsHow to query the chain
await api.call.loansApi.portfolio(PoolId)
await api.call.loansApi.expectedCashflows(PoolId, LoanId)
NOTE: If the given
PoolId
orLoanId
DOES NOT exist the chain will return a success but containingnull
.Datastructures
BigInt
here 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 typeportfolio
The call to the chain will return an
Array
of the following type[LoanId, ActiveLoanInfo]
Price
is a 18-decimalBigInt
ActiveLoan
and also theActiveLoanInfo
types SHOULD already be defined in the apps repo. See here.