# Listing XRP as an Exchange This document describes the steps that an exchange needs to take to list XRP. For details about other aspects of `rippled` and the XRP Ledger, see the [Ripple Developer Center](https://ripple.com/build). ## Alpha Exchange For illustrative purposes, this document uses a fictitious business called _Alpha Exchange_ to explain the high-level steps required to list XRP. For the purposes of this document, Alpha Exchange: * Currently specializes in listing BTC/USD * Wants to add BTC/XRP and XRP/USD trading pairs * Maintains balances for all of its customers * Maintains balances for each of its supported currencies ### User Benefits Alpha Exchange wants to list BTC/XRP and XRP/USD trading pairs partially because listing these pairs benefits its users. Specifically, this support wants to enable its users to: * Deposit XRP _to_ Alpha Exchange _from_ the XRP Ledger * Withdraw XRP _from_ Alpha Exchange _to_ the XRP Ledger * Trade XRP with other currencies, such as BTC, USD, among others ## Prerequisites for Supporting XRP To support XRP, Alpha Exchange must: * Create and maintain new [accounts](#accounts) * Create and maintain [balance sheets](#balance-sheets) See also: * [Gateway Compliance](tutorial-gateway-guide.html#gateway-compliance) — Gateways and exchanges are different, but exchanges should also ensure that they are complying with local regulations and reporting to the appropriate agencies. * [Requirements for Sending to XRP Ledger](tutorial-gateway-guide.html#requirements-for-sending-to-xrp-ledger) * [Requirements for Receiving from XRP Ledger](tutorial-gateway-guide.html#requirements-for-receiving-from-xrp-ledger) * [Gateway Precautions](tutorial-gateway-guide.html#precautions) ### Partial Payments Before integrating, exchanges should be aware of the [partial payments](reference-transaction-format.html#partial-payments) feature. This feature allows XRP Ledger users to send successful payments that reduce the amount received instead of increasing the `SendMax`. This feature can be useful for [returning payments](tutorial-gateway-guide.html#bouncing-payments) without incurring additional cost as the sender. #### Partial Payments Warning When the [tfPartialPayment flag](reference-transaction-format.html#payment-flags) is enabled, the `Amount` field **_is not guaranteed to be the amount received_**. The `delivered_amount` field of a payment's metadata indicates the amount of currency actually received by the destination account. When receiving a payment, use `delivered_amount` instead of the Amount field to determine how much your account received instead. **Warning:** Be aware that malicious actors could exploit this. For more information, see [Partial Payments](partial-payments.html). ### Accounts XRP is held in _accounts_ (also referred to as _wallets_ or _addresses_ ) on the XRP Ledger. Accounts on the XRP Ledger are different than accounts on other blockchain ledgers, such as Bitcoin, where accounts incur little to no overhead. In the XRP Ledger, accounts can [never be deleted](accounts.html#permanence-of-accounts), and each account must hold a separate [reserve of XRP](reserves.html) that cannot be sent to others. For these reasons, Ripple recommends that institutions not create excessive or needless accounts. To follow Ripple's recommended best practices, Alpha Exchange should create at least two new accounts on the XRP Ledger. To minimize the risks associated with a compromised secret key, Ripple recommends creating [_cold_, _hot_, and _warm_ accounts](https://ripple.com/build/issuing-operational-addresses/) (these are sometimes referred to, respectively, as cold, hot, and warm wallets). The hot/warm/cold model is intended to balance security and convenience. Exchanges listing XRP should create the following accounts: * A [_cold wallet_](issuing-and-operational-addresses.html#issuing-address) to securely hold the majority of XRP and customers' funds. For exchanges, this is also the address to which its users send [deposits](#deposit-xrp-into-exchange). To provide optimal security, this account's secret key should be offline. If a malicious actor compromises an exchange's cold wallet, the possible consequences are: * The malicious actor gets full access to all XRP in the cold wallet. * If the master key is compromised, the malicious actor can irrevocably take control of the cold wallet forever (by disabling the master key and setting a new regular key or signer list). This would also give the malicious actor control over all future XRP received by the cold wallet. * If this happens, the exchange has to make a new cold wallet address and tell its customers the new address. * If the regular key or signer list are comromised, the exchange can regain control of the cold wallet. However, some of a malicious actor's actions cannot easily be undone: * The malicious actor could issue currency in the XRP Ledger by using the cold wallet, but that currency should not be valued by anyone (unless the exchange explicitly stated it was also a gateway). * If a malicious actor sets the asfRequireAuth flag for the account, that cannot be unset, although this only relates to issuing currency and should not affect an exchange that is not also a gateway. Any other settings a malicious actor sets or unsets with a master key can be reverted. * One or more [_hot wallets_](issuing-and-operational-addresses.html#operational-addresses) to conduct the day-to-day business of managing customers' XRP withdrawals and deposits. For example, with a hot wallet, exchanges can securely support these types of automated XRP transfers. Hot wallets need to be online to service instant withdrawal requests. For more information about the possible consequences of a compromised hot wallet, see [Operational Account Compromise](issuing-and-operational-addresses.html#operational-address-compromise). * Optionally, one or more warm wallets to provide an additional layer of security between the cold and hot wallets. Unlike a hot wallet, the secret key of a warm wallet does not need to be online. Additionally, you can distribute the secret keys for the warm wallet to several different people and implement [multisigning](tutorial-multisign.html) to increase security. For more information about the possible consequences of a compromised warm wallet, see [Standby Account Compromise](issuing-and-operational-addresses.html#standby-address-compromise). See also: * ["Suggested Business Practices" in the _Gateway Guide_](tutorial-gateway-guide.html#suggested-business-practices) * [Issuing and Operational Addresses](issuing-and-operational-addresses.html) * [Creating Accounts](reference-transaction-format.html#creating-accounts) * [Reserves](reserves.html) ### Balance Sheets To custody its ccustomers' XRP, Alpha Exchange must track each customer's XRP balance and its own holdings. To do this, Alpha Exchange must create and maintain an additional balance sheet or accounting system. The following table illustrates what this balance sheet might look like. The new XRP Ledger accounts (_Alpha Hot_, _Alpha Warm_, _Alpha Cold_) are in the *User* column of the *XRP Balances on XRP Ledger* table. The *Alpha Exchange XRP Balances* table represents new, additional balance sheet. Alpha Exchange’s software manages their users’ balances of XRP on this accounting system.
| XRP Balances on XRP Ledger | Alpha Exchange XRP Balances | ||||
| User | Balance | Acct # | User | Balance | |
| Dave | 25,000 | 123 | Alice | 0 | |
| Edward | 45,000 | 456 | Bob | 0 | |
| Charlie | 50,000 | 789 | Charlie | 0 | |
| Alpha Hot | 0 | ... | |||
| Alpha Warm | 0 | ||||
| Alpha Cold | 0 | ||||
| ... |
| XRP Balances on XRP Ledger | Alpha Exchange XRP Balances | ||||
| User | Balance | Acct # | User | Balance | |
| Dave | 25,000 | 123 | Alice | 0 | |
| Edward | 45,000 | 456 | Bob | 0 | |
| Charlie | 50,000 | 789 | Charlie | 0 | |
| Alpha Hot | 0 | ... | |||
| Alpha Warm | 0 | ||||
| Alpha Cold | 0 | ||||
| ... |
| XRP Balances on XRP Ledger | Alpha Exchange XRP Balances | ||||
| User | Balance | Acct # | User | Balance | |
| Dave | 25,000 | 123 | Alice | 0 | |
| Edward | 45,000 | 456 | Bob | 0 | |
| Charlie | 50,000 |
789 | Charlie | 50,000 |
|
| Alpha Hot | 0 | ... | |||
| Alpha Warm | 0 | ||||
| Alpha Cold | 50,000 |
||||
| ... |
| Alpha Exchange XRP Off-Ledger Balances | Alpha Exchange XRP On-Ledger Balances | ||||
| Acct # | User | Balance | XRP Ledger Account | Balance | |
| 123 | Alice | 80,000 | Hot | 80,000 |
|
| 456 | Bob | 50,000 | Warm | 0 | |
| …. | …. | ||||
| 789 | Charlie | 50,000 | Cold | 100,000 |
|
| ... | ... |
| XRP Ledger On-Ledger XRP Balances | Alpha Exchange XRP Off-Ledger Balances | Alpha Exchange XRP On-Ledger Balances | ||||||
| User | Balance | Acct # | User | Balance | XRP Ledger Account | Balance | ||
| Dave | 25,000 | 123 | Alice | 80,000 | Hot | 55,000 |
||
| Edward | 45,000 | 456 | Bob | 50,000 | Warm | 0 | ||
| …. | …. | …. | ||||||
| Charlie XRP Ledger | 75,000 |
789 | Charlie | 25,000 |
Cold | 100,000 | ||
| ... | ... | ... |