Skip to content

LiquidityConfigurations ​

Git Source

This library contains functions to encode and decode the config of a pool and interact with the encoded bytes32.

State Variables ​

OFFSET_ID ​

solidity
uint256 private constant OFFSET_ID = 0;

OFFSET_DISTRIBUTION_Y ​

solidity
uint256 private constant OFFSET_DISTRIBUTION_Y = 24;

OFFSET_DISTRIBUTION_X ​

solidity
uint256 private constant OFFSET_DISTRIBUTION_X = 88;

PRECISION ​

solidity
uint256 private constant PRECISION = 1e18;

Functions ​

encodeParams ​

Encode the distributionX, distributionY and id into a single bytes32

solidity
function encodeParams(uint64 distributionX, uint64 distributionY, uint24 id) internal pure returns (bytes32 config);

Parameters

NameTypeDescription
distributionXuint64The distribution of the first token
distributionYuint64The distribution of the second token
iduint24The id of the pool

Returns

NameTypeDescription
configbytes32The 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

solidity
function decodeParams(bytes32 config) internal pure returns (uint64 distributionX, uint64 distributionY, uint24 id);

Parameters

NameTypeDescription
configbytes32The encoded config as follows: [0 - 24[: id [24 - 88[: distributionY [88 - 152[: distributionX [152 - 256[: empty

Returns

NameTypeDescription
distributionXuint64The distribution of the first token
distributionYuint64The distribution of the second token
iduint24The id of the bin to add the liquidity to

getAmountsAndId ​

Get the amounts and id from a config and amountsIn

solidity
function getAmountsAndId(bytes32 config, bytes32 amountsIn) internal pure returns (bytes32, uint24);

Parameters

NameTypeDescription
configbytes32The encoded config as follows: [0 - 24[: id [24 - 88[: distributionY [88 - 152[: distributionX [152 - 256[: empty
amountsInbytes32The amounts to distribute as follows: [0 - 128[: x1 [128 - 256[: x2

Returns

NameTypeDescription
<none>bytes32amounts The distributed amounts as follows: [0 - 128[: x1 [128 - 256[: x2
<none>uint24id The id of the bin to add the liquidity to

Errors ​

LiquidityConfigurations__InvalidConfig ​

solidity
error LiquidityConfigurations__InvalidConfig();