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

program: let post only make if taker limit order is older #378

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion programs/drift/src/math/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn is_maker_for_taker(
if taker_order.post_only || !maker_order.is_resting_limit_order(slot)? {
Ok(false)
// can make if taker order isn't resting (market order or limit going through auction)
} else if !taker_order.is_resting_limit_order(slot)? {
} else if !taker_order.is_resting_limit_order(slot)? || maker_order.post_only {
Ok(true)
// otherwise the maker must be older than the taker order
} else {
Expand Down
19 changes: 15 additions & 4 deletions sdk/src/dlob/DLOB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1384,18 +1384,29 @@ export class DLOB {
const bidSlot = bidNode.order.slot.add(
new BN(bidNode.order.auctionDuration)
);
if (askSlot.lte(bidSlot) && !bidNode.order.postOnly) {

if (bidNode.order.postOnly && askNode.order.postOnly) {
return undefined;
} else if (bidNode.order.postOnly) {
return {
takerNode: askNode,
makerNode: bidNode,
};
} else if (askNode.order.postOnly) {
return {
takerNode: bidNode,
makerNode: askNode,
};
} else if (bidSlot.lte(askSlot) && !askNode.order.postOnly) {
} else if (askSlot.lte(bidSlot)) {
return {
takerNode: bidNode,
makerNode: askNode,
};
} else {
return {
takerNode: askNode,
makerNode: bidNode,
};
} else {
return undefined;
}
}

Expand Down
3 changes: 2 additions & 1 deletion sdk/tests/dlob/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5207,7 +5207,8 @@ describe('DLOB Spot Tests', () => {
expect(nodesToFillAfter[1].makerNode?.order?.orderId).to.equal(3);
});

it('Test limit orders skipping more recent post onlys', () => {
// add back if dlob checks limit order age again
it.skip('Test limit orders skipping more recent post onlys', () => {
const vAsk = new BN(15);
const vBid = new BN(8);

Expand Down