Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce AMM support (XLS-30d) #4294

Merged
merged 62 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
6dc93d0
Introduce AMM support (XLS-30d)
gregtatcam Sep 4, 2022
101e3e0
[FOLD] Use average quality for one path optimization. Fix ammAccountH…
gregtatcam Sep 12, 2022
ecb7d9d
[FOLD] Make deterministic voting slot ordering in case of the same vo…
gregtatcam Sep 15, 2022
f89e44d
[FOLD] Fix AMMInstanceCreate with self-issued token.
gregtatcam Sep 19, 2022
b6befdb
[FOLD] Return tecNO_[AUTH|LINE] in requireAuth(). Simplify AMM unit-t…
gregtatcam Sep 22, 2022
7c53e89
[FOLD] Add AMM support for the transfer fee.
gregtatcam Oct 3, 2022
1cf3f28
[FOLD] Fix non-unity build.
gregtatcam Oct 3, 2022
ad07933
[FOLD] Address review comments:
gregtatcam Oct 12, 2022
479ee4f
[FOLD]
gregtatcam Oct 14, 2022
35ebb71
[FOLD]
gregtatcam Oct 17, 2022
db36c91
[FOLD]
gregtatcam Oct 18, 2022
fa404e0
[FOLD] Roll back (temp) AMM index.
gregtatcam Oct 18, 2022
ff664b4
[FOLD] Replace AMMID with asset pair and other changes
gregtatcam Nov 3, 2022
93a85a3
[FOLD] Rename Max/MinBidPrice to BidMax/Min and other changes.
gregtatcam Nov 8, 2022
b55aa43
[FOLD] Fix valid range for Deposit/Withdraw flags and update Withdraw…
gregtatcam Nov 9, 2022
e4b2986
[FOLD] Resolve sfAsset/sfAsset2 fieldValue conflict with the sidechai…
gregtatcam Nov 9, 2022
c81c370
[FOLD] Resolve merge conflict with 1.10.0-b2
gregtatcam Nov 10, 2022
c6ffd7d
[FOLD] Fix amm_info crash and other changes
gregtatcam Nov 15, 2022
5b3dba9
[FOLD] Address @godexsoft comments and other changes
gregtatcam Dec 9, 2022
33c3530
[FOLD] Adjust tokens for precision loss in deposit and withdraw and o…
gregtatcam Dec 26, 2022
4c695f6
[FOLD] Move clio related functions to xrpl_core and other changes
gregtatcam Jan 6, 2023
c97ed40
[FOLD] Set AMM creator's fee voting and action slots and other changes
gregtatcam Jan 30, 2023
853d644
Remove the fee from the spot price equation and other changes
gregtatcam Feb 3, 2023
79e1627
[FOLD] Resolve merge conflict with 1.10.0-rc4 and minor clean up.
gregtatcam Mar 8, 2023
b4d3565
[FOLD] Address reviewer feedback and other changes
gregtatcam Mar 14, 2023
4ba1bc3
[FOLD] Address reviewer feedback
gregtatcam Mar 16, 2023
33a853e
[FOLD] Rename wavesTransferFee() to waivesTransferFee()
gregtatcam Mar 16, 2023
9b6f04b
[FOLD] Address reviewer feedback
gregtatcam Mar 20, 2023
81eec0d
[FOLD] Update Copyright on all new AMM files.
gregtatcam Mar 22, 2023
22e3370
[FOLD] Rename sfAMMAccount to sfAccount and update amm_info.
gregtatcam Mar 22, 2023
cf385ff
[FOLD] Consistently handle global and individual freeze and other cha…
gregtatcam Mar 29, 2023
f99260f
[FOLD] Fix unit-test merge conflicts
gregtatcam Mar 30, 2023
1c6c38c
[FOLD] Improve Fibonnaci AMM offer generation performance and minor r…
gregtatcam Mar 31, 2023
67a37ad
[FOLD] Add comments to clarify single deposit/withdrawal with effecti…
gregtatcam Apr 3, 2023
ccd1843
[FOLD] Move fee functions to AMMCore.h and other changes
gregtatcam Apr 6, 2023
d1da8d9
[FOLD] Make sfDiscountedFee and sfTradingFee as soeDEFAULT in ltAMM a…
gregtatcam Apr 7, 2023
76b6b48
[FOLD] Fix sfTradingFee and sfDiscountedFee fields access and other c…
gregtatcam Apr 11, 2023
04f54ec
[FOLD] Fix bid pay price exceeding lp tokens
gregtatcam Apr 12, 2023
e443b78
[FOLD] Address amm info and payment engine reviewer's feedback
gregtatcam Apr 27, 2023
6dd5f02
[FOLD] Address amm unit-tests reviewer's feedback
gregtatcam May 2, 2023
c53df03
[FOLD] Split AMM_test.cpp into multiple files and remove duplicate he…
gregtatcam May 2, 2023
2bf02a2
[FOLD] Remove unneeded BEAST_EXPECT() left in unit-test run() from so…
gregtatcam May 3, 2023
5dc86be
[FOLD] Address reviewer's feedback and other changes
gregtatcam May 11, 2023
e3339de
[FOLD] Address reviewer's feedback and other changes
gregtatcam May 22, 2023
02d5db6
Ensure that switchover vars are initialized before use:
seelabs May 18, 2023
c2692d9
[FOLD] Address auditor's feedback
gregtatcam May 31, 2023
69a93a3
[FOLD] Update trading fee unit-tests; update comments
gregtatcam Jun 1, 2023
ad81c4b
[FOLD] Address reviewer's feedback
gregtatcam Jun 4, 2023
d9080e3
[FOLD] Address reviewer's feedback
gregtatcam Jun 7, 2023
ed920c0
[FOLD] Fix sfAuthAccounts conflict with side-chains
gregtatcam Jun 7, 2023
b6d3301
[FOLD] Consolidate all tecAMM_FAILED_* as tecAMM_FAILED and other cha…
gregtatcam Jun 8, 2023
39cb731
[FOLD] Add optional min deposit parameters to AMMDeposit and other ch…
gregtatcam Jun 14, 2023
1860e33
[FOLD] Disallow AMMCreate if a token issuer's account has DefaultRipp…
gregtatcam Jun 15, 2023
1d5af43
[FOLD] Address reviewer's feedback
gregtatcam Jun 15, 2023
4741cb4
[FOLD] Address reviewer's feedback
gregtatcam Jun 21, 2023
74e5762
[FOLD] Take into account the transfer fee in balance check on create/…
gregtatcam Jun 22, 2023
d79dbe3
Revert "[FOLD] Take into account the transfer fee in balance check on…
gregtatcam Jun 30, 2023
a6fc4dc
[FOLD] Remove the transfer fee from create/deposit and other changes
gregtatcam Jun 30, 2023
6e26310
[FOLD] Address reviewers feedback
gregtatcam Jul 9, 2023
515353f
[FOLD] Address reviewer feedback
gregtatcam Jul 10, 2023
902af50
[FOLD] Merge with the latest develop
gregtatcam Jul 11, 2023
84b0f86
[FOLD] Merge with develop to fix change in Conan recipe for NuDB
gregtatcam Jul 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,20 @@ target_sources (xrpl_core PRIVATE
subdir: protocol
#]===============================]
src/ripple/protocol/impl/AccountID.cpp
src/ripple/protocol/impl/AMMCore.cpp
src/ripple/protocol/impl/Book.cpp
src/ripple/protocol/impl/BuildInfo.cpp
src/ripple/protocol/impl/ErrorCodes.cpp
src/ripple/protocol/impl/Feature.cpp
src/ripple/protocol/impl/Indexes.cpp
src/ripple/protocol/impl/InnerObjectFormats.cpp
src/ripple/protocol/impl/Issue.cpp
src/ripple/protocol/impl/STIssue.cpp
src/ripple/protocol/impl/Keylet.cpp
src/ripple/protocol/impl/LedgerFormats.cpp
src/ripple/protocol/impl/PublicKey.cpp
src/ripple/protocol/impl/Quality.cpp
src/ripple/protocol/impl/QualityFunction.cpp
src/ripple/protocol/impl/Rate2.cpp
src/ripple/protocol/impl/Rules.cpp
src/ripple/protocol/impl/SField.cpp
Expand Down Expand Up @@ -200,6 +203,7 @@ install (
install (
FILES
src/ripple/protocol/AccountID.h
src/ripple/protocol/AMMCore.h
src/ripple/protocol/AmountConversions.h
src/ripple/protocol/Book.h
src/ripple/protocol/BuildInfo.h
Expand All @@ -216,12 +220,14 @@ install (
src/ripple/protocol/Protocol.h
src/ripple/protocol/PublicKey.h
src/ripple/protocol/Quality.h
src/ripple/protocol/QualityFunction.h
src/ripple/protocol/Rate.h
src/ripple/protocol/Rules.h
src/ripple/protocol/SField.h
src/ripple/protocol/SOTemplate.h
src/ripple/protocol/STAccount.h
src/ripple/protocol/STAmount.h
src/ripple/protocol/STIssue.h
src/ripple/protocol/STArray.h
src/ripple/protocol/STBase.h
src/ripple/protocol/STBitString.h
Expand Down Expand Up @@ -380,6 +386,8 @@ target_sources (rippled PRIVATE
src/ripple/app/reporting/ReportingETL.cpp
src/ripple/app/reporting/ETLSource.cpp
src/ripple/app/reporting/P2pProxy.cpp
src/ripple/app/misc/impl/AMMHelpers.cpp
src/ripple/app/misc/impl/AMMUtils.cpp
src/ripple/app/misc/CanonicalTXSet.cpp
src/ripple/app/misc/FeeVoteImpl.cpp
src/ripple/app/misc/HashRouter.cpp
Expand All @@ -405,6 +413,8 @@ target_sources (rippled PRIVATE
src/ripple/app/paths/RippleCalc.cpp
src/ripple/app/paths/RippleLineCache.cpp
src/ripple/app/paths/TrustLine.cpp
src/ripple/app/paths/impl/AMMLiquidity.cpp
src/ripple/app/paths/impl/AMMOffer.cpp
src/ripple/app/paths/impl/BookStep.cpp
src/ripple/app/paths/impl/DirectStep.cpp
src/ripple/app/paths/impl/PaySteps.cpp
Expand All @@ -421,6 +431,11 @@ target_sources (rippled PRIVATE
src/ripple/app/rdb/impl/UnitaryShard.cpp
src/ripple/app/rdb/impl/Vacuum.cpp
src/ripple/app/rdb/impl/Wallet.cpp
src/ripple/app/tx/impl/AMMBid.cpp
src/ripple/app/tx/impl/AMMCreate.cpp
src/ripple/app/tx/impl/AMMDeposit.cpp
src/ripple/app/tx/impl/AMMVote.cpp
src/ripple/app/tx/impl/AMMWithdraw.cpp
src/ripple/app/tx/impl/ApplyContext.cpp
src/ripple/app/tx/impl/BookTip.cpp
src/ripple/app/tx/impl/CancelCheck.cpp
Expand Down Expand Up @@ -585,6 +600,7 @@ target_sources (rippled PRIVATE
src/ripple/rpc/handlers/AccountObjects.cpp
src/ripple/rpc/handlers/AccountOffers.cpp
src/ripple/rpc/handlers/AccountTx.cpp
src/ripple/rpc/handlers/AMMInfo.cpp
src/ripple/rpc/handlers/BlackList.cpp
src/ripple/rpc/handlers/BookOffers.cpp
src/ripple/rpc/handlers/CanDelete.cpp
Expand Down Expand Up @@ -688,6 +704,8 @@ if (tests)
src/test/app/AccountDelete_test.cpp
src/test/app/AccountTxPaging_test.cpp
src/test/app/AmendmentTable_test.cpp
src/test/app/AMM_test.cpp
src/test/app/AMMCalc_test.cpp
src/test/app/Check_test.cpp
src/test/app/CrossingLimits_test.cpp
src/test/app/DeliverMin_test.cpp
Expand Down Expand Up @@ -828,9 +846,12 @@ if (tests)
src/test/jtx/Env_test.cpp
src/test/jtx/WSClient_test.cpp
src/test/jtx/impl/Account.cpp
src/test/jtx/impl/AMM.cpp
src/test/jtx/impl/AMMTest.cpp
src/test/jtx/impl/Env.cpp
src/test/jtx/impl/JSONRPCClient.cpp
src/test/jtx/impl/ManualTimeKeeper.cpp
src/test/jtx/impl/TestHelpers.cpp
src/test/jtx/impl/WSClient.cpp
src/test/jtx/impl/acctdelete.cpp
src/test/jtx/impl/account_txn_id.cpp
Expand Down Expand Up @@ -946,6 +967,7 @@ if (tests)
src/test/rpc/AccountSet_test.cpp
src/test/rpc/AccountTx_test.cpp
src/test/rpc/AmendmentBlocked_test.cpp
src/test/rpc/AMMInfo_test.cpp
src/test/rpc/Book_test.cpp
src/test/rpc/DepositAuthorized_test.cpp
src/test/rpc/DeliveredAmount_test.cpp
Expand Down
2 changes: 2 additions & 0 deletions Builds/levelization/results/ordering.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ test.jtx > ripple.json
test.jtx > ripple.ledger
test.jtx > ripple.net
test.jtx > ripple.protocol
test.jtx > ripple.resource
test.jtx > ripple.rpc
test.jtx > ripple.server
test.ledger > ripple.app
test.ledger > ripple.basics
Expand Down
18 changes: 17 additions & 1 deletion src/ripple/app/ledger/OrderBookDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/ledger/OrderBookDB.h>
#include <ripple/app/main/Application.h>
#include <ripple/app/misc/AMMUtils.h>
#include <ripple/app/misc/NetworkOPs.h>
#include <ripple/basics/Log.h>
#include <ripple/core/Config.h>
Expand Down Expand Up @@ -93,7 +94,7 @@ OrderBookDB::update(std::shared_ptr<ReadView const> const& ledger)

JLOG(j_.debug()) << "Beginning update (" << ledger->seq() << ")";

// walk through the entire ledger looking for orderbook entries
// walk through the entire ledger looking for orderbook/AMM entries
int cnt = 0;

try
Expand Down Expand Up @@ -126,6 +127,21 @@ OrderBookDB::update(std::shared_ptr<ReadView const> const& ledger)

++cnt;
}
else if (sle->getType() == ltAMM)
{
auto const issue1 = (*sle)[sfAsset];
auto const issue2 = (*sle)[sfAsset2];
auto addBook = [&](Issue const& in, Issue const& out) {
allBooks[in].insert(out);

if (isXRP(out))
xrpBooks.insert(in);

++cnt;
};
addBook(issue1, issue2);
addBook(issue2, issue1);
}
}
}
catch (SHAMapMissingNode const& mn)
Expand Down
Loading