I have a question about Stellar exchange matching engine.

Scenario: I want to trade AA coin for BB coin (2 Buy orders & 1 Sell order)

Buy Orders (Buy BB | Price 1 BB = 90 AA)

Order#1 Volume 10 AA --> 0.1111111 BB

Order#2 Volume 10 AA --> 0.1111111 BB

Sell Order (Sell BB | Price 1 BB = 90 AA)

Order#3 Volume 0.2222222 BB --> 19.999998 AA

Result After matching.

Order#1 (Matched) Remainder 0.0000010 AA (0.0000000 BB)

Order#2 (Not matched ) Volume 10 AA

Order#3 Remainder 0.1111111 BB

Why doesn't Stellar match the other order after matching the first one?


1 Answer 1


The behavior you encountered existed in protocol versions 1 and 2. Protocol version 10, the most recently released version, incorporates CAP-0003 and CAP-0004 which make changes to the functionality of the offer book. For example the situation you described in your question results in a crossed book, but CAP-0004 (https://github.com/stellar/stellar-protocol/pull/179) specifies that

The offer which initially had less total value is removed from the book regardless of whether it has been executed entirely, so it is guaranteed that the book never remains crossed.

As of protocol version 10, all three offers are executed entirely. Try updating to the most recent protocol version and confirm that you get the expected results.

  • Thank you for your answer @Jon, I think my Stellar core version is 10.0.0. stellar/quickstart v10-stable xxxxxxxxxxx 6 weeks ago 796MB stellar-core 2018-10-19T02:42:43.682 <startup> [default INFO] RUN_STANDALONE enabled in configuration file - node will not function properly with most networks 2018-10-19T02:42:43.702 GCTI6 [default INFO] Starting stellar-core v10.0.0 so, In your opinion what are other possible causes? Thanks.
    – Pakornsin
    Oct 19, 2018 at 3:04
  • V10.0.0 just means that you have a version that supports protocol 1 through 10; you have to upgrade your local network to protocol 10 manually Oct 20, 2018 at 4:22
  • 1
    Thank you @MonsieurNicolas. After we upgrade protocol version the problem is solved.
    – Pakornsin
    Oct 24, 2018 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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