Jump to content

Pathfinding is an AMM? ...but more powerful


Recommended Posts

This seems to be becoming more evident to me.

Even more than an AMM's single path/pair, Pathfinding can do up to 7 hops in a single ledger close making it a multi hop Atomic transaction.

Meanwhile, to do multi hops across multi AMMs, you can't even have an end to end Atomic TX chain. It's like Correspondent Banking, just send the money and see what pops out at the other end.

Honest question, How is Pathfinding not considered an AMM?

Edited by KarmaCoverage
Link to comment
Share on other sites

Man, I don't know what anyone's calling anything, anymore.  I still visualize these as like "probability paths" that are only "real" (in the "actuality is annihilated possibility" sense) when they are actually used (the uncertainty=0 / wave collapse).

(I have no idea where these names originate;  I suspect from marketing departments - or from people who don't "get it.")

Link to comment
Share on other sites

imo that's not entirely correct.

With an AMM the market making part is automated, i.e. no orders have to be (re)placed. This is not the case with order book based exchanges like XRPL's DEX, on those type of exchanges somebody needs to place orders to make the market.

Also, on the Ethereum chain AMM's can be placed in a row. For this part you do need a pathfinding algorithm, which Uniswap has built in. In practice this boils down to a chain like Asset A -> USDC -> ETH -> Asset B with some variants in the USDC and with or without ETH. It's not as sophisticated as XRPL pathfinding, but it is possible. If you want to manually define a custom path, that is also possible, it can be as long as you want.

All in all, Pathfinding is not AMM :)

Link to comment
Share on other sites

6 minutes ago, NightJanitor said:

Man, I don't know what anyone's calling anything, anymore.  I still visualize these as like "probability paths" that are only "real" (in the "actuality is annihilated possibility" sense) when they are actually used (the uncertainty=0 / wave collapse).

(I have no idea where these names originate;  I suspect from marketing departments - or from people who don't "get it.")

A few days ago I made a yet to be published video for another thread where I used the "quantum liquidity" analogy. I think it fits and you're sniffing the right conceptual trail.

Link to comment
Share on other sites

Posted (edited)
28 minutes ago, jn_r said:

imo that's not entirely correct.

With an AMM the market making part is automated, i.e. no orders have to be (re)placed. This is not the case with order book based exchanges like XRPL's DEX, on those type of exchanges somebody needs to place orders to make the market.

Also, on the Ethereum chain AMM's can be placed in a row. For this part you do need a pathfinding algorithm, which Uniswap has built in. In practice this boils down to a chain like Asset A -> USDC -> ETH -> Asset B with some variants in the USDC and with or without ETH. It's not as sophisticated as XRPL pathfinding, but it is possible. If you want to manually define a custom path, that is also possible, it can be as long as you want.

All in all, Pathfinding is not AMM :)

Interesting, I didn't know Uniswap had some Pathfinding functionality.

Guess I'd argue that Pathfinding can source liquidity (the purpose of an AMM) from more orderbooks + Trustlines and thus the sourcing of Liquidity does the AMM'S intended functionality. 

It's all about Sourcing & Routing liquidity. 

Edited by KarmaCoverage
Link to comment
Share on other sites

29 minutes ago, KarmaCoverage said:

Interesting, I didn't know Uniswap had some Pathfinding functionality.

Guess I'd argue that Pathfinding can source liquidity (the purpose of an AMM) from more orderbooks + Trustlines and thus the sourcing of Liquidity does the AMM'S intended functionality. 

It's all about Routing liquidity. 

I'm trying to find some simple documentation that shows how the routing basically works, but that's not easy without ending up in the code.. I found this page however where they explain some of the new routing that they offer. The pathfinding search engine is off-chain, but the execution is atomic on-chain. If the execution results in a lower than expected offer, then the transactions fails and is not executed.

https://uniswap.org/blog/auto-router/

I think you could argue that pathfinding helps you find the best sources of liquidity, but in essence by executing an order you are per definition not making market, but taking market. Which - if no new market is created - results in an hollowing out of the order books, which then leads to a market with bad large spread between buy and sell.

And that is one of the advantages of AMM, there is always an accurate market, it does not depend on others filling the order books with new offers, there is not a spread between buy and sell. Which makes it a good fit for ledgers that cannot handle many txps.

In the end I do think that order book based is better than AMM (if the ledger can handle many txps - so accurate offers can be made and changed). But combining AMM with Order book based (and use path-finding over that) will give us best of both worlds and possibly even more.

Edited by jn_r
Link to comment
Share on other sites

Posted (edited)
27 minutes ago, jn_r said:

I think you could argue that pathfinding helps you find the best sources of liquidity, but in essence by executing an order you are per definition not making market, but taking market. Which - if no new market is created - results in an hollowing out of the order books, which then leads to a market with bad large spread between buy and sell.

Good Point, I hadent thought of it from the Liquidity Taker angle. I guess on the AMMs users are required to post collateral on both sides of the orderbook/pair thus everyone is acting more like a Specialist or what he calls a Dealer than a regular market Trader.

Listen to the Inside vs Outside spread part. An AMM is the Inside spread. 

27 minutes ago, jn_r said:

And that is one of the advantages of AMM, there is always an accurate market, it does not depend on others filling the order books with new offers, there is not a spread between buy and sell

he bold part cant be right, risk almost never disappears, it only changes form.

The "spread" = impermanent loss risk exposure. No such risk if you are only Trading one side of an Orderbook, you have to be on both sides like a Specialist.

Like XRP is not a "counterparty free" asset, XRPL is the counterparty and XRPL is a distributed form of a Clearinghouse, which in Trad Finance is the counterparty. Risk just changed form, from a centralized Clearinghouse counterparty, to a decentralized XRPL Clearinghouse counterparty.

Edited by KarmaCoverage
Link to comment
Share on other sites

5 minutes ago, KarmaCoverage said:

he bold part cant be right, risk almost never disappears, it only changes form.

Yet it is. Not saying you are getting the best price. Let's say that with an AMM someone swaps a lot of asset A for asset B. As a result the price in the AMM shifts - B gets more expensive, or A gets cheaper. That new price is good if you want to buy back the asset A. But that same price is bad if you want to sell more from asset A. Yet both prices are the same, there is not spread ...

10 minutes ago, KarmaCoverage said:

The "spread" = impermanent loss risk exposure.

Then there is the impermanent loss thing. I would argue that it is misunderstood by about 95% of all people who claim to understand it. Just imagine that like in the example above we have an AMM pool with 2 assets A and B.

And you provide liquidity by adding an amount of A and and equal value amount of B. 

Now, In the case that someone else buys asset B for asset A, that will make the price change. Some would argue that that change leads to impermanent loss.

But now, yet again someone else does exactly the opposite, he buys the same amount asset A for asset B. Some would argue that that would also lead to impermanent loss.

But how can that be? Because the end result is now the same as the begin result. There is no profit and there is no loss, so either in the first case you would have had a loss and in the second case you would have a win, or vice versa. But not in both cases an impermanent loss.

The explanation for this phenomenon is psychological, the assets should be viewed in a relativity to each other (yeah, like Einstein ;-)). Somehow people always see the lost opportunity. But in fact, Impermanent Profit occurs just as much as Impermanent Loss.

 

Link to comment
Share on other sites

Posted (edited)

@jn_r I'm thinking the impermanent risk = the inside Dealer/Specialist spread.

Yes it does go in both directions on the two assets. Consider the "price chart" in the video to be USD:Asset on the two sides of the AMM/Dealer's orderbook, with the chart being denominated in USD.

The AMM is playing price Pong between the dotted lines.

Screenshot_20211007-173543_YouTube.thumb.jpg.df3627dcbaab8b72d10c567908a8220c.jpg

Pathfinding is minimizing the Quality of the path, basically minimizing the liquidity cost of the TX.

I'm thinking out loud, bouncing this perspective off folks. The comparison has been rattling around my head for a bit.

Edited by KarmaCoverage
Link to comment
Share on other sites

28 minutes ago, KarmaCoverage said:

@jn_r I'm thinking the impermanent risk = the inside Dealer/Specialist spread.

Yes it does go in both directions on the two assets. Consider the "price chart" in the video to be USD:Asset on the two sides of the Dealer's orddrbook, with the chart being denominated in USD.

The AMM is playing price Pong between the dotted lines.

Screenshot_20211007-173543_YouTube.thumb.jpg.df3627dcbaab8b72d10c567908a8220c.jpg

 

I would say the AMM has only 1 dotted line, where it moves to the left or to the right depending if someone bought or sold. The buy and sell price are the same. Or at least they start from the same position. Due to the curve where an AMM price moves on, the price becomes worse as you trade a larger amount. The risk is in that case more with the buyer/seller than with the liquidity provider.

And as said, when the price is back to its original position (arbitrageurs will make sure it will get back to market position - that is how you can make arbitrage money with an AMM), you - as liquidity provider - get the same amounts back as what you put in (plus the 0.025% per trade extra)

-

I think if you combine orderbook based with AMM, then you might see AMM pricing indeed happening between the 2 dotted lines .. if it gets outside the lines, then there is a new type of arbitrage opportunity (buy from order book, sell on AMM)

Edited by jn_r
Link to comment
Share on other sites

1 hour ago, jn_r said:

I would say the AMM has only 1 dotted line

The varence and liveliness of the market, aka "arbitrage opportunity" lives between the two dotted lines. 

A single dotted line would be a perfectly efficient market at every given time. My gut says that can't exist. There has to be movement & spreads & risk.

Link to comment
Share on other sites

52 minutes ago, KarmaCoverage said:

The varence and liveliness of the market, aka "arbitrage opportunity" lives between the two dotted lines. 

A single dotted line would be a perfectly efficient market at every given time. My gut says that can't exist. There has to be movement & spreads & risk.

Why should there be?

The only thing that needs to be true at all times is the formula 

x*y = k (where k = constant and x and y are the total liquidity amount of the 2 assets)

if someone makes a trade (he adds an amount 'a' to x) then the following must hold true:

(x+a)*(y-b) = k

where b = the amount the trader receives back. If you know x,y and k you can calculate b.

It is this basic principle how AMM's work. As you can notice it is logical that if 'a' is a small + or a small - amount, that it will lead to about the same amount of b you receive back or have to pay ... Hence that is the about the same price - no spread. The buy/sell will shift from each other as the amount of 'a' becomes bigger.

In practice however there is a difference. For every trade an amount of 0.030% is held back from the amount 'a': This is profit for the liquidity providers - it is simply added to the amount of x. And this does lead to a difference in price if you do a buy or a sell, namely a price difference in total of 0.06%. To be completely precise 0.005% is held back for Uniswap itself, so only 0.025% per trade is added to the pool.

For another explanation, see e.g. https://docs.uniswap.org/protocol/V2/concepts/protocol-overview/how-uniswap-works

 

Link to comment
Share on other sites

2 hours ago, KarmaCoverage said:

The varence and liveliness of the market, aka "arbitrage opportunity" lives between the two dotted lines. 

A single dotted line would be a perfectly efficient market at every given time. My gut says that can't exist. There has to be movement & spreads & risk.

I think you and Benoit Mandelbrot would get along swimmingly. :)

Link to comment
Share on other sites

5 hours ago, jn_r said:

I'm trying to find some simple documentation that shows how the routing basically works, but that's not easy without ending up in the code.. I found this page however where they explain some of the new routing that they offer. The pathfinding search engine is off-chain, but the execution is atomic on-chain. If the execution results in a lower than expected offer, then the transactions fails and is not executed.

https://uniswap.org/blog/auto-router/

I think you could argue that pathfinding helps you find the best sources of liquidity, but in essence by executing an order you are per definition not making market, but taking market. Which - if no new market is created - results in an hollowing out of the order books, which then leads to a market with bad large spread between buy and sell.

And that is one of the advantages of AMM, there is always an accurate market, it does not depend on others filling the order books with new offers, there is not a spread between buy and sell. Which makes it a good fit for ledgers that cannot handle many txps.

In the end I do think that order book based is better than AMM (if the ledger can handle many txps - so accurate offers can be made and changed). But combining AMM with Order book based (and use path-finding over that) will give us best of both worlds and possibly even more.

I think this is the correct answer.  And rippled developers are combining AMM with XRPL DEX Order books.

https://github.com/gregtatcam/rippled/commits/AMM

currently only support to add AMM LP between XRP and IOU.

https://github.com/gregtatcam/rippled/blob/AMM/src/ripple/protocol/impl/TxFormats.cpp#L82

add(jss::AMMCreate,
        ttAMM_CREATE,
        {
            {sfAMMXRPAmount, soeREQUIRED},
            {sfAMMIOUAmount, soeREQUIRED},
        },
        commonFields);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.