Open tequdev opened 1 year ago
Thanks @develoQ for raising the issue! We are examining it at the moment, and will comment here once a solution has been found.
@develoQ This seems to be a question of intent vs action. The code calls the order_book
twice, once in either direction (the cause of there being more than 10 results). I was not expecting this behavior based on the names of the parameters and the documentation which implies only a single direction is requested.
I investigated the behavior of ripple-lib, which this method was supposed to be based on, to derive intent. While it also called the order_book
api twice it did much more parsing and took into account the direction and to normalize all offers. It then produced a single array.
This comes down to whether or not to update the docs (and parameters) to match the implementation or create a breaking change to break out the offers differently (or not at all).
Thoughts? @intelliot @mvadari @mukulljangid
Code snippets:
The return value of the getOrderbook method has a buy field and a sell field, but in the following, TakerGets = XRP and TakerGets = USD are mixed in the buy.
This is because lsfSell is used to determine buy/sell, which is a flag that trades the full amount of TakerGets if there is a better rate than the rate specified when the OfferCreate transaction is sent. should not be used.
https://github.com/XRPLF/xrpl.js/blob/5d34746f1241cc17d5ad08e0c1d6aa63d6743e42/packages/xrpl/src/sugar/getOrderbook.ts#L135
Also, the number of objects in the buy and sell fields is obviously different when limit is specified in option. In the following example, limit:10 is specified, but there is only one object in the sell field.
I think this is also due to the fact that lsfSell is used to make the decision.