Skip to content

Manage offer v9 - #1431

Merged
latobarita merged 3 commits into
stellar:masterfrom
MonsieurNicolas:manageOfferV9
Dec 4, 2017
Merged

latobarita merged 3 commits into
stellar:masterfrom
MonsieurNicolas:manageOfferV9

Conversation

@MonsieurNicolas

Copy link
Copy Markdown
Contributor

This PR updates the way manage offer works when attempting to sell XLMs.

In v8 of the protocol, the bad scenario looks like this:
attempt to create an offer to sell XLMs for some other asset but with an XLM balance that is too low.
Internally, the offer is first run throw the order book (in case the offer can be taken right away).
The problem is that if the offer is only partially taken, a new offer needs to be created but if there was enough outstanding offers in the order book the XLM balance could be below the reserve required to create an offer - and the operation fails (meaning no XLMs were sold).

The v9 implementation instead assumes that the offer would be created, and thus limits the XLMs that can be sold like this to the ones above the larger reserve.
This causes the behavior to be deterministic (from a success/failure point of view) as the only thing that matters is that the starting balance can accommodate the creation of an offer (the same way you need to have a balance to sell other assets).

An alternative that was considered was to simply not fail on the last step (which allows to sell a few more XLMs that way) but it would break manageOffer's contract that is that the outcome of calling manageOffer to create an offer before or after different offers are created should be the same.
This would allow selling more XLMs in manageOffer than from a regular offer, creating additional incentives to not have standing offers.

resolves #1430

This fixes an edge case that would cause certain sell operations (via the order book) to fail
@vogel

vogel commented Dec 2, 2017

Copy link
Copy Markdown
Contributor

r+ d1977c0

@MonsieurNicolas

Copy link
Copy Markdown
Contributor Author

@latobarita: retry

latobarita added a commit that referenced this pull request Dec 4, 2017
@latobarita
latobarita merged commit d1977c0 into stellar:master Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

manage offer sometimes fails when trying to sell XLMs

3 participants