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

Genesis update #571

Closed
wants to merge 51 commits into from
Closed

Conversation

0xshinobii
Copy link

Why this should be merged

increase test account gas token balance for multiple order matching testing

0xshinobii and others added 30 commits November 23, 2022 08:18
* place and save order onchain

* execute matched orders

* changes based on PR comments
* Send a sample tx when a tx is received

It goes into an infinite loop right now

* add limit order processor

* Add ABI parser

* Remove hardcoded ABI

* Order book (#1)

* place and save order onchain

* execute matched orders

* changes based on PR comments

* Make contarct call to OrderBook

* add limit_order database layer to store and get limit_orders from sqlite database

* Fix contract calls to OrderBook

* Insert orders in sqlite database

Read transactions and insert/update orders in database

* Fix db tests

* fix tests

* check for price equality in GetLimitOrderByPositionTypeAndPrice method

* return status in limit_orders in GetLimitOrder method

* add test for updatelimit order status method

* Add new run script

* Review changes

* Execute orders after block production

* Store orders in memory and send tx at buildBlock

* return if len of transaction input data is less than 4 fields

* fix tests

* change public methods to private and use them

* add test for limit_order

* add test for NewLimitOrderProcessor

* minor refactoring

Co-authored-by: vipul sharma <vipulsharma2190@gmail.com>
Co-authored-by: asquare <21087753+asquare08@users.noreply.github.com>
* orderbook as genesis

* reduce blocktime and clean tests

* fix tests

Co-authored-by: Atul Agarwal <21087753+asquare08@users.noreply.github.com>
* add tests for memory_database

* add GetOrdersByPriceAndPositionType method

* remove execute test order and add logic for matching limit orders and making contract call

* refactoring limit_order private methods

* add OrderMatched event in orderbook contract and test event generation

* log error is baseAssetQuantity is zero, add method for position type

* break matching limit order loop if matching order is found

* Use contract address instead of ABI for parseTx

* Use ChainAcceptedEvent instead of NewHeadEvent

* fix syntax error

* refactor memory_database and remove matching logic from limit_order

* add limit order matching engine and call it during buildblock

* add purge local tx before running matching logic

* minor fixes

* check executeMatchedOrder tx status before deleting limit orders

* delete pending executeMatchedOrders txs before running matching engine

Co-authored-by: Shubham Goyal <sgshubham@gmail.com>
refactor limit_order to move out limit_order_txs logic
* add filledBaseAssetQuantity in limit order

* fix tests

* add test for RunMatchingEngine

* pull changes from hubble-v2

* remove sqlite database files

* add LimitOrderDatabase interface and implement in inMemoryDatabase

* deven|fdgod create LimitOrderTxProcessor interface

* deven|fdgod add tests for limit_order and mocks for LimitOrderDatabase and LimitOrderTxProcessor

* add tests for RunMatchingLogic in limit_order

* fix previous tests

* change memory_database to return object instead of pointer to limit_orders stored in memory_database

* change matching logic to partial match limit orders with different BaseAssetQuantity

* change ExecuteMatchedOrdersTx as per new contract

* delete order if filledBaseAssetQuantity is equal to BaseAssetQuantity

* update filledBaseAssetQuantity after parsing executeMatchedOrders

* return LimitOrder instead of pointer in its memory_database

* add test for GetOrder

* return InMemoryDatabase from NewInMemoryDatabase and remove GetOrder function

* remove GetOrder method from mocks

* change salt to int64

* convert fillAmount to uint

* add parsing logic for two orders in function input and output

* pass orders with type Order to executeMatchedOrders tx

* change logic of skipping already filled orders in RunMatchingEngine method in limit_order

* refactor code
#13)

* change price check in matching engine to match if longOrder price >= shortOrder price

* more aggresive assertions

* Add tests for getUnFilledBaseAssetQuantity

* refactor TestGetUnfilledBaseAssetQuantity

* refactor RunMatchingEngine in limit_order and add tests

Co-authored-by: atvanguard <3612498+atvanguard@users.noreply.github.com>
* add genesis contracts

* update orderbook.sol

* update comments

* precision
* funding skeleton

* Handle events and add liquidation logic

* Fix merge errors

* minor fixes

* Ignore orders matched during liquidation for matching

* add tests for UpdateMargin, UpdatePosition, UpdateUnrealisedFunding method in memory_database

* check for presence of positions for address in ResetUnrealisedFunding and add tests

* fix tests

* add lastPrice when db initialized and add tests

* Liquidation and UnrealisedFunding fixes

* Review changes

* Use big.Int everywhere

* add functions specified in LimitOrderTxProcessor interface

* fix liquidations compare marginFraction logic

* check if position nil in UpdateUnrealisedFunding and fix tests

* Add missing file

* Fetch all logs at once

* Add missing file

* fix: Change multiplication factor

* purge liquidateAndExecuteOrder and settleFunding tx

* Fix precision handling

* refactor liquidations and add tests

* Review fixes

* fix tests

* Fix incorrect amounts in runLiquidations

* Fix errors after merge

* fix tests

* fix tests

* add genesis contracts + mocked orderBook (#14)

* add genesis contracts

* update orderbook.sol

* update comments

* precision

* Review fixes

* Handle OrderCancelled

* Pass notionalPosition in function

* fix tests

* Review fixes

* Change IsFundingPaymentTime

Co-authored-by: Shubham Goyal <sgshubham@gmail.com>
Co-authored-by: fdgod <vipulsharma2190@gmail.com>
expose api which return all database data
* move liquidations from database and change GetLiquidations into a standalone pure function, fix tests

* move out contract events processor from limit_order_tx_processor and add tests
vipulsharma21 and others added 20 commits February 15, 2023 13:18
refactor limit_order.go and add unit tests
* fix tests and some refactoring

* add test for cancelOrder event and some refactoring

* remove nil check on order
* add genesis contract interfaces

* abis.go

---------

Co-authored-by: Shubham Goyal <sgshubham@gmail.com>
* Run and upgrade scripts using avalanche cli

* Add logs handling in new scripts

* Handle when multitail is not installed
@0xshinobii 0xshinobii closed this Mar 15, 2023
@0xshinobii 0xshinobii deleted the genesis-update branch March 15, 2023 21:09
@0xshinobii 0xshinobii restored the genesis-update branch March 15, 2023 21:11
@atvanguard atvanguard deleted the genesis-update branch March 17, 2023 07:48
ceyonur pushed a commit that referenced this pull request Jun 6, 2024
ceyonur added a commit that referenced this pull request Jun 6, 2024
* remove notes/ (#571)

* Remove optional gatherer (#563)

* Remove optional gatherer

* nit

* Do not register chain state metrics when metrics are disabled

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* add compatibility for v0.6.6

* update avago in readme

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
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.

4 participants