-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
506dde5
commit e10ca58
Showing
1 changed file
with
70 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 70 additions & 1 deletion
71
docs/contracts/v4/guides/02-manage-liquidity/05-burn-liquidity.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,72 @@ | ||
--- | ||
title: Burn Position | ||
--- | ||
--- | ||
|
||
### Context | ||
|
||
To liquidate a position, the _burn_ functionality can be invoked. | ||
The funds in the position will be withdrawn and | ||
all the information of the underlying token will be cleared. | ||
Burning the position is a cost effective way to | ||
exit as a liquidity provider. | ||
|
||
### Setup | ||
|
||
See the [setup guide](./00-setup-liquidity.mdx) | ||
|
||
# Guide | ||
|
||
Below is a step-by-step guide to burn a position. | ||
|
||
### 1. Import and define `IPositionManager` | ||
|
||
```solidity | ||
import {IPositionManager} from "v4-periphery/src/interfaces/IPositionManager.sol"; | ||
// inside a contract, test, or foundry script: | ||
IPositionManager posm = IPositionManager(<address>); | ||
``` | ||
|
||
### 2. Encode Actions | ||
|
||
To burn a position, one action is required: | ||
|
||
* burn operation - clears position entirely, withdrawing funds | ||
|
||
```solidity | ||
import {Actions} from "v4-periphery/src/libraries/Actions.sol"; | ||
bytes memory actions = abi.encodePacked(Actions.BURN_POSITION); | ||
``` | ||
|
||
### 3. Encode Parameters | ||
|
||
```solidity | ||
bytes[] memory params = new bytes[](1); | ||
``` | ||
|
||
The `BURN_POSITION` action requires the following parameters: | ||
|
||
| Parameter | Type | Description | | ||
|--------------|-----------|-------------------------------------------------------------------------------| | ||
| `tokenId` | _uint256_ | position identifier | | ||
| `amount0Min` | _uint128_ | the minimum amount of currency0 liquidity msg.sender is expecting to get back | | ||
| `amount1Min` | _uint128_ | the minimum amount of currency1 liquidity msg.sender is expecting to get back | | ||
| `hookData` | _bytes_ | arbitrary data that will be forwarded to hook functions | | ||
|
||
```solidity | ||
params[0] = abi.encode(tokenId, amount0Min, amount1Min, hookData); | ||
``` | ||
|
||
### 4. Submit Call | ||
|
||
The entrypoint for all liquidity operations is `modifyLiquidities()` | ||
|
||
```solidity | ||
uint256 deadline = block.timestamp + 60; | ||
posm.modifyLiquidities( | ||
abi.encode(actions, params), | ||
deadline | ||
); | ||
``` |