5/5
## Modifying Liquidity in Uniswap v4 Hooks In Uniswap v4, modifying the liquidity of a position within a hook-enabled pool follows a consistent, two-step operational flow. Whether you are increasing or decreasing your liquidity, the process involves first signaling your intent and then resolving the resulting token balance changes. This two-step pattern is fundamental: 1. **Request the Modification:** You begin by calling an action to state your intention. This will be either `INCREASE_LIQUIDITY` to add funds to a position or `DECREASE_LIQUIDITY` to remove them. This action updates the pool's internal accounting for your position. 2. **Resolve the Token Delta:** After the modification is requested, you must settle the change in token balances. * When **increasing liquidity**, you must transfer the required tokens into the pool manager contract. This is typically done with a `PAY` action. * When **decreasing liquidity**, the pool manager now owes you tokens. You must explicitly withdraw these tokens to your wallet. Let's explore the practical application of this flow by examining how to decrease liquidity. ### How to Decrease Liquidity Decreasing liquidity involves two primary actions that are typically bundled into a single transaction: `DECREASE_LIQUIDITY` and `TAKE_PAIR`. 1. **`DECREASE_LIQUIDITY` Action:** This is the initial call that instructs the pool manager to reduce the liquidity associated with your specific position. The pool manager calculates the amount of `token0` and `token1` you are entitled to based on the amount of liquidity you are removing. 2. **`TAKE_PAIR` Action:** Once the liquidity has been logically decreased, the corresponding tokens are held by the pool manager. The `TAKE_PAIR` action withdraws this pair of tokens from the contract and sends them to your specified address. To execute both operations sequentially and atomically, you can encode them together. This ensures that the liquidity is decreased and the tokens are withdrawn in the same transaction, preventing the funds from being left in the pool manager contract. The actions are packed into a single `bytes` variable using `abi.encodePacked`, as shown in this Solidity snippet: ```solidity bytes memory actions = abi.encodePacked( Actions.DECREASE_LIQUIDITY, Actions.TAKE_PAIR ); ``` This encoded `actions` data is then passed to the pool manager, which executes each action in the order they were packed. ### Completing the Liquidity Management Cycle The same pattern applies when increasing liquidity, but the second action is different. You would first call `INCREASE_LIQUIDITY` and follow it with a `PAY` action to send the necessary tokens into the pool manager. Occasionally, an operation might result in excess tokens remaining in the pool manager's balance under your name. To handle this, Uniswap v4 provides a `SWEEP` action, which allows you to claim and withdraw any leftover tokens, ensuring your balance is fully settled. By understanding this "request and resolve" pattern, you can effectively manage liquidity in Uniswap v4, whether you are adding, removing, or simply cleaning up residual balances.
In Uniswap v4, modifying the liquidity of a position within a hook-enabled pool follows a consistent, two-step operational flow. Whether you are increasing or decreasing your liquidity, the process involves first signaling your intent and then resolving the resulting token balance changes.
This two-step pattern is fundamental:
Request the Modification: You begin by calling an action to state your intention. This will be either INCREASE_LIQUIDITY to add funds to a position or DECREASE_LIQUIDITY to remove them. This action updates the pool's internal accounting for your position.
Resolve the Token Delta: After the modification is requested, you must settle the change in token balances.
When increasing liquidity, you must transfer the required tokens into the pool manager contract. This is typically done with a PAY action.
When decreasing liquidity, the pool manager now owes you tokens. You must explicitly withdraw these tokens to your wallet.
Let's explore the practical application of this flow by examining how to decrease liquidity.
Decreasing liquidity involves two primary actions that are typically bundled into a single transaction: DECREASE_LIQUIDITY and TAKE_PAIR.
DECREASE_LIQUIDITY Action: This is the initial call that instructs the pool manager to reduce the liquidity associated with your specific position. The pool manager calculates the amount of token0 and token1 you are entitled to based on the amount of liquidity you are removing.
TAKE_PAIR Action: Once the liquidity has been logically decreased, the corresponding tokens are held by the pool manager. The TAKE_PAIR action withdraws this pair of tokens from the contract and sends them to your specified address.
To execute both operations sequentially and atomically, you can encode them together. This ensures that the liquidity is decreased and the tokens are withdrawn in the same transaction, preventing the funds from being left in the pool manager contract.
The actions are packed into a single bytes variable using abi.encodePacked, as shown in this Solidity snippet:
This encoded actions data is then passed to the pool manager, which executes each action in the order they were packed.
The same pattern applies when increasing liquidity, but the second action is different. You would first call INCREASE_LIQUIDITY and follow it with a PAY action to send the necessary tokens into the pool manager.
Occasionally, an operation might result in excess tokens remaining in the pool manager's balance under your name. To handle this, Uniswap v4 provides a SWEEP action, which allows you to claim and withdraw any leftover tokens, ensuring your balance is fully settled.
By understanding this "request and resolve" pattern, you can effectively manage liquidity in Uniswap v4, whether you are adding, removing, or simply cleaning up residual balances.
An action-oriented guide to Modifying Liquidity in Uniswap v4 Hooks - Learn the core "request and resolve" pattern for managing positions, from signaling your intent to settling the final token balance.
Previous lesson
Previous
Next lesson
Next
Note:
Last updated on January 5, 2026
Course Overview
About the course
Difference between Uniswap v3 and v4
Uniswap v4 PoolManager
Uniswap v4 Hooks
Uniswap v4 PositionManager
Uniswap v4 Universal Router
Uniswap v4 Singleton architecture and flash accounting
Uniswap v4 operations and lifecycle
Uniswap v4 multihopping and quoting
How to build a Uniswap v4 swap router
How to build a smart contract a liquidation bot executes
Last updated on November 6, 2025
Duration: 5min
Duration: 7min
Duration: 39min
Duration: 35min
Duration: 34min
Duration: 31min
Course Overview
About the course
Difference between Uniswap v3 and v4
Uniswap v4 PoolManager
Uniswap v4 Hooks
Uniswap v4 PositionManager
Uniswap v4 Universal Router
Uniswap v4 Singleton architecture and flash accounting
Uniswap v4 operations and lifecycle
Uniswap v4 multihopping and quoting
How to build a Uniswap v4 swap router
How to build a smart contract a liquidation bot executes
Last updated on November 6, 2025