You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AMM style DEXes are well known to provide an on-chain price oracle between the assets that trade in them. This price oracle acts as a positive externality for the entire ecosystem.
AMMs are not that well suited for UTXO chains and Order Books are naturally better. This concept is explored further in our order book dex tutorial.
So then the natural question is whether an order book dex can provide a price oracle as well. My intuition is that it can. Consider a centralized exchange. By looking at its spread and perhaps other order data, you get a good sense of what the market price is. The trick is that in the UTXO world it is only easy to "look" at all that data from off-chain.
Here I sketch out a simple on-chain price oracle built on top of the dex. It has some problems including incentivizing people to update it, but I think it may be the basis of something workable.
You build the order book in the usual way.
Then you also have a piece of state in a single utxo that is the "current oracle price".
Any transaction can peek at this "current oracle price" utxo when interacting with some defi thing that needs the price.
The price is updated by a transaction that peeks at some currently open offer and mutates the price accordingly. For example if the current oracle price is 1012 X/Y, but I see an open offer for 1015 X/Y then I can peek at that offer, consume to old oracle, and produce a new oracle with the same price.
It might be nice to have some way to indicate how wide the spread is too, but I'm not sure how to do that yet. My description above just guarantees that the price in somewhere in the spread assuming there is someone willing to diligently watch the book and update the spread.
The text was updated successfully, but these errors were encountered:
AMM style DEXes are well known to provide an on-chain price oracle between the assets that trade in them. This price oracle acts as a positive externality for the entire ecosystem.
AMMs are not that well suited for UTXO chains and Order Books are naturally better. This concept is explored further in our order book dex tutorial.
So then the natural question is whether an order book dex can provide a price oracle as well. My intuition is that it can. Consider a centralized exchange. By looking at its spread and perhaps other order data, you get a good sense of what the market price is. The trick is that in the UTXO world it is only easy to "look" at all that data from off-chain.
Here I sketch out a simple on-chain price oracle built on top of the dex. It has some problems including incentivizing people to update it, but I think it may be the basis of something workable.
You build the order book in the usual way.
Then you also have a piece of state in a single utxo that is the "current oracle price".
Any transaction can peek at this "current oracle price" utxo when interacting with some defi thing that needs the price.
The price is updated by a transaction that peeks at some currently open offer and mutates the price accordingly. For example if the current oracle price is 1012 X/Y, but I see an open offer for 1015 X/Y then I can peek at that offer, consume to old oracle, and produce a new oracle with the same price.
It might be nice to have some way to indicate how wide the spread is too, but I'm not sure how to do that yet. My description above just guarantees that the price in somewhere in the spread assuming there is someone willing to diligently watch the book and update the spread.
The text was updated successfully, but these errors were encountered: