4

I’m dying to use pathfinding for exchanging assets and it would greatly expand the way people trade over the network. Why isn’t it implemented by UI exchanges? Is it complicated to do? Is work from anchors required too?

Thanks

1

Based on the orderbooks for different asset pairs you could use some graph algorithm like Dijkstra for the best path.

Pathfinding is implemented in Horizon. You can find the code on github: https://github.com/stellar/go/tree/master/services/horizon/internal/simplepath

| improve this answer | |
1

You're confusing the different layers here.

Path finding is implemented, and has been, since day one. It is only used for (path) payments, however.

When you make a buy/sell order, it is applied to a specific order book, between two assets.

Path payments are done one layer up, bridging order books to find a path from asset A to asset B by chaining together multiple trades in one atomic operation.

| improve this answer | |
0

Pathfinding allows you to find payment paths using intermediate assets going from a source asset to a destination asset. This already exists in Horizon and is a process that happens "off-chain".

Path Payments allows you to make a payment using one asset to a receiver in a different asset without the risk of ever holding an intermediate asset and is a feature of stellar-core. This can be done using the Path Payments Operation and happens "on-chain".


Pathfinding by itself is a computationally expensive problem but is not complicated to implement. The implementation in Horizon is only a Proof-of-Concept since everyone's needs are different. As an example: not everyone would want the shortest path since that would take longer to compute as well. If you want to make use of path payments it would be best to have your own implementation of pathfinding that is robust.

My guess for why it's not implemented by UI exchanges is that it's not very useful for UI exchanges since path payments is more closely related to making payments as opposed to trading. However, it can be useful if you only want to consume offers from the orderbook by doing a path payment to yourself (atomic fill-or-kill offer across multiple orderbooks).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.