First DEX liquidity position: fee math vs impermanent loss
For a $200 liquidity position, a dollar of fees is worth measuring carefully. I need to know how the token composition changed, what holding the original assets would have returned, and what I paid to open or close the position.
This walkthrough covers a Uniswap V3 position on Arbitrum and a worked accounting example. There is no verified 11-day performance record here; the figures below are synthetic.
Range selection determines what I hold
V3 liquidity earns swap fees while the price is inside its range. Outside the range, the position holds one token and stops earning swap fees until the price returns. A narrower range can concentrate liquidity, but it can also leave the position inactive sooner. Concentrated liquidity
I would compare active liquidity and volume at each fee tier before selecting a pool. Total pair volume does not establish my share of fees, and a quoted APY does not describe the next week’s price path.
For the first run, I would cap the deposit at $200 and record the exact starting token quantities, tick bounds, fee tier, and mint receipt.
Read the NFT position and simulate collection
The position manager stores token addresses, ticks, liquidity, and fee-accounting fields for a token ID. Check token0 and token1 against the pool before applying decimals. The example assumes token0 is USDC and token1 is WETH. Position manager source
Run the following blocks together with Web3.py, TOKEN_ID, and WALLET set for the position you own.
from web3 import Web3
rpc = Web3(Web3.HTTPProvider("https://arb1.arbitrum.io/rpc"))
# Uniswap V3 Position Manager on Arbitrum
NPM_ADDRESS = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
npm_abi = [
{
"inputs": [{"name": "tokenId", "type": "uint256"}],
"name": "positions",
"outputs": [
{"name": "nonce", "type": "uint96"},
{"name": "operator", "type": "address"},
{"name": "token0", "type": "address"},
{"name": "token1", "type": "address"},
{"name": "fee", "type": "uint24"},
{"name": "tickLower", "type": "int24"},
{"name": "tickUpper", "type": "int24"},
{"name": "liquidity", "type": "uint128"},
{"name": "feeGrowthInside0LastX128", "type": "uint256"},
{"name": "feeGrowthInside1LastX128", "type": "uint256"},
{"name": "tokensOwed0", "type": "uint128"},
{"name": "tokensOwed1", "type": "uint128"},
],
"stateMutability": "view",
"type": "function",
},
]
npm = rpc.eth.contract(address=NPM_ADDRESS, abi=npm_abi)
import os
MY_TOKEN_ID = int(os.environ["TOKEN_ID"])
MY_WALLET = Web3.to_checksum_address(os.environ["WALLET"])
pos = npm.functions.positions(MY_TOKEN_ID).call()
print(f"tickLower: {pos[5]}, tickUpper: {pos[6]}")
print(f"liquidity: {pos[7]}")
print(f"tokensOwed0 (USDC, 6 decimals): {pos[10] / 1e6}")
print(f"tokensOwed1 (WETH, 18 decimals): {pos[11] / 1e18}")
tokensOwed0 and tokensOwed1 are only updated when you interact with the position (collect, increase, decrease). The real-time fee figure requires computing it from feeGrowthInside deltas — more on that below.
Reading accrued fees without calling collect
Stored tokensOwed can lag fee accrual. Simulating collect lets the position manager update its accounting within the call and return the collectible amounts. If principal was removed earlier, those amounts can include principal too; they are not automatically all fees.
With Web3.py, .call() asks the node to execute without broadcasting or persisting changes. Set the caller to the authorized NFT owner:
collect_abi = [
{
"inputs": [
{
"components": [
{"name": "tokenId", "type": "uint256"},
{"name": "recipient", "type": "address"},
{"name": "amount0Max", "type": "uint128"},
{"name": "amount1Max", "type": "uint128"},
],
"name": "params",
"type": "tuple",
}
],
"name": "collect",
"outputs": [
{"name": "amount0", "type": "uint256"},
{"name": "amount1", "type": "uint256"},
],
"stateMutability": "payable",
"type": "function",
},
]
npm_collect = rpc.eth.contract(address=NPM_ADDRESS, abi=collect_abi)
MAX_UINT128 = (1 << 128) - 1
amount0, amount1 = npm_collect.functions.collect({
"tokenId": MY_TOKEN_ID,
"recipient": MY_WALLET,
"amount0Max": MAX_UINT128,
"amount1Max": MAX_UINT128,
}).call({"from": MY_WALLET})
print(f"Claimable USDC: {amount0 / 1e6}")
print(f"Claimable WETH: {amount1 / 1e18}")
This does not broadcast the transaction. It asks the node: “if I called collect right now, what would come back?” Cheap, no gas, no state change.
Compare with holding, once
Keep uncollected fees separate from principal. In this synthetic end snapshot:
# Illustrative USD values; excludes entry and exit gas.
initial_usdc = 100
initial_weth = 0.03
ending_eth_price = 3300
lp_principal_usd = 198.60
fees_usd = 0.94
wallet_costs_usd = 0.30
hold_value = initial_usdc + initial_weth * ending_eth_price
net_lp = lp_principal_usd + fees_usd - wallet_costs_usd
print(f"Holding: ${hold_value:.2f}") # $199.00
print(f"LP after fees and costs: ${net_lp:.2f}") # $199.24
print(f"Difference: ${net_lp - hold_value:.2f}") # +$0.24
The LP principal trails holding by $0.40. Adding $0.94 of fees and subtracting $0.30 of costs leaves a $0.24 advantage in this example. That is the comparison; subtracting fees from a value that already excluded them would count the shortfall twice.
Use the original quantities from the mint receipt for the holding benchmark. Rounded wallet displays can move a small result by enough to change its sign.
Risk analysis
- Technical: The pool and position manager are contract dependencies. Verify the deployment and retain the token ID and NFT ownership information.
- Economic: Price moves change composition. If ETH falls below an ETH/USDC range, the position becomes ETH-heavy just as ETH is losing value; above the range it becomes USDC-heavy and gives up further ETH upside. Fees may not cover the difference from holding.
- Operational: Collection, withdrawal, and rebalancing cost gas and may require swaps. Estimate the complete exit before concluding that a small fee balance is profit.
A November 2021 Topaze Blue / Bancor study of 17 Uniswap v3 pools found that 49.5% of liquidity providers had negative returns versus holding: $260.1m of impermanent loss against $199.3m in fees, from May 5 to September 20, 2021 (Loesch, Hindman, Richardson, and Welch). The share of wallets with negative returns varied by pool, from about 34% (FTM/ETH) to about 74% (MKR/ETH).
What I would record for a real comparison
I would save the mint and exit receipts, periodic token amounts, separately valued fees, and the holding benchmark at the same prices. One quiet week would describe one position over one path, not validate a range strategy.
At $200, the first useful outcome is being able to explain the accounting and withdraw the position. If that record is missing, I would not publish an annualized return.