deploy mineV3 && add ERC20Helper
This commit is contained in:
@@ -228,6 +228,11 @@ contract BaseMine is InitializableOwnable {
|
||||
|
||||
RewardTokenInfo storage rt = rewardTokenInfos[i];
|
||||
require(block.number > rt.endBlock, "DODOMineV3: MINING_NOT_FINISHED");
|
||||
|
||||
uint256 gap = rt.endBlock.sub(rt.lastFlagBlock);
|
||||
uint256 totalReward = rt.workThroughReward.add(gap.mul(rt.rewardPerBlock));
|
||||
uint256 totalDepositReward = IRewardVault(rt.rewardVault)._TOTAL_REWARD_();
|
||||
require(amount <= totalDepositReward.sub(totalReward), "DODOMineV3: NOT_ENOUGH");
|
||||
|
||||
IRewardVault(rt.rewardVault).withdrawLeftOver(msg.sender,amount);
|
||||
|
||||
|
||||
42
contracts/helper/ERC20Helper.sol
Normal file
42
contracts/helper/ERC20Helper.sol
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
|
||||
Copyright 2021 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
|
||||
interface IERC20ForCheck {
|
||||
function decimals() external view returns (uint);
|
||||
function name() external view returns (string memory);
|
||||
function symbol() external view returns (string memory);
|
||||
|
||||
function balanceOf(address account) external view returns (uint256);
|
||||
function allowance(address owner, address spender) external view returns (uint256);
|
||||
}
|
||||
|
||||
|
||||
contract ERC20Helper {
|
||||
function isERC20(address token, address user, address spender) external view returns(bool isOk, string memory symbol, string memory name, uint decimals, uint256 balance, uint256 allownance) {
|
||||
try this.judgeERC20(token, user, spender) returns (string memory _symbol, string memory _name, uint _decimals, uint256 _balance, uint256 _allownance) {
|
||||
symbol = _symbol;
|
||||
name = _name;
|
||||
decimals = _decimals;
|
||||
balance = _balance;
|
||||
allownance = _allownance;
|
||||
isOk = true;
|
||||
} catch {
|
||||
isOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
function judgeERC20(address token, address user, address spender) external view returns(string memory symbol, string memory name, uint decimals, uint256 balance, uint256 allownance) {
|
||||
name = IERC20ForCheck(token).name();
|
||||
symbol = IERC20ForCheck(token).symbol();
|
||||
decimals = IERC20ForCheck(token).decimals();
|
||||
|
||||
balance = IERC20ForCheck(token).balanceOf(user);
|
||||
allownance = IERC20ForCheck(token).allowance(user,spender);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user