XRPL AMM API
The ledger’s own amm_info answers for one pool at a time. The xrpl.to API ranks every pool by fees, yield and liquidity, keeps their history, and works out an account’s positions, with no node of your own.
The endpoints
| GET /amm | Pools ranked by sort=fees, apy, liquidity, volume or created; filter with token or minLiquidity |
| GET /amm/info | One pool’s live state, by amm_account, or by asset and asset2 |
| GET /amm/liquidity-chart | A pool’s value over time: ammAccount (or token and token2) and period, 1d to all |
| GET /lp-positions/{account} | An account’s LP positions: pool share, value, fees earned and impermanent loss |
A pool list, live
curl "https://api.xrpl.to/v1/amm?sort=liquidity&limit=2"
{
"success": true,
"total": 31640,
"pools": [
{
"ammAccount": "rLjUKpwUVmz3vCTmFkXungxwzdoyrWRsFG",
"asset": {
"currency": "XRP",
"issuer": "XRPL"
},
"asset2": {
"currency": "43525950544F0000000000000000000000000000",
"issuer": "rRbiKwcueo6MchUpMFDce9XpDwHhRLPFo",
"md5": "8abb595944142e48da8f479ee1b3a8f0"
},
"tradingFee": 864,
"apy7d": {
"apy": 0.01111293215033454,
"fees": 11.5219021968,
"volume": 1333.5534949999999,
"liquidity": 5406178.064748
}
},
{
"ammAccount": "rhWTXC2m2gGGA9WozUaoMm6kLAVPb1tcS3",
"asset": {
"currency": "XRP",
"issuer": "XRPL"
},
"asset2": {
"currency": "524C555344000000000000000000000000000000",
"issuer": "rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De",
"md5": "0dd550278b74cb6690fdae351e8e0df3"
},
"tradingFee": 205,
"apy7d": {
"apy": 4.276407207944159,
"fees": 3024.1342128245,
"volume": 1475187.42089,
"liquidity": 3687370.976908
}
}
]
}Ranking pools by yield
const res = await fetch('https://api.xrpl.to/v1/amm?sort=apy&minLiquidity=10000&limit=10');
const { pools } = await res.json();
for (const p of pools) {
console.log(p.asset2.currency, p.apy7d.apy.toFixed(1) + '%', // asset is XRP for XRP pools
'fees 7d:', p.apy7d.fees, 'XRP');
}A tiny pool can show a huge APY from a few trades, so pass minLiquidity when ranking by yield. What every pool paid this week, with logos: AMM pool rankings.
Credit the data
Any app that shows xrpl.to data must show a visible, clickable “Data by xrpl.to” credit beside it (API terms). Related: how AMM pools work, DEX API.
Questions
- How do I get every AMM pool on the XRP Ledger?
- GET https://api.xrpl.to/v1/amm pages through all of them (31,640 today), up to 100 a page with offset; sort and filter as you need.
- How is a pool’s APY worked out?
- From the fees its trades paid over the last 7 days (or 24 hours), set against its liquidity and scaled to a year. It moves week to week with trading.
- Can I get my LP positions and their impermanent loss?
- Yes: GET /lp-positions/{account} returns each pool’s share, current value, fees earned and impermanent loss against simply holding.