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

maxQuoteQuantity is being set incorrectly for bids #84

Open
sconybeare opened this issue Apr 7, 2021 · 1 comment
Open

maxQuoteQuantity is being set incorrectly for bids #84

sconybeare opened this issue Apr 7, 2021 · 1 comment

Comments

@sconybeare
Copy link
Contributor

sconybeare commented Apr 7, 2021

maxQuoteQuantity is being calculated as price*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 to price*quantity*(1+fee_rate), unless the order is post-only.

@yamen
Copy link

yamen commented Aug 9, 2021

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:

lamports = Math.round(price * size * 1.01 * LAMPORTS_PER_SOL);

Suggesting the same could be done here for consistency:

maxQuoteQuantity: new BN(this._decoded.quoteLotSize.toNumber()).mul(
this.baseSizeNumberToLots(size).mul(this.priceNumberToLots(price)),

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 (#86) fixes the issue properly by assuming taker fees as long as its not a postOnly order.

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

No branches or pull requests

2 participants