jediswap_v2_pool
Functions
initialize
Sets the initial price for the pool
Emits Initialize.
Parameters:
Name | Type | Description |
---|---|---|
sqrt_price_X96 | u256 | The initial sqrt price of the pool as a Q64.96 |
mint
Adds liquidity for the given recipient/tick_lower/tick_upper position
The caller of this method receives a callback in the form of jediswap_v2_mint_callback in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends on tick_lower, tick_upper, the amount of liquidity, and the current price.
Emits Mint.
Parameters:
Name | Type | Description |
---|---|---|
recipient | ContractAddress | The address for which the liquidity will be created |
tick_lower | i32 | The lower tick of the position in which to add liquidity |
tick_upper | i32 | The upper tick of the position in which to add liquidity |
amount | u128 | The amount of liquidity to mint |
data | Array<felt252> | Any data that should be passed through to the callback |
Return Values:
Type | Description |
---|---|
u256 | The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback |
u256 | The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback |
collect
Collects tokens owed to a position
It does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. Collect must be called by the position owner. To withdraw only token0 or only token1, amount0_requested or amount1_requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the actual tokens owed, e.g. BoundedInt::<u128>::max(). Tokens owed may be from accumulated swap fees or burned liquidity.
Emits Collect.
Parameters:
Name | Type | Description |
---|---|---|
recipient | ContractAddress | The address which should receive the fees collected |
tick_lower | i32 | The lower tick of the position for which to collect fees |
tick_upper | i32 | The upper tick of the position for which to collect fees |
amount0_requested | u128 | How much token0 should be withdrawn from the fees owed |
amount1_requested | u128 | How much token1 should be withdrawn from the fees owed |
Return Values:
Type | Description |
---|---|
u128 | The amount of fees collected in token0 |
u128 | The amount of fees collected in token1 |
burn
Burn liquidity from the sender and account tokens owed for the liquidity to the position
It can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0. Fees must be collected separately via a call to collect.
Emits Burn.
Parameters:
Name | Type | Description |
---|---|---|
tick_lower | i32 | The lower tick of the position for which to burn liquidity |
tick_upper | i32 | The upper tick of the position for which to burn liquidity |
amount | u128 | How much liquidity to burn |
Return Values:
Type | Description |
---|---|
u256 | The amount of token0 sent to the recipient |
u256 | The amount of token1 sent to the recipient |
swap
Swap token0 for token1, or token1 for token0
The caller of this method receives a callback in the form of jediswap_v2_swap_callback
Emits Swap.
Parameters:
Name | Type | Description |
---|---|---|
recipient | ContractAddress | The address to receive the output of the swap |
zero_for_one | bool | The direction of the swap, true for token0 to token1, false for token1 to token0 |
amount_specified | i256 | The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) |
sqrt_price_limit_X96 | u256 | The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap |
data | Array<felt252> | Any data to be passed through to the callback |
Return Values:
Type | Description |
---|---|
i256 | The delta of the balance of token0 of the pool, exact when negative, minimum when positive |
i256 | The delta of the balance of token1 of the pool, exact when negative, minimum when positive |
collect_protocol
Collect the protocol fee accrued to the pool
Only the factory owner can call this function.
Emits CollectProtocol.
Parameters:
Name | Type | Description |
---|---|---|
recipient | ContractAddress | The address to which collected protocol fees should be sent |
amount0_requested | u128 | The maximum amount of token0 to send, can be 0 to collect fees in only token1 |
amount1_requested | u128 | The maximum amount of token1 to send, can be 0 to collect fees in only token0 |
Return Values:
Type | Description |
---|---|
u128 | The protocol fee collected in token0 |
u128 | The protocol fee collected in token1 |
Events
Initialize
Emitted exactly once by a pool when initialize is first called on the pool
Mint/Burn/Swap cannot be emitted by the pool before Initialize
Parameters:
Name | Type | Description |
---|---|---|
sqrt_price_X96 | u256 | The initial sqrt price of the pool, as a Q64.96 |
tick | i32 | The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool |
Mint
Parameters:
Name | Type | Description |
---|---|---|
sender | ContractAddress | The address that minted the liquidity |
owner | ContractAddress | The owner of the position and recipient of any minted liquidity |
tick_lower | i32 | The lower tick of the position |
tick_upper | i32 | The upper tick of the position |
amount | u128 | The amount of liquidity minted to the position range |
amount0 | u256 | How much token0 was required for the minted liquidity |
amount1 | u256 | How much token1 was required for the minted liquidity |
Collect
Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
Parameters:
Name | Type | Description |
---|---|---|
owner | ContractAddress | The owner of the position for which fees are collected |
recipient | ContractAddress | The address which should receive the fees collected |
tick_lower | i32 | The lower tick of the position |
tick_upper | i32 | The upper tick of the position |
amount0 | u128 | The amount of token0 fees collected |
amount1 | u128 | The amount of token1 fees collected |
Burn
Parameters:
Name | Type | Description |
---|---|---|
owner | ContractAddress | The owner of the position for which liquidity is removed |
tick_lower | i32 | The lower tick of the position |
tick_upper | i32 | The upper tick of the position |
amount | u128 | The amount of liquidity to remove |
amount0 | u256 | The amount of token0 withdrawn |
amount1 | u256 | The amount of token1 withdrawn |
Swap
Parameters:
Name | Type | Description |
---|---|---|
sender | ContractAddress | The address that initiated the swap call, and that received the callback |
recipient | ContractAddress | The address that received the output of the swap |
amount0 | i256 | The delta of the token0 balance of the pool |
amount1 | i256 | The delta of the token1 balance of the pool |
sqrt_price_X96 | u256 | The sqrt(price) of the pool after the swap, as a Q64.96 |
liquidity | u128 | The liquidity of the pool after the swap |
tick | i32 | The log base 1.0001 of price of the pool after the swap |
CollectProtocol
Parameters:
Name | Type | Description |
---|---|---|
sender | ContractAddress | The address that collects the protocol fees |
recipient | ContractAddress | The address that receives the collected protocol fees |
amount0 | u128 | The amount of token0 protocol fees that is withdrawn |
amount1 | u128 | The amount of token1 protocol fees that is withdrawn |
ABI
Last updated