arrow-left Course Hub
Lesson 0: Exchanging tokens on the DEX with pathfinding and autobridging
Estimated reading time:

15 minutes

Difficulty:

Beginner

Key takeaway:

  • Pathfinding assists in finding the best route for token transfers.
  • Paths in the XRP Ledger facilitate token movement between senders and receivers.
  • Auto-bridging uses intermediary tokens to connect marketplaces and order books.
Lesson 0

Exchanging tokens on the DEX with pathfinding and autobridging

Optimizing asset trading on the blockchain

What is Pathfinding?

Pathfinding is the process of finding an efficient route for trading between two tokens on the XRPL DEX. Often, there are hidden deals that are better than direct ones. For example, if you want to trade USD for EUR, you may find a better deal by trading USD for XRP, followed by XRP for EUR. Checking all the possible trade paths from one token to another takes a long time, but the XRPL can check quite a few to help find a great exchange rate.

This three-way trade is the simplest example of how pathfinding can help you use different paths to get a better rate for a single exchange. Imagine a person’s account has offers to accept USD in exchange for their XRP and also offers to accept EUR for their XRP. They are also willing to do both those trades at a better rate than everyone else, just trying to trade their EUR for USD. Pathfinding is how the algorithm on the XRPL identifies this account as a possible path and the best option to execute the trade. Pathfinding can even include 5 intermediary steps in a potential trade. This expands the number of potential paths for any given trade, which helps traders on the XRPL DEX get the best possible exchange rates.

Let’s imagine a newly issued token on the XRPL. If you want to trade with it, you can imagine the number of paths for any given trade is much fewer. Your odds of getting a good deal wouldn’t be as high, right? In comes “Auto-bridging” to save the day!

Auto-bridging is one of the main uses for XRP

On the XRPL, as long as there’s an offer from XRP to a token, it can be “automatically bridged” to any other offers which are exchanging with XRP. This is similar to how people who speak two languages, including English, can use it to communicate with each other as a “bridge language.”

Let’s look at a metaphor. Imagine two markets which are next door to each other, like in the illustration below.


The market on the left has vendors who trade wheat for XRP. The market on the right has vendors who trade apples for XRP. It’s a ‘free market’ where every vendor sells their apples and their wheat for whatever price in XRP they want. If we zoom out a bit, we can imagine one marketplace instead of two where traders can exchange wheat directly for apples, using XRP as a bridge currency. Auto-bridging does just this. When there’s no direct trading pair to get the tokens you want, auto-bridging creates a synthetic order book to get you the best price across all marketplaces. In the diagram below, you can see how two XRP-based order books add liquidity to the EUR/USD order book by using auto-bridging.

END OF LESSON

Okay, time to test your knowledge! See if you can answer these questions about pathfinding and autobridging:

What is the primary purpose of pathfinding on the XRP Ledger DEX?
What is the main benefit of pathfinding on the XRPL DEX?
What is auto-bridging used for on the XRP Ledger?
How does auto-bridging enhance liquidity on the XRP Ledger DEX?