Open sconybeare opened 3 years ago
Background on this is here: https://docs.google.com/document/d/17-FlYTIcLiciWdjXaQEdUnEJFbvIeIEYW3fdcEQu8ds/edit
Currently a brute force approach of using 1% is done when creating the wrapped SOL account in cases where quote token == SOL: https://github.com/project-serum/serum-ts/blob/5f7ceafb1e99e542a74e4377cde1ffcf5a999e1c/packages/serum/src/market.ts#L672
Suggesting the same could be done here for consistency: https://github.com/project-serum/serum-ts/blob/5f7ceafb1e99e542a74e4377cde1ffcf5a999e1c/packages/serum/src/market.ts#L817-L818
Ideal version of course takes into account the actual fees expected, but given there are scenarios where it's not obvious if order will be a taker or maker, this is not foolproof.
Alternatively the current PR (https://github.com/project-serum/serum-ts/pull/86) fixes the issue properly by assuming taker fees as long as its not a postOnly
order.
maxQuoteQuantity
is being calculated asprice*quantity
, which fails to take fees into account when the order is a bid that matches against a resting offer. Instead,maxQuoteQuantity
should be set toprice*quantity*(1+fee_rate)
, unless the order is post-only.