From 84e73feb4518245acc7cece087a108c96a4edaca Mon Sep 17 00:00:00 2001 From: owen05 Date: Tue, 15 Sep 2020 17:52:24 +0800 Subject: [PATCH] Dodomine user rewardDebt bug fix --- contracts/token/DODOMine.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/token/DODOMine.sol b/contracts/token/DODOMine.sol index 61c00d4..b5b384d 100644 --- a/contracts/token/DODOMine.sol +++ b/contracts/token/DODOMine.sol @@ -55,7 +55,7 @@ contract DODOMine is Ownable { mapping(uint256 => mapping(address => UserInfo)) public userInfo; 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; // The block number when DODO mining starts. uint256 public startBlock; @@ -234,7 +234,7 @@ contract DODOMine is Ownable { } IERC20(pool.lpToken).safeTransferFrom(address(msg.sender), address(this), _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); } @@ -248,7 +248,7 @@ contract DODOMine is Ownable { uint256 pending = DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt); safeDODOTransfer(msg.sender, pending); 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); emit Withdraw(msg.sender, pid, _amount); } @@ -277,7 +277,7 @@ contract DODOMine is Ownable { UserInfo storage user = userInfo[pid][msg.sender]; updatePool(pid); 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); } @@ -294,7 +294,7 @@ contract DODOMine is Ownable { pending = pending.add( 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); }