mirror of
https://github.com/Xahau/xahaud.git
synced 2026-08-22 07:50:52 +00:00
When an AMM account is deleted, the owner directory entries must be
deleted in order to ensure consistent ledger state.
* When deleting AMM account:
* Clean up AMM owner dir, linking AMM account and AMM object
* Delete trust lines to AMM
* Disallow `CheckCreate` to AMM accounts
* AMM cannot cash a check
* Constrain entries in AuthAccounts array to be accounts
* AuthAccounts is an array of objects for the AMMBid transaction
* SetTrust (TrustSet): Allow on AMM only for LP tokens
* If the destination is an AMM account and the trust line doesn't
exist, then:
* If the asset is not the AMM LP token, then fail the tx with
`tecNO_PERMISSION`
* If the AMM is in empty state, then fail the tx with `tecAMM_EMPTY`
* This disallows trustlines to AMM in empty state
* Add AMMID to AMM root account
* Remove lsfAMM flag and use sfAMMID instead
* Remove owner dir entry for ltAMM
* Add `AMMDelete` transaction type to handle amortized deletion
* Limit number of trust lines to delete on final withdraw + AMMDelete
* Put AMM in empty state when LPTokens is 0 upon final withdraw
* Add `tfTwoAssetIfEmpty` deposit option in AMM empty state
* Fail all AMM transactions in AMM empty state except special deposit
* Add `tecINCOMPLETE` to indicate that not all AMM trust lines are
deleted (i.e. partial deletion)
* This is handled in Transactor similar to deleted offers
* Fail AMMDelete with `tecINTERNAL` if AMM root account is nullptr
* Don't validate for invalid asset pair in AMMDelete
* AMMWithdraw deletes AMM trust lines and AMM account/object only if the
number of trust lines is less than max
* Current `maxDeletableAMMTrustLines` = 512
* Check no directory left after AMM trust lines are deleted
* Enable partial trustline deletion in AMMWithdraw
* Add `tecAMM_NOT_EMPTY` to fail any transaction that expects an AMM in
empty state
* Clawback considerations
* Disallow clawback out of AMM account
* Disallow AMM create if issuer can claw back
This patch applies to the AMM implementation in #4294.
Acknowledgements:
Richard Holland and Nik Bougalis for responsibly disclosing this issue.
Bug Bounties and Responsible Disclosures:
We welcome reviews of the project code and urge researchers to
responsibly disclose any issues they may find.
To report a bug, please send a detailed report to:
bugs@xrpl.org
Signed-off-by: Manoj Doshi <mdoshi@ripple.com>
76 lines
2.5 KiB
C++
76 lines
2.5 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2019 Ripple Labs Inc.
|
|
|
|
Permission to use, copy, modify, and/or 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 <ripple/protocol/TxFlags.h>
|
|
#include <ripple/protocol/jss.h>
|
|
#include <test/jtx/check.h>
|
|
|
|
namespace ripple {
|
|
namespace test {
|
|
namespace jtx {
|
|
|
|
namespace check {
|
|
|
|
// Cash a check requiring that a specific amount be delivered.
|
|
Json::Value
|
|
cash(jtx::Account const& dest, uint256 const& checkId, STAmount const& amount)
|
|
{
|
|
Json::Value jv;
|
|
jv[sfAccount.jsonName] = dest.human();
|
|
jv[sfAmount.jsonName] = amount.getJson(JsonOptions::none);
|
|
jv[sfCheckID.jsonName] = to_string(checkId);
|
|
jv[sfTransactionType.jsonName] = jss::CheckCash;
|
|
jv[sfFlags.jsonName] = tfUniversal;
|
|
return jv;
|
|
}
|
|
|
|
// Cash a check requiring that at least a minimum amount be delivered.
|
|
Json::Value
|
|
cash(
|
|
jtx::Account const& dest,
|
|
uint256 const& checkId,
|
|
DeliverMin const& atLeast)
|
|
{
|
|
Json::Value jv;
|
|
jv[sfAccount.jsonName] = dest.human();
|
|
jv[sfDeliverMin.jsonName] = atLeast.value.getJson(JsonOptions::none);
|
|
jv[sfCheckID.jsonName] = to_string(checkId);
|
|
jv[sfTransactionType.jsonName] = jss::CheckCash;
|
|
jv[sfFlags.jsonName] = tfUniversal;
|
|
return jv;
|
|
}
|
|
|
|
// Cancel a check.
|
|
Json::Value
|
|
cancel(jtx::Account const& dest, uint256 const& checkId)
|
|
{
|
|
Json::Value jv;
|
|
jv[sfAccount.jsonName] = dest.human();
|
|
jv[sfCheckID.jsonName] = to_string(checkId);
|
|
jv[sfTransactionType.jsonName] = jss::CheckCancel;
|
|
jv[sfFlags.jsonName] = tfUniversal;
|
|
return jv;
|
|
}
|
|
|
|
} // namespace check
|
|
|
|
} // namespace jtx
|
|
} // namespace test
|
|
} // namespace ripple
|