Order-book & Decentralized Exchange

Does anyone know whether an order-book in a decentralized exchange could be implemented in Algorand infrastructure?

I think you may be able to build this up using the indexer. Take a look at this simplified DEX example: Example Digital Exchange Smart Contract Application | Algorand Developer Portal

Thanks a lot, JasonW.

One more question: how to increase the limit of 16 Open Orders?
In your example I read:

When the user opens the order, a call is made to the stateful smart contract to open the order. The stateful smart contract stores the order number in the user’s local storage. This limits the number of open orders to 16. This could have been extended by using a different order number generator, but for simplicity and readability this limitation is used.

What could be a “different order number generator” ?

So in that example I used a delegated signature instead of an escrow. If i would have used an escrow I could have opted the escrow into the stateful contract and stored the order number there. That would mean for every open order I would have an escrow which is opted into the stateful contract with the order number in its state. Then use the indexer the same way. The only issue is the contract has to hold the funds instead of staying in the account of the order opener. So to get the tokens back on a close order would require an additional tx. You also have a tx for every escrow to opt it into the stateful contract. I hope that makes sense.

Thanks again, JasonW.
So, with more transactions it seems possible.

Last question : in your solution the matching between a buyer and a seller is manually done by one of these twos; it’s not automatically done by an algorithm, such as in a centralized order-book. Am I right?

correct but it would take much to make that happen too. Currently that would be a layer2 app.

This is correct, the clients perform the matching to choose which orders to execute against, since there is no decentralized order book.

Also by the way we are actively working on building out an Algorand decentralized exchange that uses limit orders and order books on the blockchain. Feel free to ask questions about it at our Telegram channel: Telegram: Contact @algodex