Fix PR comments

Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
JCW
2026-03-26 23:56:54 +00:00
parent e74a24bced
commit 0bc4be2b9c
9 changed files with 544 additions and 82 deletions

View File

@@ -514,6 +514,7 @@ LEDGER_ENTRY(ltLOAN_BROKER, 0x0088, LoanBroker, loan_broker, ({
{sfDebtMaximum, soeDEFAULT},
{sfCoverAvailable, soeDEFAULT},
{sfCoverRateMinimum, soeDEFAULT},
// Deprecated by featureLendingProtocolV1_1
{sfCoverRateLiquidation, soeDEFAULT},
}))

View File

@@ -108,6 +108,7 @@ TYPED_SFIELD(sfPaymentRemaining, UINT32, 59)
TYPED_SFIELD(sfPaymentTotal, UINT32, 60)
TYPED_SFIELD(sfLoanSequence, UINT32, 61)
TYPED_SFIELD(sfCoverRateMinimum, UINT32, 62) // 1/10 basis points (bips)
// Deprecated by featureLendingProtocolV1_1
TYPED_SFIELD(sfCoverRateLiquidation, UINT32, 63) // 1/10 basis points (bips)
TYPED_SFIELD(sfOverpaymentFee, UINT32, 64) // 1/10 basis points (bips)
TYPED_SFIELD(sfInterestRate, UINT32, 65) // 1/10 basis points (bips)

View File

@@ -960,6 +960,7 @@ TRANSACTION(ttLOAN_BROKER_SET, 74, LoanBrokerSet,
{sfManagementFeeRate, soeOPTIONAL},
{sfDebtMaximum, soeOPTIONAL},
{sfCoverRateMinimum, soeOPTIONAL},
// Deprecated by featureLendingProtocolV1_1
{sfCoverRateLiquidation, soeOPTIONAL},
}))

View File

@@ -219,6 +219,49 @@ computeFullPaymentInterest(
std::uint32_t startDate,
TenthBips32 closeInterestRate);
/** Whether to use the proportional (new) default cover formula.
*
* Returns true when featureLendingProtocolV1_1 is enabled AND the broker
* does not carry the deprecated sfCoverRateLiquidation field.
*/
inline bool
useProportionalDefaultCover(Rules const& rules, std::shared_ptr<SLE const> brokerSle)
{
return rules.enabled(featureLendingProtocolV1_1) &&
!brokerSle->isFieldPresent(sfCoverRateLiquidation);
}
/** Compute the amount of First-Loss Capital seized to cover a defaulted loan.
*
* Selects between the old (global) and new (proportional) formula based on
* whether featureLendingProtocolV1_1 is enabled and whether the broker still
* carries the deprecated sfCoverRateLiquidation value.
*
* @param useProportionalFormula true when featureLendingProtocolV1_1 is
* enabled AND the broker has no
* sfCoverRateLiquidation.
* @param coverRateLiquidation The broker's CoverRateLiquidation in 1/10
* bips. Only used by the old formula; ignored
* when \p useProportionalFormula is true.
* @param coverAvailable The broker's current CoverAvailable.
* @param vaultAsset The Vault's asset type (for rounding).
* @param totalDefaultAmount The loan's default amount (owed to the vault).
* @param brokerDebtTotal The broker's total debt before this default.
* @param coverRateMinimum The broker's CoverRateMinimum in 1/10 bips.
* @param loanScale The loan's rounding scale.
* @return The amount of cover seized, capped at \p coverAvailable.
*/
Number
computeDefaultCovered(
bool useProportionalFormula,
std::uint32_t coverRateLiquidation,
Number const& coverAvailable,
Asset const& vaultAsset,
Number const& totalDefaultAmount,
Number const& brokerDebtTotal,
TenthBips32 coverRateMinimum,
std::int32_t loanScale);
namespace detail {
// These classes and functions should only be accessed by LendingHelper
// functions and unit tests