Skip to content

Fix market order clearing price calculation#46

Merged
codchen merged 1 commit intomasterfrom
tony-chen-fix-market-order-clearing-price
Jun 16, 2022
Merged

Fix market order clearing price calculation#46
codchen merged 1 commit intomasterfrom
tony-chen-fix-market-order-clearing-price

Conversation

@codchen
Copy link
Collaborator

@codchen codchen commented Jun 16, 2022

We use a uniform clearing price for all market orders for the same pair in the same block.

The old clearing price calculation logic is the weighted average of the mid point between market order's price limit and order book order's price limit. Such calculation has been shown to be vulnerable to exploitations.

The new clearing price calculation is the weighted average of only order book side's price limit.

Tested with unit tests

@codchen codchen requested review from LCyson and philipsu522 June 16, 2022 03:40
@codchen codchen merged commit f85c898 into master Jun 16, 2022
masih pushed a commit that referenced this pull request Sep 26, 2025
* Remove Non-Multiplier Gas Meter

* Remove go mod changes

* Remove go sum changes
masih pushed a commit that referenced this pull request Sep 29, 2025
masih pushed a commit that referenced this pull request Oct 1, 2025
masih pushed a commit that referenced this pull request Oct 9, 2025
Update config description and defaults
@masih masih deleted the tony-chen-fix-market-order-clearing-price branch October 31, 2025 15:53
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

Successfully merging this pull request may close these issues.

2 participants