From 7acd630e506bf394c4c93e61cdc5b025357a5d5d Mon Sep 17 00:00:00 2001 From: owen05 Date: Mon, 28 Jun 2021 23:51:34 +0800 Subject: [PATCH] update --- contracts/DODOToken/DODOMineV3/BaseMine.sol | 2 +- contracts/DODOToken/DODOMineV3/ERC20Mine.sol | 7 ++++--- contracts/Factory/ERC20V2Factory.sol | 4 ++-- contracts/Factory/Registries/DODOMineV3Registry.sol | 8 ++++++++ contracts/SmartRoute/proxies/DODOMineV3Proxy.sol | 4 +++- contracts/SmartRoute/proxies/DODORouteProxy.sol | 2 ++ contracts/external/ERC20/CustomERC20.sol | 4 ++-- 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/contracts/DODOToken/DODOMineV3/BaseMine.sol b/contracts/DODOToken/DODOMineV3/BaseMine.sol index bab854a..9830983 100644 --- a/contracts/DODOToken/DODOMineV3/BaseMine.sol +++ b/contracts/DODOToken/DODOMineV3/BaseMine.sol @@ -173,7 +173,7 @@ contract BaseMine is InitializableOwnable { rt.rewardVault = address(new RewardVault(rewardToken)); uint256 rewardAmount = rewardPerBlock.mul(endBlock.sub(startBlock)); - IERC20(rewardToken).transfer(rt.rewardVault, rewardAmount); + IERC20(rewardToken).safeTransfer(rt.rewardVault, rewardAmount); RewardVault(rt.rewardVault).syncValue(); emit NewRewardToken(len, rewardToken); diff --git a/contracts/DODOToken/DODOMineV3/ERC20Mine.sol b/contracts/DODOToken/DODOMineV3/ERC20Mine.sol index 38da2c5..996f566 100644 --- a/contracts/DODOToken/DODOMineV3/ERC20Mine.sol +++ b/contracts/DODOToken/DODOMineV3/ERC20Mine.sol @@ -10,9 +10,10 @@ pragma experimental ABIEncoderV2; import {SafeERC20} from "../../lib/SafeERC20.sol"; import {IERC20} from "../../intf/IERC20.sol"; import {SafeMath} from "../../lib/SafeMath.sol"; +import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol"; import {BaseMine} from "./BaseMine.sol"; -contract ERC20Mine is BaseMine { +contract ERC20Mine is ReentrancyGuard, BaseMine { using SafeERC20 for IERC20; using SafeMath for uint256; @@ -32,7 +33,7 @@ contract ERC20Mine is BaseMine { // ============ Deposit && Withdraw && Exit ============ - function deposit(uint256 amount) external { + function deposit(uint256 amount) external preventReentrant { require(amount > 0, "DODOMineV3: CANNOT_DEPOSIT_ZERO"); _updateAllReward(msg.sender); @@ -47,7 +48,7 @@ contract ERC20Mine is BaseMine { emit Deposit(msg.sender, actualStakeAmount); } - function withdraw(uint256 amount) external { + function withdraw(uint256 amount) external preventReentrant { require(amount > 0, "DODOMineV3: CANNOT_WITHDRAW_ZERO"); _updateAllReward(msg.sender); diff --git a/contracts/Factory/ERC20V2Factory.sol b/contracts/Factory/ERC20V2Factory.sol index 1de61d3..7c1b094 100644 --- a/contracts/Factory/ERC20V2Factory.sol +++ b/contracts/Factory/ERC20V2Factory.sol @@ -73,7 +73,7 @@ contract ERC20V2Factory is InitializableOwnable { uint256 totalSupply, string memory name, string memory symbol, - uint256 decimals + uint8 decimals ) external returns (address newERC20) { newERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_ERC20_TEMPLATE_); IStdERC20(newERC20).init(msg.sender, totalSupply, name, symbol, decimals); @@ -85,7 +85,7 @@ contract ERC20V2Factory is InitializableOwnable { uint256 initSupply, string memory name, string memory symbol, - uint256 decimals, + uint8 decimals, uint256 tradeBurnRatio, uint256 tradeFeeRatio, address teamAccount, diff --git a/contracts/Factory/Registries/DODOMineV3Registry.sol b/contracts/Factory/Registries/DODOMineV3Registry.sol index c9af03d..46457ba 100644 --- a/contracts/Factory/Registries/DODOMineV3Registry.sol +++ b/contracts/Factory/Registries/DODOMineV3Registry.sol @@ -39,6 +39,10 @@ contract DODOMineV3Registry is InitializableOwnable, IDODOMineV3Registry { // ============ Events ============ event NewMineV3(address mine, address stakeToken, bool isLpToken); event RemoveMineV3(address mine, address stakeToken); + event addAdmin(address admin); + event removeAdmin(address admin); + event addSingleToken(address token); + event removeSingleToken(address token); function addMineV3( @@ -86,17 +90,21 @@ contract DODOMineV3Registry is InitializableOwnable, IDODOMineV3Registry { function addAdminList (address contractAddr) external onlyOwner { isAdminListed[contractAddr] = true; + emit addAdmin(contractAddr); } function removeAdminList (address contractAddr) external onlyOwner { isAdminListed[contractAddr] = false; + emit removeAdmin(contractAddr); } function addSingleTokenList(address token) external onlyOwner { singleTokenList[token] = true; + emit addSingleToken(token); } function removeSingleTokenList(address token) external onlyOwner { singleTokenList[token] = false; + emit removeSingleToken(token); } } \ No newline at end of file diff --git a/contracts/SmartRoute/proxies/DODOMineV3Proxy.sol b/contracts/SmartRoute/proxies/DODOMineV3Proxy.sol index 5266cd1..c44c884 100644 --- a/contracts/SmartRoute/proxies/DODOMineV3Proxy.sol +++ b/contracts/SmartRoute/proxies/DODOMineV3Proxy.sol @@ -50,6 +50,7 @@ contract DODOMineV3Proxy is InitializableOwnable { event DepositRewardToVault(address mine, address rewardToken, uint256 amount); event DepositRewardToMine(address mine, address rewardToken, uint256 amount); event CreateMineV3(address account, address mineV3); + event ChangeMineV3Template(address mineV3); constructor( address cloneFactory, @@ -125,7 +126,8 @@ contract DODOMineV3Proxy is InitializableOwnable { // ============ Admin Operation Functions ============ - function updateMineV2Template(address _newMineV3Template) external onlyOwner { + function updateMineV3Template(address _newMineV3Template) external onlyOwner { _MINEV3_TEMPLATE_ = _newMineV3Template; + emit ChangeMineV3Template(_newMineV3Template); } } diff --git a/contracts/SmartRoute/proxies/DODORouteProxy.sol b/contracts/SmartRoute/proxies/DODORouteProxy.sol index bdfe9a6..3cc091a 100644 --- a/contracts/SmartRoute/proxies/DODORouteProxy.sol +++ b/contracts/SmartRoute/proxies/DODORouteProxy.sol @@ -195,6 +195,8 @@ contract DODORouteProxy { if(assetFrom[i-1] == address(this)) { uint256 curAmount = curTotalAmount.div(curTotalWeight).mul(curPoolInfo.weight); + //can improved + // uint256 curAmount = curTotalAmount.mul(curPoolInfo.weight).div(curTotalWeight); if(curPoolInfo.poolEdition == 1) { //For using transferFrom pool (like dodoV1, Curve) diff --git a/contracts/external/ERC20/CustomERC20.sol b/contracts/external/ERC20/CustomERC20.sol index f50f7e2..1f6cb29 100644 --- a/contracts/external/ERC20/CustomERC20.sol +++ b/contracts/external/ERC20/CustomERC20.sol @@ -14,7 +14,7 @@ contract CustomERC20 is InitializableOwnable { using SafeMath for uint256; string public name; - uint256 public decimals; + uint8 public decimals; string public symbol; uint256 public totalSupply; @@ -39,7 +39,7 @@ contract CustomERC20 is InitializableOwnable { uint256 _initSupply, string memory _name, string memory _symbol, - uint256 _decimals, + uint8 _decimals, uint256 _tradeBurnRatio, uint256 _tradeFeeRatio, address _team,