51 uint32_t
const flags = 0,
52 bool const domainOffer =
false)
54 auto offerInDir = [&](
uint256 const& directory,
55 uint64_t
const pageIndex,
61 if (
domain != (*page)[~sfDomainID])
64 auto const& indexes = page->getFieldV256(sfIndexes);
65 for (
auto const& index : indexes)
77 if (sle->getFieldAmount(sfTakerGets) != takerGets)
79 if (sle->getFieldAmount(sfTakerPays) != takerPays)
81 if (sle->getFlags() !=
flags)
83 if (domainOffer && !sle->isFieldPresent(sfDomainID))
85 if (!domainOffer && sle->isFieldPresent(sfDomainID))
87 if (!offerInDir(sle->getFieldH256(sfBookDirectory), sle->getFieldU64(sfBookNode), (*sle)[~sfDomainID]))
92 if (!sle->isFieldPresent(sfDomainID))
94 if (!sle->isFieldPresent(sfAdditionalBooks))
96 if (sle->getFieldArray(sfAdditionalBooks).size() != 1)
99 auto const& additionalBookDirs = sle->getFieldArray(sfAdditionalBooks);
101 for (
auto const& bookDir : additionalBookDirs)
103 auto const& dirIndex = bookDir.getFieldH256(sfBookDirectory);
104 auto const& dirNode = bookDir.getFieldU64(sfBookNode);
114 if (sle->isFieldPresent(sfAdditionalBooks))
163 Env env(*
this, features - featurePermissionedDEX);
164 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
177 Env env(*
this, features);
178 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
184 env.
trust(USD(1000), devin);
186 env(
pay(gw, devin, USD(100)));
209 Env env(*
this, features);
210 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
216 env.
trust(USD(1000), devin);
218 env(
pay(gw, devin, USD(100)));
222 uint32_t
const t = env.
current()->header().parentCloseTime.time_since_epoch().count();
223 jv[sfExpiration.jsonName] = t + 20;
243 Env env(*
this, features);
244 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
246 "F10D0CC9A0F9A3CBF585B80BE09A186483668FDBDD39AA7E3370F3649CE134"
256 Env env(*
this, features);
257 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
262 auto const bobOfferSeq{env.
seq(bob)};
266 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
true));
272 Env env(*
this, features);
273 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
278 auto const bobOfferSeq{env.
seq(bob)};
282 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq, USD(10),
XRP(10), 0,
true));
287 Env env(*
this, features);
288 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
290 auto const bobOfferSeq{env.
seq(bob)};
294 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
true));
298 env(
offer(carol, USD(10),
XRP(10)));
301 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
true));
303 auto const aliceOfferSeq{env.
seq(alice)};
307 BEAST_EXPECT(!
offerExists(env, alice, aliceOfferSeq));
314 Env env(*
this, features);
315 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
320 for (
size_t i = 0; i <= 100; i++)
322 auto const bobOfferSeq{env.
seq(bob)};
327 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
true));
330 for (
auto const offerSeq : offerSeqs)
346 Env env(*
this, features - featurePermissionedDEX);
347 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
364 Env env(*
this, features);
365 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
367 "F10D0CC9A0F9A3CBF585B80BE09A186483668FDBDD39AA7E3370F3649CE134"
376 Env env(*
this, features);
377 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
386 env.
trust(USD(1000), devin);
388 env(
pay(gw, devin, USD(100)));
413 Env env(*
this, features);
414 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
423 env.
trust(USD(1000), devin);
425 env(
pay(gw, devin, USD(100)));
450 Env env(*
this, features);
451 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
476 Env env(*
this, features);
477 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
480 auto const regularOfferSeq{env.
seq(bob)};
483 BEAST_EXPECT(
checkOffer(env, bob, regularOfferSeq,
XRP(10), USD(10)));
486 BEAST_EXPECT(regularDirKey);
494 auto const domainOfferSeq{env.
seq(bob)};
498 BEAST_EXPECT(
checkOffer(env, bob, domainOfferSeq,
XRP(10), USD(10), 0,
true));
501 BEAST_EXPECT(domainDirKey);
508 BEAST_EXPECT(!
offerExists(env, bob, domainOfferSeq));
509 BEAST_EXPECT(
checkOffer(env, bob, regularOfferSeq,
XRP(10), USD(10)));
518 Env env(*
this, features);
519 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
521 auto const EUR = gw[
"EUR"];
522 env.
trust(EUR(1000), alice);
524 env.
trust(EUR(1000), bob);
526 env.
trust(EUR(1000), carol);
528 env(
pay(gw, bob, EUR(100)));
532 auto const usdOfferSeq{env.
seq(bob)};
536 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(10), USD(10), 0,
true));
541 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(10), USD(10), 0,
true));
544 auto const regularOfferSeq{env.
seq(bob)};
545 env(
offer(bob, USD(10), EUR(10)));
547 BEAST_EXPECT(
checkOffer(env, bob, regularOfferSeq, USD(10), EUR(10)));
555 auto const eurOfferSeq{env.
seq(bob)};
556 env(
offer(bob, USD(10), EUR(10)),
domain(domainID));
558 BEAST_EXPECT(
checkOffer(env, bob, eurOfferSeq, USD(10), EUR(10), 0,
true));
564 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(5), USD(5), 0,
true));
565 BEAST_EXPECT(
checkOffer(env, bob, eurOfferSeq, USD(5), EUR(5), 0,
true));
576 BEAST_EXPECT(
checkOffer(env, bob, regularOfferSeq, USD(10), EUR(10)));
581 Env env(*
this, features);
582 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
585 Account badDomainOwner(
"badDomainOwner");
587 env.
fund(
XRP(1000), badDomainOwner, devin);
589 env.
trust(USD(1000), devin);
591 env(
pay(gw, devin, USD(100)));
594 auto const badCredType =
"badCred";
599 auto const badDomainID = objects.begin()->first;
614 auto const bobOfferSeq{env.
seq(bob)};
617 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
true));
630 Env env(*
this, features);
631 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
655 Env env(*
this, features);
656 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
662 env.
trust(USD(1000), devin);
664 env(
pay(gw, devin, USD(100)));
668 uint32_t
const t = env.
current()->header().parentCloseTime.time_since_epoch().count();
669 jv[sfExpiration.jsonName] = t + 20;
676 auto const offerSeq{env.
seq(devin)};
683 BEAST_EXPECT(
checkOffer(env, devin, offerSeq,
XRP(5), USD(5), 0,
true));
691 BEAST_EXPECT(
checkOffer(env, devin, offerSeq,
XRP(5), USD(5), 0,
true));
696 Env env(*
this, features);
697 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
699 auto const offerSeq{env.
seq(bob)};
706 BEAST_EXPECT(
checkOffer(env, bob, offerSeq,
XRP(5), USD(5), 0,
true));
715 BEAST_EXPECT(
checkOffer(env, bob, offerSeq,
XRP(5), USD(5), 0,
true));
804 Env env(*
this, features);
805 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
807 auto const aliceOfferSeq{env.
seq(alice)};
811 auto const bobOfferSeq{env.
seq(bob)};
815 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(20), USD(20), 0,
true));
816 BEAST_EXPECT(
checkOffer(env, alice, aliceOfferSeq,
XRP(100), USD(100), 0,
true));
819 BEAST_EXPECT(domainDirKey);
829 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
true));
832 BEAST_EXPECT(!
offerExists(env, alice, aliceOfferSeq));
865 Env env(*
this, features - featurePermissionedDEX);
866 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
882 auto const offerSeq{env.
seq(bob)};
890 Env env(*
this, features);
891 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
893 auto const bobOfferSeq{env.
seq(bob)};
901 auto const aliceOfferSeq{env.
seq(alice)};
905 BEAST_EXPECT(!
offerExists(env, alice, aliceOfferSeq));
912 Env env(*
this, features);
913 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
915 auto const bobOfferSeq{env.
seq(bob)};
923 auto const aliceOfferSeq{env.
seq(alice)};
924 env(
offer(alice, USD(10),
XRP(10)));
927 BEAST_EXPECT(!
offerExists(env, alice, aliceOfferSeq));
935 Env env(*
this, features);
936 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
938 auto const bobOfferSeq{env.
seq(bob)};
942 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
true));
946 auto const aliceOfferSeq{env.
seq(alice)};
950 BEAST_EXPECT(!
offerExists(env, alice, aliceOfferSeq));
958 Env env(*
this, features);
959 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
961 auto const bobOfferSeq{env.
seq(bob)};
965 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
false));
969 auto const aliceOfferSeq{env.
seq(alice)};
973 BEAST_EXPECT(
offerExists(env, alice, aliceOfferSeq));
975 BEAST_EXPECT(
checkOffer(env, bob, bobOfferSeq,
XRP(10), USD(10), 0,
false));
989 Env env(*
this, features);
990 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
992 auto const hybridOfferSeq{env.
seq(bob)};
1013 auto const regularOfferSeq{env.
seq(bob)};
1016 BEAST_EXPECT(
offerExists(env, bob, regularOfferSeq));
1017 BEAST_EXPECT(
checkOffer(env, bob, regularOfferSeq,
XRP(10), USD(10)));
1019 auto const sleHybridOffer = env.
le(
keylet::offer(bob.id(), hybridOfferSeq));
1020 BEAST_EXPECT(sleHybridOffer);
1021 auto const openDir = sleHybridOffer->getFieldArray(sfAdditionalBooks)[0].getFieldH256(sfBookDirectory);
1029 BEAST_EXPECT(!
offerExists(env, bob, hybridOfferSeq));
1030 BEAST_EXPECT(
checkOffer(env, bob, regularOfferSeq,
XRP(5), USD(5)));
1041 Env env(*
this, features);
1042 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
1044 auto const hybridOfferSeq{env.
seq(bob)};
1056 BEAST_EXPECT(!
offerExists(env, bob, hybridOfferSeq));
1062 Env env(*
this, features);
1063 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
1066 Account badDomainOwner(
"badDomainOwner");
1068 env.
fund(
XRP(1000), badDomainOwner, devin);
1071 auto const badCredType =
"badCred";
1076 auto const badDomainID = objects.begin()->first;
1083 auto const hybridOfferSeq{env.
seq(bob)};
1100 BEAST_EXPECT(!
offerExists(env, bob, hybridOfferSeq));
1105 Env env(*
this, features);
1106 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
1108 auto const EUR = gw[
"EUR"];
1109 env.
trust(EUR(1000), alice);
1111 env.
trust(EUR(1000), bob);
1113 env.
trust(EUR(1000), carol);
1115 env(
pay(gw, bob, EUR(100)));
1118 auto const usdOfferSeq{env.
seq(bob)};
1122 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(10), USD(10), 0,
true));
1127 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(10), USD(10), 0,
true));
1130 auto const eurOfferSeq{env.
seq(bob)};
1139 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(5), USD(5), 0,
true));
1145 Env env(*
this, features);
1146 auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] =
PermissionedDEX(env);
1148 auto const EUR = gw[
"EUR"];
1149 env.
trust(EUR(1000), alice);
1151 env.
trust(EUR(1000), bob);
1153 env.
trust(EUR(1000), carol);
1155 env(
pay(gw, bob, EUR(100)));
1159 auto const usdOfferSeq{env.
seq(bob)};
1163 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(10), USD(10), 0,
false));
1166 auto const eurOfferSeq{env.
seq(bob)};
1175 BEAST_EXPECT(
checkOffer(env, bob, usdOfferSeq,
XRP(5), USD(5), 0,
false));