mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
minor code improvements
This commit is contained in:
@@ -985,6 +985,11 @@ sharesToAssetsWithdraw(
|
||||
std::shared_ptr<SLE const> const& issuance,
|
||||
STAmount const& shares);
|
||||
|
||||
// Determine if a vault is insolvent. A vault is considered insolvent when
|
||||
// the total assets in the vault are zero, and outstanding shares are non-zero.
|
||||
[[nodiscard]] bool
|
||||
isVaultInsolvent(std::shared_ptr<SLE const> const& vault, std::shared_ptr<SLE const> const& shareIssuance);
|
||||
|
||||
/** Has the specified time passed?
|
||||
|
||||
@param now the current time
|
||||
|
||||
@@ -270,13 +270,11 @@ constexpr std::uint32_t const tfBatchMask =
|
||||
// LoanPay: True, indicates any excess in this payment can be used
|
||||
// as an overpayment. False, no overpayments will be taken.
|
||||
constexpr std::uint32_t const tfLoanOverpayment = 0x00010000;
|
||||
|
||||
// LoanPay exclusive flags:
|
||||
// tfLoanFullPayment: True, indicates that the payment is an early
|
||||
// full payment. It must pay the entire loan including close
|
||||
// interest and fees, or it will fail. False: Not a full payment.
|
||||
constexpr std::uint32_t const tfLoanFullPayment = 0x00020000;
|
||||
|
||||
// tfLoanLatePayment: True, indicates that the payment is late,
|
||||
// and includes late interest and fees. If the loan is not late,
|
||||
// it will fail. False: not a late payment. If the current payment
|
||||
|
||||
@@ -3438,4 +3438,13 @@ after(NetClock::time_point now, std::uint32_t mark)
|
||||
return now.time_since_epoch().count() > mark;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
isVaultInsolvent(std::shared_ptr<SLE const> const& vault, std::shared_ptr<SLE const> const& shareIssuance)
|
||||
{
|
||||
auto const assetsTotal = vault->at(sfAssetsTotal);
|
||||
auto const sharesOutstanding = shareIssuance->at(sfOutstandingAmount);
|
||||
|
||||
return assetsTotal == 0 && sharesOutstanding > 0;
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -82,7 +82,7 @@ VaultDeposit::preclaim(PreclaimContext const& ctx)
|
||||
// Perform these checks early to avoid unnecessary processing
|
||||
|
||||
// The Vault is insolvent, deposits are not allowed
|
||||
if (vault->at(sfAssetsTotal) == 0 && sleShareIssuance->at(sfOutstandingAmount) > 0)
|
||||
if (isVaultInsolvent(vault, sleShareIssuance))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultDeposit: Vault is insolvent, deposits are not allowed";
|
||||
return tecNO_PERMISSION;
|
||||
|
||||
@@ -35,13 +35,13 @@ VaultSet::getFlagsMask(PreflightContext const& ctx)
|
||||
static bool
|
||||
isValidVaultUpdate(PreflightContext const& ctx)
|
||||
{
|
||||
auto const checkFlags = ctx.rules.enabled(fixLendingProtocolV1_1);
|
||||
auto const shouldCheckFlags = ctx.rules.enabled(fixLendingProtocolV1_1);
|
||||
|
||||
auto const atLeastOneFieldPresent =
|
||||
ctx.tx.isFieldPresent(sfDomainID) || ctx.tx.isFieldPresent(sfAssetsMaximum) || ctx.tx.isFieldPresent(sfData);
|
||||
|
||||
return atLeastOneFieldPresent ||
|
||||
(checkFlags && (ctx.tx.isFlag(tfVaultDepositBlock) || ctx.tx.isFlag(tfVaultDepositUnblock)));
|
||||
(shouldCheckFlags && (ctx.tx.isFlag(tfVaultDepositBlock) || ctx.tx.isFlag(tfVaultDepositUnblock)));
|
||||
}
|
||||
|
||||
NotTEC
|
||||
|
||||
Reference in New Issue
Block a user