1#include <test/jtx/AMM.h>
2#include <test/jtx/AMMTest.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/PathSet.h>
5#include <test/jtx/TestHelpers.h>
6#include <test/jtx/amount.h>
7#include <test/jtx/balance.h>
8#include <test/jtx/delivermin.h>
9#include <test/jtx/fee.h>
10#include <test/jtx/flags.h>
11#include <test/jtx/jtx_json.h>
12#include <test/jtx/mpt.h>
13#include <test/jtx/multisign.h>
14#include <test/jtx/noop.h>
15#include <test/jtx/offer.h>
16#include <test/jtx/owners.h>
17#include <test/jtx/paths.h>
18#include <test/jtx/pay.h>
19#include <test/jtx/regkey.h>
20#include <test/jtx/require.h>
21#include <test/jtx/sendmax.h>
22#include <test/jtx/sig.h>
23#include <test/jtx/tags.h>
24#include <test/jtx/ter.h>
25#include <test/jtx/txflags.h>
27#include <xrpl/beast/unit_test/suite.h>
28#include <xrpl/json/json_value.h>
29#include <xrpl/json/to_string.h>
30#include <xrpl/ledger/ApplyView.h>
31#include <xrpl/ledger/OpenView.h>
32#include <xrpl/ledger/PaymentSandbox.h>
33#include <xrpl/ledger/Sandbox.h>
34#include <xrpl/ledger/helpers/OfferHelpers.h>
35#include <xrpl/protocol/AccountID.h>
36#include <xrpl/protocol/Feature.h>
37#include <xrpl/protocol/Indexes.h>
38#include <xrpl/protocol/Issue.h>
39#include <xrpl/protocol/KeyType.h>
40#include <xrpl/protocol/Quality.h>
41#include <xrpl/protocol/SField.h>
42#include <xrpl/protocol/STPathSet.h>
43#include <xrpl/protocol/Seed.h>
44#include <xrpl/protocol/TER.h>
45#include <xrpl/protocol/TxFlags.h>
46#include <xrpl/protocol/UintTypes.h>
47#include <xrpl/protocol/XRPAmount.h>
48#include <xrpl/protocol/jss.h>
49#include <xrpl/tx/paths/Flow.h>
50#include <xrpl/tx/paths/detail/Steps.h>
67 testcase(
"Incorrect Removal of Funded Offers");
79 Env env{*
this, features};
87 .pay = 200'000'000'000'000'000,
95 .pay = 2'000'000'000'000'000,
111 AMM const ammCarol(env,
carol_, btc(1'000'000'000'000'000), eth(100'100'000'000'000'000));
117 Sendmax(btc(1'000'000'000'000'000)),
121 btc(1'001'000'000'374'814), eth(100'000'000'000'000'000), ammCarol.
tokens()));
133 auto const startBalance =
XRP(1'000'000);
139 [&](
AMM& ammAlice,
Env& env) {
140 auto const& btc =
MPT(ammAlice[1]);
141 auto const baseFee = env.
current()->fees().base;
170 [&](
AMM& ammAlice,
Env& env) {
171 auto const& btc =
MPT(ammAlice[1]);
172 auto const baseFee = env.
current()->fees().base;
194 Env env{*
this, features};
205 AMM const ammAlice(env,
alice_,
XRP(10'100'000), btc(10'000'000));
213 ammAlice.expectBalances(
XRP(10'100'000), btc(10'000'000), ammAlice.tokens()));
219 [&](
AMM& ammAlice,
Env& env) {
220 auto const& btc =
MPT(ammAlice[1]);
241 testcase(
"Offer Crossing with XRP, Normal order");
245 Env env{*
this, features};
257 AMM const ammAlice(env,
alice_,
XRP(150'000), btc(50'000'000));
262 auto const xrpTransferred =
XRPAmount{3'061'224'490};
265 BEAST_EXPECT(ammAlice.expectBalances(
266 XRP(150'000) + xrpTransferred, btc(49'000'000),
IOUAmount{273'861'278752583, -5}));
277 testcase(
"Offer Crossing with Limit Override");
281 Env env{*
this, features};
290 AMM const ammAlice(env,
alice_,
XRP(150'000), btc(51'000'000));
302 testcase(
"Currency Conversion: Entire Offer");
306 Env env{*
this, features};
318 AMM const ammBob(env,
bob_, btc(200'000'000),
XRP(1'500));
332 testcase(
"Currency Conversion: In Parts");
336 Env env{*
this, features};
344 .pay = 30'000'000'000,
349 AMM const ammAlice(env,
alice_,
XRP(10'000), btc(10'000'000'000));
374 testcase(
"Cross Currency Payment: Start with XRP");
378 Env env{*
this, features};
387 AMM const ammAlice(env,
alice_,
XRP(10'000), btc(10'100'000'000));
398 testcase(
"Cross Currency Payment: End with XRP");
402 Env env{*
this, features};
411 AMM const ammAlice(env,
alice_,
XRP(10'100), btc(10'000'000'000));
422 testcase(
"Cross Currency Payment: Bridged");
426 auto const test = [&](
auto&& issue1,
auto&& issue2) {
428 auto const dan =
Account{
"dan"};
431 auto const eth = issue1({
436 .limit = 10'000'000'000'000'000,
438 auto const btc = issue2({
443 .limit = 10'000'000'000'000'000,
447 env(
pay(
gw_, dan, eth(400'000'000'000'000)));
450 AMM const ammCarol(env,
carol_, btc(5'000'000'000'000'000),
XRP(50'000));
452 env(
offer(dan,
XRP(500), eth(50'000'000'000'000)));
456 jtp[0u][0u][jss::currency] =
"XRP";
458 Json(jss::Paths, jtp),
459 Sendmax(btc(333'000'000'000'000)));
462 XRP(49'700), btc(5'030'181'086'519'115), ammCarol.
tokens()));
472 testcase(
"Offer Fees Consume Funds");
476 Env env{*
this, features};
480 auto const startingXrp =
481 XRP(100) + env.
current()->fees().accountReserve(2, 1) + env.
current()->fees().base * 3;
494 env(
pay(
gw_,
bob_, btc(1'200'000'000'000'000)));
496 AMM const ammBob(env,
bob_,
XRP(1'000), btc(1'200'000'000'000'000));
513 testcase(
"Offer Create, then Cross");
517 Env env{*
this, features};
532 AMM const ammAlice(env,
alice_, btc(150'000'000'000'000),
XRP(150'100));
545 testcase(
"Offer tfSell: Basic Sell");
549 Env env{*
this, features};
562 AMM const ammAlice(env,
alice_,
XRP(9'900), btc(10'100));
576 testcase(
"Offer tfSell: 2x Sell Exceed Limit");
580 Env env{*
this, features};
582 auto const startingXrp =
XRP(100) +
reserve(env, 1) + env.
current()->fees().base * 2;
592 AMM const ammBob(env,
bob_,
XRP(1'000), btc(2'200'000'000));
608 testcase(
"Client Issue: Gateway Cross Currency");
612 Env env{*
this, features};
614 auto const startingXrp =
XRP(100.1) +
reserve(env, 1) + env.
current()->fees().base * 2;
621 .pay = 1'000'000'000'000'000,
628 .pay = 1'000'000'000'000'000,
632 AMM const ammAlice(env,
alice_, xts(1'000'000'000'000'000), xxx(1'000'000'000'000'000));
636 payment[jss::id] = env.
seq(
bob_);
637 payment[jss::build_path] =
true;
638 payment[jss::tx_json] =
pay(
bob_,
bob_, xxx(10'000'000'000'000));
639 payment[jss::tx_json][jss::Sequence] =
642 payment[jss::tx_json][jss::SendMax] =
644 payment[jss::tx_json][jss::Flags] = tfPartialPayment;
645 auto const jrr = env.
rpc(
"json",
"submit",
to_string(payment));
646 BEAST_EXPECT(jrr[jss::result][jss::status] ==
"success");
647 BEAST_EXPECT(jrr[jss::result][jss::engine_result] ==
"tesSUCCESS");
649 BEAST_EXPECT(ammAlice.expectBalances(
650 xts(1'010'101'010'101'011), xxx(990'000'000'000'000), ammAlice.tokens()));
663 Env env{*
this, features};
670 .pay = 15'000'000'000,
677 .pay = 15'000'000'000,
687 AMM const ammAlice(env,
alice_,
XRP(10'000), btc(10'100'000'000));
688 AMM const ammBob(env,
bob_, eth(10'000'000'000),
XRP(10'100));
692 env(
offer(
carol_, btc(100'000'000), eth(100'000'000)));
696 ammAlice.expectBalances(
XRP(10'100), btc(10'000'000'000), ammAlice.tokens()));
704 Env env{*
this, features};
711 .pay = 15'000'000'000,
718 .pay = 15'000'000'000,
729 AMM const ammAlice(env,
alice_,
XRP(10'000), btc(10'100'000'000));
735 env(
offer(
carol_, btc(100'000'000), eth(100'000'000)));
739 ammAlice.expectBalances(
XRP(10'100), btc(10'000'000'000), ammAlice.tokens()));
747 Env env{*
this, features};
754 .pay = 15'000'000'000,
761 .pay = 15'000'000'000,
774 AMM const ammBob(env,
bob_, eth(10'000'000'000),
XRP(10'100));
778 env(
offer(
carol_, btc(100'000'000), eth(100'000'000)));
794 testcase(
"Combine tfSell with tfFillOrKill");
799 Env env{*
this, features};
806 .pay = 20'000'000'000,
809 AMM const ammBob(env,
bob_,
XRP(20'000), btc(200'000'000));
813 BEAST_EXPECT(ammBob.expectBalances(
XRP(20'000), btc(200'000'000), ammBob.tokens()));
817 Env env{*
this, features};
824 .pay = 1'000'000'000'000'000,
827 AMM const ammBob(env,
bob_,
XRP(20'000), btc(200'000'000'000'000));
830 env(
offer(
alice_, btc(2'000'000'000'000),
XRP(220), tfSell | tfFillOrKill));
833 ammBob.expectBalances(
XRP(20'220), btc(197'823'936'696'341), ammBob.tokens()));
840 Env env{*
this, features};
847 .pay = 1'000'000'000'000'000,
850 AMM const ammBob(env,
bob_,
XRP(20'000), btc(200'000'000'000'000));
852 env(
offer(
alice_, btc(10'000'000'000'000),
XRP(1'500), tfSell | tfFillOrKill));
856 ammBob.expectBalances(
XRP(21'500), btc(186'046'511'627'907), ammBob.tokens()));
866 Env env{*
this, features};
873 .pay = 10'000'000'000,
876 AMM const ammBob(env,
bob_,
XRP(5000), btc(10'000'000));
894 Env env(*
this, features);
902 .transferFee = 25'000,
908 AMM const ammAlice(env,
alice_,
XRP(10'000), btc(10'100'000));
921 Env env(*
this, features);
929 .transferFee = 25'000,
935 AMM const ammAlice(env,
alice_,
XRP(10'100), btc(10'000'000));
949 Env env{*
this, features};
956 .transferFee = 25'000,
964 .transferFee = 25'000,
975 AMM const ammAlice(env,
alice_,
XRP(10'000), btc(10'100'000));
985 BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'100), btc(10'000'000), ammAlice.tokens()));
996 Env env{*
this, features};
1003 .transferFee = 25'000,
1011 .transferFee = 25'000,
1022 AMM const ammAlice(env,
alice_,
XRP(10'000), btc(10'050'000));
1035 BEAST_EXPECT(ammAlice.expectBalances(
XRP(10'050), btc(10'000'000), ammAlice.tokens()));
1050 using namespace jtx;
1052 Env env{*
this, features};
1054 auto const f = env.
current()->fees().base;
1062 AMM const ammBob(env,
bob_,
XRP(10'000), btc(10'100));
1067 BEAST_EXPECT(ammBob.expectBalances(
XRP(10'100), btc(10'000), ammBob.tokens()));
1081 using namespace jtx;
1083 Env env{*
this, features};
1085 auto const ann =
Account(
"ann");
1086 auto const bob =
Account(
"bob");
1087 auto const cam =
Account(
"cam");
1088 auto const carol =
Account(
"carol");
1090 auto const fee = env.
current()->fees().base;
1092 env.
fund(
reserve(env, 4) + (fee * 5), ann, bob, cam);
1096 {.env = env, .issuer = ann, .holders = {bob, cam, carol}, .flags =
kMptDexFlags});
1099 {.env = env, .issuer = bob, .holders = {ann, cam, carol}, .flags =
kMptDexFlags});
1101 env(
pay(ann, cam, aBux(350'000'000'000'000)));
1102 env(
pay(bob, cam, bBux(350'000'000'000'000)));
1103 env(
pay(bob, carol, bBux(4'000'000'000'000'000)));
1104 env(
pay(ann, carol, aBux(4'000'000'000'000'000)));
1106 AMM const ammCarol(env, carol, aBux(3'000'000'000'000'000), bBux(3'300'000'000'000'000));
1111 env(
offer(cam, aBux(290'000'000'000'000), bBux(300'000'000'000'000), tfPassive));
1118 env(
offer(cam, bBux(300'000'000'000'000), aBux(300'000'000'000'000)));
1122 aBux(3'093'541'659'651'603), bBux(3'200'215'509'984'419), ammCarol.
tokens()));
1124 env, cam, 1, {{
Amounts{bBux(200'215'509'984'419), aBux(200'215'509'984'419)}}}));
1132 using namespace jtx;
1134 Env env{*
this, features};
1146 btc.authorize({.holder =
bob_});
1152 AMM const ammAlice(env,
alice_, btc(1'000),
XRP(1'050));
1173 using namespace jtx;
1175 Env env{*
this, features};
1207 AMM const ammAlice(env,
alice_, btc(1'000),
XRP(1'050));
1225 using namespace jtx;
1254 using namespace jtx;
1264 .pay = 100'000'000'000'000,
1268 AMM const ammCarol(env,
carol_,
XRP(100), eth(100'000'000'000'000));
1275 BEAST_EXPECT(st.
empty());
1279 BEAST_EXPECT(sa ==
XRP(100'000'000));
1282 BEAST_EXPECT(
equal(da, eth(99'999'900'000'099)));
1292 using namespace jtx;
1302 .transferFee = 10'000,
1310 .transferFee = 10'000,
1324 BEAST_EXPECT(std::get<0>(result).empty());
1331 using namespace jtx;
1332 auto const charlie =
Account(
"charlie");
1342 .pay = 11'000'000'000'000,
1346 AMM const ammCharlie(env, charlie,
XRP(10), eth(11'000'000'000'000));
1348 BEAST_EXPECT(sa ==
XRP(1));
1349 BEAST_EXPECT(
equal(da, eth(1'000'000'000'000)));
1350 if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1))
1352 auto const& pathElem = st[0][0];
1354 pathElem.isOffer() && pathElem.getIssuerID() ==
gw_.id() &&
1355 pathElem.getMPTID() == eth.issuanceID());
1367 .pay = 11'000'000'000'000,
1371 AMM const ammCharlie(env, charlie,
XRP(11), eth(10'000'000'000'000));
1375 BEAST_EXPECT(sa == eth(1'000'000'000'000));
1377 if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1))
1379 auto const& pathElem = st[0][0];
1381 pathElem.isOffer() && pathElem.getIssuerID() ==
xrpAccount() &&
1390 testcase(
"Path Find: XRP -> XRP and XRP -> MPT");
1391 using namespace jtx;
1403 env.
fund(
XRP(1'000), a3, g1, g2, g3);
1408 {.env = env, .issuer = g1, .holders = {a1, m1, a2}, .flags =
kMptDexFlags});
1411 {.env = env, .issuer = g2, .holders = {a2, m1, a1}, .flags =
kMptDexFlags});
1414 {.env = env, .issuer = g3, .holders = {a1, a2, m1, a3}, .flags =
kMptDexFlags});
1417 {.env = env, .issuer = a2, .holders = {g3, a1}, .flags =
kMptDexFlags});
1419 env(
pay(g1, a1, xyzG1(3'500'000'000)));
1420 env(
pay(g3, a1, abcG3(1'200'000'000)));
1421 env(
pay(g1, m1, xyzG1(25'000'000'000)));
1422 env(
pay(g2, m1, xyzG2(25'000'000'000)));
1423 env(
pay(g3, m1, abcG3(25'000'000'000)));
1424 env(
pay(a2, g3, abcA2(101'000'000)));
1427 AMM const ammM1XyzG1XyzG2(env, m1, xyzG1(1'000'000'000), xyzG2(1'000'000'000));
1428 AMM const ammM1XrpAbcG3(env, m1,
XRP(10'000), abcG3(1'000'000'000));
1429 AMM const ammG3AbcG3AbcA2(env, g3, abcG3(100'000'000), abcA2(101'000'000));
1436 auto const& sendAmt =
XRP(10);
1438 BEAST_EXPECT(
equal(da, sendAmt));
1439 BEAST_EXPECT(st.
empty());
1445 auto const& sendAmt =
XRP(200);
1448 BEAST_EXPECT(
equal(da, sendAmt));
1449 BEAST_EXPECT(st.
empty());
1453 auto const& sendAmt = abcG3(10'000'000);
1455 BEAST_EXPECT(
equal(da, sendAmt));
1461 auto const& sendAmt = abcA2(1'000'000);
1463 BEAST_EXPECT(
equal(da, sendAmt));
1472 testcase(
"Path Find: non-XRP -> XRP");
1473 using namespace jtx;
1480 env.
fund(
XRP(1'000), a1, a2, g3);
1487 .holders = {a1, a2, m1},
1488 .pay = 1'000'000'000,
1492 AMM const ammM1(env, m1, eth(1'000'000'000),
XRP(10'010));
1497 auto const& sendAmt =
XRP(10);
1501 BEAST_EXPECT(
equal(da, sendAmt));
1502 BEAST_EXPECT(
equal(sa, eth(1'000'000)));
1509 testcase(
"Path Find: non-XRP -> non-XRP, same issuanceID");
1510 using namespace jtx;
1521 env.
fund(
XRP(1'000), a1, a2, a3, g1, g2);
1527 .holders = {a1, m1},
1528 .pay = 5'000'000'000,
1535 .holders = {a2, m1},
1536 .pay = 5'000'000'000,
1540 AMM const ammM1(env, m1, hkdG1(1'000'000'000), hkdG2(1'010'000'000));
1542 auto const& sendAmt = hkdG2(10'000'000);
1546 env, g1, a2, sendAmt, std::nullopt, hkdG1.issuanceID(), std::nullopt, std::nullopt);
1547 BEAST_EXPECT(
equal(da, sendAmt));
1548 BEAST_EXPECT(
equal(sa, hkdG1(10'000'000)));
1556 testcase(
"Path Find: MPT AMM source amount is executable");
1557 using namespace jtx;
1583 AMM const ammCarol(env,
carol_, usd(usdPool), eur(eurPool));
1588 auto const deliver = eur(deliverAmount);
1600 BEAST_EXPECT(
equal(da, deliver));
1601 BEAST_EXPECT(
equal(sa, usd(expectedSourceAmount)));
1602 BEAST_EXPECT(!st.
empty());
1604 auto const before = eur.getBalance(
bob_);
1609 BEAST_EXPECT(eur.getBalance(
bob_) == before + deliverAmount);
1622 TestCase
const testCases[] = {
1623 {.usdPool = 2'000'000, .eurPool = 1'000'000, .deliverAmount = 1, .expectedSourceAmount = 3},
1624 {.usdPool = 2'000'000, .eurPool = 1'000'000, .deliverAmount = 2, .expectedSourceAmount = 5},
1625 {.usdPool = 2'000'000, .eurPool = 1'000'000, .deliverAmount = 10, .expectedSourceAmount = 21},
1626 {.usdPool = 2'000'000, .eurPool = 1'000'000, .deliverAmount = 100, .expectedSourceAmount = 201},
1627 {.usdPool = 2'000'000, .eurPool = 1'000'000, .deliverAmount = 1'000, .expectedSourceAmount = 2'003},
1628 {.usdPool = 2'000, .eurPool = 1'000, .deliverAmount = 1, .expectedSourceAmount = 3},
1629 {.usdPool = 2'000, .eurPool = 1'000, .deliverAmount = 2, .expectedSourceAmount = 5},
1630 {.usdPool = 2'000, .eurPool = 1'000, .deliverAmount = 10, .expectedSourceAmount = 21},
1631 {.usdPool = 2'000, .eurPool = 1'000, .deliverAmount = 100, .expectedSourceAmount = 223},
1635 for (
auto const& testCase : testCases)
1640 testCase.deliverAmount,
1641 testCase.expectedSourceAmount);
1650 using namespace jtx;
1652 Env env(*
this, features);
1657 auto const ammxrpPool = env.
current()->fees().increment * 2;
1678 AMM const ammBob(env,
bob_, ammxrpPool, btc(150'000));
1683 Txflags(tfNoRippleDirect | tfPartialPayment));
1686 BEAST_EXPECT(carolBTC > btc(0) && carolBTC < btc(50'000));
1694 using namespace jtx;
1698 auto const test = [&](
auto&& issue1,
auto&& issue2) {
1702 auto const eth = issue1({
1707 .limit = 100'000'000,
1709 auto const btc = issue2({
1714 .limit = 100'000'000,
1723 AMM const ammBob(env,
bob_, btc(100'000), eth(150'000));
1738 Env env(*
this, features);
1757 AMM const ammBobBtcXrp(env,
bob_, btc(100'000),
XRP(150));
1758 AMM const ammBobXrpEth(env,
bob_,
XRP(100), eth(150'000));
1767 ammBobBtcXrp.expectBalances(btc(150'000),
XRP(100), ammBobBtcXrp.tokens()));
1773 Env env(*
this, features);
1785 AMM const ammBob(env,
bob_,
XRP(100), eth(150'000));
1793 BEAST_EXPECT(ammBob.expectBalances(
XRP(150), eth(100'000), ammBob.tokens()));
1797 Env env(*
this, features);
1809 AMM const ammBob(env,
bob_, eth(100'000),
XRP(150));
1818 BEAST_EXPECT(ammBob.expectBalances(eth(150'000),
XRP(100), ammBob.tokens()));
1823 auto const test = [&](
auto&& issue1,
auto&& issue2,
auto&& issue3) {
1824 Env env(*
this, features);
1827 auto const btc = issue1({
1832 .limit = 1000'000000,
1834 auto const eth = issue2({
1839 .limit = 1000'000000,
1841 auto const gbp = issue3({
1846 .limit = 1000'000000,
1852 env(
offer(
bob_, btc(50'000), eth(50'000)));
1853 env(
offer(
bob_, btc(40'000), gbp(50'000)));
1855 AMM const ammBob(env,
bob_, gbp(100'000), eth(150'000));
1859 BEAST_EXPECT(
isOffer(env,
bob_, btc(50'000), eth(50'000)));
1860 BEAST_EXPECT(
isOffer(env,
bob_, btc(40'000), gbp(50'000)));
1871 BEAST_EXPECT(!
isOffer(env,
bob_, btc(50'000), eth(50'000)));
1873 BEAST_EXPECT(!
isOffer(env,
bob_, btc(40'000), gbp(50'000)));
1890 Env env(*
this, features);
1927 AMM const ammBobBtcEth(env,
bob_, btc(50'000'000), eth(50'000'000));
1928 env(
offer(
bob_, btc(60'000'000), gbp(50'000'000)));
1929 env(
offer(
carol_, btc(1'000'000'000), gbp(1'000'000)));
1930 env(
offer(
bob_, gbp(50'000'000), eth(50'000'000)));
1935 btc(50'000'000), eth(50'000'000), ammBobBtcEth.
tokens()));
1936 BEAST_EXPECT(
isOffer(env,
bob_, btc(60'000'000), gbp(50'000'000)));
1937 BEAST_EXPECT(
isOffer(env,
carol_, btc(1'000'000'000), gbp(1'000'000)));
1938 BEAST_EXPECT(
isOffer(env,
bob_, gbp(50'000'000), eth(50'000'000)));
1941 auto const flowResult = [&] {
1942 STAmount const deliver(eth(51'000'000));
1978 BEAST_EXPECT(flowResult.removableOffers.size() == 1);
1980 if (flowResult.removableOffers.empty())
1983 for (
auto const& o : flowResult.removableOffers)
1996 btc(50'000'000), eth(50'000'000), ammBobBtcEth.
tokens()));
1997 BEAST_EXPECT(
isOffer(env,
carol_, btc(1'000'000'000), gbp(1'000'000)));
1999 BEAST_EXPECT(!
isOffer(env,
bob_, btc(60'000'000), gbp(50'000'000)));
2010 auto const test = [&](
auto&& issue1,
auto&& issue2) {
2014 auto const eth = issue1({
2019 .limit = 10'000'000,
2021 auto const btc = issue2({
2026 .limit = 10'000'000,
2040 Txflags(tfNoRippleDirect | tfPartialPayment));
2043 BEAST_EXPECT(ammBob.expectBalances(eth(8400),
XRPAmount{20}, ammBob.tokens()));
2053 using namespace jtx;
2057 Env env(*
this, features);
2064 .transferFee = 25'000,
2065 .pay = 1'000'000'000'000'000,
2073 .transferFee = 25'000,
2074 .pay = 1'000'000'000'000'000,
2078 AMM const amm(env,
bob_, gbp(1'000'000'000'000'000), btc(1'000'000'000'000'000));
2082 Sendmax(gbp(150'000'000'000'000)),
2083 Txflags(tfNoRippleDirect | tfPartialPayment));
2090 BEAST_EXPECT(
amm.expectBalances(
2091 gbp(1'120'000'000'000'000), btc(892'857'142'857'143),
amm.tokens()));
2099 Env env(*
this, features);
2108 .transferFee = 25'000,
2109 .pay = 1'000'000'000'000'000,
2117 .transferFee = 25'000,
2118 .pay = 1'000'000'000'000'000,
2126 .transferFee = 25'000,
2127 .pay = 1'000'000'000'000'000,
2131 env(
offer(ed, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)),
2135 AMM const amm(env,
bob_, eth(1'000'000'000'000'000), btc(1'000'000'000'000'000));
2139 Sendmax(gbp(150'000'000'000'000)),
2140 Txflags(tfNoRippleDirect | tfPartialPayment));
2152 env, ed, 1, {
Amounts{gbp(880'000'000'000'000), eth(880'000'000'000'000)}}));
2155 BEAST_EXPECT(
amm.expectBalances(
2156 eth(1'096'000'000'000'000), btc(912'408'759'124'088),
amm.tokens()));
2163 Env env(*
this, features);
2172 .transferFee = 25'000,
2173 .pay = 1'000'000'000'000'000,
2181 .transferFee = 25'000,
2182 .pay = 1'000'000'000'000'000,
2190 .transferFee = 25'000,
2191 .pay = 1'000'000'000'000'000,
2195 AMM const amm1(env,
bob_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000));
2196 AMM const amm2(env, ed, eth(1'000'000'000'000'000), btc(1'000'000'000'000'000));
2200 Sendmax(gbp(150'000'000'000'000)),
2201 Txflags(tfNoRippleDirect | tfPartialPayment));
2209 BEAST_EXPECT(amm1.expectBalances(
2210 gbp(1'120'000'000'000'000), eth(892'857'142'857'143), amm1.tokens()));
2214 eth(1'085'714'285'714'285), btc(921'052'631'578'948), amm2.
tokens()));
2222 Env env(*
this, features);
2230 .transferFee = 25'000,
2239 .transferFee = 25'000,
2244 AMM const amm(env,
bob_, btc(1'000'000), eth(1'100'000));
2249 BEAST_EXPECT(
amm.expectBalances(btc(1'100'000), eth(1'000'000),
amm.tokens()));
2257 Env env(*
this, features);
2265 .transferFee = 25'000,
2266 .pay = 1'000'000'000'000'000,
2274 .transferFee = 25'000,
2275 .pay = 1'000'000'000'000'000,
2279 AMM const amm(env,
bob_, gbp(1'000'000'000'000'000), btc(1'000'000'000'000'000));
2285 Sendmax(gbp(178'580'000'000'000)),
2286 Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality));
2294 BEAST_EXPECT(
amm.expectBalances(
2295 gbp(1'142'857'142'857'143), btc(875'000'000'000'000),
amm.tokens()));
2303 Env env(*
this, features);
2311 .transferFee = 25'000,
2312 .pay = 1'200'000'000'000'000,
2320 .transferFee = 25'000,
2321 .pay = 1'200'000'000'000'000,
2325 AMM const amm(env,
bob_, gbp(1'000'000'000'000'000), btc(1'200'000'000'000'000));
2331 Sendmax(gbp(120'000'000'000'000)),
2332 Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality));
2342 BEAST_EXPECT(
amm.expectBalances(
2343 gbp(1'024'000'000'000'000), btc(1'171'875'000'000'001),
amm.tokens()));
2352 Env env(*
this, features);
2361 .transferFee = 25'000,
2362 .pay = 1'400'000'000'000'000,
2370 .transferFee = 25'000,
2371 .pay = 1'400'000'000'000'000,
2379 .transferFee = 25'000,
2380 .pay = 1'400'000'000'000'000,
2384 env(
offer(ed, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)),
2388 AMM const amm(env,
bob_, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000));
2394 Sendmax(gbp(140'000'000'000'000)),
2395 Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality));
2408 env, ed, 1, {
Amounts{gbp(929'578'947'368'420), eth(929'578'947'368'420)}}));
2411 BEAST_EXPECT(
amm.expectBalances(
2412 eth(1'056'336'842'105'264), btc(1'325'334'821'428'571),
amm.tokens()));
2421 Env env(*
this, features);
2430 .transferFee = 25'000,
2431 .pay = 1'400'000'000'000'000,
2439 .transferFee = 25'000,
2440 .pay = 1'400'000'000'000'000,
2448 .transferFee = 25'000,
2449 .pay = 1'400'000'000'000'000,
2453 AMM const amm(env,
bob_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000));
2455 env(
offer(ed, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000)),
2463 Sendmax(gbp(140'000'000'000'000)),
2464 Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality));
2477 BEAST_EXPECT(
amm.expectBalances(
2478 gbp(1'056'336'842'105'264), eth(946'667'729'591'836),
amm.tokens()));
2485 env, ed, 1, {
Amounts{eth(957'334'183'673'469), btc(1'340'267'857'142'857)}}));
2493 Env env(*
this, features);
2502 .transferFee = 25'000,
2503 .pay = 1'400'000'000'000'000,
2511 .transferFee = 25'000,
2512 .pay = 1'400'000'000'000'000,
2520 .transferFee = 25'000,
2521 .pay = 1'400'000'000'000'000,
2525 AMM const amm1(env,
bob_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000));
2526 AMM const amm2(env, ed, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000));
2532 Sendmax(gbp(145'000'000'000'000)),
2533 Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality));
2542 BEAST_EXPECT(amm1.expectBalances(
2543 gbp(1'086'024'691'358'028), eth(920'789'377'955'618), amm1.tokens()));
2547 eth(1'063'368'497'635'505), btc(1'316'570'881'226'053), amm2.
tokens()));
2556 Env env(*
this, features);
2564 .transferFee = 25'000,
2565 .pay = 1'400'000'000'000'000,
2573 .transferFee = 25'000,
2574 .pay = 1'400'000'000'000'000,
2582 .transferFee = 25'000,
2583 .pay = 1'400'000'000'000'000,
2587 AMM const amm1(env,
alice_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000));
2588 AMM const amm2(env,
bob_, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000));
2594 Sendmax(gbp(120'000'000'000'000)),
2595 Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality));
2599 BEAST_EXPECT(amm1.expectBalances(
2600 gbp(1'108'148'148'148'150), eth(902'406'417'112'298), amm1.tokens()));
2604 eth(1'078'074'866'310'161), btc(1'298'611'111'111'111), amm2.
tokens()));
2620 using namespace jtx;
2634 AMM const ammBob(env,
bob_,
XRP(1'000), eth(1'050'000));
2640 Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality));
2642 BEAST_EXPECT(ammBob.expectBalances(
XRP(1'050), eth(1'000'000), ammBob.tokens()));
2653 using namespace jtx;
2657 auto const test = [&](
auto&& issue1,
auto&& issue2) {
2661 auto const eth = issue1({
2668 auto const btc = issue2({
2682 AMM const ammAliceXrpBtc(env,
alice_,
XRP(100), btc(101'000));
2683 AMM const ammAliceXrpEth(env,
alice_,
XRP(100), eth(101'000));
2695 auto const test = [&](
auto&& issue1,
auto&& issue2) {
2699 auto const eth = issue1({
2706 auto const btc = issue2({
2720 AMM const ammAliceXrpBtc(env,
alice_,
XRP(100), btc(100'000));
2721 AMM const ammAliceXrpEth(env,
alice_,
XRP(100), eth(100'000));
2735 auto const test = [&](
auto&& issue1,
auto&& issue2,
auto&& issue3) {
2739 auto const eth = issue1({
2746 auto const btc = issue2({
2753 auto const jpy = issue2({
2769 AMM const ammAliceXrpBtc(env,
alice_,
XRP(100), btc(100'000));
2770 AMM const ammAliceXrpEth(env,
alice_,
XRP(100), eth(100'000));
2771 AMM const ammAliceXrpJpy(env,
alice_,
XRP(100), jpy(100'000));
2788 using namespace jtx;
2790 Env env(*
this, features);
2791 auto const dan =
Account(
"dan");
2792 auto const ed =
Account(
"ed");
2799 env(
pay(
gw_, ed, btc(11'000'000'000'000)));
2801 env(
pay(
gw_, dan, btc(1'000'000'000'000)));
2804 nOffers(env, 1, dan,
XRP(1), btc(1'000'000'000'000));
2805 AMM const ammEd(env, ed,
XRP(9), btc(11'000'000'000'000));
2831 Env env(*
this, features);
2832 auto const dan =
Account(
"dan");
2833 auto const ed =
Account(
"ed");
2842 .pay = 10000'000'000,
2846 env.
trust(
BTC(11'000'000'000'000), ed);
2847 env(
pay(
gw_, ed,
BTC(11'000'000'000'000)));
2850 env.
trust(
BTC(1'000'000'000'000), dan);
2851 env(
pay(
gw_, dan,
BTC(1'000'000'000'000)));
2855 nOffers(env, 1, dan, usd(1000000),
BTC(1'000'000'000'000));
2856 AMM const ammEd(env, ed, usd(9000000),
BTC(11'000'000'000'000));
2857 env(
offer(
alice_,
BTC(1'000'000'000'000'000), usd(1'000000000)));
2869 Env env(*
this, features);
2870 auto const dan =
Account(
"dan");
2871 auto const ed =
Account(
"ed");
2882 env.
trust(
USD(10000'000'000), dan);
2891 env(
pay(
gw_, ed, btc(11'000'000'000'000)));
2893 env(
pay(
gw_, dan, btc(1'000'000'000'000)));
2897 nOffers(env, 1, dan,
USD(1000000), btc(1'000'000'000'000));
2898 AMM const ammEd(env, ed,
USD(9000000), btc(11'000'000'000'000));
2899 env(
offer(
alice_, btc(1'000'000'000'000'000),
USD(1'000000000)));
2911 Env env(*
this, features);
2912 auto const dan =
Account(
"dan");
2913 auto const ed =
Account(
"ed");
2924 .pay = 10000'000'000,
2928 env(
pay(
gw_, ed, btc(11'000'000'000'000)));
2930 env(
pay(
gw_, dan, btc(1'000'000'000'000)));
2933 nOffers(env, 2'000,
bob_, usd(1000000), btc(1'000'000'000'000));
2934 nOffers(env, 1, dan, usd(1000000), btc(1'000'000'000'000));
2935 AMM const ammEd(env, ed, usd(9000000), btc(11'000'000'000'000));
2936 env(
offer(
alice_, btc(1'000'000'000'000'000), usd(1'000000000)));
2950 testcase(
"Convert all of an asset using DeliverMin");
2952 using namespace jtx;
2955 Env env(*
this, features);
2996 Env env(*
this, features);
3003 AMM const ammBob(env,
bob_,
XRP(1'000), btc(1'100'000));
3014 auto const test = [&](
auto&& issue1,
auto&& issue2) {
3018 auto const usd = issue1({
3025 auto const btc = issue2({
3038 AMM const ammBob(env,
bob_, usd(1'000), btc(1'100));
3050 Env env(*
this, features);
3057 AMM const ammBob(env,
bob_,
XRP(5'500), btc(1'200'000));
3075 auto const test = [&](
auto&& issue1,
auto&& issue2) {
3079 auto const usd = issue1({
3086 auto const btc = issue2({
3101 AMM const ammBob(env,
bob_, usd(5'500), btc(1'200));
3120 auto const dan =
Account(
"dan");
3121 Env env(*
this, features);
3128 env(
pay(
gw_, dan, btc(1'100'000'000)));
3131 AMM const ammDan(env, dan,
XRP(1'000), btc(1'100'000'000));
3150 using namespace jtx;
3153 Env env(*
this, features);
3162 AMM const ammAlice(env,
alice_,
XRP(100), btc(140'000));
3172 env(
fset(becky, asfDepositAuth));
3188 using namespace jtx;
3209 auto const failedMptPayments = [
this, &env, &btc] {
3231 failedMptPayments();
3248 failedMptPayments();
3255 failedMptPayments();
3278 Env env(*
this, features);
3284 env.
fund(
XRP(1'000), g1, alice, bob);
3289 .holders = {alice, bob},
3293 env(
pay(g1, bob, btc(10)));
3294 env(
pay(g1, alice, btc(205)));
3297 AMM const ammAlice(env, alice,
XRP(500), btc(105));
3304 env(
pay(alice, bob, btc(1)));
3307 env(
pay(bob, alice, btc(1)));
3311 btc.set({.holder = bob, .flags = tfMPTLock});
3335 btc.set({.holder = bob, .flags = tfMPTUnlock});
3337 env(
pay(bob, alice, btc(1)));
3338 env(
pay(alice, bob, btc(1)));
3349 Env env(*
this, features);
3359 env.
fund(
XRP(20'000), a2, a3, a4);
3364 .holders = {a1, a2, a3, a4},
3371 .holders = {a1, a2, a3, a4},
3375 env(
pay(g1, a1, eth(1'000)));
3376 env(
pay(g1, a2, eth(100)));
3377 env(
pay(g1, a3, btc(100)));
3378 env(
pay(g1, a4, btc(100)));
3381 AMM const ammG1(env, g1,
XRP(10'000), eth(100));
3403 AMM ammA3(env, a3, btc(1),
XRP(1));
3407 env(
pay(g1, a2, eth(1)));
3408 env(
pay(a2, g1, eth(1)));
3409 env(
pay(a2, a1, eth(1)));
3410 env(
pay(a1, a2, eth(1)));
3417 btc.set({.flags = tfMPTLock});
3423 env(
pay(g1, a2, btc(1)));
3424 env(
pay(a2, g1, btc(1)));
3444 testcase(
"Offers for Locked MPTs");
3447 Env env(*
this, features);
3454 env.
fund(
XRP(2'000), g1, a3, a4);
3461 .holders = {a2, a3, a4},
3465 env(
pay(g1, a3, btc(2'000)));
3466 env(
pay(g1, a4, btc(2'001)));
3469 AMM const ammA3(env, a3,
XRP(1'000), btc(1'001));
3479 env(
offer(a4,
XRP(999), btc(999)));
3485 btc.set({.holder = ammA3.
ammAccount(), .flags = tfMPTLock});
3487 BEAST_EXPECT(info[jss::amm][jss::asset2_frozen].asBool());
3498 btc.set({.holder = a4, .flags = tfMPTUnlock});
3502 env(
offer(a2, btc(999),
XRP(999)));
3514 testcase(
"Multisign AMM Transactions");
3516 using namespace jtx;
3517 Env env{*
this, features};
3522 fund(env,
gw_, {alice, becky, zelda},
XRP(20'000));
3527 .holders = {alice, becky, zelda},
3528 .pay = 20'000'000'000,
3534 env(
regkey(alice, alie));
3535 env(
fset(alice, asfDisableMaster),
Sig(alice));
3538 env(
signers(alice, 2, {{becky, 1}, {bogie, 1}}),
Sig(alie));
3540 static constexpr int kSignerListOwners{2};
3543 Msig const ms{becky, bogie};
3560 ammAlice.
deposit(alice, 1'000'000);
3563 ammAlice.
withdraw(alice, 1'000'000);
3566 ammAlice.
vote({}, 1'000);
3569 env(ammAlice.
bid({.account = alice, .bidMin = 100}), ms).
close();
3580 using namespace jtx;
3584 auto const test = [&](
auto&& issue1,
auto&& issue2) {
3588 auto const eth = issue1({
3595 auto const btc = issue2({
3609 AMM const bobXrpBtc(env,
bob_,
XRP(1'000), btc(1'000));
3610 AMM const bobBtcEth(env,
bob_, btc(1'000), eth(1'000));
3614 Path(~btc, ~eth, ~btc),
3626 using namespace jtx;
3630 Env env(*
this, features);
3649 AMM const ammXrpBtc(env,
bob_,
XRP(100), btc(100'000));
3652 AMM const ammBtcEth(env,
bob_, btc(100'000), eth(100'000));
3667 Txflags(tfNoRippleDirect | tfPartialPayment),
3672 Env env(*
this, features);
3684 AMM const ammBob(env,
bob_,
XRP(100), btc(100));
3694 Env env(*
this, features);
3706 AMM const ammBob(env,
bob_,
XRP(100), btc(100));
3721 using namespace jtx;
3724 Env env(*
this, features);
3739 AMM const ammBob(env,
bob_,
XRP(100), btc(100'000'000));
3750 auto const test = [&](
auto&& issue1,
auto&& issue2,
auto&& issue3) {
3751 Env env(*
this, features);
3756 auto const btc = issue1(
3758 auto const eth = issue2(
3760 auto const cny = issue3(
3768 AMM const ammBobXrpBtc(env,
bob_,
XRP(100), btc(100));
3769 AMM const ammBobBtcEth(env,
bob_, btc(100), eth(100));
3770 AMM const ammBobEthCny(env,
bob_, eth(100), cny(100));
3775 Path(~btc, ~eth, ~btc, ~cny),
3798 using namespace jtx;
3811 using namespace jtx;
3819 using namespace jtx;
3845 using namespace jtx;
3854 using namespace jtx;
A generic endpoint for log messages.
TestcaseT testcase
Memberspace for declaring test cases.
Floating point representation of amounts with high dynamic range.
beast::Journal journal(std::string const &name)
bool modify(ModifyType const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
A wrapper which makes credits unavailable to balances.
json::Value getJson(JsonOptions) const override
bool pushBack(STPath const &e)
pushBack adds a path to the set.
Discardable, editable view to a ledger.
virtual OpenLedger & getOpenLedger()=0
virtual Logs & getLogs()=0
SLE::pointer peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
TestPath & pushBack(Issue const &iss)
jtx::Account const alice_
void testAMM(std::function< void(jtx::AMM &, jtx::Env &)> const &cb, std::optional< std::pair< STAmount, STAmount > > const &pool=std::nullopt, std::uint16_t tfee=0, std::optional< jtx::Ter > const &ter=std::nullopt, std::vector< FeatureBitset > const &features={testableAmendments()})
testAMM() funds 30,000XRP and 30,000IOU for each non-XRP asset to Alice and Carol
static FeatureBitset testableAmendments()
jtx::Account const carol_
static XRPAmount reserve(jtx::Env &env, std::uint32_t count)
static XRPAmount ammCrtFee(jtx::Env &env)
Convenience class to test AMM functionality.
bool expectTradingFee(std::uint16_t fee) const
json::Value bid(BidArg const &arg)
IOUAmount withdrawAll(std::optional< Account > const &account, std::optional< STAmount > const &asset1OutDetails=std::nullopt, std::optional< Ter > const &ter=std::nullopt)
bool expectAuctionSlot(std::uint32_t fee, std::optional< std::uint8_t > timeSlot, IOUAmount expectedPrice) const
IOUAmount deposit(std::optional< Account > const &account, LPToken tokens, std::optional< STAmount > const &asset1InDetails=std::nullopt, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< Ter > const &ter=std::nullopt)
IOUAmount withdraw(std::optional< Account > const &account, std::optional< LPToken > const &tokens, std::optional< STAmount > const &asset1OutDetails=std::nullopt, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< Ter > const &ter=std::nullopt)
json::Value ammRpcInfo(std::optional< AccountID > const &account=std::nullopt, std::optional< std::string > const &ledgerIndex=std::nullopt, std::optional< Asset > const &asset1=std::nullopt, std::optional< Asset > const &asset2=std::nullopt, std::optional< AccountID > const &ammAccount=std::nullopt, bool ignoreParams=false, unsigned apiVersion=rpc::kApiInvalidVersion) const
Send amm_info RPC command.
AccountID const & ammAccount() const
void vote(std::optional< Account > const &account, std::uint32_t feeVal, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< jtx::Seq > const &seq=std::nullopt, std::optional< std::pair< Asset, Asset > > const &assets=std::nullopt, std::optional< Ter > const &ter=std::nullopt)
bool expectBalances(STAmount const &asset1, STAmount const &asset2, IOUAmount const &lpt, std::optional< AccountID > const &account=std::nullopt) const
Verify the AMM balances.
Immutable cryptographic account descriptor.
Sets the DeliverMin on a JTx.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
void memoize(Account const &account)
Associate AccountID with account.
void require(Args const &... args)
Check a set of requirements.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
void authorize(MPTAuthorize const &arg=MPTAuthorize{}, std::source_location const &loc=std::source_location::current())
Converts to MPT Issue or STAmount.
Set a multisignature on a JTx.
Match the number of items in the account's owner directory.
Set Paths, SendMax on a JTx.
Check a set of conditions.
Sets the SendMax on a JTx.
Set the regular signature on a JTx.
Set the expected result code for a JTx The test will fail if the code doesn't match.
@ Array
array value (ordered list)
Keylet offer(AccountID const &id, SeqProxy const &seq) noexcept
An offer from an account.
Keylet account(AccountID const &id) noexcept
AccountID root.
void nOffers(Env &env, std::size_t n, Account const &account, STAmount const &in, STAmount const &out)
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
std::vector< STAmount > fund(jtx::Env &env, jtx::Account const &gw, std::vector< jtx::Account > const &accounts, std::vector< STAmount > const &amts, Fund how)
bool expectLedgerEntryRoot(Env &env, Account const &acct, STAmount const &expectedValue)
json::Value regkey(Account const &account, DisabledT)
Disable the regular key.
STPathElement allPathElements(AccountID const &a, Asset const &asset)
void testHelper2TokensMix(TTester &&tester)
XrpT const XRP
Converts to XRP Issue or STAmount.
std::tuple< STPathSet, STAmount, STAmount > findPaths(jtx::Env &env, jtx::Account const &src, jtx::Account const &dst, STAmount const &saDstAmount, std::optional< STAmount > const &saSendMax, std::optional< PathAsset > const &srcAsset, std::optional< AccountID > const &srcIssuer, std::optional< UInt256 > const &domain)
json::Value noop(Account const &account)
The null transaction.
bool expectOffers(Env const &env, AccountID const &account, std::uint16_t size, std::vector< Amounts > const &toMatch)
bool same(STPathSet const &st1, Args const &... args)
XRPAmount txFee(Env const &env, std::uint16_t n)
json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
FeatureBitset testableAmendments()
void testHelper3TokensMix(TTester &&tester)
OwnerCount< ltOFFER > Offers
Match the number of offers in the account's owner directory.
STPathElement cpe(PathAsset const &pa)
STPathElement ipe(Asset const &asset)
bool equal(STAmount const &sa1, STAmount const &sa2)
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
json::Value ledgerEntryRoot(Env &env, Account const &acct)
std::tuple< STPathSet, STAmount, STAmount > findPathsByElement(jtx::Env &env, jtx::Account const &src, jtx::Account const &dst, STAmount const &saDstAmount, std::optional< STAmount > const &saSendMax, std::optional< STPathElement > const &srcElement, std::optional< AccountID > const &srcIssuer, std::optional< UInt256 > const &domain)
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
STPath stpath(Args const &... args)
json::Value signers(Account const &account, std::uint32_t quorum, std::vector< Signer > const &v)
bool checkArraySize(json::Value const &val, unsigned int size)
json::Value getAccountOffers(Env &env, AccountID const &acct, bool current)
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
bool isOffer(jtx::Env const &env, jtx::Account const &account, STAmount const &takerPays, STAmount const &takerGets)
An offer exists.
constexpr XRPAmount
Convert XRP to drops (integral types).
BEAST_DEFINE_TESTSUITE_PRIO(AccountDelete, app, xrpl, 2)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
TER offerDelete(ApplyView &view, SLE::Ref sle, beast::Journal j)
Delete an offer.
TAmounts< STAmount, STAmount > Amounts
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Seed generateSeed(std::string const &passPhrase)
Generate a seed deterministically.
Currency const & xrpCurrency()
XRP currency.
std::string to_string(BaseUInt< Bits, Tag > const &a)
StrandResult< TInAmt, TOutAmt > flow(PaymentSandbox const &baseView, Strand const &strand, std::optional< TInAmt > const &maxIn, TOutAmt const &out, beast::Journal j)
Request out amount from a strand.
AccountID const & xrpAccount()
Compute AccountID from public key.
Tests of AMM MPT that use offers.
void pathFindMPTAMMExecutableSourceAmount()
void pathFindConsumeAll()
void testOfferCrossWithXRP(FeatureBitset features)
void testSellFlagBasic(FeatureBitset features)
void testSellWithFillOrKill(FeatureBitset features)
void testBridgedCross(FeatureBitset features)
void testCrossCurrencyEndXRP(FeatureBitset features)
void testCurrencyConversionEntire(FeatureBitset features)
void testTxMultisign(FeatureBitset features)
void testDirectToDirectPath(FeatureBitset features)
void testOffersWhenLocked(FeatureBitset features)
void testFalseDry(FeatureBitset features)
void testCrossCurrencyBridged(FeatureBitset features)
void testCrossingLimits()
void testOfferFeesConsumeFunds(FeatureBitset features)
void testRequireAuth(FeatureBitset features)
void testCurrencyConversionInParts(FeatureBitset features)
void testOfferCreateThenCross(FeatureBitset features)
void run() override
Runs the suite.
void testStepLimit(FeatureBitset features)
void testSellFlagExceedLimit(FeatureBitset features)
void testFillModes(FeatureBitset features)
void testPayment(FeatureBitset features)
void testSelfIssueOffer(FeatureBitset features)
void testOfferCrossWithLimitOverride(FeatureBitset features)
void testTransferRateOffer(FeatureBitset features)
void testRmFundedOffer(FeatureBitset features)
void testLoop(FeatureBitset features)
void testConvertAllOfAnAsset(FeatureBitset features)
void testCrossCurrencyStartXRP(FeatureBitset features)
void testToStrand(FeatureBitset features)
void testGlobalLock(FeatureBitset features)
void viaOffersViaGateway()
void testTransferRateNoOwnerFee(FeatureBitset features)
void testMissingAuth(FeatureBitset features)
void testGatewayCrossCurrency(FeatureBitset features)
void testRIPD1373(FeatureBitset features)
void testIndividualLock(FeatureBitset features)
void testBookStep(FeatureBitset features)
Represents an XRP, IOU, or MPT quantity This customizes the string conversion and supports XRP conver...