mirror of
https://github.com/Xahau/xahaud.git
synced 2026-04-29 15:37:46 +00:00
Introduce AMM support (XLS-30d): (#4294)
Add AMM functionality: - InstanceCreate - Deposit - Withdraw - Governance - Auctioning - payment engine integration To support this functionality, add: - New RPC method, `amm_info`, to fetch pool and LPT balances - AMM Root Account - trust line for each IOU AMM token - trust line to track Liquidity Provider Tokens (LPT) - `ltAMM` object The `ltAMM` object tracks: - fee votes - auction slot bids - AMM tokens pair - total outstanding tokens balance - `AMMID` to AMM `RootAccountID` mapping Add new classes to facilitate AMM integration into the payment engine. `BookStep` uses these classes to infer if AMM liquidity can be consumed. The AMM formula implementation uses the new Number class added in #4192. IOUAmount and STAmount use Number arithmetic. Add AMM unit tests for all features. AMM requires the following amendments: - featureAMM - fixUniversalNumber - featureFlowCross Notes: - Current trading fee threshold is 1% - AMM currency is generated by: 0x03 + 152 bits of sha256{cur1, cur2} - Current max AMM Offers is 30 --------- Co-authored-by: Howard Hinnant <howard.hinnant@gmail.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/PathSet.h>
|
||||
#include <test/jtx/TestHelpers.h>
|
||||
#include <test/jtx/WSClient.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -41,42 +42,6 @@ class Offer_test : public beast::unit_test::suite
|
||||
return env.current()->info().parentCloseTime.time_since_epoch().count();
|
||||
}
|
||||
|
||||
static auto
|
||||
xrpMinusFee(jtx::Env const& env, std::int64_t xrpAmount)
|
||||
-> jtx::PrettyAmount
|
||||
{
|
||||
using namespace jtx;
|
||||
auto feeDrops = env.current()->fees().base;
|
||||
return drops(dropsPerXRP * xrpAmount - feeDrops);
|
||||
}
|
||||
|
||||
static auto
|
||||
ledgerEntryState(
|
||||
jtx::Env& env,
|
||||
jtx::Account const& acct_a,
|
||||
jtx::Account const& acct_b,
|
||||
std::string const& currency)
|
||||
{
|
||||
Json::Value jvParams;
|
||||
jvParams[jss::ledger_index] = "current";
|
||||
jvParams[jss::ripple_state][jss::currency] = currency;
|
||||
jvParams[jss::ripple_state][jss::accounts] = Json::arrayValue;
|
||||
jvParams[jss::ripple_state][jss::accounts].append(acct_a.human());
|
||||
jvParams[jss::ripple_state][jss::accounts].append(acct_b.human());
|
||||
return env.rpc(
|
||||
"json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
}
|
||||
|
||||
static auto
|
||||
ledgerEntryRoot(jtx::Env& env, jtx::Account const& acct)
|
||||
{
|
||||
Json::Value jvParams;
|
||||
jvParams[jss::ledger_index] = "current";
|
||||
jvParams[jss::account_root] = acct.human();
|
||||
return env.rpc(
|
||||
"json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
}
|
||||
|
||||
static auto
|
||||
ledgerEntryOffer(
|
||||
jtx::Env& env,
|
||||
@@ -2718,7 +2683,7 @@ public:
|
||||
env.close();
|
||||
|
||||
// The scenario:
|
||||
// o alice has USD but wants XPR.
|
||||
// o alice has USD but wants XRP.
|
||||
// o bob has XRP but wants EUR.
|
||||
// o carol has EUR but wants USD.
|
||||
// Note that carol's offer must come last. If carol's offer is placed
|
||||
@@ -3317,7 +3282,7 @@ public:
|
||||
env.fund(XRP(2) + reserve(env, 3) + (fee * 3), ova, pat, qae);
|
||||
env.close();
|
||||
|
||||
// o ova has USD but wants XPR.
|
||||
// o ova has USD but wants XRP.
|
||||
// o pat has XRP but wants EUR.
|
||||
// o qae has EUR but wants USD.
|
||||
env(trust(ova, USD(200)));
|
||||
|
||||
Reference in New Issue
Block a user