Commit Graph

83 Commits

Author SHA1 Message Date
Peter Chen
d5fde211a3 APIv2(gateway_balances, channel_authorize): update errors (#4618)
gateway_balances
* When `account` does not exist in the ledger, return `actNotFound`
  * (Previously, a normal response was returned)
  * Fix #4290
* When required field(s) are missing, return `invalidParams`
  * (Previously, `invalidHotWallet` was incorrectly returned)
  * Fix #4548

channel_authorize
* When the specified `key_type` is invalid, return `badKeyType`
  * (Previously, `invalidParams` was returned)
  * Fix #4289

Since these are breaking changes, they apply only to API version 2.

Supersedes #4577
2026-02-20 06:48:47 +09:00
Gregory Tsipenyuk
200a635499 fix(AMM): prevent orphaned objects, inconsistent ledger state: (#4626)
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>
2026-02-20 06:40:58 +09:00
Gregory Tsipenyuk
233f060b0b 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>
2026-02-20 06:38:25 +09:00
Denis Angell
9abea13649 Feature Clawback (#534) 2025-07-09 12:48:46 +10:00
Denis Angell
810e15319c Feature DeepFreeze (#536)
---------

Co-authored-by: tequ <git@tequ.dev>
2025-07-09 10:33:08 +10:00
Denis Angell
d2c45bf560 Refactor Testcases (#219)
* Refactor Testcases (#216)

* remove unused function

* add offer id tests

* add escrow id tests

* clang-format

* fix offer

* fix escrow

* fix offer test
2023-11-24 11:41:16 +01:00
Denis Angell
c36683a825 XRPLF review of XLS34 (#69)
* add amendment guard for sfTransferRate

* make `sfTransferRate` optional

* split tests into existing / xls34

* make variables `const`

* clang-format

* chage error code

* guard optional `sfTransferRate`

* rename tests

* Guard Optional sfTransferRate

* clang-format

* fixup tests
2023-07-17 12:12:36 +02:00
Denis Angell
056262d922 fix precision loss 2023-04-06 17:02:05 +00:00
Denis Angell
669a0bc040 Sync IOUEscrow (#51) 2023-04-06 17:01:28 +00:00
Richard Holland
584db523b4 merge fail 2023-02-06 10:50:43 +00:00
Richard Holland
14dee2d976 Merge branch 'icv2-super' into dev 2023-02-06 10:35:57 +00:00
Denis Angell
163c2b4631 clang-format 2023-02-06 09:03:11 +00:00
Denis Angell
be7ca74e46 finish tests 2023-02-06 09:01:39 +00:00
Denis Angell
4e6e81f5de clang-format 2023-02-06 08:59:33 +00:00
Denis Angell
b5e9325bd9 clang-format 2023-02-06 08:59:21 +00:00
Denis Angell
c7aec60cec precision paychan test 2023-02-06 08:59:08 +00:00
Denis Angell
5d6726ce07 update insuficient funds error 2023-02-06 08:58:35 +00:00
Denis Angell
c681de1d39 nit 2023-02-06 08:58:04 +00:00
Denis Angell
b3168c7ea5 nit 2023-02-06 08:56:35 +00:00
Denis Angell
272a6c0999 todo: fix this failing test 2023-02-06 08:56:18 +00:00
Denis Angell
0133a4136e add transfer rate 2023-02-06 08:55:46 +00:00
Denis Angell
676480cc44 clang-format 2023-01-30 00:00:11 -05:00
Denis Angell
8ca7a2e2b3 finish tests 2023-01-29 23:52:47 -05:00
Denis Angell
8eb4589e09 clang-format 2023-01-24 17:36:15 -05:00
Denis Angell
8b6efee476 clang-format 2023-01-24 17:33:05 -05:00
Denis Angell
a0ce24d4e3 precision paychan test 2023-01-24 17:13:10 -05:00
Denis Angell
10c94831e9 update insuficient funds error 2023-01-24 17:12:45 -05:00
Denis Angell
8a8c980be7 nit 2023-01-24 16:29:55 -05:00
Denis Angell
139d57921a nit 2023-01-24 05:50:17 -05:00
Denis Angell
a145dd7379 todo: fix this failing test 2023-01-24 05:44:51 -05:00
Denis Angell
3b5e4b7e33 add transfer rate 2023-01-24 05:43:35 -05:00
Denis Angell
776d1fb797 Merge branch 'develop-nonconan' into icv2-super 2023-01-23 22:10:45 -05:00
RichardAH
5f12c22fbe featureDisallowIncoming: Opt-out of incoming Checks, PayChans, NFTokenOffers and Trustlines (#4336)
featureDisallowIncoming is a new amendment that would allow users to opt-out of incoming Checks, Payment Channels, NFTokenOffers, and trust lines. This commit includes tests.

Adds four new AccountSet Flags:
1. asfDisallowIncomingNFTOffer
2. asfDisallowIncomingCheck
3. asfDisallowIncomingPayChan
4. asfDisallowIncomingTrustline
2023-01-23 22:03:58 -05:00
dangell7
8a344a39e1 clang-format 2023-01-23 12:21:20 +00:00
dangell7
6569421524 add gateway feature 2023-01-23 12:21:10 +00:00
dangell7
14c68f88ea clang-format 2023-01-23 02:43:52 -05:00
dangell7
8740108f99 add gateway feature 2023-01-23 02:27:17 -05:00
dangell7
ccb3f36245 update rpc call value/currency/issuer 2023-01-22 17:31:05 +00:00
dangell7
f8342a7069 fix disallow XRP tests 2023-01-22 17:30:35 +00:00
dangell7
fb58424598 paychan tests tests; rpc, disallow & abusetl 2023-01-22 17:21:35 +00:00
dangell7
0c43377d6f cont. paychan tests 2023-01-22 17:20:33 +00:00
Richard Holland
a9c15ddbfc - 2023-01-22 17:20:21 +00:00
dangell7
312c10e053 enable test w/ features 2023-01-22 15:25:53 +00:00
dangell7
fc55a7cd04 update rpc call value/currency/issuer 2023-01-19 23:40:17 -05:00
dangell7
c7dfc60571 fix disallow XRP tests 2023-01-19 12:57:17 -05:00
dangell7
4e9d1fd575 paychan tests tests; rpc, disallow & abusetl 2023-01-19 09:40:32 -05:00
dangell7
dafba0fb10 cont. paychan tests 2023-01-17 18:17:36 -05:00
dangell7
989d386912 add paychan tests 2023-01-16 11:44:16 +00:00
dangell7
3f922eb8c5 enable test w/ features 2023-01-16 06:26:08 -05:00
dangell7
b3559f1f88 add paychan tests 2023-01-14 23:13:35 -05:00