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
2023-07-12 13:52:50 -04:00
committed by GitHub
parent eeb8b41889
commit 3c9db4b69e
100 changed files with 18092 additions and 649 deletions

View File

@@ -26,17 +26,22 @@ namespace test {
namespace jtx {
Json::Value
pay(Account const& account, Account const& to, AnyAmount amount)
pay(AccountID const& account, AccountID const& to, AnyAmount amount)
{
amount.to(to);
Json::Value jv;
jv[jss::Account] = account.human();
jv[jss::Account] = to_string(account);
jv[jss::Amount] = amount.value.getJson(JsonOptions::none);
jv[jss::Destination] = to.human();
jv[jss::Destination] = to_string(to);
jv[jss::TransactionType] = jss::Payment;
jv[jss::Flags] = tfUniversal;
return jv;
}
Json::Value
pay(Account const& account, Account const& to, AnyAmount amount)
{
return pay(account.id(), to.id(), amount);
}
} // namespace jtx
} // namespace test