DODO mine test finished

This commit is contained in:
mingda
2020-09-22 00:47:50 +08:00
parent 4880b39e2a
commit 108cc2af1f
2 changed files with 173 additions and 3 deletions

View File

@@ -99,8 +99,8 @@ contract DODOMine is Ownable {
// ============ Ownable ============
function addLpToken(
uint256 _allocPoint,
address _lpToken,
uint256 _allocPoint,
bool _withUpdate
) public lpTokenNotExist(_lpToken) onlyOwner {
if (_withUpdate) {
@@ -160,7 +160,7 @@ contract DODOMine is Ownable {
uint256 length = poolInfos.length;
uint256 totalReward = 0;
for (uint256 pid = 0; pid < length; ++pid) {
if (userInfo[pid][msg.sender].amount == 0 || poolInfos[pid].allocPoint == 0) {
if (userInfo[pid][_user].amount == 0 || poolInfos[pid].allocPoint == 0) {
continue; // save gas
}
PoolInfo storage pool = poolInfos[pid];
@@ -187,6 +187,12 @@ contract DODOMine is Ownable {
return realizedReward[_user];
}
function getDlpMiningSpeed(address _lpToken) external view returns (uint256) {
uint256 pid = getPid(_lpToken);
PoolInfo storage pool = poolInfos[pid];
return dodoPerBlock.mul(pool.allocPoint).div(totalAllocPoint);
}
// ============ Update Pools ============
// Update reward vairables for all pools. Be careful of gas spending!
@@ -242,7 +248,7 @@ contract DODOMine is Ownable {
uint256 pid = getPid(_lpToken);
PoolInfo storage pool = poolInfos[pid];
UserInfo storage user = userInfo[pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
require(user.amount >= _amount, "withdraw too much");
updatePool(pid);
uint256 pending = DecimalMath.mul(user.amount, pool.accDODOPerShare).sub(user.rewardDebt);
safeDODOTransfer(msg.sender, pending);