-
-
-
+
574 bool const bPassive(uTxFlags &
tfPassive);
+
+
+
577 bool const bSell(uTxFlags &
tfSell);
+
578 bool const bHybrid(uTxFlags &
tfHybrid);
+
+
580 auto saTakerPays =
ctx_.
tx[sfTakerPays];
+
581 auto saTakerGets =
ctx_.
tx[sfTakerGets];
+
582 auto const domainID =
ctx_.
tx[~sfDomainID];
+
+
584 auto const cancelSequence =
ctx_.
tx[~sfOfferSequence];
-
-
-
588 bool const bPassive(uTxFlags &
tfPassive);
-
-
-
591 bool const bSell(uTxFlags &
tfSell);
-
592 bool const bHybrid(uTxFlags &
tfHybrid);
-
-
594 auto saTakerPays =
ctx_.
tx[sfTakerPays];
-
595 auto saTakerGets =
ctx_.
tx[sfTakerGets];
-
596 auto const domainID =
ctx_.
tx[~sfDomainID];
-
-
598 auto const cancelSequence =
ctx_.
tx[~sfOfferSequence];
-
-
-
-
-
-
-
-
-
607 auto uRate =
getRate(saTakerGets, saTakerPays);
-
-
-
-
-
-
-
-
-
616 auto const sleCancel =
-
-
-
-
-
-
-
-
624 JLOG(
j_.
debug()) <<
"Create cancels order " << *cancelSequence;
-
-
-
-
-
629 auto const expiration =
ctx_.
tx[~sfExpiration];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
644 bool const bOpenLedger = sb.
open();
-
645 bool crossed =
false;
-
-
-
-
-
650 auto const& uPaysIssuerID = saTakerPays.
getIssuer();
-
651 auto const& uGetsIssuerID = saTakerGets.
getIssuer();
-
-
-
654 if (!
isXRP(uPaysIssuerID))
-
-
-
657 if (sle && sle->isFieldPresent(sfTickSize))
-
658 uTickSize =
std::min(uTickSize, (*sle)[sfTickSize]);
-
-
660 if (!
isXRP(uGetsIssuerID))
-
-
-
663 if (sle && sle->isFieldPresent(sfTickSize))
-
664 uTickSize =
std::min(uTickSize, (*sle)[sfTickSize]);
-
-
666 if (uTickSize < Quality::maxTickSize)
-
-
-
669 Quality{saTakerGets, saTakerPays}.round(uTickSize).rate();
-
-
-
-
-
-
-
-
677 saTakerPays =
multiply(saTakerGets, rate, saTakerPays.
issue());
-
-
-
-
-
682 saTakerGets =
divide(saTakerPays, rate, saTakerGets.
issue());
-
-
684 if (!saTakerGets || !saTakerPays)
-
-
686 JLOG(
j_.
debug()) <<
"Offer rounded to zero";
-
687 return {result,
true};
-
-
-
690 uRate =
getRate(saTakerGets, saTakerPays);
-
-
-
-
694 Amounts
const takerAmount(saTakerGets, saTakerPays);
-
-
696 JLOG(
j_.
debug()) <<
"Attempting cross: "
-
697 <<
to_string(takerAmount.in.issue()) <<
" -> "
-
-
-
-
-
702 stream <<
" mode: " << (bPassive ?
"passive " :
"")
-
703 << (bSell ?
"sell" :
"buy");
-
-
-
-
-
-
-
-
-
-
-
-
-
716 flowCross(psbFlow, psbCancelFlow, takerAmount, domainID);
-
-
718 psbCancelFlow.apply(sbCancel);
+
+
+
+
+
+
+
+
593 auto uRate =
getRate(saTakerGets, saTakerPays);
+
+
+
+
+
+
+
+
+
602 auto const sleCancel =
+
+
+
+
+
+
+
+
610 JLOG(
j_.
debug()) <<
"Create cancels order " << *cancelSequence;
+
+
+
+
+
615 auto const expiration =
ctx_.
tx[~sfExpiration];
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
630 bool const bOpenLedger = sb.
open();
+
631 bool crossed =
false;
+
+
+
+
+
636 auto const& uPaysIssuerID = saTakerPays.
getIssuer();
+
637 auto const& uGetsIssuerID = saTakerGets.
getIssuer();
+
+
+
640 if (!
isXRP(uPaysIssuerID))
+
+
+
643 if (sle && sle->isFieldPresent(sfTickSize))
+
644 uTickSize =
std::min(uTickSize, (*sle)[sfTickSize]);
+
+
646 if (!
isXRP(uGetsIssuerID))
+
+
+
649 if (sle && sle->isFieldPresent(sfTickSize))
+
650 uTickSize =
std::min(uTickSize, (*sle)[sfTickSize]);
+
+
652 if (uTickSize < Quality::maxTickSize)
+
+
+
655 Quality{saTakerGets, saTakerPays}.round(uTickSize).rate();
+
+
+
+
+
+
+
+
663 saTakerPays =
multiply(saTakerGets, rate, saTakerPays.
issue());
+
+
+
+
+
668 saTakerGets =
divide(saTakerPays, rate, saTakerGets.
issue());
+
+
670 if (!saTakerGets || !saTakerPays)
+
+
672 JLOG(
j_.
debug()) <<
"Offer rounded to zero";
+
673 return {result,
true};
+
+
+
676 uRate =
getRate(saTakerGets, saTakerPays);
+
+
+
+
680 Amounts
const takerAmount(saTakerGets, saTakerPays);
+
+
682 JLOG(
j_.
debug()) <<
"Attempting cross: "
+
683 <<
to_string(takerAmount.in.issue()) <<
" -> "
+
+
+
+
+
688 stream <<
" mode: " << (bPassive ?
"passive " :
"")
+
689 << (bSell ?
"sell" :
"buy");
+
+
+
+
+
+
+
+
+
+
+
+
+
702 flowCross(psbFlow, psbCancelFlow, takerAmount, domainID);
+
+
704 psbCancelFlow.apply(sbCancel);
+
+
+
+
+
+
710 "ripple::CreateOffer::applyGuts : result is tesSUCCESS or "
+
+
+
+
+
715 stream <<
"Cross result: " <<
transToken(result);
+
+
+
-
-
-
-
-
724 "ripple::CreateOffer::applyGuts : result is tesSUCCESS or "
-
-
-
-
-
729 stream <<
"Cross result: " <<
transToken(result);
-
-
-
-
-
-
-
-
-
-
-
740 return {result,
true};
-
-
-
-
744 saTakerGets.
issue() == place_offer.in.issue(),
-
745 "ripple::CreateOffer::applyGuts : taker gets issue match");
-
-
747 saTakerPays.
issue() == place_offer.out.issue(),
-
748 "ripple::CreateOffer::applyGuts : taker pays issue match");
-
-
750 if (takerAmount != place_offer)
-
-
-
-
-
755 if (place_offer.in < zero || place_offer.out < zero)
-
-
757 JLOG(
j_.
fatal()) <<
"Cross left offer negative!"
-
-
-
-
-
-
763 if (place_offer.in == zero || place_offer.out == zero)
-
-
765 JLOG(
j_.
debug()) <<
"Offer fully crossed!";
-
766 return {result,
true};
-
-
-
-
-
-
772 saTakerPays = place_offer.out;
-
773 saTakerGets = place_offer.in;
-
-
-
-
777 saTakerPays > zero && saTakerGets > zero,
-
778 "ripple::CreateOffer::applyGuts : taker pays and gets positive");
-
-
-
-
-
783 return {result,
true};
-
-
-
-
-
788 stream <<
"Place" << (crossed ?
" remaining " :
" ") <<
"offer:";
-
-
-
-
-
-
-
-
-
797 JLOG(
j_.
trace()) <<
"Fill or Kill: offer killed";
-
+
+
+
+
+
+
+
726 return {result,
true};
+
+
+
+
730 saTakerGets.
issue() == place_offer.in.issue(),
+
731 "ripple::CreateOffer::applyGuts : taker gets issue match");
+
+
733 saTakerPays.
issue() == place_offer.out.issue(),
+
734 "ripple::CreateOffer::applyGuts : taker pays issue match");
+
+
736 if (takerAmount != place_offer)
+
+
+
+
+
741 if (place_offer.in < zero || place_offer.out < zero)
+
+
743 JLOG(
j_.
fatal()) <<
"Cross left offer negative!"
+
+
+
+
+
+
749 if (place_offer.in == zero || place_offer.out == zero)
+
+
751 JLOG(
j_.
debug()) <<
"Offer fully crossed!";
+
752 return {result,
true};
+
+
+
+
+
+
758 saTakerPays = place_offer.out;
+
759 saTakerGets = place_offer.in;
+
+
+
+
763 saTakerPays > zero && saTakerGets > zero,
+
764 "ripple::CreateOffer::applyGuts : taker pays and gets positive");
+
+
+
+
+
769 return {result,
true};
+
+
+
+
+
774 stream <<
"Place" << (crossed ?
" remaining " :
" ") <<
"offer:";
+
+
+
+
+
+
+
+
+
783 JLOG(
j_.
trace()) <<
"Fill or Kill: offer killed";
+
+
+
+
+
+
789 if (bImmediateOrCancel)
+
+
791 JLOG(
j_.
trace()) <<
"Immediate or cancel: offer canceled";
+
792 if (!crossed && sb.
rules().
enabled(featureImmediateOfferKilled))
+
+
+
+
+
+
-
-
-
803 if (bImmediateOrCancel)
-
-
805 JLOG(
j_.
trace()) <<
"Immediate or cancel: offer canceled";
-
806 if (!crossed && sb.
rules().
enabled(featureImmediateOfferKilled))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
836 return {result,
true};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
851 <<
"final result: failed to add offer to owner's directory";
-
-
-
-
-
-
-
-
-
-
861 << (domainID ? (
" : " +
to_string(*domainID)) :
"");
-
-
863 Book const book{saTakerPays.
issue(), saTakerGets.
issue(), domainID};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
822 return {result,
true};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
837 <<
"final result: failed to add offer to owner's directory";
+
+
+
+
+
+
+
+
+
+
847 << (domainID ? (
" : " +
to_string(*domainID)) :
"");
+
+
849 Book const book{saTakerPays.
issue(), saTakerGets.
issue(), domainID};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
863 bool const bookExisted =
static_cast<bool>(sb.
peek(dir));
-
-
-
-
-
-
-
-
-
-
-
-
-
877 bool const bookExisted =
static_cast<bool>(sb.
peek(dir));
-
-
-
-
881 sle->setFieldH160(sfTakerPaysCurrency, saTakerPays.
issue().
currency);
-
882 sle->setFieldH160(sfTakerPaysIssuer, saTakerPays.
issue().
account);
-
883 sle->setFieldH160(sfTakerGetsCurrency, saTakerGets.
issue().
currency);
-
884 sle->setFieldH160(sfTakerGetsIssuer, saTakerGets.
issue().
account);
-
885 sle->setFieldU64(sfExchangeRate, uRate);
-
-
887 sle->setFieldH256(sfDomainID, *maybeDomain);
-
-
-
-
-
892 setBookDir(sle, domainID);
-
-
-
-
-
-
898 JLOG(
j_.
debug()) <<
"final result: failed to add offer to book";
-
-
-
-
-
-
904 sleOffer->setAccountID(sfAccount,
account_);
-
905 sleOffer->setFieldU32(sfSequence, offerSequence);
-
906 sleOffer->setFieldH256(sfBookDirectory, dir.key);
-
907 sleOffer->setFieldAmount(sfTakerPays, saTakerPays);
-
908 sleOffer->setFieldAmount(sfTakerGets, saTakerGets);
-
909 sleOffer->setFieldU64(sfOwnerNode, *ownerNode);
-
910 sleOffer->setFieldU64(sfBookNode, *bookNode);
-
-
912 sleOffer->setFieldU32(sfExpiration, *expiration);
-
-
-
-
-
-
918 sleOffer->setFieldH256(sfDomainID, *domainID);
+
+
+
867 sle->setFieldH160(sfTakerPaysCurrency, saTakerPays.
issue().
currency);
+
868 sle->setFieldH160(sfTakerPaysIssuer, saTakerPays.
issue().
account);
+
869 sle->setFieldH160(sfTakerGetsCurrency, saTakerGets.
issue().
currency);
+
870 sle->setFieldH160(sfTakerGetsIssuer, saTakerGets.
issue().
account);
+
871 sle->setFieldU64(sfExchangeRate, uRate);
+
+
873 sle->setFieldH256(sfDomainID, *maybeDomain);
+
+
+
+
+
878 setBookDir(sle, domainID);
+
+
+
+
+
+
884 JLOG(
j_.
debug()) <<
"final result: failed to add offer to book";
+
+
+
+
+
+
890 sleOffer->setAccountID(sfAccount,
account_);
+
891 sleOffer->setFieldU32(sfSequence, offerSequence);
+
892 sleOffer->setFieldH256(sfBookDirectory, dir.key);
+
893 sleOffer->setFieldAmount(sfTakerPays, saTakerPays);
+
894 sleOffer->setFieldAmount(sfTakerGets, saTakerGets);
+
895 sleOffer->setFieldU64(sfOwnerNode, *ownerNode);
+
896 sleOffer->setFieldU64(sfBookNode, *bookNode);
+
+
898 sleOffer->setFieldU32(sfExpiration, *expiration);
+
+
+
+
+
+
904 sleOffer->setFieldH256(sfDomainID, *domainID);
+
+
+
+
+
+
910 sb, sleOffer, offer_index, saTakerPays, saTakerGets, setBookDir);
+
+
+
+
+
+
+
+
-
-
-
-
-
924 sb, sleOffer, offer_index, saTakerPays, saTakerGets, setBookDir);
-
-
-
-
-
-
-
-
-
-
934 JLOG(
j_.
debug()) <<
"final result: success";
-
-
-
+
920 JLOG(
j_.
debug()) <<
"final result: success";
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
951 auto const result =
applyGuts(sb, sbCancel);
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
937 auto const result =
applyGuts(sb, sbCancel);
+
+
+
+
+
+
-
-
+
+
A generic endpoint for log messages.
@@ -1080,14 +1066,14 @@ $(document).ready(function() { init_codefold(0); });
std::pair< TER, Amounts > flowCross(PaymentSandbox &psb, PaymentSandbox &psbCancel, Amounts const &takerAmount, std::optional< uint256 > const &domainID)
static TER checkAcceptAsset(ReadView const &view, ApplyFlags const flags, AccountID const id, beast::Journal const j, Issue const &issue)
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
-
static std::string format_amount(STAmount const &amount)
+
static std::string format_amount(STAmount const &amount)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
-
TER applyHybrid(Sandbox &sb, std::shared_ptr< STLedgerEntry > sleOffer, Keylet const &offer_index, STAmount const &saTakerPays, STAmount const &saTakerGets, std::function< void(SLE::ref, std::optional< uint256 >)> const &setDir)
-
TER doApply() override
Precondition: fee collection is likely.
+
TER applyHybrid(Sandbox &sb, std::shared_ptr< STLedgerEntry > sleOffer, Keylet const &offer_index, STAmount const &saTakerPays, STAmount const &saTakerGets, std::function< void(SLE::ref, std::optional< uint256 >)> const &setDir)
+
TER doApply() override
Precondition: fee collection is likely.
static bool checkExtraFeatures(PreflightContext const &ctx)
-
std::pair< TER, bool > applyGuts(Sandbox &view, Sandbox &view_cancel)
+
std::pair< TER, bool > applyGuts(Sandbox &view, Sandbox &view_cancel)
A currency issued by an account.
@@ -1198,7 +1184,6 @@ $(document).ready(function() { init_codefold(0); });
bool isTesSuccess(TER x) noexcept
-
STAmount divRound(STAmount const &v1, STAmount const &v2, Asset const &asset, bool roundUp)
std::string to_string(base_uint< Bits, Tag > const &a)
STAmount mulRound(STAmount const &v1, STAmount const &v2, Asset const &asset, bool roundUp)
STAmount multiplyRound(STAmount const &amount, Rate const &rate, bool roundUp)
diff --git a/CreateOffer_8h_source.html b/CreateOffer_8h_source.html
index 75cc6685f9..f1f810ca5b 100644
--- a/CreateOffer_8h_source.html
+++ b/CreateOffer_8h_source.html
@@ -190,15 +190,15 @@ $(document).ready(function() { init_codefold(0); });
static TER checkAcceptAsset(ReadView const &view, ApplyFlags const flags, AccountID const id, beast::Journal const j, Issue const &issue)
CreateOffer(ApplyContext &ctx)
Construct a Transactor subclass that creates an offer in the ledger.
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
-
static std::string format_amount(STAmount const &amount)
+
static std::string format_amount(STAmount const &amount)
static constexpr ConsequencesFactoryType ConsequencesFactory
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
-
TER applyHybrid(Sandbox &sb, std::shared_ptr< STLedgerEntry > sleOffer, Keylet const &offer_index, STAmount const &saTakerPays, STAmount const &saTakerGets, std::function< void(SLE::ref, std::optional< uint256 >)> const &setDir)
-
TER doApply() override
Precondition: fee collection is likely.
+
TER applyHybrid(Sandbox &sb, std::shared_ptr< STLedgerEntry > sleOffer, Keylet const &offer_index, STAmount const &saTakerPays, STAmount const &saTakerGets, std::function< void(SLE::ref, std::optional< uint256 >)> const &setDir)
+
TER doApply() override
Precondition: fee collection is likely.
static bool checkExtraFeatures(PreflightContext const &ctx)
-
std::pair< TER, bool > applyGuts(Sandbox &view, Sandbox &view_cancel)
+
std::pair< TER, bool > applyGuts(Sandbox &view, Sandbox &view_cancel)
A currency issued by an account.
A wrapper which makes credits unavailable to balances.
diff --git a/OfferStream_8cpp_source.html b/OfferStream_8cpp_source.html
index 7c6905c1f1..cd11d9858e 100644
--- a/OfferStream_8cpp_source.html
+++ b/OfferStream_8cpp_source.html
@@ -280,261 +280,253 @@ $(document).ready(function() { init_codefold(0); });
186 TTakerGets
const ownerFunds = toAmount<TTakerGets>(*ownerFunds_);
-
187 bool const fixReduced = view_.rules().enabled(fixReducedOffersV1);
-
-
189 auto const effectiveAmounts = [&] {
-
190 if (offer_.owner() != offer_.issueOut().account &&
-
191 ownerFunds < ofrAmts.out)
-
-
-
-
-
-
-
-
199 return offer_.quality().ceil_out_strict(
-
200 ofrAmts, ownerFunds,
false);
+
+
188 auto const effectiveAmounts = [&] {
+
189 if (offer_.owner() != offer_.issueOut().account &&
+
190 ownerFunds < ofrAmts.out)
+
+
+
+
+
+
196 return offer_.quality().ceil_out_strict(
+
197 ofrAmts, ownerFunds,
false);
+
+
+
-
202 return offer_.quality().ceil_out(ofrAmts, ownerFunds);
-
-
-
-
-
-
-
-
210 (effectiveAmounts.in.signum() <= 0 ||
-
211 effectiveAmounts.out.signum() <= 0))
-
-
-
214 if (effectiveAmounts.in > TTakerPays::minPositiveAmount())
-
-
-
217 Quality
const effectiveQuality{effectiveAmounts};
-
218 return effectiveQuality < offer_.quality();
-
+
+
203 if (effectiveAmounts.in.signum() <= 0 || effectiveAmounts.out.signum() <= 0)
+
+
+
206 if (effectiveAmounts.in > TTakerPays::minPositiveAmount())
+
+
+
209 Quality
const effectiveQuality{effectiveAmounts};
+
210 return effectiveQuality < offer_.quality();
+