diff --git a/contracts/solidity/NFTXLPStaking.sol b/contracts/solidity/NFTXLPStaking.sol index 17bc297..d3844c4 100644 --- a/contracts/solidity/NFTXLPStaking.sol +++ b/contracts/solidity/NFTXLPStaking.sol @@ -30,6 +30,9 @@ contract NFTXLPStaking is PausableUpgradeable { event PoolUpdated(uint256 vaultId, address pool); event FeesReceived(uint256 vaultId, uint256 amount); + event Deposit(uint256 vaultId, address stakingToken, uint256 amount, address account, uint256 timelockLength); + event Withdraw(uint256 vaultId, address stakingToken, uint256 amount, address account); + struct StakingPool { address stakingToken; address rewardToken; @@ -136,10 +139,13 @@ contract NFTXLPStaking is PausableUpgradeable { // Maintain the same timelock if they already have one. // We do this instead of patching in the token because // the xSLP contracts as currently deployed are not upgradeable. - xSLPToken.timelockMint(msg.sender, amount, currentTimelock-block.timestamp); + uint256 timestamp = currentTimelock-block.timestamp; + xSLPToken.timelockMint(msg.sender, amount, timestamp); + emit Deposit(vaultId, pool.stakingToken, amount, msg.sender, timestamp); } else { // Timelock for 2 seconds if they don't already have a timelock to prevent flash loans. xSLPToken.timelockMint(msg.sender, amount, 2); + emit Deposit(vaultId, pool.stakingToken, amount, msg.sender, 2); } } @@ -156,13 +162,14 @@ contract NFTXLPStaking is PausableUpgradeable { require(pool.stakingToken != address(0), "LPStaking: Nonexistent pool"); IERC20Upgradeable(pool.stakingToken).safeTransferFrom(msg.sender, address(this), amount); _rewardDistributionTokenAddr(pool).timelockMint(account, amount, timelockLength); + emit Deposit(vaultId, pool.stakingToken, amount, account, timelockLength); } function exit(uint256 vaultId) external { StakingPool memory pool = vaultStakingInfo[vaultId]; _distributeFees(vaultId); _claimRewards(pool, msg.sender); - _withdraw(pool, balanceOf(vaultId, msg.sender), msg.sender); + _withdraw(vaultId, pool, balanceOf(vaultId, msg.sender), msg.sender); } function emergencyExitAndClaim(address _stakingToken, address _rewardToken) external { @@ -171,14 +178,14 @@ contract NFTXLPStaking is PausableUpgradeable { require(isContract(address(dist)), "Not a pool"); _distributeFees(INFTXVault(_rewardToken).vaultId()); _claimRewards(pool, msg.sender); - _withdraw(pool, dist.balanceOf(msg.sender), msg.sender); + _withdraw(INFTXVault(_rewardToken).vaultId(), pool, dist.balanceOf(msg.sender), msg.sender); } function emergencyExit(address _stakingToken, address _rewardToken) external { StakingPool memory pool = StakingPool(_stakingToken, _rewardToken); TimelockRewardDistributionTokenImpl dist = _rewardDistributionTokenAddr(pool); require(isContract(address(dist)), "Not a pool"); - _withdraw(pool, dist.balanceOf(msg.sender), msg.sender); + _withdraw(INFTXVault(_rewardToken).vaultId(), pool, dist.balanceOf(msg.sender), msg.sender); } // function emergencyMigrate(uint256 vaultId) external { @@ -216,7 +223,7 @@ contract NFTXLPStaking is PausableUpgradeable { StakingPool memory pool = vaultStakingInfo[vaultId]; _distributeFees(vaultId); _claimRewards(pool, msg.sender); - _withdraw(pool, amount, msg.sender); + _withdraw(vaultId, pool, amount, msg.sender); } function claimRewards(uint256 vaultId) public { @@ -310,10 +317,11 @@ contract NFTXLPStaking is PausableUpgradeable { _rewardDistributionTokenAddr(pool).withdrawReward(account); } - function _withdraw(StakingPool memory pool, uint256 amount, address account) internal { + function _withdraw(uint256 vaultId, StakingPool memory pool, uint256 amount, address account) internal { require(pool.stakingToken != address(0), "LPStaking: Nonexistent pool"); _rewardDistributionTokenAddr(pool).burnFrom(account, amount); IERC20Upgradeable(pool.stakingToken).safeTransfer(account, amount); + emit Withdraw(vaultId, pool.stakingToken, amount, account); } function _deployDividendToken(StakingPool memory pool) internal returns (address) {