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

Figure out and handle Serum market orders #216

Closed
tomjohn1028 opened this issue Apr 5, 2021 · 4 comments
Closed

Figure out and handle Serum market orders #216

tomjohn1028 opened this issue Apr 5, 2021 · 4 comments
Assignees

Comments

@tomjohn1028
Copy link
Collaborator

Screen Shot 2021-04-04 at 9 31 47 PM

Image showing the OrderParams being passed to Serum's Market.makePlaceOrderTransaction function along side the existing order book for context.

https://explorer.solana.com/tx/54TDQAGSUzbKYAiPSCSMjwpYMS37NvKi6n66DzSFuJhTWyXaJyY7Lo7acStbhw9vZYwB157Hf7hYRpXEnScLhGNU?cluster=devnet

When trying to handle a market order I'm using the "ioc" orderType. But for some reason the order book doesn't change. You can even see from the posted explorer link above that 15 USDCT (mint address HinfVnJuzMtJsyuLE2ArYCChDZB6FCxEu2p3CQeMcDiF) gets debited from my token account.

Are we handling market orders correctly? Or is there some sort of crank we need to turn for the orders to match and the order book to update? If we need to run the ConsumeEvents function, I'll need more information on the arguments. I have not been able to get it to work properly and it stems from the openOrdersAccounts passed in.

Note [this, quite confusing, document[(https://docs.google.com/document/d/17-FlYTIcLiciWdjXaQEdUnEJFbvIeIEYW3fdcEQu8ds/edit) listing some of the changes from DEX V2 -> DEX V3. In particular "The MatchOrders instruction still exists, but it doesn’t do anything.".

@tomjohn1028 tomjohn1028 self-assigned this Apr 6, 2021
@tomjohn1028
Copy link
Collaborator Author

After talking with the Serum team it seems like the fees weren't being accounted for. Let's say the lowest ASK was 15. If we use a makePlaceOrderTransaction instruction passing in the limitPrice of 15, the transaction will pass but nothing happens because after the fees are accounted for there's not enough to match the order.

When placing a limit order that is higher than the lowest Ask, the DEX matches the order appropriately

@tomjohn1028
Copy link
Collaborator Author

This is tied to this Serum-TS bug project-serum/serum-ts#84

@tomjohn1028 tomjohn1028 removed their assignment Apr 8, 2021
@Taylor123 Taylor123 self-assigned this Apr 8, 2021
@Taylor123
Copy link
Collaborator

WIP on the FE repo here: fix/serum-market-orders
WIP on the serum-ts repo here: https://github.com/mithraiclabs/serum-ts/tree/fix/support-fee-rate-input

Currently using the serum taker fees when it's a market order. This transaction goes through, however the maxQuoteQuantity is still not high enough with just the taker fees. I manually set the feeRate to 20% and the TX removed a limit ask from the order book. So the TX works, its just that the quantity still isn't high enough.

Not sure if we should add an additional buffer for market orders or what. If it takes too long, could do that just to get Devnet beta on its way

@tomjohn1028
Copy link
Collaborator Author

new branch to use is fix/serum-taker-orders

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