最近看了sushi的流动性挖矿合约,这块有点疑问
function deposit(uint256 _pid, uint256 _amount) public{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if(user.amount > 0) {
uint256 pending = user.amount.mul(pool.accSushiPerShare).div(1e12).sub(user.rewardDebt);
safeSushiTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accSushiPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
这里是用户刚质押LP进来的操作,那为什么马上计算了user.rewardDebt,这个值不是用户已提取的收益吗,这里用户好像都还没有收益呀?