LiquidityConfigurations
This library contains functions to encode and decode the config of a pool and interact with the encoded bytes32.
State Variables
OFFSET_ID
uint256 private constant OFFSET_ID = 0;
OFFSET_DISTRIBUTION_Y
uint256 private constant OFFSET_DISTRIBUTION_Y = 24;
OFFSET_DISTRIBUTION_X
uint256 private constant OFFSET_DISTRIBUTION_X = 88;
PRECISION
uint256 private constant PRECISION = 1e18;
Functions
encodeParams
Encode the distributionX, distributionY and id into a single bytes32
function encodeParams(uint64 distributionX, uint64 distributionY, uint24 id) internal pure returns (bytes32 config);
Parameters
distributionX
uint64
The distribution of the first token
distributionY
uint64
The distribution of the second token
id
uint24
The id of the pool
Returns
config
bytes32
The encoded config as follows: [0 - 24[: id [24 - 88[: distributionY [88 - 152[: distributionX [152 - 256[: empty
decodeParams
Decode the distributionX, distributionY and id from a single bytes32
function decodeParams(bytes32 config) internal pure returns (uint64 distributionX, uint64 distributionY, uint24 id);
Parameters
config
bytes32
The encoded config as follows: [0 - 24[: id [24 - 88[: distributionY [88 - 152[: distributionX [152 - 256[: empty
Returns
distributionX
uint64
The distribution of the first token
distributionY
uint64
The distribution of the second token
id
uint24
The id of the bin to add the liquidity to
getAmountsAndId
Get the amounts and id from a config and amountsIn
function getAmountsAndId(bytes32 config, bytes32 amountsIn) internal pure returns (bytes32, uint24);
Parameters
config
bytes32
The encoded config as follows: [0 - 24[: id [24 - 88[: distributionY [88 - 152[: distributionX [152 - 256[: empty
amountsIn
bytes32
The amounts to distribute as follows: [0 - 128[: x1 [128 - 256[: x2
Returns
<none>
bytes32
amounts The distributed amounts as follows: [0 - 128[: x1 [128 - 256[: x2
<none>
uint24
id The id of the bin to add the liquidity to
Errors
LiquidityConfigurations__InvalidConfig
error LiquidityConfigurations__InvalidConfig();
Last updated