Skip to content
LogoLogo

TickBitmap

Git Source

Three-level occupancy bitmap for the bounded tick-key domain.

Not a replacement for the 128-bit fee/sequence tree. Changes storage layout.

Constants

MAX_KEY

uint128 internal constant MAX_KEY = 1_774_545;

Functions

insert

function insert(Tree storage self, uint128 key) internal returns (bool);

Parameters

NameTypeDescription
selfTree
keyuint128

Returns

NameTypeDescription
<none>bool

remove

function remove(Tree storage self, uint128 key) internal;

Parameters

NameTypeDescription
selfTree
keyuint128

best

function best(Tree storage self, bool highest) public view returns (bool, uint128);

Parameters

NameTypeDescription
selfTree
highestbool

Returns

NameTypeDescription
<none>bool
<none>uint128

_bit

function _bit(uint256 bits, bool highest) private pure returns (uint8);

Parameters

NameTypeDescription
bitsuint256
highestbool

Returns

NameTypeDescription
<none>uint8

Errors

InvalidKey

error InvalidKey();

PriceLevelMissing

error PriceLevelMissing();

Structs

Tree

struct Tree {
        // Each parent bit means its child word is nonempty: root -> middle -> leaf.
        uint256 root;
        mapping(uint256 group => uint256 bits) middle;
        mapping(uint256 word => uint256 bits) leaves;
    }

Properties

NameTypeDescription
rootuint256
middlemapping(uint256 group => uint256 bits)
leavesmapping(uint256 word => uint256 bits)