1#include <xrpld/app/tx/detail/LoanDelete.h>
3#include <xrpld/app/misc/LendingHelpers.h>
5#include <xrpl/protocol/STTakesAsset.h>
18 if (ctx.
tx[sfLoanID] == beast::zero)
27 auto const& tx = ctx.
tx;
29 auto const account = tx[sfAccount];
30 auto const loanID = tx[sfLoanID];
35 JLOG(ctx.
j.
warn()) <<
"Loan does not exist.";
38 if (loanSle->at(sfPaymentRemaining) > 0)
40 JLOG(ctx.
j.
warn()) <<
"Active loan can not be deleted.";
44 auto const loanBrokerID = loanSle->at(sfLoanBrokerID);
51 if (loanBrokerSle->at(sfOwner) != account && loanSle->at(sfBorrower) != account)
53 JLOG(ctx.
j.
warn()) <<
"Account is not Loan Broker Owner or Loan Borrower.";
66 auto const loanID = tx[sfLoanID];
70 auto const borrower = loanSle->at(sfBorrower);
75 auto const brokerID = loanSle->at(sfLoanBrokerID);
79 auto const brokerPseudoAccount = brokerSle->at(sfAccount);
84 auto const vaultAsset = vaultSle->at(sfAsset);
102 if (brokerSle->at(sfOwnerCount) == 0)
104 auto debtTotalProxy = brokerSle->at(sfDebtTotal);
105 if (*debtTotalProxy != beast::zero)
111 "xrpl::LoanDelete::doApply",
112 "last loan, remaining debt rounds to zero");
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static TER preclaim(PreclaimContext const &ctx)
static bool checkExtraFeatures(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
Keylet loanbroker(AccountID const &owner, std::uint32_t seq) noexcept
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet loan(uint256 const &loanBrokerID, std::uint32_t loanSeq) noexcept
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
int getAssetsTotalScale(SLE::const_ref vaultSle)
bool checkLendingProtocolDependencies(PreflightContext const &ctx)
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
void roundToAsset(A const &asset, Number &value)
Round an arbitrary precision Number IN PLACE to the precision of a given Asset.
void associateAsset(STLedgerEntry &sle, Asset const &asset)
Associate an Asset with all sMD_NeedsAsset fields in a ledger entry.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.