Skip to content

Commit e5547d0

Browse files
saucepointhensha256marktoda
authored
Natspec: Inflated feeGrowthGlobal (#906)
document inflated feeGrowthGlobal possibility Co-authored-by: Alice <34962750+hensha256@users.noreply.github.com> Co-authored-by: marktoda <toda.mark@gmail.com>
1 parent b619b67 commit e5547d0

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/interfaces/IPoolManager.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload, IExttload {
136136
/// @param hookData The data to pass through to the add/removeLiquidity hooks
137137
/// @return callerDelta The balance delta of the caller of modifyLiquidity. This is the total of both principal, fee deltas, and hook deltas if applicable
138138
/// @return feesAccrued The balance delta of the fees generated in the liquidity range. Returned for informational purposes
139+
/// @dev Note that feesAccrued can be artificially inflated by a malicious actor and integrators should be careful using the value
140+
/// For pools with a single liquidity position, actors can donate to themselves to inflate feeGrowthGlobal (and consequently feesAccrued)
141+
/// atomically donating and collecting fees in the same unlockCallback may make the inflated value more extreme
139142
function modifyLiquidity(PoolKey memory key, ModifyLiquidityParams memory params, bytes calldata hookData)
140143
external
141144
returns (BalanceDelta callerDelta, BalanceDelta feesAccrued);

src/libraries/Pool.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ library Pool {
7676
uint256 feeGrowthOutside1X128;
7777
}
7878

79-
/// @dev The state of a pool
79+
/// @notice The state of a pool
80+
/// @dev Note that feeGrowthGlobal can be artificially inflated
81+
/// For pools with a single liquidity position, actors can donate to themselves to freely inflate feeGrowthGlobal
82+
/// atomically donating and collecting fees in the same unlockCallback may make the inflated value more extreme
8083
struct State {
8184
Slot0 slot0;
8285
uint256 feeGrowthGlobal0X128;

src/libraries/StateLibrary.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ library StateLibrary {
150150
* @param poolId The ID of the pool.
151151
* @return feeGrowthGlobal0 The global fee growth for token0.
152152
* @return feeGrowthGlobal1 The global fee growth for token1.
153+
* @dev Note that feeGrowthGlobal can be artificially inflated
154+
* For pools with a single liquidity position, actors can donate to themselves to freely inflate feeGrowthGlobal
155+
* atomically donating and collecting fees in the same unlockCallback may make the inflated value more extreme
153156
*/
154157
function getFeeGrowthGlobals(IPoolManager manager, PoolId poolId)
155158
internal

0 commit comments

Comments
 (0)