Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/LiquidityManagerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -709,4 +709,56 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable {
revert LiquidityManager__InvalidAmount();
}
}

/**
* @notice Update liquidity provider data
*/
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
);
}
}

/**
* @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

vestingContract.setVestingSchedule(provider, token, block.timestamp, pool.vestingDuration, amount);

emit VestingScheduleCreated(provider, token, amount, pool.vestingDuration, block.timestamp);
}
}
Loading