Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
doublesharp committed Jan 12, 2024
1 parent 09cdde4 commit 948da84
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

![swob](https://github.com/PaintSwap/samwitch-orderbook/assets/84033732/977c060f-e6e7-418f-9d44-1012599f41c6)

This efficient order book utilises the BokkyPooBahsRedBlackTreeLibrary library for sorting prices allowing O(log n) for tree segment insertion, traversal and deleting. It supports batch orders and batch cancelling, ERC2981 royalties, a dev and burn fee on each trade.
This efficient order book utilises the BokkyPooBahsRedBlackTreeLibrary library for sorting prices allowing O(log n) for tree segment insertion, traversal, and deletion. It supports batch orders and batch cancelling, ERC2981 royalties, and a dev and burn fee on each trade.

It is kept gas efficient by packing dataq in many areas:
It is kept gas efficient by packing data in many areas:

- 4 orders (uint24 quantity + uint40 order id) into a 256bit word giving a 4x improvement compared to using 1 storage slot per order.
- Four orders (uint24 quantity + uint40 order id) into a 256bit word giving a 4x improvement compared to using 1 storage slot per order.
- When taking from the order book no tokens/nfts are transferred. Instead the orderId is stored in a claimable array
- The tokens claimable are packed with 3 orders per storage slot

The order book is kept healthy by requiring a minimum quantity that can be added, partial quantities can still be taken from the order book. Cancelling orders shifts all at the price level to remove gaps.
The order book is kept healthy by requiring a minimum quantity that can be added - partial quantities can still be taken from the order book. Cancelling orders shifts all entries at that price level to remove gaps.

Constraints:

- The order quantity is limited to ~16mil
- The maximum number of orders in the book that can ever be added is limited to 1 trillion
- The maximum number of orders that can be added to a specific price level is between 4.2 - 16 billion

While this OrderBook was created for ERC1155 NFTs it could be adapted for ERC20s
While this order book was created for ERC1155 NFTs it could be adapted for ERC20 tokens.

Note: Not suitable for production until more tests are added with more code coverage.

Expand All @@ -30,7 +30,7 @@ Potential improvements:
- Range delete of the red-black tree using split/join
- The tree, either pack red & numDeletedInSegment or reduce number of decimals for the price and use uint64 instead.

To start copy the .env.sample file to .env and fill in PRIVATE_KEY at minimum, starts with 0x
To start copy the `.env.sample` file to `.env` and fill in `PRIVATE_KEY` at a minimum (starts with `0x`).

```shell
yarn install
Expand Down

0 comments on commit 948da84

Please sign in to comment.