diff --git a/contracts/mainnet/connectors/uniswap/v3_staker/events.sol b/contracts/mainnet/connectors/uniswap/v3_staker/events.sol index fa8bbebf..99b98a61 100644 --- a/contracts/mainnet/connectors/uniswap/v3_staker/events.sol +++ b/contracts/mainnet/connectors/uniswap/v3_staker/events.sol @@ -3,6 +3,8 @@ pragma solidity ^0.7.0; contract Events { event LogDeposit(uint256 tokenId); + event LogDepositAndStake(uint256 tokenId, bytes32 incentiveId); + event LogWithdraw(uint256 indexed tokenId); event LogDepositTransfer(uint256 indexed tokenId, address to); diff --git a/contracts/mainnet/connectors/uniswap/v3_staker/main.sol b/contracts/mainnet/connectors/uniswap/v3_staker/main.sol index 2da11c59..617bc8e5 100644 --- a/contracts/mainnet/connectors/uniswap/v3_staker/main.sol +++ b/contracts/mainnet/connectors/uniswap/v3_staker/main.sol @@ -34,6 +34,51 @@ abstract contract UniswapResolver is Helpers, Events { _eventParam = abi.encode(_tokenId); } + /** + * @dev Deposit and Stake NFT token + * @notice To Deposit and Stake NFT for Staking + * @param _rewardToken _rewardToken address + * @param _startTime stake start time + * @param _endTime stake end time + * @param _refundee refundee address + * @param _tokenId NFT LP token id + */ + function depositAndStake ( + address _rewardToken, + uint256 _startTime, + uint256 _endTime, + address _refundee, + uint256 _tokenId + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + if (_tokenId == 0) _tokenId = _getLastNftId(address(this)); + nftManager.safeTransferFrom( + address(this), + address(staker), + _tokenId, + "" + ); + + address poolAddr = getPoolAddress(_tokenId); + + IUniswapV3Pool pool = IUniswapV3Pool(poolAddr); + IUniswapV3Staker.IncentiveKey memory _key = IUniswapV3Staker + .IncentiveKey( + IERC20Minimal(_rewardToken), + pool, + _startTime, + _endTime, + _refundee + ); + _stake(_tokenId, _key); + + _eventName = "LogDepositAndStake(uint256,bytes32)"; + _eventParam = abi.encode(_tokenId, keccak256(abi.encode(_key))); + } + /** * @dev Deposit Transfer * @notice Transfer deposited NFT token @@ -45,7 +90,6 @@ abstract contract UniswapResolver is Helpers, Events { payable returns (string memory _eventName, bytes memory _eventParam) { - if (_tokenId == 0) _tokenId = _getLastNftId(address(this)); staker.transferDeposit(_tokenId, _to); _eventName = "LogDepositTransfer(uint256,address)"; @@ -62,7 +106,6 @@ abstract contract UniswapResolver is Helpers, Events { payable returns (string memory _eventName, bytes memory _eventParam) { - if (_tokenId == 0) _tokenId = _getLastNftId(address(this)); staker.withdrawToken(_tokenId, address(this), ""); _eventName = "LogWithdraw(uint256)"; @@ -78,7 +121,7 @@ abstract contract UniswapResolver is Helpers, Events { * @param _refundee refundee address * @param _tokenId NFT LP token id */ - function stake( + function stake ( address _rewardToken, uint256 _startTime, uint256 _endTime, @@ -89,7 +132,6 @@ abstract contract UniswapResolver is Helpers, Events { payable returns (string memory _eventName, bytes memory _eventParam) { - if (_tokenId == 0) _tokenId = _getLastNftId(address(this)); address poolAddr = getPoolAddress(_tokenId); IUniswapV3Pool pool = IUniswapV3Pool(poolAddr); @@ -127,7 +169,6 @@ abstract contract UniswapResolver is Helpers, Events { payable returns (string memory _eventName, bytes memory _eventParam) { - if (_tokenId == 0) _tokenId = _getLastNftId(address(this)); address poolAddr = getPoolAddress(_tokenId); IUniswapV3Pool pool = IUniswapV3Pool(poolAddr);