-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
def get_unclaimed_fees(token_id: int):
logger.info(f"--- Starting fee calculation for Token ID: {token_id} ---")
# Step 1: Call the functions that we have proven to work.
liquidity = pos_contract.functions.getPositionLiquidity(token_id).call()
logger.info(f"getPositionLiquidity returned: {liquidity}")
if liquidity == 0:
logger.warning(f"Position has zero liquidity.")
return 0.0, 0.0, "N/A", "N/A"
pool_key, info = pos_contract.functions.getPoolAndPositionInfo(token_id).call()
logger.info(f"getPoolAndPositionInfo returned data successfully.")
# Step 2: Decode the packed ticks from the 'info' variable.
tick_lower, tick_upper = decode_position_info(info)
logger.info(f"Decoded Ticks: Lower={tick_lower}, Upper={tick_upper}")
# Step 3: Get the CURRENT total fee growth from the official StateView contract.
# This call is the one that might fail depending on the token's state.
current0, current1 = svc_contract.functions.getFeeGrowthInside(pool_key, tick_lower, tick_upper).call()
logger.info(f"StateView getFeeGrowthInside returned current fees successfully.")
# Step 4: Assume the "last collected" fee growth is 0.
feeGrowthInside0LastX128 = 0
feeGrowthInside1LastX128 = 0
log:
2025-08-28 16:47:20,225 - INFO - Connected to Ethereum Mainnet.
2025-08-28 16:47:20,229 - INFO - --- Starting fee calculation for Token ID: 52700 ---
2025-08-28 16:47:21,319 - INFO - getPositionLiquidity returned: 2132995710697919
2025-08-28 16:47:22,399 - INFO - getPoolAndPositionInfo returned data successfully.
2025-08-28 16:47:22,399 - INFO - Decoded Ticks: Lower=-3446421, Upper=86416
2025-08-28 16:47:23,357 - ERROR - Execution failed for Token ID 52700. This is likely due to the specific on-chain state of this NFT, which causes the contract to revert.
2025-08-28 16:47:23,357 - ERROR - Details: ('execution reverted', '0x')
Expected Behavior
return
feeGrowthInside0LastX128
feeGrowthInside1LastX128
To Reproduce
No response
Additional context
No response