It looks like Stellar built-in exchange becomes more an more popular, anchors implement automated market-making strategies. But unlike other exchanges where orders are set and executed in order of arrival, trades on Stellar Network are processed in discrete time periods, every 4-5 seconds as new ledger is generated. The biggest question here is the transaction application order.
Let's look closer into the following case.
Our old friends, Bob and Alice, trade on the same exchange pair, say XLM-BTC.
- Alice submits an order to buy BTC at 0.001 XLM/BTC
- 2 seconds later Bob submits his own bid at 0.002 XLM/BTC
- Both transactions are included in the same ledger
And now a few questions.
- Which order will be executed in the first place? A bid with higher price or another one, which was submitted first? Who is lucky today, Bob or Alice?
- What if orders were submitted to the different nodes? Is there any priority or penalties in terms of tx application order for nodes with a low-latency network?
- Does the transaction fee amount correlate with the transactions application order? And if yes, can I specify non-default transaction fee (smaller or larger than default value)?