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:
Gregory Tsipenyuk
2026-02-19 15:01:11 +09:00
committed by tequ
parent ac415e24fb
commit 233f060b0b
112 changed files with 18961 additions and 1684 deletions

View File

@@ -22,6 +22,7 @@
#include <ripple/protocol/jss.h>
#include <test/app/Import_json.h>
#include <test/jtx.h>
#include <test/jtx/TestHelpers.h>
namespace ripple {
namespace test {
@@ -258,7 +259,7 @@ class BaseFee_test : public beast::unit_test::suite
// build tx
auto const seq1 = env.seq(account);
auto tx = escrow::cancel(account, account, seq1);
auto tx = cancel(account, account, seq1);
// verify hooks fee
std::string const feeResult =
@@ -282,7 +283,7 @@ class BaseFee_test : public beast::unit_test::suite
env.close();
// build tx
auto tx = escrow::create(account, dest, XRP(10));
auto tx = escrow(account, dest, XRP(10));
// verify hooks fee
std::string const feeResult =
@@ -306,7 +307,7 @@ class BaseFee_test : public beast::unit_test::suite
// build tx
auto const seq1 = env.seq(account);
auto tx = escrow::finish(account, account, seq1);
auto tx = finish(account, account, seq1);
// verify hooks fee
std::string const feeResult =