EligiblePrice
Exact-price summaries on a priority-key radix tree.
A buy subtree stores its maximum limit; a sell subtree its minimum. This is an existence certificate, not an approximation of an order's limit.
Functions
le
Exact comparison of positive-denominator ratios using two 512-bit products.
function le(Ratio memory a, Ratio memory b) internal pure returns (bool result);Parameters
| Name | Type | Description |
|---|---|---|
| a | Ratio | |
| b | Ratio |
Returns
| Name | Type | Description |
|---|---|---|
| result | bool |
refresh
function refresh(
RadixPriceTree.Tree storage tree,
mapping(uint32 => Ratio) storage bounds,
uint128 rank,
Ratio memory price,
bool isBuy
) public;Parameters
| Name | Type | Description |
|---|---|---|
| tree | RadixPriceTree.Tree | |
| bounds | mapping(uint32 => Ratio) | |
| rank | uint128 | |
| price | Ratio | |
| isBuy | bool |
remove
function remove(RadixPriceTree.Tree storage tree, mapping(uint32 => Ratio) storage bounds, uint128 rank, bool isBuy)
public;Parameters
| Name | Type | Description |
|---|---|---|
| tree | RadixPriceTree.Tree | |
| bounds | mapping(uint32 => Ratio) | |
| rank | uint128 | |
| isBuy | bool |
_repair
function _repair(
RadixPriceTree.Tree storage tree,
mapping(uint32 => Ratio) storage bounds,
uint32 cursor,
bool isBuy,
bool forceFirst
) private;Parameters
| Name | Type | Description |
|---|---|---|
| tree | RadixPriceTree.Tree | |
| bounds | mapping(uint32 => Ratio) | |
| cursor | uint32 | |
| isBuy | bool | |
| forceFirst | bool |
_eligible
function _eligible(Ratio memory bound, Ratio memory limit, bool isBuy) private pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| bound | Ratio | |
| limit | Ratio | |
| isBuy | bool |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
best
Highest priority key among orders crossing limit, in at most 128 branches.
Right children have greater priority keys. No backtracking or linear scan.
function best(
RadixPriceTree.Tree storage tree,
mapping(uint32 => Ratio) storage bounds,
Ratio memory limit,
bool isBuy
) internal view returns (bool found, uint128 rank);Parameters
| Name | Type | Description |
|---|---|---|
| tree | RadixPriceTree.Tree | |
| bounds | mapping(uint32 => Ratio) | |
| limit | Ratio | |
| isBuy | bool |
Returns
| Name | Type | Description |
|---|---|---|
| found | bool | |
| rank | uint128 |
Structs
Ratio
struct Ratio {
uint256 numerator;
uint256 denominator;
}Properties
| Name | Type | Description |
|---|---|---|
| numerator | uint256 | |
| denominator | uint256 |