HomePhabricator

[ecash-agora] Do not allow creation of unacceptable agora partials

Description

[ecash-agora] Do not allow creation of unacceptable agora partials

Summary:
An agora partial offer that requires a min accept amount higher than the total amount of tokens offered cannot be accepted.

Throw an error in this case.

Note: this could have some downstream impact for users trying to accept an agora offer that creates a new offer for change using the same min accept params as the parent offer. Right now, it will make the offer and it will be unacceptable. Now it will throw an error...I think (I have not dug into this part of the code yet).

Cashtab handles this by preventing users from accepting a partial offer that would create an unacceptable offer as change. I think the more elegant way to handle it is to create the change offer but set the min buy to the change amount, if the change amount is lower than the parent min buy...though this may be impractical for the price impacts it would have.

Either way, we never want unacceptable offers to be created. This is a step toward that goal.

Note

I have now changed the unit tests in this lib from the original tests for two conditions.

earlier diff - min buy must be at least dust satoshis
this diff - we cannot create an offer if min accept is greater than offered tokens

These also ended up changing what the original tests were probably exploring, i.e. edge cases of very low offers. However in both cases, we do not want these offers to ever exist.

Test Plan: npm test, any feedback on potential downstream impacts or strategy

Reviewers: #bitcoin_abc, Fabien, tobias_ruck

Reviewed By: #bitcoin_abc, Fabien, tobias_ruck

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17517

Details

Provenance
bytesofmanAuthored on Sat, Jan 11, 23:53
bytesofmanPushed on Mon, Jan 13, 22:50
Reviewer
Restricted Project
Differential Revision
D17517: [ecash-agora] Do not allow creation of unacceptable agora partials
Parents
rABC1659e6453360: [ecash-agora] Upgrade historicOffers to return token amounts purchased (and…
Branches
Unknown
Tags
Unknown