# The rewards distribution in the NFTPositionManager is unfair

NFTPositionManager tracks reward balances in asset units instead of pool shares, so users who refresh their position after index growth capture disproportionate rewards.

- Payout: Audit contest
- Severity: medium
- Program: New Scope
- Found by: 000000
- Disclosed: 2024-06-27
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-06-new-scope-judging/issues/393
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-new-scope%3AM-6
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:second-order technique:source-review vuln:business-logic vuln:reward-distribution

**Target:** NFTPositionManager reward accounting (supply/borrow/withdraw/repay)
**Root cause:** _handleSupplies stores pool.getBalance (asset amount) as the reward basis rather than supplyShares; balances only refresh on user-triggered operations, so stale balances don't scale with the liquidity index while refreshed ones do.
**Steps:**
1. U1 and U2 each supply 100 tokens at liquidity index 1.5; both reward balances = 100.
2. Alice supplies 1000 and borrows 600 to raise liquidityRate; warp time so liquidityIndex grows to ~1.238.
3. U2 supplies 100 wei to trigger _updateReward, refreshing balance to ~123.8 while U1 stays at 100.
4. U3 supplies 110 fresh; reward balance = 110.
5. Observe U1 (largest actual pool balance) receives smallest rewards; frequent updaters over-earn.
**How found:** Code reading of _supply/_handleSupplies: noticed balance comes from pool.getBalance (assets) not shares, and that _updateReward only fires on user operations, so index growth is only reflected for users who transact.
**Exploitation:** Any user repeatedly supplies/withdraws dust to refresh their reward balance after index growth, capturing rewards proportional to inflated asset balance while passive users' balances stay stale; no capital beyond dust required.
**Insight:** In reward/staking accounting, check whether the tracked balance is shares or assets and whether it is lazily refreshed only on user interaction; stale asset-denominated balances diverge from true share value as the index grows.

## Proof of concept (copied exactly from the original report)

**Supply helper using asset amount for rewards**

```
function supplyForUser(address user, uint256 supplyAmount, uint256 tokenId, bool mintNewToken) public {
  uint256 mintAmount = supplyAmount;
  DataTypes.ExtraData memory data = DataTypes.ExtraData(bytes(''), bytes(''));
  INFTPositionManager.AssetOperationParams memory params =
    INFTPositionManager.AssetOperationParams(address(tokenA), user, supplyAmount, tokenId, data);

  \_mintAndApprove(user, tokenA, mintAmount, address(nftPositionManager));

  vm.startPrank(user);
  if (mintNewToken == true) {
    nftPositionManager.mint(address(pool));
  }
  nftPositionManager.supply(params);
  vm.stopPrank();
}
```

**Recommended fix using supplyShares**

```
function _supply(AssetOperationParams memory params) internal nonReentrant {
  pool.supply(params.asset, address(this), params.amount, params.tokenId, params.data);

57:  uint256 balance = pool.getBalance(params.asset, address(this), params.tokenId);
  _handleSupplies(address(pool), params.asset, params.tokenId, balance);
}
```

