-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor!: refactor matching logic and add ranged liquidity pools #318
Conversation
this prevents pool to place orders too densely
also add more tests
also update broken tests
this reduces decimal error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hallazzang I left some more comments on amm/pool.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found no issue. Great work other than the docs/cli
and docs/api
need to be updated to include a ranged pool, which @jeonghoyeo7 mentioned offline and @hallazzang is already working on it.
#37) * refactor!: new matching logic (WIP) (cherry-picked) (cherry picked from commit a9d0475) * refactor: distribute order amount to tick (cherry picked from commit 2cf6023) * test: update test (cherry picked from commit 6a2bf05) * fix: remove unnecessary variables (cherry picked from commit 7d2c5e3) * chore: apply micro optimization (cherry picked from commit 9d14b9b) * feat: add Match method (cherry-picked) (cherry picked from commit 8a6185c) * fix: use correct match price considering price direction (cherry picked from commit 72d9ccd) * fix: drop last orders when distributing amount (cherry picked from commit 39ffd43) * fix: consider previously matched amount (cherry picked from commit e2d4b90) * fix: implement HasPriority() for user/pool order (cherry picked from commit f8a70fb) * test: fix test (cherry picked from commit e154e38) * refactor!: new pool interface and remove old code (cherry-picked) (cherry picked from commit bc5a6f2) * fix: clean up code and switch buy/sell side in order book repr (cherry picked from commit d6d58dc) * fix: return match price (cherry picked from commit c128f4b) * refactor: use in-place matching again (cherry picked from commit 7f1ae4e) * refactor: track offer/demand coin amount and generalize pool orders (cherry picked from commit 22e8876) * fix: apply updated matching logic (cherry-picked) (cherry picked from commit 5a89447) * fix: remove old order types (cherry picked from commit 0e43d95) * chore: remove outdated code (cherry-picked) (cherry picked from commit db9a709) * fix: introduce MinPoolOrderPriceGapRatio param this prevents pool to place orders too densely (cherry picked from commit c120720) * feat: add order books query (cherry-picked) (cherry picked from commit 175e7e4) * fix: add linear pool order price gap ratio function (cherry picked from commit d7ed46b) * fix: consider receiving quote coin truncation (cherry picked from commit 41734ae) * chore: add comments (cherry picked from commit 2b35f79) * fix: add missing order books grpc query (cherry picked from commit 568f681) * fix: pool places orders properly (cherry-picked) (cherry picked from commit 350b990) * feat: calculate quote coin diff (cherry picked from commit fd08796) * fix: uncomment previous logic (cherry picked from commit 44cdb0e) * feat: run single price auction when there's no last price (cherry picked from commit c437e09) * refactor: simplify match logic (cherry picked from commit 27a19d4) * style: refine code style (cherry picked from commit 31d35ce) * fix: place pool orders based on price ratio (cherry picked from commit d3e7f67) * fix: send quote coin dust to the collector (cherry picked from commit 5215e3c) * refactor: optimize BulkSendCoinsOperation for the same sender and receiver, SendCoins will now happen only once. (cherry picked from commit cad91f9) * fix: implement order books grpc api and query cmd (cherry-picked) (cherry picked from commit 37f3f17) * feat: add ranged pool (WIP) (cherry-picked) (cherry picked from commit 6e825c6) * refactor: implement ranged liqudity (cherry-picked) (cherry picked from commit 2c6ecd6) * fix: fix bugs - when placing pool orders, reinitialize tmpPool with correct pool type - correct IsDepleted condition for ranged pool (cherry picked from commit 03529b3) * test: add tests (cherry picked from commit f74723e) * fix: simplify equations (cherry picked from commit 6c64809) * feat: add migration (cherry picked from commit 3100d40) * fix: register codec (cherry picked from commit 7b1367b) * fix: update PoolResponse (cherry-picked) (cherry picked from commit e25faa1) * fix: limit the ranged pool's order amount based on its balances (cherry picked from commit 304853f) * fix: use correct pool type when returning order books (cherry picked from commit 7688ee2) * feat: add create-ranged-pool tx cmd (cherry picked from commit ae71be8) * fix: add new event type and update spec docs (cherry picked from commit 311b6a2) * test: uncomment and update old tests (cherry picked from commit 77a06ed) * feat: add ranged liquidity pools (#319) (cherry-picked) * feat: add ranged pool (WIP) * refactor: implement ranged liqudity * fix: fix bugs - when placing pool orders, reinitialize tmpPool with correct pool type - correct IsDepleted condition for ranged pool * test: add tests * fix: simplify equations * feat: add migration * fix: register codec * fix: update PoolResponse * fix: limit the ranged pool's order amount based on its balances * fix: use correct pool type when returning order books * feat: add create-ranged-pool tx cmd * fix: add new event type and update spec docs * test: uncomment and update old tests (cherry picked from commit c9762c1) * fix: fix typo * fix: only match matchable amount considering remaining offer coin * fix: change pool order price gap ratio curve (cherry-picked) * fix: remove MatchRecord (cherry picked from commit 2f3ca6d) * test: add tests (cherry picked from commit b40eb18) * feat: add more param getters (cherry picked from commit 48725b8) * refactor: use param getters (cherry picked from commit 16774bf) * fix: fix bug in poolOrderPriceGapRaio and add tests (cherry picked from commit a2b6be3) * refactor: optimize OrderBook.AddOrder now orders are grouped and sorted only before matching (cherry picked from commit 389af70) * refactor: derive transX, transY when creating a ranged pool (cherry-picked) these parameters are no longer stored in state (cherry picked from commit ea6cdaf) * chore: use amm.OrderView (cherry picked from commit 0569710) * fix: add more safe guards and add comments (cherry picked from commit 65200d7) * chore: add comments above equations (cherry picked from commit 1e4838b) * fix: add restrictions about min/max price (cherry picked from commit a9b0494) * fix: check min price against chain's tick precision (cherry picked from commit 405227a) * test: add MsgCreateRangedPool validation test (cherry picked from commit 1705698) * fix: handle single asset pool in Deposit (cherry-picked) (cherry picked from commit 850cc20) * test: add test for Withdraw (cherry picked from commit ca8a4c5) * test: add more testcases and fix typo in comment (cherry picked from commit 733de74) * fix: fix matching logic - consider match price when matching orders at single price - when remaining matchable amount is too small, skip the tick (cherry picked from commit f480aa9) * chore: remove unused method (cherry picked from commit eeb2513) * test: add more tests (cherry-picked) (cherry picked from commit 0ea0689) * fix: limit basic pool price (cherry picked from commit c73c8f4) * fix: prevent PoolOrders to panic, instead return empty orders (cherry picked from commit b553dd7) * fix: limit price range between MinPoolPrice and MaxPoolPrice (cherry picked from commit 0e12c7a) * fix: check price when pseudo-matching OrderView (cherry-picked) (cherry picked from commit 7e8aaee) * test: fix example test * fix: fix bug in OrderBookView.Match (cherry picked from commit decd873) * fix: handle deposit in single sided ranged pool (cherry picked from commit 9a419bc) * fix: increment tick precision to 4 for mainnet upgrade * fix: accept only 2 deposit coins in CreatePool (cherry picked from commit fa6656c) * fix: emit pool_order_matched event once for each pool in batch (cherry picked from commit f888374) * test: add tests (cherry picked from commit 29349c0) * fix: handle negative order amount returned from RangedPool (cherry-picked) also add more tests (cherry picked from commit 24a9408) * fix!: calculate pool buy amount from dx and move guard (cherry picked from commit e493484) * chore: do not recalculate translation when calling Translation() (cherry picked from commit 0684aea) * test: add CreateRangedPool simulation operation (cherry picked from commit 4a3219d) * fix: accept prices on ticks and change DefaultTickPrecision to 4 also update broken tests (cherry picked from commit 4cf088c) * fix: fix DeriveTranslation equations this reduces decimal error (cherry picked from commit e0b259a) * test: fix simulation test (cherry picked from commit 7784284) * chore: add comments (cherry picked from commit 5a162d5) * test: add test (cherry picked from commit 826a840) * test: add tests (cherry picked from commit 8c7e208) * fix: fix deposit request validation condition (cherry picked from commit ace01c8) * fix: fix test (cherry picked from commit 6351532) * test: add test (cherry picked from commit 21158a3) * fix: fix upgrade test manually set tick precision to 3 since the default has been changed * docs: update docs (cherry-picked) (cherry picked from commit 0732b2a) * fix: add OrderBooks query cmd and update cli docs (cherry-picked) (cherry picked from commit ce0b85e) * chore: update CHANGELOG.md Co-authored-by: Hanjun Kim <[email protected]>
Description
Tasks