Skip to content

Commit cf27919

Browse files
author
tyranis0x01
authored
Merge pull request #64 from malgus01/dev-branch
feat: add position management and liquidity calculation to LiquidityManagerV2
2 parents 6ec371a + 7d09f7a commit cf27919

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

src/LiquidityManagerV2.sol

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,8 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable {
741741
lpData.lockEndTime = block.timestamp + pool.vestingDuration;
742742

743743
emit LiquidityThresholdReached(
744-
address(poolKeys[poolId].currency0),
745-
address(poolKeys[poolId].currency1),
744+
Currency.unwrap(poolKeys[poolId].currency0),
745+
Currency.unwrap(poolKeys[poolId].currency1),
746746
poolId,
747747
pool.totalLiquidity,
748748
block.timestamp
@@ -755,10 +755,48 @@ contract LiquidityManagerV2 is Ownable, ReentrancyGuard, Pausable {
755755
*/
756756
function _setupVesting(bytes32 poolId, address provider, uint256 amount) internal {
757757
PoolInfo storage pool = poolInfo[poolId];
758-
address token = address(poolKeys[poolId].currency0); // Use token0 for vesting
758+
address token = Currency.unwrap(poolKeys[poolId].currency0); // Use token0 for vesting
759759

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

762762
emit VestingScheduleCreated(provider, token, amount, pool.vestingDuration, block.timestamp);
763763
}
764+
765+
/**
766+
* @notice Create a position record
767+
*/
768+
function _createPosition(
769+
address user,
770+
address token0,
771+
address token1,
772+
uint24 fee,
773+
int24 tickLower,
774+
int24 tickUpper,
775+
uint256 liquidity,
776+
uint256 amount0,
777+
uint256 amount1
778+
)
779+
internal
780+
{
781+
userPositions[user].push(
782+
LiquidityPosition({
783+
token0: token0,
784+
token1: token1,
785+
fee: fee,
786+
tickLower: tickLower,
787+
tickUpper: tickUpper,
788+
liquidity: liquidity,
789+
token0Amount: amount0,
790+
token1Amount: amount1,
791+
timestamp: block.timestamp,
792+
active: true
793+
})
794+
);
795+
}
796+
797+
function _calculateLiquidity(uint256 amount0, uint256 amount1) internal pure returns (uint256) {
798+
// Simplified liquidity calculation
799+
// In practice, this would use Uniswap V4's math libraries
800+
return (amount0 + amount1) / 2;
801+
}
764802
}

0 commit comments

Comments
 (0)