PoolLib
Functions
uniqueOrderedTicksCheck
Check to ensure that the ticks are in ascending order and amount array is same length as tick array.
Parameters
Name | Type | Description |
---|---|---|
|
| An array of int32 values representing ticks to be checked. |
|
| Amount array length. |
binReserves
Compute bin reserves assuming the bin is not merged; not accurate reflection of reserves for merged bins.
Parameters
Name | Type | Description |
---|---|---|
|
| The storage reference to the state for this bin. |
|
| The memory reference to the state for this tick. |
Returns
Name | Type | Description |
---|---|---|
|
| The reserve amount for token A. |
|
| The reserve amount for token B. |
binReserves
Compute bin reserves assuming the bin is not merged; not accurate reflection of reserves for merged bins.
Parameters
Name | Type | Description |
---|---|---|
|
| Bin's balance in the tick. |
|
| Tick's tokenA reserves. |
|
| Tick's tokenB reserves. |
|
| Tick total supply of bin balances. |
reserveValue
Reserves of a bin in a tick.
Parameters
Name | Type | Description |
---|---|---|
|
| Tick reserve amount in a given token. |
|
| Bin's balance in the tick. |
|
| Tick total supply of bin balances. |
deltaTickBalanceFromDeltaLpBalance
Calculate delta A, delta B, and delta Tick Balance based on delta LP balance and the Tick/Bin state.
_setRequiredDeltaReservesForEmptyTick
Calculates deltaA = liquidity * (sqrt(upper) - sqrt(lower))
Calculates deltaB = liquidity / sqrt(lower) - liquidity / sqrt(upper),
i.e., liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))
we set liquidity = deltaLpBalance / (1.0001^(tick * tickspacing) - 1)
which simplifies the A/B amounts to:
deltaA = deltaLpBalance * sqrt(lower)
deltaB = deltaLpBalance / sqrt(upper)
Structs
AddLiquidityInfo
Last updated