Merge pull request #4 from DODOEX/bug-fix
Dodomine user rewardDebt bug fix
This commit is contained in:
@@ -55,7 +55,7 @@ contract DODOMine is Ownable {
|
|||||||
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
|
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
|
||||||
mapping(address => uint256) public realizedReward;
|
mapping(address => uint256) public realizedReward;
|
||||||
|
|
||||||
// Total allocation poitns. Must be the sum of all allocation points in all pools.
|
// Total allocation points. Must be the sum of all allocation points in all pools.
|
||||||
uint256 public totalAllocPoint = 0;
|
uint256 public totalAllocPoint = 0;
|
||||||
// The block number when DODO mining starts.
|
// The block number when DODO mining starts.
|
||||||
uint256 public startBlock;
|
uint256 public startBlock;
|
||||||
@@ -234,7 +234,7 @@ contract DODOMine is Ownable {
|
|||||||
}
|
}
|
||||||
IERC20(pool.lpToken).safeTransferFrom(address(msg.sender), address(this), _amount);
|
IERC20(pool.lpToken).safeTransferFrom(address(msg.sender), address(this), _amount);
|
||||||
user.amount = user.amount.add(_amount);
|
user.amount = user.amount.add(_amount);
|
||||||
user.rewardDebt = DecimalMath.divFloor(user.amount, pool.accDODOPerShare);
|
user.rewardDebt = DecimalMath.mul(user.amount, pool.accDODOPerShare);
|
||||||
emit Deposit(msg.sender, pid, _amount);
|
emit Deposit(msg.sender, pid, _amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ contract DODOMine is Ownable {
|
|||||||
uint256 pending = DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt);
|
uint256 pending = DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt);
|
||||||
safeDODOTransfer(msg.sender, pending);
|
safeDODOTransfer(msg.sender, pending);
|
||||||
user.amount = user.amount.sub(_amount);
|
user.amount = user.amount.sub(_amount);
|
||||||
user.rewardDebt = DecimalMath.divFloor(user.amount, pool.accDODOPerShare);
|
user.rewardDebt = DecimalMath.mul(user.amount, pool.accDODOPerShare);
|
||||||
IERC20(pool.lpToken).safeTransfer(address(msg.sender), _amount);
|
IERC20(pool.lpToken).safeTransfer(address(msg.sender), _amount);
|
||||||
emit Withdraw(msg.sender, pid, _amount);
|
emit Withdraw(msg.sender, pid, _amount);
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ contract DODOMine is Ownable {
|
|||||||
UserInfo storage user = userInfo[pid][msg.sender];
|
UserInfo storage user = userInfo[pid][msg.sender];
|
||||||
updatePool(pid);
|
updatePool(pid);
|
||||||
uint256 pending = DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt);
|
uint256 pending = DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt);
|
||||||
user.rewardDebt = DecimalMath.divFloor(user.amount, pool.accDODOPerShare);
|
user.rewardDebt = DecimalMath.mul(user.amount, pool.accDODOPerShare);
|
||||||
safeDODOTransfer(msg.sender, pending);
|
safeDODOTransfer(msg.sender, pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ contract DODOMine is Ownable {
|
|||||||
pending = pending.add(
|
pending = pending.add(
|
||||||
DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt)
|
DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt)
|
||||||
);
|
);
|
||||||
user.rewardDebt = DecimalMath.divFloor(user.amount, pool.accDODOPerShare);
|
user.rewardDebt = DecimalMath.mul(user.amount, pool.accDODOPerShare);
|
||||||
}
|
}
|
||||||
safeDODOTransfer(msg.sender, pending);
|
safeDODOTransfer(msg.sender, pending);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user