feat: add multi-path market orders + on-chain mark price - #21
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Market orders now walk both books per step, taking the cheapest crossable path between same-outcome normal fills and opposite-outcome mint/merge fills. Slippage is anchored to a new on-chain mark price waterfall — no caller-supplied price.
What's new
placeMarketBuy/placeMarketSell— single multi-path entry onMarketOrdersFacet. Parameter shape:(marketId, outcomeId, amount, slippageBps, orderType). FOK / FAK only.LibMarkPriceService— implied midpoint via cross-outcome mint/merge complement, tick-size-scaled spread threshold (~$0.10), honest(0, false)when neither implied mid nor last-trade yields a defensible reference.OrderBookFacet.getImpliedTopOfBook— new external view exposing the cross-outcome implied book for SDK / UI previews.Breaking changes
placeMarketOrder(uint,uint,uint,uint,uint8)selector removed.placeMarketSellselector preserved but parameter 4 changes meaning:minPriceTick→slippageBps.MarketOrderExecuted/MarketSellExecutedreplaced byMarketOrderBuy/MarketOrderSell(+markTick,maxEffTick/minEffTick,fillCounttrailers).Diamond cut shape
6 entries: 1 Remove, 2 Add, 3 Replace across
MarketOrdersFacet,OrderBookFacet,MatchingFacet. Storage diff: none. Upgrade script:script/upgrades/20260527_MarketOrders_MultiPathMintMerge.s.sol.Tests
494 passing, 0 failed, 1 skipped (was 465 at v1.4.x). Coverage in
FillServicesRefactor.t.sol,MarkPriceService.t.sol,MarketTakeService.t.sol.Deployments
Downstream
Requires
@oddmaki-protocol/sdk@^1.14.0and the matching subgraph release.