1#include <xrpld/app/tx/detail/LoanBrokerCoverDeposit.h>
3#include <xrpld/app/misc/LendingHelpers.h>
5#include <xrpl/protocol/STTakesAsset.h>
18 if (ctx.
tx[sfLoanBrokerID] == beast::zero)
21 auto const dstAmount = ctx.
tx[sfAmount];
22 if (dstAmount <= beast::zero)
34 auto const& tx = ctx.
tx;
36 auto const account = tx[sfAccount];
37 auto const brokerID = tx[sfLoanBrokerID];
38 auto const amount = tx[sfAmount];
43 JLOG(ctx.
j.
warn()) <<
"LoanBroker does not exist.";
46 if (account != sleBroker->at(sfOwner))
48 JLOG(ctx.
j.
warn()) <<
"Account is not the owner of the LoanBroker.";
55 JLOG(ctx.
j.
fatal()) <<
"Vault is missing for Broker " << brokerID;
60 auto const vaultAsset = vault->at(sfAsset);
61 if (amount.asset() != vaultAsset)
64 auto const pseudoAccountID = sleBroker->at(sfAccount);
66 if (
auto const ret =
canTransfer(ctx.
view, vaultAsset, account, pseudoAccountID))
96 auto const brokerID = tx[sfLoanBrokerID];
97 auto const amount = tx[sfAmount];
107 auto const vaultAsset = vault->at(sfAsset);
109 auto const brokerPseudoID = broker->at(sfAccount);
116 broker->at(sfCoverAvailable) += amount;
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static bool checkExtraFeatures(PreflightContext const &ctx)
static TER preclaim(PreclaimContext 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 vault(AccountID const &owner, std::uint32_t seq) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TER checkDeepFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
TER checkFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
bool isLegalNet(STAmount const &value)
bool checkLendingProtocolDependencies(PreflightContext const &ctx)
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j, SpendableHandling includeFullBalance=shSIMPLE_BALANCE)
TER accountSend(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee=WaiveTransferFee::No)
Calls static accountSendIOU if saAmount represents Issue.
TER requireAuth(ReadView const &view, Issue const &issue, AccountID const &account, AuthType authType=AuthType::Legacy)
Check if the account lacks required authorization.
TER canTransfer(ReadView const &view, MPTIssue const &mptIssue, AccountID const &from, AccountID const &to)
Check if the destination account is allowed to receive MPT.
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.