Class LoanManagement
A loan broker's LoanManage computed offline from the Loan, LoanBroker and
Vault entries, the way rippled 3.4.1's LoanManage transactor and
loanVaultExposure compute it: when impairing, unimpairing and defaulting a loan is
allowed, and what each does to the vault, the broker's cover and the depositors' share value.
Inheritance
Namespace: Xrpl.Sugar
Assembly: Xrpl.dll
Syntax
public static class LoanManagement
Remarks
The exposure depends on the vault's accounting basis. A vault created under
LendingProtocolV1_1 carries LEVersion 1 (cash basis), and its exposure is the
loan's PrincipalOutstanding. Every other vault keeps accrual accounting, whatever the
amendment's state later, and its exposure is TotalValueOutstanding less
ManagementFeeOutstanding.
fixCleanup3_4_0 changes the time conditions. Under it a loan can be impaired only once
the parent close time is past NextPaymentDueDate, and defaulted only once it is past
NextPaymentDueDate + GracePeriod; both boundaries are exclusive. Before it,
impairment has no time condition and the default boundary is inclusive, and impairing and
unimpairing move NextPaymentDueDate.
Repeated here is everything that depends on the entries and the time: the state transitions,
the owner check, the time conditions, the amounts and their rounding, and the refusals they lead
to. Signatures, fees, the transfer of the cover between the pseudo-accounts and the
FixedPrecision vault version of rippled develop (LEVersion 2, not in any release
yet) are not: a vault of that version throws System.NotSupportedException.
PreviewLoanManage(IXrplClient, LoanManage, CancellationToken) runs the transaction through the node.
Methods
| Edit this page View SourceAvailability(LOLoan, LOLoanBroker, string, DateTime, LedgerRules)
Which actions account may take on the loan in a ledger whose parent closed
at parentCloseTime, with the result LoanManage::preclaim and
LoanManage::doApply give otherwise, checked in their order.
Declaration
public static LoanManageAvailability Availability(LOLoan loan, LOLoanBroker broker, string account, DateTime parentCloseTime, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOLoan | loan | The |
| LOLoanBroker | broker | The loan's |
| string | account | The account that would submit the transaction; null skips the owner check. |
| DateTime | parentCloseTime | The close time of the ledger before the one the transaction lands in. A local time is converted to UTC; an unspecified one is taken as UTC. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
Returns
| Type | Description |
|---|---|
| LoanManageAvailability |
Remarks
A defaulted or fully paid loan cannot be changed (tecNO_PERMISSION); an impaired loan
cannot be impaired again and only an impaired one can be unimpaired
(tecNO_PERMISSION); only the broker's owner may act (tecNO_PERMISSION). The
time conditions give tecTOO_SOON; the node checks the default's in preclaim, before
the owner, and the impairment's in doApply, where the fee is still charged.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The broker is not the loan's. |
Default(LOLoan, LOLoanBroker, LOVault, LedgerRules, DateTime?, ulong?)
A LoanManage with tfLoanDefault: what the broker's first-loss cover pays to
the vault and what the vault's depositors lose.
Declaration
public static LoanManageQuote Default(LOLoan loan, LOLoanBroker broker, LOVault vault, LedgerRules rules = null, DateTime? parentCloseTime = null, ulong? sharesOutstanding = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOLoan | loan | The |
| LOLoanBroker | broker | The loan's |
| LOVault | vault | The broker's |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| Nullable | parentCloseTime | The close time of the ledger before the one the transaction lands in, for the grace period; null skips that check. A local time is converted to UTC; an unspecified one is taken as UTC. |
| ulong? | sharesOutstanding | The vault share issuance's |
Returns
| Type | Description |
|---|---|
| LoanManageQuote |
Remarks
The cover pays CoverRateLiquidation of the minimum cover (CoverRateMinimum of
DebtTotal), at most the exposure, rounded up at the loan's scale and capped at
CoverAvailable. The rest of the exposure, rounded down at the scale of
AssetsTotal, comes off AssetsTotal; the cover paid is added to
AssetsAvailable. An impaired loan also takes its exposure out of
LossUnrealized. The broker's DebtTotal drops by the exposure and its
CoverAvailable by the cover paid.
The time condition is checked only when parentCloseTime is given; the
owner is not checked; Availability(LOLoan, LOLoanBroker, string, DateTime, LedgerRules) does both.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The vault carries no asset, or the entries do not belong together. |
| NotSupportedException | The vault's |
| OverflowException | An amount is beyond decimal. |
Exposure(LOLoan, LOVault, LedgerRules)
The loan's exposure for the vault (loanVaultExposure): PrincipalOutstanding
for a cash-basis vault (LEVersion 1), TotalValueOutstanding less
ManagementFeeOutstanding otherwise. In the vault asset's unit.
Declaration
public static decimal Exposure(LOLoan loan, LOVault vault, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOLoan | loan | The |
| LOVault | vault | The vault of the loan's broker. |
| LedgerRules | rules | The amendments in force, for the |
Returns
| Type | Description |
|---|---|
| decimal |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The vault carries no asset. |
| NotSupportedException | The vault's |
| OverflowException | The exposure is beyond decimal. |
Impair(LOLoan, LOVault, DateTime, LedgerRules, ulong?)
A LoanManage with tfLoanImpair: the exposure added to the vault's
LossUnrealized, rounded to the scale of AssetsTotal.
Declaration
public static LoanManageQuote Impair(LOLoan loan, LOVault vault, DateTime parentCloseTime, LedgerRules rules = null, ulong? sharesOutstanding = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOLoan | loan | The |
| LOVault | vault | The vault of the loan's broker. |
| DateTime | parentCloseTime | The close time of the ledger before the one the transaction lands in. A local time is converted to UTC; an unspecified one is taken as UTC. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| ulong? | sharesOutstanding | The vault share issuance's |
Returns
| Type | Description |
|---|---|
| LoanManageQuote |
Remarks
Besides the state transitions and, under fixCleanup3_4_0, the late-payment condition
(tecTOO_SOON), the node refuses an impairment that would take LossUnrealized
past the assets the vault has lent out, AssetsTotal - AssetsAvailable
(tecLIMIT_EXCEEDED). The owner is not checked; Availability(LOLoan, LOLoanBroker, string, DateTime, LedgerRules) does that.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The vault carries no asset. |
| NotSupportedException | The vault's |
| OverflowException | An amount is beyond decimal. |
Unimpair(LOLoan, LOVault, DateTime, LedgerRules, ulong?)
A LoanManage with tfLoanUnimpair: the exposure taken back out of the vault's
LossUnrealized, rounded to the scale of AssetsTotal.
Declaration
public static LoanManageQuote Unimpair(LOLoan loan, LOVault vault, DateTime parentCloseTime, LedgerRules rules = null, ulong? sharesOutstanding = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOLoan | loan | The |
| LOVault | vault | The vault of the loan's broker. |
| DateTime | parentCloseTime | The close time of the ledger before the one the transaction lands in, for the due date
before |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| ulong? | sharesOutstanding | The vault share issuance's |
Returns
| Type | Description |
|---|---|
| LoanManageQuote |
Remarks
Before fixCleanup3_4_0 the node also recomputes NextPaymentDueDate: the
regular due date (PreviousPaymentDueDate or StartDate, whichever is later,
plus PaymentInterval) while it has not passed, else the parent close time plus
PaymentInterval. The owner is not checked; Availability(LOLoan, LOLoanBroker, string, DateTime, LedgerRules) does that.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The vault carries no asset. |
| NotSupportedException | The vault's |
| OverflowException | An amount is beyond decimal. |