diff --git a/contracts/DODOToken/DODOBscToken.sol b/contracts/DODOToken/DODOBscToken.sol index 8aeb597..66fc2b6 100644 --- a/contracts/DODOToken/DODOBscToken.sol +++ b/contracts/DODOToken/DODOBscToken.sol @@ -72,8 +72,8 @@ contract DODOBscToken is InitializableOwnable { return allowed[owner][spender]; } - function redeem(uint256 amount, uint256 value, address redeemToEthAccount) external { + require(balances[msg.sender] >= value, "DODOBscToken: NOT_ENOUGH"); balances[msg.sender] = balances[msg.sender].sub(value); totalSupply = totalSupply.sub(value); emit Redeem(msg.sender, redeemToEthAccount, value); diff --git a/contracts/DODOToken/DODOCirculationHelper.sol b/contracts/DODOToken/DODOCirculationHelper.sol index 3370127..5b57bbd 100644 --- a/contracts/DODOToken/DODOCirculationHelper.sol +++ b/contracts/DODOToken/DODOCirculationHelper.sol @@ -30,9 +30,23 @@ contract DODOCirculationHelper is InitializableOwnable { _DODO_TOKEN_ = dodoToken; } - function addLockedContractAddress(address lockedContract) external onlyOwner {} // todo + function addLockedContractAddress(address lockedContract) external onlyOwner { + require(lockedContract != address(0)); + _LOCKED_CONTRACT_ADDRESS_.push(lockedContract); + } - function removeLockedContractAddress(address lockedContract) external onlyOwner {} // todo + function removeLockedContractAddress(address lockedContract) external onlyOwner { + require(lockedContract != address(0)); + address[] memory lockedContractAddress = _LOCKED_CONTRACT_ADDRESS_; + for (uint256 i = 0; i < lockedContractAddress.length; i++) { + if (lockedContractAddress[i] == lockedContract) { + lockedContractAddress[i] = lockedContractAddress[lockedContractAddress.length - 1]; + break; + } + } + _LOCKED_CONTRACT_ADDRESS_ = lockedContractAddress; + _LOCKED_CONTRACT_ADDRESS_.pop(); + } function getCirculation() public view returns (uint256 circulation) { circulation = 10**10 * 10**18; diff --git a/contracts/DODOToken/vDODOToken.sol b/contracts/DODOToken/vDODOToken.sol index c7a22b2..805a27c 100644 --- a/contracts/DODOToken/vDODOToken.sol +++ b/contracts/DODOToken/vDODOToken.sol @@ -12,7 +12,6 @@ import {SafeMath} from "../lib/SafeMath.sol"; import {DecimalMath} from "../lib/DecimalMath.sol"; import {InitializableOwnable} from "../lib/InitializableOwnable.sol"; import {SafeERC20} from "../lib/SafeERC20.sol"; -import {ReentrancyGuard} from "../lib/ReentrancyGuard.sol"; import {IDODOApproveProxy} from "../SmartRoute/DODOApproveProxy.sol"; interface IGovernance { @@ -26,7 +25,7 @@ interface IDODOCirculationHelper { function getVDODOWithdrawFeeRatio() external view returns (uint256); } -contract vDODOToken is InitializableOwnable, ReentrancyGuard { +contract vDODOToken is InitializableOwnable { using SafeMath for uint256; // ============ Storage(ERC20) ============ @@ -132,10 +131,15 @@ contract vDODOToken is InitializableOwnable, ReentrancyGuard { function updateGovernance(address governance) public onlyOwner { _DOOD_GOV_ = governance; } + + function emergencyWithdraw() public onlyOwner { + uint256 dodoBalance = IERC20(_DODO_TOKEN_).balanceOf(address(this)); + IERC20(_DODO_TOKEN_).transfer(_OWNER_, dodoBalance); + } // ============ Functions ============ - function mint(uint256 dodoAmount, address superiorAddress) public preventReentrant { + function mint(uint256 dodoAmount, address superiorAddress) public { require(superiorAddress != address(0) && superiorAddress != msg.sender, "vDODOToken: Superior INVALID"); require(dodoAmount > 0, "vDODOToken: must mint greater than 0"); @@ -166,7 +170,6 @@ contract vDODOToken is InitializableOwnable, ReentrancyGuard { function redeem(uint256 vDodoAmount) public - preventReentrant balanceEnough(msg.sender, vDodoAmount) { _updateAlpha(); @@ -248,7 +251,7 @@ contract vDODOToken is InitializableOwnable, ReentrancyGuard { // ============ View Functions ============ - function canWithdraw(address account) public view returns (uint256 dodoAmount) { + function dodoBalanceOf(address account) public view returns (uint256 dodoAmount) { UserInfo memory user = userInfo[account]; dodoAmount = DecimalMath.mulFloor(uint256(user.VDODOAmount),getLatestAlpha()).sub(user.credit); }