Skip to content
Alpha

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.

Use-cases

  1. Trading and market making - Providing liquidity into AMMs makes it easy to generate revenue on-chain.
  2. Asset Tokenization - XRP’s AMMs make it easy to provide liquidity on-chain, enabling token issuers to facilitate trades using the built-in DEX.

Security considerations

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:

  1. RLUSD.
  2. USD.

Note that issuer must be defined in the policy for issued assets such as above.

Limitations

AMM APIs are available on XRP Ledger only.

AMM Deposit

Summary

AMM Deposit is only supported in two-asset mode. Depositing using a single asset into a two-asset pool is currently unsupported.

Unsupported modes

The request parameter lpTokenOut is not yet supported.

Flag DEPOSIT_SINGLE_ASSET is not supported.

The request parameter amount2 must be specified.

AMM Withdraw

Summary

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:

flagsAmount fieldsBehavior
WITHDRAW_LP_TOKENlpTokenIn only. Omit amount.Redeems LP tokens for both pool assets.
WITHDRAW_ONE_ASSET_LP_TOKENlpTokenIn 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"
}

Unsupported modes

Wallet-as-a-Service rejects an AMM Withdraw request that:

  • Omits lpTokenIn or flags
  • Sets any flag other than WITHDRAW_LP_TOKEN or WITHDRAW_ONE_ASSET_LP_TOKEN
  • Sets amount2 or ePrice
  • Sets amount with WITHDRAW_LP_TOKEN, or omits it with WITHDRAW_ONE_ASSET_LP_TOKEN

References