Automated Market Makers (2024)

(Requires the XLS-30 AMM amendment)

Automated Market Makers (AMMs) provide liquidity in the XRP Ledger's decentralized exchange. Each AMM holds a pool of two assets. You can swap between the two assets at an exchange rate set by a formula.

Automated Market Makers (1)

Those who deposit assets into an AMM are called liquidity providers. In return, liquidity providers receive LP tokens from the AMM.

Automated Market Makers (2)

LP tokens enable liquidity providers to:

  • Redeem their LP tokens for a share of the assets in the AMM pool, including fees collected.
  • Vote to change the AMM fee settings, each vote weighted by how many LP tokens the voter holds.
  • Bid some of their LP tokens to receive a temporary discount on the AMM trading fees.

How the AMM Works

An AMM holds two different assets: at most one of these can be XRP, and one or both of them can be tokens. For any given pair of assets, there can be up to one AMM in the ledger. Anyone can create the AMM for an asset pair if it doesn't exist, or deposit to an AMM if it already exists.

When you want to trade in the decentralized exchange, your Offers and Cross-Currency Payments can automatically use AMMs to complete the trade. A single transaction might execute by matching Offers, AMMs, or a mix of both, depending on what's cheaper.

Automated Market Makers (3)

Note

You can determine if a Payment or OfferCreate transaction interacted with an AMM by checking for a RippleState ledger entry in the transaction metadata. A Flags value of 16777216 indicates AMM liquidity was consumed.

An AMM sets its exchange rate based on the balance of assets in the pool. When you trade against an AMM, the exchange rate adjusts based on how much your trade shifts the balance of assets the AMM holds. As its supply of one asset goes down, the price of that asset goes up; as its supply of an asset goes up, the price of that asset goes down.

Automated Market Makers (4)

An AMM gives generally better exchange rates when it has larger overall amounts in its pool. This is because any given trade causes a smaller shift in the balance of the AMM's assets. The more a trade unbalances the AMM's supply of the two assets, the more extreme the exchange rate becomes.

The AMM also charges a percentage trading fee on top of the exchange rate.

The XRP Ledger implements a geometric mean AMM with a weight parameter of 0.5, so it functions like a constant product market maker. For a detailed explanation of the constant product AMM formula and the economics of AMMs in general, see Kris Machowski's Introduction to Automated Market Makers.

Token Issuers

Tokens with different issuers are considered different assets. This means that there can be an AMM for two tokens with the same currency code but different issuers. For example, FOO issued by WayGate is different than FOO issued by StableFoo. Similarly, the tokens can have the same issuer but different currency codes. The trade direction doesn't matter; the AMM for FOO.WayGate to XRP is the same as the AMM for XRP to FOO.WayGate.

Currency Risk

When the flow of funds between the two assets in a pool is relatively active and balanced, the fees provide a source of passive income for liquidity providers. However, when the relative price between the assets shifts, liquidity providers can take a loss on the currency risk.

Restrictions on Assets

To prevent misuse, some restrictions apply to the assets used in an AMM. If you try to create an AMM with an asset that does not meet these restrictions, the transaction fails. The rules are as follows:

  • The asset must not be an LP token from another AMM.
  • If the asset is a token whose issuer uses Authorized Trust Lines, the creator of the AMM must be authorized to hold those tokens. Only your authorized trust lines can deposit that token into the AMM or withdraw it; however, you can still deposit or withdraw the other asset.
  • If the Clawback amendment is enabled, the issuer of the token must not have enabled the ability to claw back their tokens.

LP Tokens

Whoever creates the AMM becomes the first liquidity provider, and receives LP tokens that represent 100% ownership of assets in the AMM's pool. They can redeem some or all of those LP tokens to withdraw assets from the AMM in proportion to the amounts currently there. (The proportions shift over time as people trade against the AMM.) The AMM does not charge a fee when withdrawing both assets.

For example, if you created an AMM with 5 ETH and 5 USD, and then someone exchanged 1.26 USD for 1 ETH, the pool now has 4 ETH and 6.26 USD in it. You can spend half your LP tokens to withdraw 2 ETH and 3.13 USD.

Automated Market Makers (5)

Anyone can deposit assets to an existing AMM. When they do, they receive new LP tokens based on how much they deposited. The amount that a liquidity provider can withdraw from an AMM is based on the proportion of the AMM's LP tokens they hold compared to the total number of LP tokens outstanding.

LP tokens are like other tokens in the XRP Ledger. You can use them in many types of payment, or trade them in the decentralized exchange. (To receive LP tokens as payment, you must set up a trust line with a non-zero limit with the AMM Account as the issuer.) However, you can only send LP tokens directly to the AMM (redeeming them) using the AMMWithdraw transaction type, not through other types of payments. Similarly, you can only send assets to the AMM's pool through the AMMDeposit transaction type.

The AMM is designed so that an AMM's asset pool is empty if and only if the AMM has no outstanding LP tokens. This situation can only occur as the result of an AMMWithdraw transaction; when it does, the AMM is automatically deleted.

LP Token Currency Codes

LP tokens use a special type of currency code in the 160-bit hexadecimal "non-standard" format. These codes have the first 8 bits 0x03. The remainder of the code is a SHA-512 hash, truncated to the first 152 bits, of the two assets' currency codes and their issuers. (The assets are placed in a "canonical order" with the numerically lower currency+issuer pair first.) As a result, the LP tokens for a given asset pair's AMM have a predictable, consistent currency code.

Trading Fees

Trading fees are a source of passive income for liquidity providers. They offset the currency risk of letting others trade against the pool's assets. Trading fees are paid to the AMM, not directly to liquidity providers. Liquidity providers benefit because they can redeem their LP tokens for a percentage of the AMM pool.

Liquidity providers can vote to set the fee from 0% to 1%, in increments of 0.001%. Liquidity providers have an incentive to set trading fees at an appropriate rate: if fees are too high, trades will use order books to get a better rate instead; if fees are too low, liquidity providers don't get any benefit for contributing to the pool.

Each AMM gives its liquidity providers the power to vote on its fees, in proportion to the number of LP tokens they hold. To vote, a liquidity provider sends an AMMVote transaction. Whenever anyone places a new vote, the AMM recalculates its fee to be an average of the latest votes, weighted by how many LP tokens those voters hold. Up to 8 liquidity providers' votes can be counted this way; if more liquidity providers try to vote, then only the top 8 votes (by most LP tokens held) are counted. Even though liquidity providers' share of LP tokens can shift rapidly for many reasons (such as trading those tokens using Offers), the trading fees are only recalculated whenever someone places a new vote (even if that vote is not one of the top 8).

Auction Slot

The XRP Ledger's AMM design includes an auction slot. A liquidity provider can bid LP Tokens to claim the auction slot to receive a discount on the trading fee for a 24-hour period. The LP tokens that were bid are returned to the AMM.

With any AMM, when the price of its assets shifts significantly in external markets, traders can use arbitrage to profit off the AMM. That can result in a loss for liquidity providers. The auction mechanism is intended to return more of that value to liquidity providers, and more quickly bring the AMM's prices back into balance with external markets.

No more than one account can hold the auction slot at a time, but as the successful bidder you can name up to 4 additional accounts to receive the discount. If the slot is currently occupied, you must outbid the current slot holder to displace them. If someone displaces you, you get a percentage of your bid back, based on how much time remains. As long as you hold an active auction slot, you pay a discounted trading fee equal to 1/10 (one tenth) of the normal trading fee when making trades against that AMM.

The minimum bid to win the auction slot, if it is empty or expired, is equal to the current total number of LP Tokens outstanding multiplied by the trading fee, divided by 25. (In pseudocode, MinBid = LPTokens * TradingFee / 25.) If the auction slot is occupied, you must bid at least the minimum plus up to 105% of what the current slot holder paid, discounted by how much time they have remaining.

Representation in the Ledger

In the ledger's state data, an AMM consists of multiple ledger entries:

  • An AMM entry describing the automated market maker itself.

  • A special AccountRoot entry that issues the AMM's LP tokens, and holds the AMM's XRP (if it has any).

    The address of this AccountRoot is chosen somewhat randomly when the AMM is created, and it is different if the AMM is deleted and re-created. This is to prevent people from funding the AMM account with excess XRP in advance.

  • Trust lines to the special AMM Account for the tokens in the AMM's pool.

These ledger entries are not owned by any account, so the reserve requirement does not apply to them. However, to prevent spam, the transaction to create an AMM has a special transaction cost that requires the sender to burn a larger than usual amount of XRP.

Deletion

An AMM is deleted when an AMMWithdraw transaction withdraws all assets from its pool. This only happens by redeeming all of the AMM's outstanding LP tokens. Deleting the AMM removes all the ledger entries associated with it, such as:

  • AMM
  • AccountRoot
  • Trust lines for the AMM's LP tokens. Those trust lines would have a balance of 0 but may have other details, such as the limit, set to a non-default value.
  • Trust lines for the tokens that were in the AMM pool.

If there are more than 512 trust lines attached to the AMM account when it would be deleted, the withdraw succeeds and deletes as many trust lines as it can, but leaves the AMM in the ledger with no assets in its pool.

While an AMM has no assets in its pool, anyone can delete it by sending an AMMDelete transaction; if the remaining number of trust lines is still greater than the limit, multiple AMMDelete transactions might be necessary to fully delete the AMM. Alternatively, anyone can perform a special deposit to fund the AMM as if it were new. No other operations are valid on an AMM with an empty asset pool.

There is no refund or incentive for deleting an empty AMM.

Automated Market Makers (2024)

FAQs

What is an example of an automated market maker? ›

The prices of assets on an AMM automatically change depending on the demand. For example, a liquidity pool could hold ten million dollars of ETH and ten million dollars of USDC. A trader could then swap 500k dollars worth of their own USDC for ETH, which would raise the price of ETH on the AMM.

What is auto market maker? ›

Automated Market Makers Explained

Automated market makers (AMMs) allow digital assets to be traded without permission and automatically by using liquidity pools instead of a traditional market of buyers and sellers. On a traditional exchange platform, buyers and sellers offer up different prices for an asset.

Who created the first automated market maker? ›

Automated market makers were first introduced by Vitalik Buterin in 2017 in his post about on-chain market makers. Various approaches to AMMs have been developed since then. What LP tokens are used for? LP tokens have various use cases in the DeFi ecosystem.

What is the difference between AMM and Dex? ›

Automated Market Makers (AMMs) are a type of decentralized exchange (DEX) that use algorithmic mechanisms to facilitate the trading of digital assets. Unlike traditional financial markets that rely on buyers and sellers, AMMs aim to maintain liquidity in the DeFi ecosystem through liquidity pools.

What is the best AMM crypto? ›

Top Automated Market Maker (AMM) Coins Today By Market Cap
#Name7D
1Uniswap ( UNI )0.00%
2Pendle ( PENDLE )+3.12%
3PancakeSwap ( CAKE )+2.35%
4Aerodrome Finance ( AERO )+23.93%
39 more rows

How to make money with automated market maker? ›

Every time other market participants trade against the bids and offers sent by the AMM on your behalf, you will receive a portion of the AMM payments generated by those trades. This payment derives from the Taker Fee paid by the trader and the spread you chose when you created the AMM Instruction.

Who is the top auto maker? ›

1 Automaker for Fourth Year. Toyota Motor Corp. sold more passenger vehicles than ever in 2023, cruising ahead of Volkswagen AG as the world's top carmaker for a fourth consecutive year.

Is it legal to be a market maker? ›

Market makers must operate under a given exchange's bylaws, which are approved by a country's securities regulator. In the United States, that regulator is the Securities and Exchange Commission (SEC).

What is the difference between an order book and an automated market maker? ›

Unlike traditional trading systems, AMMs do not rely on order books to match buyers and sellers. Instead, they use mathematical algorithms to determine the price of assets, allowing for continuous and automated trading. This model is particularly beneficial in markets where liquidity might otherwise be scarce.

What is the automated market maker protocol? ›

An automated market maker (AMM) is an autonomous protocol that decentralized crypto exchanges (DEXs) use to facilitate crypto trades on a blockchain.

What is the function of AMM? ›

AMMs are algorithmic protocols that remove intermediaries from the market-making process. DEXs use AMM algorithms to confirm crypto transfers between traders without using orderbooks or centralized market makers. Instead, AMM DEXs use smart contracts to verify P2P crypto transfers between traders.

What does DeFi mean? ›

Short for decentralized finance, DeFi is an umbrella term for peer-to-peer financial services on public blockchains, primarily Ethereum. DeFi (or “decentralized finance”) is an umbrella term for financial services on public blockchains, primarily Ethereum.

What is the downside of Dex? ›

Some of the potential drawbacks of using a crypto DEX are: Lack of liquidity: DEXs may have lower trading volumes and fewer market makers than centralized exchanges, which can result in wider spreads and higher slippage.

What are the three types of Dex? ›

There are three types of DEXs: order book DEXs, automated market makers (AMMs), and DEX aggregators. All of them allow users to trade tokens through their smart contracts but they're based on slightly different principles.

Is PancakeSwap an AMM? ›

PancakeSwap is an Automated Market Maker (AMM), and the Exchange is at the heart of PancakeSwap.

Who is an example of a market maker? ›

The simplest example of a market maker is a currency exchange counter at the airport: imagine you wanted to convert EUR 100 euros (EUR) into US dollars (US$) for a weekend trip to New York. The person behind the counter might offer you US$ 110 – this is a price quote.

What is an example of a market maker product? ›

For example, if a market maker quotes a bid price of ₹100 and an asking price of ₹100.10 for a stock, the bid-ask spread is ₹0.10. Market makers are obligated to continuously quote bid and ask prices, even during periods of market volatility or uncertainty.

What is an example of a market creator? ›

Typical examples are eBay and Etsy. Market creators make money by charging a fee for each transaction on their platform, or asking merchants to pay a fee to access the marketplace.

What is an example of automated trading? ›

For example: 'buy 100 Apple shares when its 50-day moving average goes above the 200-day average'. The automated trading strategy that's been set will constantly monitor financial market prices, and trades will automatically be executed if predetermined parameters are met.

Top Articles
10 Things You Need to Buy a House
Capital Budgeting Examples | Top 5 Capital Budgeting Technique Example
Frases para un bendecido domingo: llena tu día con palabras de gratitud y esperanza - Blogfrases
How To Fix Epson Printer Error Code 0x9e
Patreon, reimagined — a better future for creators and fans
Genesis Parsippany
Cooking Chutney | Ask Nigella.com
Tj Nails Victoria Tx
7543460065
Umn Biology
William Spencer Funeral Home Portland Indiana
C-Date im Test 2023 – Kosten, Erfahrungen & Funktionsweise
Keniakoop
Oc Craiglsit
10-Day Weather Forecast for Florence, AL - The Weather Channel | weather.com
Craigslist Panama City Fl
Average Salary in Philippines in 2024 - Timeular
Prestige Home Designs By American Furniture Galleries
Jellyfin Ps5
Where to Find Scavs in Customs in Escape from Tarkov
Skip The Games Fairbanks Alaska
Contracts for May 28, 2020
MyCase Pricing | Start Your 10-Day Free Trial Today
Nesb Routing Number
Obituaries Milwaukee Journal Sentinel
Myql Loan Login
Phantom Fireworks Of Delaware Watergap Photos
Geico Car Insurance Review 2024
Paradise Point Animal Hospital With Veterinarians On-The-Go
1964 Impala For Sale Craigslist
How Do Netspend Cards Work?
Fastpitch Softball Pitching Tips for Beginners Part 1 | STACK
Frommer's Belgium, Holland and Luxembourg (Frommer's Complete Guides) - PDF Free Download
Emily Katherine Correro
Shaman's Path Puzzle
ShadowCat - Forestry Mulching, Land Clearing, Bush Hog, Brush, Bobcat - farm & garden services - craigslist
Envy Nails Snoqualmie
Senior Houses For Sale Near Me
New York Rangers Hfboards
Publictributes
Torrid Rn Number Lookup
Pokemon Reborn Gyms
Differential Diagnosis
Hkx File Compatibility Check Skyrim/Sse
Thotsbook Com
Sapphire Pine Grove
Barber Gym Quantico Hours
Strange World Showtimes Near Century Federal Way
Mike De Beer Twitter
Latest Posts
Article information

Author: Arline Emard IV

Last Updated:

Views: 5657

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Arline Emard IV

Birthday: 1996-07-10

Address: 8912 Hintz Shore, West Louie, AZ 69363-0747

Phone: +13454700762376

Job: Administration Technician

Hobby: Paintball, Horseback riding, Cycling, Running, Macrame, Playing musical instruments, Soapmaking

Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.