Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OfferCreate with tfFillOrKill fails with tecKILLED if offer is better than, but doesn't exactly match, open offer rate #4684

Closed
nhartner opened this issue Aug 31, 2023 · 1 comment
Assignees
Labels

Comments

@nhartner
Copy link

nhartner commented Aug 31, 2023

Issue Description

CreateOffer with tfFillOrKill flag will always results in a tecKILLED result if the exchange rate on the offer is better than, but doesn't exactly match, the order book rate.

Steps to Reproduce

  1. Create 3 accounts and fund them with faucet:
  1. Enable Default Ripple flag on ISSUER (ex. https://test.bithomp.com/explorer/424CF9443FBBE23734DF9E49BA2297D2A2ECE58C11F01B4EE8FD251F63E85A6C)

  2. Create trustlines:

  1. Send a payment of 100 units of currency ONE from ISSUER to MAKER (ex. https://test.bithomp.com/explorer/BBFBC0CB6B6ECE68050E8C57E7F7F33F0437D9EF03E638F74D70DFF5DBF1B06B)

  2. Create an offer on MAKER account to sell 100 units of currency ONE for 100 XRP (ex. https://test.bithomp.com/explorer/DDFF0C28494332C491147A9A85AC8F5C1A988A848B4366271E72A67266AF5556)

  3. Create an offer on TAKER account to buy 100 units of currency ONE for 101 XRP with tfFillOrKill flag (ex. https://test.bithomp.com/explorer/7251BC0895848886B9419FC1E209DABAAA2BE3BD66CB690BABFD92D660EA4743)

Expected Result

Offer should fill and not be killed because TAKER is offering to pay 101 XRP for 100 ONE and maker is offering to sell 100 ONE for 100 XRP. Since TAKER is offering MORE XRP than the MAKER is asking, the order should match and execute with a tesSUCCESS result.

Actual Result

Offer is killed with tecKILLED status. (see https://test.bithomp.com/explorer/7251BC0895848886B9419FC1E209DABAAA2BE3BD66CB690BABFD92D660EA4743)

Note:

  • If the TAKER offers to pay exactly 100 XRP for 100 ONE, the tfFillOrKill offer will get fully matched
  • If the tfImmediateOrCancel flag is used instead, the offer for 101 XRP for 100 ONE also gets fully matched

Environment

Reproduced on testnet and mainnet

@scottschurr
Copy link
Collaborator

@gregtatcam has a unit test reproducing what @nhartner is observing. It looks like the problem was introduced with the flowCross amendment which went live August of 2020. @gregtatcam has offered to write an amendment with a fix.

@intelliot intelliot added the Bug label Sep 3, 2023
sophiax851 pushed a commit to sophiax851/rippled that referenced this issue Jun 12, 2024
Introduce the `fixFillOrKill` amendment.

Fix an edge case occurring when an offer with `tfFillOrKill` set (but
without `tfSell` set) fails to cross an offer with a better rate. If
`tfFillOrKill` is set, then the owner must receive the full TakerPays.
Without this amendment, an offer fails if the entire `TakerGets` is not
spent. With this amendment, when `tfSell` is not set, the entire
`TakerGets` does not have to be spent.

For details about OfferCreate, see: https://xrpl.org/offercreate.html

Fix XRPLF#4684

---------

Co-authored-by: Scott Schurr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants