-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #283
- Loading branch information
Showing
16 changed files
with
1,878 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of clio: https://github.com/XRPLF/clio | ||
Copyright (c) 2024, the clio developers. | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#include "rpc/AMMHelpers.h" | ||
|
||
#include "data/BackendInterface.h" | ||
#include "util/log/Logger.h" | ||
|
||
#include <ripple/protocol/AMMCore.h> | ||
|
||
namespace rpc { | ||
|
||
std::pair<ripple::STAmount, ripple::STAmount> | ||
getAmmPoolHolds( | ||
BackendInterface const& backend, | ||
std::uint32_t sequence, | ||
ripple::AccountID const& ammAccountID, | ||
ripple::Issue const& issue1, | ||
ripple::Issue const& issue2, | ||
bool freezeHandling, | ||
boost::asio::yield_context yield | ||
) | ||
{ | ||
auto const assetInBalance = | ||
accountHolds(backend, sequence, ammAccountID, issue1.currency, issue1.account, freezeHandling, yield); | ||
auto const assetOutBalance = | ||
accountHolds(backend, sequence, ammAccountID, issue2.currency, issue2.account, freezeHandling, yield); | ||
return std::make_pair(assetInBalance, assetOutBalance); | ||
} | ||
|
||
ripple::STAmount | ||
getAmmLpHolds( | ||
BackendInterface const& backend, | ||
std::uint32_t sequence, | ||
ripple::Currency const& cur1, | ||
ripple::Currency const& cur2, | ||
ripple::AccountID const& ammAccount, | ||
ripple::AccountID const& lpAccount, | ||
boost::asio::yield_context yield | ||
) | ||
{ | ||
auto const lptCurrency = ammLPTCurrency(cur1, cur2); | ||
return accountHolds(backend, sequence, lpAccount, lptCurrency, ammAccount, true, yield); | ||
} | ||
|
||
ripple::STAmount | ||
getAmmLpHolds( | ||
BackendInterface const& backend, | ||
std::uint32_t sequence, | ||
ripple::SLE const& ammSle, | ||
ripple::AccountID const& lpAccount, | ||
boost::asio::yield_context yield | ||
) | ||
{ | ||
return getAmmLpHolds( | ||
backend, | ||
sequence, | ||
ammSle[ripple::sfAsset].currency, | ||
ammSle[ripple::sfAsset2].currency, | ||
ammSle[ripple::sfAccount], | ||
lpAccount, | ||
yield | ||
); | ||
} | ||
|
||
} // namespace rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of clio: https://github.com/XRPLF/clio | ||
Copyright (c) 2024, the clio developers. | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#pragma once | ||
|
||
#include "data/BackendInterface.h" | ||
#include "rpc/RPCHelpers.h" | ||
|
||
namespace rpc { | ||
|
||
/** | ||
* @brief getAmmPoolHolds returns the balances of the amm asset pair. | ||
*/ | ||
std::pair<ripple::STAmount, ripple::STAmount> | ||
getAmmPoolHolds( | ||
BackendInterface const& backend, | ||
std::uint32_t sequence, | ||
ripple::AccountID const& ammAccountID, | ||
ripple::Issue const& issue1, | ||
ripple::Issue const& issue2, | ||
bool freezeHandling, | ||
boost::asio::yield_context yield | ||
); | ||
|
||
/** | ||
* @brief getAmmLpHolds returns the lp token balance. | ||
*/ | ||
ripple::STAmount | ||
getAmmLpHolds( | ||
BackendInterface const& backend, | ||
std::uint32_t sequence, | ||
ripple::Currency const& cur1, | ||
ripple::Currency const& cur2, | ||
ripple::AccountID const& ammAccount, | ||
ripple::AccountID const& lpAccount, | ||
boost::asio::yield_context yield | ||
); | ||
|
||
/** | ||
* @brief getAmmLpHolds returns the lp token balance. | ||
*/ | ||
ripple::STAmount | ||
getAmmLpHolds( | ||
BackendInterface const& backend, | ||
std::uint32_t sequence, | ||
ripple::SLE const& ammSle, | ||
ripple::AccountID const& lpAccount, | ||
boost::asio::yield_context yield | ||
); | ||
|
||
} // namespace rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.