Show / Hide Table of Contents

Class LoanBrokerCover

A loan broker's first-loss cover computed offline from the LoanBroker and Vault entries, the way rippled's LoanBrokerCoverDeposit, LoanBrokerCoverWithdraw, LoanBrokerCoverClawback and minimumBrokerCover compute it.

Inheritance
object
LoanBrokerCover
Namespace: Xrpl.Sugar
Assembly: Xrpl.dll
Syntax
public static class LoanBrokerCover
Remarks

The broker must keep CoverRateMinimum (in 1/10 basis points) of its DebtTotal as cover, rounded up. Under fixCleanup3_2_0 the minimum is rounded to the scale of the vault's AssetsTotal. Before it, a withdrawal rounds it to the scale of DebtTotal and a clawback does not round it to the asset at all, so the same broker can have a different minimum on either side of the amendment.

Repeated here is everything that depends on the amounts: the minimum, the rounding of a deposit to the cover's scale and the refusals they lead to - an amount below that scale (tecPRECISION_LOSS) and a withdrawal or clawback that would take the cover below the minimum (tecINSUFFICIENT_FUNDS). Ownership, the asset, transferability, freezes, authorization, the destination, the depositor's funds, what the broker's pseudo-account actually holds and the issuer's clawback flags are not; PreviewLoanBrokerCoverDeposit(IXrplClient, LoanBrokerCoverDeposit, LedgerRules, CancellationToken), PreviewLoanBrokerCoverWithdraw(IXrplClient, LoanBrokerCoverWithdraw, LedgerRules, CancellationToken) and PreviewLoanBrokerCoverClawback(IXrplClient, LoanBrokerCoverClawback, LedgerRules, CancellationToken) cover them.

Methods

| Edit this page View Source

CheckClawback(LOLoanBroker, LOVault, XrplNumber?, LedgerRules)

A LoanBrokerCoverClawback by the asset's issuer: what it takes back. Without an amount, or with zero, the issuer takes everything above the minimum; a larger amount is cut down to that.

Declaration
public static LoanBrokerCoverQuote CheckClawback(LOLoanBroker broker, LOVault vault, XrplNumber? amount = null, LedgerRules rules = null)
Parameters
Type Name Description
LOLoanBroker broker

The LoanBroker entry.

LOVault vault

The broker's Vault entry.

Nullable amount

The amount to claw back, in the vault asset's unit; null takes all it can.

LedgerRules rules

The amendments in force; the current rules when null.

Returns
Type Description
LoanBrokerCoverQuote
Exceptions
Type Condition
ArgumentException

The vault carries no asset, or is not the broker's.

OverflowException

An amount is beyond decimal.

| Edit this page View Source

CheckDeposit(LOLoanBroker, LOVault, XrplNumber, LedgerRules)

A LoanBrokerCoverDeposit of amount: what the cover is credited, which under fixCleanup3_2_0 is the amount rounded down to the cover's scale.

Declaration
public static LoanBrokerCoverQuote CheckDeposit(LOLoanBroker broker, LOVault vault, XrplNumber amount, LedgerRules rules = null)
Parameters
Type Name Description
LOLoanBroker broker

The LoanBroker entry.

LOVault vault

The broker's Vault entry.

XrplNumber amount

The deposit, in the vault asset's unit.

LedgerRules rules

The amendments in force; the current rules when null.

Returns
Type Description
LoanBrokerCoverQuote
Exceptions
Type Condition
ArgumentException

The vault carries no asset, or is not the broker's.

OverflowException

An amount is beyond decimal.

| Edit this page View Source

CheckWithdraw(LOLoanBroker, LOVault, XrplNumber, LedgerRules)

A LoanBrokerCoverWithdraw of amount: whether the cover left keeps the minimum.

Declaration
public static LoanBrokerCoverQuote CheckWithdraw(LOLoanBroker broker, LOVault vault, XrplNumber amount, LedgerRules rules = null)
Parameters
Type Name Description
LOLoanBroker broker

The LoanBroker entry.

LOVault vault

The broker's Vault entry.

XrplNumber amount

The withdrawal, in the vault asset's unit.

LedgerRules rules

The amendments in force; the current rules when null.

Returns
Type Description
LoanBrokerCoverQuote
Exceptions
Type Condition
ArgumentException

The vault carries no asset, or is not the broker's.

OverflowException

An amount is beyond decimal.

| Edit this page View Source

MaxClawback(LOLoanBroker, LOVault, LedgerRules)

What a LoanBrokerCoverClawback without an amount takes back; zero when the node would refuse it.

Declaration
public static decimal MaxClawback(LOLoanBroker broker, LOVault vault, LedgerRules rules = null)
Parameters
Type Name Description
LOLoanBroker broker

The LoanBroker entry.

LOVault vault

The broker's Vault entry.

LedgerRules rules

The amendments in force; the current rules when null.

Returns
Type Description
decimal
Exceptions
Type Condition
ArgumentException

The vault carries no asset, or is not the broker's.

OverflowException

An amount is beyond decimal.

| Edit this page View Source

MaxWithdrawable(LOLoanBroker, LOVault, LedgerRules)

The largest LoanBrokerCoverWithdraw the node accepts: the cover above the minimum, as an amount of the asset rounded down. Zero when nothing can be withdrawn.

Declaration
public static decimal MaxWithdrawable(LOLoanBroker broker, LOVault vault, LedgerRules rules = null)
Parameters
Type Name Description
LOLoanBroker broker

The LoanBroker entry.

LOVault vault

The broker's Vault entry.

LedgerRules rules

The amendments in force; the current rules when null.

Returns
Type Description
decimal
Exceptions
Type Condition
ArgumentException

The vault carries no asset, or is not the broker's.

OverflowException

The amount is beyond decimal.

| Edit this page View Source

MinimumCover(LOLoanBroker, LOVault, LedgerRules)

The minimum cover LoanBrokerCoverWithdraw requires the broker to keep.

Declaration
public static decimal MinimumCover(LOLoanBroker broker, LOVault vault, LedgerRules rules = null)
Parameters
Type Name Description
LOLoanBroker broker

The LoanBroker entry.

LOVault vault

The broker's Vault entry.

LedgerRules rules

The amendments in force; the current rules when null.

Returns
Type Description
decimal
Remarks

LoanPay compares the cover with the same minimum under fixCleanup3_2_0 to decide whether the broker's fee goes to its owner. Before the amendment it rounds at the loan's scale instead, which this method does not compute.

Exceptions
Type Condition
ArgumentException

The vault carries no asset, or is not the broker's.

OverflowException

The minimum is beyond decimal.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX