mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-27 00:50:45 +00:00
Address PR comments
This commit is contained in:
@@ -587,27 +587,6 @@ checkLoanFreeze(
|
||||
AccountID const& brokerOwner,
|
||||
beast::Journal j);
|
||||
|
||||
/**
|
||||
* Validate a loan against the vault and broker limits.
|
||||
*
|
||||
* Checks the vault maximum, precision loss, loan guards, the computed loan
|
||||
* properties, the broker debt maximum, and the broker's first-loss cover.
|
||||
*/
|
||||
[[nodiscard]] TER
|
||||
checkLoanLimits(
|
||||
ApplyView& view,
|
||||
STTx const& tx,
|
||||
SLE::ref brokerSle,
|
||||
SLE::ref vaultSle,
|
||||
Asset const& vaultAsset,
|
||||
Number const& principalRequested,
|
||||
TenthBips32 interestRate,
|
||||
std::uint32_t paymentTotal,
|
||||
LoanProperties const& properties,
|
||||
LoanState const& state,
|
||||
std::vector<OptionaledField<STNumber>> const& valueFields,
|
||||
beast::Journal j);
|
||||
|
||||
/**
|
||||
* Increment the borrower's owner count for the new loan object and verify the
|
||||
* borrower still meets its reserve requirement.
|
||||
|
||||
@@ -33,6 +33,52 @@ private:
|
||||
static bool
|
||||
isOneStepFlow(STTx const& tx);
|
||||
|
||||
/* Returns the counterparty account: the explicit Counterparty field if
|
||||
* present, otherwise the LoanBroker owner. */
|
||||
static AccountID
|
||||
getCounterparty(STTx const& tx, AccountID const& brokerOwner);
|
||||
/* Returns the borrower account. In the two-step flow this is the named
|
||||
* Borrower; in the immediate flow it is whichever of the signer /
|
||||
* counterparty is not the LoanBroker owner. */
|
||||
static AccountID
|
||||
getBorrower(STTx const& tx, AccountID const& brokerOwner, AccountID const& signingAccount);
|
||||
|
||||
/* Holds the values validated and computed by doApply() that the flow
|
||||
* functions need to create the loan and update the ledger. The ledger
|
||||
* entries themselves are fetched (and their existence verified) by the flow
|
||||
* functions that mutate them; the derived borrower / counterparty account
|
||||
* IDs and the pure computed scalars are carried here so they are resolved
|
||||
* once, in doApply(), rather than in each flow function. */
|
||||
struct LoanPlan
|
||||
{
|
||||
uint256 brokerID;
|
||||
AccountID borrower;
|
||||
AccountID counterparty;
|
||||
Number principalRequested;
|
||||
Number originationFee;
|
||||
Number interestDue;
|
||||
LoanProperties properties;
|
||||
std::uint32_t paymentInterval;
|
||||
std::uint32_t paymentTotal;
|
||||
};
|
||||
|
||||
/* Build the Loan ledger entry from the plan, setting the pending flag when
|
||||
* requested. Does not insert the entry into the view. */
|
||||
std::shared_ptr<SLE>
|
||||
buildLoan(LoanPlan const& plan, SLE::ref brokerSle, bool pending);
|
||||
|
||||
/* Create a pending loan for the two-step flow: charge the broker owner the
|
||||
* owner reserve, create the loan flagged pending, reserve the principal in
|
||||
* the vault, and link the loan into the broker directory only. */
|
||||
TER
|
||||
applyPendingLoan(LoanPlan const& plan);
|
||||
|
||||
/* Create an active loan for the immediate flow: charge the borrower the
|
||||
* owner reserve, disburse the funds, create the loan, update the vault, and
|
||||
* link the loan into both the broker and borrower directories. */
|
||||
TER
|
||||
applyImmediateLoan(LoanPlan const& plan);
|
||||
|
||||
public:
|
||||
static constexpr auto kConsequencesFactory = ConsequencesFactoryType::Normal;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user