2#include <test/jtx/AMM.h>
3#include <test/jtx/AMMTest.h>
16 Env env{*
this, features};
31 auto const lpIssue = ammAlice.
lptIssue();
52 if (features[fixFrozenLPTokenTransfer])
70 Env env{*
this, features};
74 ammAlice.deposit(
carol, 1'000);
75 ammAlice.deposit(
bob, 1'000);
77 auto const lpIssue = ammAlice.lptIssue();
96 if (features[fixFrozenLPTokenTransfer])
108 env(
trust(
gw,
carol[
"USD"](1'000'000'000), tfClearFreeze));
130 env(
trust(
gw,
carol[
"USD"](1'000'000'000), tfClearFreeze));
160 Env env{*
this, features};
164 ammAlice.deposit(
carol, 1'000);
165 ammAlice.deposit(
bob, 1'000);
167 auto const lpIssue = ammAlice.lptIssue();
175 if (features[fixFrozenLPTokenTransfer])
188 env(
trust(
gw,
carol[
"USD"](1'000'000'000), tfClearFreeze));
220 Env env{*
this, features};
225 ammAlice1.deposit(
carol, 10'000'000);
229 ammAlice2.deposit(
carol, 10'000'000);
230 auto const token1 = ammAlice1.lptIssue();
231 auto const token2 = ammAlice2.lptIssue();
249 if (features[fixFrozenLPTokenTransfer])
281 Env env{*
this, features};
285 ammAlice.deposit(
carol, 1'000);
286 ammAlice.deposit(
bob, 1'000);
288 auto const lpIssue = ammAlice.lptIssue();
301 if (features[fixFrozenLPTokenTransfer])
327 using namespace test::jtx;
329 Env env{*
this, features};
334 ammAlice.deposit(
carol, 1'000);
335 ammAlice.deposit(
bob, 1'000);
337 auto const lpIssue = ammAlice.lptIssue();
355 if (features[fixFrozenLPTokenTransfer])
385 env(
trust(
gw,
bob[
"USD"](1'000'000), tfClearFreeze));
422 for (
auto const features : {all, all - fixFrozenLPTokenTransfer})
434BEAST_DEFINE_TESTSUITE(LPTokenTransfer, app,
xrpl);
testcase_t testcase
Memberspace for declaring test cases.
Floating point representation of amounts with high dynamic range.
void run() override
Runs the suite.
void testOfferCrossing(FeatureBitset features)
void testOfferCreation(FeatureBitset features)
void testDirectStep(FeatureBitset features)
void testBookStep(FeatureBitset features)
void testCheck(FeatureBitset features)
void testNFTOffers(FeatureBitset features)
Convenience class to test AMM functionality.
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)
bool expectBalances(STAmount const &asset1, STAmount const &asset2, IOUAmount const &lpt, std::optional< AccountID > const &account=std::nullopt) const
Verify the AMM balances.
A transaction testing environment.
Sets the SendMax on a JTx.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Sets the optional Owner on an NFTokenOffer.
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Json::Value cash(jtx::Account const &dest, uint256 const &checkId, STAmount const &amount)
Cash a check requiring that a specific amount be delivered.
Json::Value create(A const &account, A const &dest, STAmount const &sendMax)
Create a check.
Json::Value mint(jtx::Account const &account, std::uint32_t nfTokenTaxon)
Mint an NFToken.
Json::Value acceptBuyOffer(jtx::Account const &account, uint256 const &offerIndex)
Accept an NFToken buy offer.
Json::Value acceptSellOffer(jtx::Account const &account, uint256 const &offerIndex)
Accept an NFToken sell offer.
Json::Value createOffer(jtx::Account const &account, uint256 const &nftokenID, STAmount const &amount)
Create an NFTokenOffer.
uint256 getNextID(jtx::Env const &env, jtx::Account const &issuer, std::uint32_t nfTokenTaxon, std::uint16_t flags, std::uint16_t xferFee)
Get the next NFTokenID that will be issued.
bool expectOffers(Env &env, AccountID const &account, std::uint16_t size, std::vector< Amounts > const &toMatch)
void fund(jtx::Env &env, jtx::Account const &gw, std::vector< jtx::Account > const &accounts, std::vector< STAmount > const &amts, Fund how)
bool expectHolding(Env &env, AccountID const &account, STAmount const &value, bool defaultLimits)
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
XRP_t const XRP
Converts to XRP Issue or STAmount.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
FeatureBitset testable_amendments()
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.