1/5
### Collect Function on NonfungiblePositionManager Contract The `collect` function within the `NonfungiblePositionManager` contract can be invoked in two distinct scenarios. The first scenario involves collecting swap fees that have been accrued from providing liquidity. The second scenario involves removing liquidity from a pool. When removing liquidity, the user will first call the `decreaseLiquidity` function on the `NonfungiblePositionManager` contract. Then, to actually transfer the tokens out, the user will next call the `collect` function, again on the `NonfungiblePositionManager` contract. Whether the user intends to collect fees or remove tokens after decreasing liquidity, they will call the `collect` function on the `NonfungiblePositionManager` contract. After the `collect` function on the `NonfungiblePositionManager` contract is invoked, the contract then interacts with the `UniswapV3Pool` contract, making two calls. First, it invokes the `burn` function. This function calculates and updates the amount of collectable fees for the `NonfungiblePositionManager` contract. Next, the `collect` function is called on the `UniswapV3Pool` contract. This step transfers the tokens from the `UniswapV3Pool` to the user.
A technical overview of the Uniswap V3 collect function. The lesson covers the two scenarios in which the collect function is called: to collect swap fees for providing liquidity, or to remove liquidity. It also includes a breakdown of the four steps involved in the removal of liquidity process.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Concentrated liquidity and derive its equations
Uniswap V3 math
How to calculate the spot price of tokens
Single and multi position swapping
Factory contract architecture
How to calculate liquidity requirements
Uniswap V3 fee algorithm
Flash loans
TWAP price oracle
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 15, 2025
DeFi Developer
Uniswap V3Duration: 3min
Duration: 35min
Duration: 25min
Duration: 22min
Duration: 1h 43min
Duration: 11min
Duration: 1h 03min
Duration: 12min
Duration: 51min
Duration: 41min
Duration: 10min
Duration: 7min
Course Overview
About the course
Concentrated liquidity and derive its equations
Uniswap V3 math
How to calculate the spot price of tokens
Single and multi position swapping
Factory contract architecture
How to calculate liquidity requirements
Uniswap V3 fee algorithm
Flash loans
TWAP price oracle
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 15, 2025