API Categorization: Alpha (unstable API, expect changes).
Wallet-as-a-Service brings deeper integration into the XRP ledger through our latest AMM APIs. These APIs allow customers to programmatically interact with AMMs on the XRP Ledger.
- Trading and market making - Providing liquidity into AMMs makes it easy to generate revenue on-chain.
- Asset Tokenization - XRP’s AMMs make it easy to provide liquidity on-chain, enabling token issuers to facilitate trades using the built-in DEX.
Transactions initiated using AMM APIs are subject to the same policy engine rules. Since AMMCreate and AMMDeposit result in multiple assets being withdrawn from the wallet, the policy engine will expect policies to be defined for each affected asset.
For example, if an AMMDeposit transaction is depositing into a RLUSD/USD pool, the policy engine will require the policies to be defined for the following assets:
- RLUSD.
- USD.
Note that issuer must be defined in the policy for issued assets such as above.
AMM APIs are available on XRP Ledger only.
AMM Deposit is only supported in two-asset mode. Depositing using a single asset into a two-asset pool is currently unsupported.
The request parameter lpTokenOut is not yet supported.
Flag DEPOSIT_SINGLE_ASSET is not supported.
The request parameter amount2 must be specified.
AMM Withdraw supports two request shapes. Both require asset and asset2 to identify the pool, lpTokenIn for the number of LP tokens to redeem, and a flags value:
flags | Amount fields | Behavior |
|---|---|---|
WITHDRAW_LP_TOKEN | lpTokenIn only. Omit amount. | Redeems LP tokens for both pool assets. |
WITHDRAW_ONE_ASSET_LP_TOKEN | lpTokenIn and amount. | Redeems LP tokens for the first asset only. |
Example: Redeem LP tokens for both pool assets.
{
"asset": { "asset": "XRP" },
"asset2": { "asset": "USD", "issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq" },
"lpTokenIn": {
"asset": "03930D02208264E2E40EC1B0C09E4DB96EE197B1",
"issuer": "rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W",
"value": "100"
},
"flags": "WITHDRAW_LP_TOKEN"
}Wallet-as-a-Service rejects an AMM Withdraw request that:
- Omits
lpTokenInorflags - Sets any flag other than
WITHDRAW_LP_TOKENorWITHDRAW_ONE_ASSET_LP_TOKEN - Sets
amount2orePrice - Sets
amountwithWITHDRAW_LP_TOKEN, or omits it withWITHDRAW_ONE_ASSET_LP_TOKEN
- AMM Create
- XRP Ledger reference: https://xrpl.org/docs/references/protocol/transactions/types/ammcreate
- Wallet-as-a-Service API reference: Wallet-as-a-Service API
- AMM Deposit
- XRP Ledger reference: https://xrpl.org/docs/references/protocol/transactions/types/ammdeposit
- Wallet-as-a-Service API reference: Wallet-as-a-Service API
- AMM Withdraw
- XRP Ledger reference: https://xrpl.org/docs/references/protocol/transactions/types/ammwithdraw
- Wallet-as-a-Service API reference: Wallet-as-a-Service API