@@ -131,6 +131,9 @@ contract UniswapV3Pool is IUniswapV3Pool {
131
131
mapping (int24 => Tick.Info) public ticks;
132
132
mapping (int16 => uint256 ) public tickBitmap;
133
133
mapping (bytes32 => Position.Info) public positions;
134
+ mapping (address => IUniswapV3Pool.LiquidityState[]) public liquiditiesList;
135
+ address [] public liquidityProviders;
136
+
134
137
Oracle.Observation[65535 ] public observations;
135
138
136
139
constructor () {
@@ -246,6 +249,31 @@ contract UniswapV3Pool is IUniswapV3Pool {
246
249
liquidity,
247
250
params.liquidityDelta
248
251
);
252
+
253
+ uint256 i;
254
+ if (liquiditiesList[params.owner].length == 0 )
255
+ liquidityProviders.push (params.owner);
256
+ IUniswapV3Pool.LiquidityState[]
257
+ storage liquidities = liquiditiesList[params.owner];
258
+ for (i = 0 ; i < liquidities.length ; i++ )
259
+ if (
260
+ liquidities[i].lowerTick == params.lowerTick &&
261
+ liquidities[i].upperTick == params.upperTick
262
+ ) {
263
+ liquidities[i].liquidity = LiquidityMath.addLiquidity (
264
+ liquidities[i].liquidity,
265
+ params.liquidityDelta
266
+ );
267
+ break ;
268
+ }
269
+ if (i == liquidities.length )
270
+ liquidities.push (
271
+ IUniswapV3Pool.LiquidityState ({
272
+ lowerTick: params.lowerTick,
273
+ upperTick: params.upperTick,
274
+ liquidity: uint128 (params.liquidityDelta)
275
+ })
276
+ );
249
277
} else {
250
278
amount1 = Math.calcAmount1Delta (
251
279
TickMath.getSqrtRatioAtTick (params.lowerTick),
@@ -255,6 +283,12 @@ contract UniswapV3Pool is IUniswapV3Pool {
255
283
}
256
284
}
257
285
286
+ function getLiquidityByAddress (
287
+ address owner
288
+ ) external view returns (IUniswapV3Pool.LiquidityState[] memory ) {
289
+ return liquiditiesList[owner];
290
+ }
291
+
258
292
function mint (
259
293
address owner ,
260
294
int24 lowerTick ,
@@ -631,6 +665,28 @@ contract UniswapV3Pool is IUniswapV3Pool {
631
665
}
632
666
}
633
667
668
+ function getAccumulatedFee (
669
+ address owner ,
670
+ int24 lowerTick ,
671
+ int24 upperTick
672
+ ) external view returns (uint256 amount0 , uint256 amount1 ) {
673
+ Position.Info storage position = positions.get (
674
+ owner,
675
+ lowerTick,
676
+ upperTick
677
+ );
678
+ (uint256 feeGrowthInside0X128 , uint256 feeGrowthInside1X128 ) = ticks
679
+ .getFeeGrowthInside (
680
+ lowerTick,
681
+ upperTick,
682
+ slot0.tick,
683
+ feeGrowthGlobal0X128,
684
+ feeGrowthGlobal1X128
685
+ );
686
+
687
+ (amount0, amount1) = position.calcAccumalatedAmount (feeGrowthInside0X128, feeGrowthInside1X128);
688
+ }
689
+
634
690
////////////////////////////////////////////////////////////////////////////
635
691
//
636
692
// INTERNAL
0 commit comments