From 32675889b013c266e86319f8116a9534605b9c82 Mon Sep 17 00:00:00 2001 From: malgus01 Date: Mon, 22 Sep 2025 08:41:00 -0700 Subject: [PATCH 1/5] feat: Add _updateLiquidityProvider Internal Function --- src/LiquidityManagerV2.sol | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/LiquidityManagerV2.sol b/src/LiquidityManagerV2.sol index 771732b..f25df6e 100644 --- a/src/LiquidityManagerV2.sol +++ b/src/LiquidityManagerV2.sol @@ -709,4 +709,39 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable { revert LiquidityManager__InvalidAmount(); } } + + function _updateLiquidityProvider( + bytes32 poolId, + address provider, + uint256 totalAmount, + uint256 liquidity + ) internal { + PoolInfo storage pool = poolInfo[poolId]; + LiquidityProvider storage lpData = pool.providers[provider]; + + // If first time provider, add to list + if (lpData.amountProvided == 0) { + pool.providersList.push(provider); + pool.providersCount++; + } + + lpData.amountProvided += totalAmount; + lpData.lastContribution = block.timestamp; + pool.totalLiquidity += totalAmount; + + // Check threshold and set up vesting + if (!lpData.hasVested && lpData.amountProvided >= pool.liquidityThreshold) { + _setupVesting(poolId, provider, lpData.amountProvided); + lpData.hasVested = true; + lpData.lockEndTime = block.timestamp + pool.vestingDuration; + + emit LiquidityThresholdReached( + address(poolKeys[poolId].currency0), + address(poolKeys[poolId].currency1), + poolId, + pool.totalLiquidity, + block.timestamp + ); + } + } } From 68bc844772a5e4c743f04d98739768a95ab6cbf7 Mon Sep 17 00:00:00 2001 From: malgus01 Date: Mon, 22 Sep 2025 08:41:28 -0700 Subject: [PATCH 2/5] feat: Add _updateLiquidityProvider Internal Function Natspec Comment --- src/LiquidityManagerV2.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LiquidityManagerV2.sol b/src/LiquidityManagerV2.sol index f25df6e..9a313f5 100644 --- a/src/LiquidityManagerV2.sol +++ b/src/LiquidityManagerV2.sol @@ -710,6 +710,9 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable { } } + /** + * @notice Update liquidity provider data + */ function _updateLiquidityProvider( bytes32 poolId, address provider, From 1f7e669205d96f0cada66c4e80351c438c5929a7 Mon Sep 17 00:00:00 2001 From: malgus01 Date: Mon, 22 Sep 2025 08:41:54 -0700 Subject: [PATCH 3/5] feat: Add _setupVesting Internal Function --- src/LiquidityManagerV2.sol | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/LiquidityManagerV2.sol b/src/LiquidityManagerV2.sol index 9a313f5..edefe24 100644 --- a/src/LiquidityManagerV2.sol +++ b/src/LiquidityManagerV2.sol @@ -747,4 +747,19 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable { ); } } + + function _setupVesting(bytes32 poolId, address provider, uint256 amount) internal { + PoolInfo storage pool = poolInfo[poolId]; + address token = address(poolKeys[poolId].currency0); // Use token0 for vesting + + vestingContract.setVestingSchedule( + provider, + token, + block.timestamp, + pool.vestingDuration, + amount + ); + + emit VestingScheduleCreated(provider, token, amount, pool.vestingDuration, block.timestamp); + } } From da90b7bb02fd6440b8a1fd73240378f83edce28a Mon Sep 17 00:00:00 2001 From: malgus01 Date: Mon, 22 Sep 2025 08:42:21 -0700 Subject: [PATCH 4/5] feat: Add _setupVesting Internal Function Natspec Comments --- src/LiquidityManagerV2.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LiquidityManagerV2.sol b/src/LiquidityManagerV2.sol index edefe24..0995c91 100644 --- a/src/LiquidityManagerV2.sol +++ b/src/LiquidityManagerV2.sol @@ -748,6 +748,9 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable { } } + /** + * @notice Set up vesting schedule for liquidity provider + */ function _setupVesting(bytes32 poolId, address provider, uint256 amount) internal { PoolInfo storage pool = poolInfo[poolId]; address token = address(poolKeys[poolId].currency0); // Use token0 for vesting From a43bf25f9a17332c9a24e7d02a5fefb4a1e59004 Mon Sep 17 00:00:00 2001 From: malgus01 Date: Mon, 22 Sep 2025 08:42:52 -0700 Subject: [PATCH 5/5] feat: forge fmt --- src/LiquidityManagerV2.sol | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/LiquidityManagerV2.sol b/src/LiquidityManagerV2.sol index 0995c91..eeabf2d 100644 --- a/src/LiquidityManagerV2.sol +++ b/src/LiquidityManagerV2.sol @@ -718,7 +718,9 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable { address provider, uint256 totalAmount, uint256 liquidity - ) internal { + ) + internal + { PoolInfo storage pool = poolInfo[poolId]; LiquidityProvider storage lpData = pool.providers[provider]; @@ -737,12 +739,12 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable { _setupVesting(poolId, provider, lpData.amountProvided); lpData.hasVested = true; lpData.lockEndTime = block.timestamp + pool.vestingDuration; - + emit LiquidityThresholdReached( - address(poolKeys[poolId].currency0), - address(poolKeys[poolId].currency1), - poolId, - pool.totalLiquidity, + address(poolKeys[poolId].currency0), + address(poolKeys[poolId].currency1), + poolId, + pool.totalLiquidity, block.timestamp ); } @@ -754,14 +756,8 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable { function _setupVesting(bytes32 poolId, address provider, uint256 amount) internal { PoolInfo storage pool = poolInfo[poolId]; address token = address(poolKeys[poolId].currency0); // Use token0 for vesting - - vestingContract.setVestingSchedule( - provider, - token, - block.timestamp, - pool.vestingDuration, - amount - ); + + vestingContract.setVestingSchedule(provider, token, block.timestamp, pool.vestingDuration, amount); emit VestingScheduleCreated(provider, token, amount, pool.vestingDuration, block.timestamp); }