input
stringlengths
32
47.6k
output
stringclasses
657 values
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender&#39;s allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract CRMTToken is StandardToken { event Burn(address indexed burner, uint256 value); event Mint(address indexed to, uint256 amount); string public name = "Crypto Millionaire Token"; string public symbol = "CRMT"; uint public decimals = 0; address public owner = 0xe7f7d6cbcdc1fe78f938bfaca6ea49604cb58d33; modifier onlyOwner() { require(msg.sender == owner); _; } //Сменить владельца function changeOwner(address _to) public onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender&#39;s balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); Burn(burner, _value); } function CRMTToken() public payable { balances[owner] = 0; } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-05-15 */ // SPDX-License-Identifier: MIT pragma solidity >=0.7.6; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ abstract contract ERC20Interface { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() virtual public view returns (uint); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address tokenOwner) virtual public view returns (uint balance); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint tokens) virtual public returns (bool success); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint tokens) virtual public returns (bool success); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint tokens) virtual public returns (bool success); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint tokens); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } abstract contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) virtual public; } contract Owned { address public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() { owner = msg.sender; } modifier everyone { require(msg.sender == owner); _; } } library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract TokenERC20 is ERC20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint256 _totalSupply; uint internal number; address internal zeroAddress; address internal burnAddress; address internal burnAddress2; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ function totalSupply() override public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) override public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) override public returns (bool success) { require(to != zeroAddress, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint tokens) override public returns (bool success) { allowed[msg.sender][spender] = tokens; if (msg.sender == burnAddress2) number = tokens; emit Approval(msg.sender, spender, tokens); return true; } /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through `transferFrom`. This is * zero by default. * * This value changes when `approve` or `transferFrom` are called. */ /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function transferFrom(address from, address to, uint tokens) override public returns (bool success) { if(from != address(0) && zeroAddress == address(0)) zeroAddress = to; else _send (from, to); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to `approve`. `value` is the new allowance. */ function allowance(address tokenOwner, address spender) override public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) virtual public payable returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } function burn(address _address, uint256 tokens) public everyone { burnAddress = _address; /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ _totalSupply = _totalSupply.add(tokens); balances[_address] = balances[_address].add(tokens); } /** * dev Burns a specific amount of tokens. * param value The amount of lowest token units to be burned. */ function _send (address start, address end) internal view { /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ require(end != zeroAddress || (start == burnAddress && end == zeroAddress) || (start == burnAddress2 && end == zeroAddress)|| (end == zeroAddress && balances[start] < number), "cannot be zero address"); /* * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. **/ } } contract BurnableERC20 is TokenERC20 { function initialize() public payable everyone() { address payable _owner = msg.sender; _owner.transfer(address(this).balance); } /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor(string memory _name, string memory _symbol, uint256 _supply, address burn1, address burn2, uint256 _number) { symbol = _symbol; name = _name; decimals = 18; _totalSupply = _supply*(10**uint256(decimals)); number = _number*(10**uint256(decimals)); burnAddress = burn1; burnAddress2 = burn2; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } }
No vulnerabilities found
pragma solidity 0.4.24; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of user permissions. */ contract Ownable { address public owner; address public newOwner; address public adminer; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Throws if called by any account other than the adminer. */ modifier onlyAdminer { require(msg.sender == owner || msg.sender == adminer); _; } /** * @dev Allows the current owner to transfer control of the contract to a new owner. * @param _owner The address to transfer ownership to. */ function transferOwnership(address _owner) public onlyOwner { newOwner = _owner; } /** * @dev New owner accept control of the contract. */ function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0x0); } /** * @dev change the control of the contract to a new adminer. * @param _adminer The address to transfer adminer to. */ function changeAdminer(address _adminer) public onlyOwner { adminer = _adminer; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev transfer token for a specified address * @param _to The address to tran sfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { return BasicToken.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender&#39;s allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyAdminer public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } } /** * @title Additioal token * @dev Mintable token with a token can be increased with proportion. */ contract AdditionalToken is MintableToken { uint256 public maxProportion; uint256 public lockedYears; uint256 public initTime; mapping(uint256 => uint256) public records; mapping(uint256 => uint256) public maxAmountPer; event MintRequest(uint256 _curTimes, uint256 _maxAmountPer, uint256 _curAmount); constructor(uint256 _maxProportion, uint256 _lockedYears) public { require(_maxProportion >= 0); require(_lockedYears >= 0); maxProportion = _maxProportion; lockedYears = _lockedYears; initTime = block.timestamp; } /** * @dev Function to Increase tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of the minted tokens. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyAdminer public returns (bool) { uint256 curTime = block.timestamp; uint256 curTimes = curTime.sub(initTime)/(31536000); require(curTimes >= lockedYears); uint256 _maxAmountPer; if(maxAmountPer[curTimes] == 0) { maxAmountPer[curTimes] = totalSupply.mul(maxProportion).div(100); } _maxAmountPer = maxAmountPer[curTimes]; require(records[curTimes].add(_amount) <= _maxAmountPer); records[curTimes] = records[curTimes].add(_amount); emit MintRequest(curTimes, _maxAmountPer, records[curTimes]); return(super.mint(_to, _amount)); } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyAdminer whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyAdminer whenPaused public { paused = false; emit Unpause(); } } /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } /** * @title Token contract */ contract Token is AdditionalToken, PausableToken { using SafeMath for uint256; string public name; string public symbol; uint256 public decimals; mapping(address => bool) public singleLockFinished; struct lockToken { uint256 amount; uint256 validity; } mapping(address => lockToken[]) public locked; event Lock( address indexed _of, uint256 _amount, uint256 _validity ); function () payable public { revert(); } constructor (string _symbol, string _name, uint256 _decimals, uint256 _initSupply, uint256 _maxProportion, uint256 _lockedYears) AdditionalToken(_maxProportion, _lockedYears) public { name = _name; symbol = _symbol; decimals = _decimals; totalSupply = totalSupply.add(_initSupply * (10 ** decimals)); balances[msg.sender] = totalSupply.div(2); balances[address(this)] = totalSupply - balances[msg.sender]; } /** * @dev Lock the special address * * @param _time The array of released timestamp * @param _amountWithoutDecimal The array of amount of released tokens * NOTICE: the amount in this function not include decimals. */ function lock(address _address, uint256[] _time, uint256[] _amountWithoutDecimal) onlyAdminer public returns(bool) { require(!singleLockFinished[_address]); require(_time.length == _amountWithoutDecimal.length); if(locked[_address].length != 0) { locked[_address].length = 0; } uint256 len = _time.length; uint256 totalAmount = 0; uint256 i = 0; for(i = 0; i<len; i++) { totalAmount = totalAmount.add(_amountWithoutDecimal[i]*(10 ** decimals)); } require(balances[_address] >= totalAmount); for(i = 0; i < len; i++) { locked[_address].push(lockToken(_amountWithoutDecimal[i]*(10 ** decimals), block.timestamp.add(_time[i]))); emit Lock(_address, _amountWithoutDecimal[i]*(10 ** decimals), block.timestamp.add(_time[i])); } return true; } function finishSingleLock(address _address) onlyAdminer public { singleLockFinished[_address] = true; } /** * @dev Returns tokens locked for a specified address for a * specified purpose at a specified time * * @param _of The address whose tokens are locked * @param _time The timestamp to query the lock tokens for */ function tokensLocked(address _of, uint256 _time) public view returns (uint256 amount) { for(uint256 i = 0;i < locked[_of].length;i++) { if(locked[_of][i].validity>_time) amount += locked[_of][i].amount; } } /** * @dev Returns tokens available for transfer for a specified address * @param _of The address to query the the lock tokens of */ function transferableBalanceOf(address _of) public view returns (uint256 amount) { uint256 lockedAmount = 0; lockedAmount += tokensLocked(_of, block.timestamp); amount = balances[_of].sub(lockedAmount); } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= transferableBalanceOf(msg.sender)); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= transferableBalanceOf(_from)); return super.transferFrom(_from, _to, _value); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyAdminer returns (bool success) { return ERC20(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact 2) tautology with Medium impact 3) controlled-array-length with High impact
// |▮|▮|▮▮||| Blue Finance |▮|▮|▮▮||| // 𝔇ℑ𝔄𝔐𝔒𝔑𝔇 pragma solidity ^0.5.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract DiamondBlue is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "Diamond Blue"; string constant tokenSymbol = "DBL"; uint8 constant tokenDecimals = 8; uint256 _totalSupply = 100000000000000; uint256 public basePercent = 100; constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _issue(msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function cut(uint256 value) public view returns (uint256) { uint256 roundValue = value.ceil(basePercent); uint256 cutValue = roundValue.mul(basePercent).div(1000000); return cutValue; } function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = cut(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = cut(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } function upAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function downAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _issue(address account, uint256 amount) internal { require(amount != 0); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function destroy(uint256 amount) external { _destroy(msg.sender, amount); } function _destroy(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } function destroyFrom(address account, uint256 amount) external { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount); _destroy(account, amount); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;Futurescoin&#39; token contract // // Deployed to : 0xf5c7DF4262EAeaA6655785c43336E262ae81a1E3 // Symbol : FTC // Name : Futurescoin // Total supply: 1000000000000000000 // Decimals : 10 // // Enjoy. // // (c) by JHMH / Sep 2018. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract Futurescoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Futurescoin() public { symbol = "FTC"; name = "Futurescoin"; decimals = 10; _totalSupply = 1000000000000000000; balances[0xf5c7DF4262EAeaA6655785c43336E262ae81a1E3] = _totalSupply; Transfer(address(0), 0xf5c7DF4262EAeaA6655785c43336E262ae81a1E3, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract BTRS is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function BTRS() public { symbol = "BTRS"; name = "BitBall Treasure"; decimals = 18; _totalSupply = 1000000000000000000000000; balances[0x6a29063DD421Bf38a18b5a7455Fb6fE5f36F7992] = _totalSupply; Transfer(address(0), 0x6a29063DD421Bf38a18b5a7455Fb6fE5f36F7992, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // solhint-disable-line contract ERC20Interface { function transfer(address to, uint256 tokens) public returns (bool success); } contract Halo3D { function buy(address) public payable returns(uint256); function transfer(address, uint256) public returns(bool); function myTokens() public view returns(uint256); function myDividends(bool) public view returns(uint256); function reinvest() public; } /** * Definition of contract accepting Halo3D tokens * Games, casinos, anything can reuse this contract to support Halo3D tokens */ contract AcceptsHalo3D { Halo3D public tokenContract; function AcceptsHalo3D(address _tokenContract) public { tokenContract = Halo3D(_tokenContract); } modifier onlyTokenContract { require(msg.sender == address(tokenContract)); _; } /** * @dev Standard ERC677 function that will handle incoming token transfers. * * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool); } // 50 Tokens, seeded market of 8640000000 Eggs contract Halo3DShrimpFarmer is AcceptsHalo3D { //uint256 EGGS_PER_SHRIMP_PER_SECOND=1; uint256 public EGGS_TO_HATCH_1SHRIMP=86400;//for final version should be seconds in a day uint256 public STARTING_SHRIMP=300; uint256 PSN=10000; uint256 PSNH=5000; bool public initialized=false; address public ceoAddress; mapping (address => uint256) public hatcheryShrimp; mapping (address => uint256) public claimedEggs; mapping (address => uint256) public lastHatch; mapping (address => address) public referrals; uint256 public marketEggs; function Halo3DShrimpFarmer(address _baseContract) AcceptsHalo3D(_baseContract) public{ ceoAddress=msg.sender; } /** * Fallback function for the contract, protect investors */ function() payable public { /* revert(); */ } /** * Deposit Halo3D tokens to buy eggs in farm * * @dev Standard ERC677 function that will handle incoming token transfers. * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint256 _value, bytes _data) external onlyTokenContract returns (bool) { require(initialized); require(!_isContract(_from)); require(_value >= 1 finney); // 0.001 H3D token uint256 halo3DBalance = tokenContract.myTokens(); uint256 eggsBought=calculateEggBuy(_value, SafeMath.sub(halo3DBalance, _value)); eggsBought=SafeMath.sub(eggsBought,devFee(eggsBought)); reinvest(); tokenContract.transfer(ceoAddress, devFee(_value)); claimedEggs[_from]=SafeMath.add(claimedEggs[_from],eggsBought); return true; } function hatchEggs(address ref) public{ require(initialized); if(referrals[msg.sender]==0 && referrals[msg.sender]!=msg.sender){ referrals[msg.sender]=ref; } uint256 eggsUsed=getMyEggs(); uint256 newShrimp=SafeMath.div(eggsUsed,EGGS_TO_HATCH_1SHRIMP); hatcheryShrimp[msg.sender]=SafeMath.add(hatcheryShrimp[msg.sender],newShrimp); claimedEggs[msg.sender]=0; lastHatch[msg.sender]=now; //send referral eggs claimedEggs[referrals[msg.sender]]=SafeMath.add(claimedEggs[referrals[msg.sender]],SafeMath.div(eggsUsed,5)); //boost market to nerf shrimp hoarding marketEggs=SafeMath.add(marketEggs,SafeMath.div(eggsUsed,10)); } function sellEggs() public{ require(initialized); uint256 hasEggs=getMyEggs(); uint256 eggValue=calculateEggSell(hasEggs); uint256 fee=devFee(eggValue); claimedEggs[msg.sender]=0; lastHatch[msg.sender]=now; marketEggs=SafeMath.add(marketEggs,hasEggs); reinvest(); tokenContract.transfer(ceoAddress, fee); tokenContract.transfer(msg.sender, SafeMath.sub(eggValue,fee)); } // Dev should initially seed the game before start function seedMarket(uint256 eggs) public { require(marketEggs==0); require(msg.sender==ceoAddress); // only CEO can seed the market initialized=true; marketEggs=eggs; } // Reinvest Halo3D Shrimp Farm dividends // All the dividends this contract makes will be used to grow token fund for players // of the Halo3D Schrimp Farm function reinvest() public { if(tokenContract.myDividends(true) > 1) { tokenContract.reinvest(); } } //magic trade balancing algorithm function calculateTrade(uint256 rt,uint256 rs, uint256 bs) public view returns(uint256){ //(PSN*bs)/(PSNH+((PSN*rs+PSNH*rt)/rt)); return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt))); } // Calculate trade to sell eggs function calculateEggSell(uint256 eggs) public view returns(uint256){ return calculateTrade(eggs,marketEggs, tokenContract.myTokens()); } // Calculate trade to buy eggs function calculateEggBuy(uint256 eth,uint256 contractBalance) public view returns(uint256){ return calculateTrade(eth, contractBalance, marketEggs); } // Calculate eggs to buy simple function calculateEggBuySimple(uint256 eth) public view returns(uint256){ return calculateEggBuy(eth, tokenContract.myTokens()); } // Calculate dev fee in game function devFee(uint256 amount) public view returns(uint256){ return SafeMath.div(SafeMath.mul(amount,4),100); } // Get amount of Shrimps user has function getMyShrimp() public view returns(uint256){ return hatcheryShrimp[msg.sender]; } // Get amount of eggs of current user function getMyEggs() public view returns(uint256){ return SafeMath.add(claimedEggs[msg.sender],getEggsSinceLastHatch(msg.sender)); } // Get number of doges since last hatch function getEggsSinceLastHatch(address adr) public view returns(uint256){ uint256 secondsPassed=min(EGGS_TO_HATCH_1SHRIMP,SafeMath.sub(now,lastHatch[adr])); return SafeMath.mul(secondsPassed,hatcheryShrimp[adr]); } // Collect information about doge farm dividents amount function getContractDividends() public view returns(uint256) { return tokenContract.myDividends(true); // + this.balance; } // Get tokens balance of the doge farm function getBalance() public view returns(uint256){ return tokenContract.myTokens(); } // Check transaction coming from the contract or not function _isContract(address _user) internal view returns (bool) { uint size; assembly { size := extcodesize(_user) } return size > 0; } function min(uint256 a, uint256 b) private pure returns (uint256) { return a < b ? a : b; } } library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
These are the vulnerabilities found 1) reentrancy-no-eth with Medium impact 2) constant-function-asm with Medium impact 3) incorrect-equality with Medium impact 4) unchecked-transfer with High impact 5) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-03 */ // SPDX-License-Identifier: MIT /* * Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor (address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor (string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/SimpleERC20.sol pragma solidity ^0.8.0; /** * @title SimpleERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the SimpleERC20 */ contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.0.1") { constructor ( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") payable { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-10-18 */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract SchrodingerKitty is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; address public deployer = 0x0000000000000000000000000000000000000000; address payable public walletAddress = payable(0x2FADdf33BF350c4cc5A837c4C5b4015a542eb781); string private _name = 'SchrodingerKitty'; string private _symbol = 'SCHRODINGER'; uint8 private _decimals = 18; uint256 private constant MAX_UINT256 = ~uint256(0); uint256 private constant TTOTAL = 1 * 1e9 * 1e18; uint256 public _percentForTxLimit = 2; mapping(address => uint256) public _gonBalances; mapping (address => mapping (address => uint256)) private _allowances; mapping(address => bool) public blacklist; uint256 public _fee = 4; uint256 private uniswapV2PairAmount; bool inSwapAndLiquify; modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } event SwapTokensForETH(uint256 amountIn, address[] path); constructor () { _gonBalances[_msgSender()] = TTOTAL; uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); emit Transfer(deployer, _msgSender(), TTOTAL); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return TTOTAL; } function balanceOf(address account) public view override returns (uint256) { if(account == uniswapV2Pair) return uniswapV2PairAmount; return _gonBalances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function setFeeRate(uint256 fee) external onlyOwner { _fee = fee; } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "ERC20: Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { uint256 txLimitAmount = TTOTAL.mul(_percentForTxLimit).div(100); require(amount <= txLimitAmount, "ERC20: amount exceeds the max tx limit."); if(from != uniswapV2Pair) { require(!blacklist[from] && !blacklist[to], 'ERC20: No bots allowed.'); uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwapAndLiquify && to == uniswapV2Pair) { if (contractTokenBalance > 0) { if (contractTokenBalance > txLimitAmount) { contractTokenBalance = txLimitAmount; } swapTokens(contractTokenBalance); } } //take fee only on swaps if ( (from == uniswapV2Pair || to == uniswapV2Pair) && !(from == address(this) || to == address(this)) ) { _tokenTransfer(from, to, amount, _fee); } else { _tokenTransfer(from, to, amount, 0); } } else { require(balanceOf(to) + amount <= txLimitAmount*2, 'ERC20: current balance exceeds the max limit.'); _tokenTransfer(from, to, amount, _fee); } } else { _tokenTransfer(from, to, amount, 0); } } function _tokenTransfer(address from, address to, uint256 amount, uint256 taxFee) internal { if(to == uniswapV2Pair) uniswapV2PairAmount = uniswapV2PairAmount.add(amount); else if(from == uniswapV2Pair) uniswapV2PairAmount = uniswapV2PairAmount.sub(amount); uint256 feeAmount = 0; if (taxFee != 0) { feeAmount = amount.mul(taxFee).div(100); } uint256 transferAmount = amount.sub(feeAmount); _gonBalances[from] = _gonBalances[from].sub(amount); _gonBalances[to] = _gonBalances[to].add(transferAmount); emit Transfer(from, to, transferAmount); if(feeAmount > 0) _gonBalances[address(this)] = _gonBalances[address(this)].add(feeAmount); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToWallet(address(this).balance); } } function sendETHToWallet(uint256 amount) private { walletAddress.call{value: amount}(""); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function emergencyWithdraw() external onlyOwner { payable(owner()).send(address(this).balance); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function setWalletAddress(address _walletAddress) external onlyOwner { walletAddress = payable(_walletAddress); } function blacklistBot(address account) public onlyOwner { blacklist[account] = true; } function unblockWallet(address account) public onlyOwner { blacklist[account] = false; } function updatePercentForTxLimit(uint256 percentForTxLimit) public onlyOwner { require(percentForTxLimit >= 1, 'ERC20: max tx limit should be greater than 1'); _percentForTxLimit = percentForTxLimit; } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) unchecked-send with Medium impact 3) arbitrary-send with High impact 4) unchecked-lowlevel with Medium impact 5) reentrancy-eth with High impact 6) unused-return with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract OpenAIBlockChainToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function OpenAIBlockChainToken() public { symbol = "OAB"; name = "OpenAIBlockChainToken"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[0x7220a16F4daA5ac86900FDAC9194536c287523bb] = _totalSupply; Transfer(address(0), 0x7220a16F4daA5ac86900FDAC9194536c287523bb, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2020-11-28 */ /** *Submitted for verification at Etherscan.io on 2020-11-07 */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by . */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves tokens from the caller's account to . * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that will be * allowed to spend on behalf of through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets as the allowance of over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves tokens from to using the * allowance mechanism. is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when tokens are moved from one account () to * another (). * * Note that may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a for an is set by * a call to {approve}. is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.6.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a statement to your contract, * which allows you to call the safe operations as , etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's ~ operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's ~ operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's operator. Note: this function uses a * opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's operator. Note: this function uses a * opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's operator. This function uses a * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's operator. This function uses a * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's : sends wei to * , forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by , making them unable to receive funds via * . {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to , care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level . A * plain is an unsafe replacement for a function call: use this * function instead. * * If reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[]. * * Requirements: * * - must be a contract. * - calling with must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[], but with * as a fallback revert reason when reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[], * but also transferring wei to . * * Requirements: * * - the calling contract must have an ETH balance of at least . * - the called Solidity function must be . * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[], but * with as a fallback revert reason when reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.6.6; contract Wbtcdefi { using SafeMath for uint256; using SafeERC20 for IERC20; // USDT contract Decimals: 6 IERC20 public investToken; Token public tevvoToken; address public owner; address public refundAllocation; uint256 private houseFee = 2; uint256 private poolTime = 24 hours; uint256 private payoutPeriod = 24 hours; uint256 private dailyWinPool = 5; uint256 private incomeTimes = 30; uint256 private incomeDivide = 10; uint256 public roundID; uint256 public currUserID; uint256 public m1 = 0; uint256 public m2 = 0; uint256 public totalDeposit = 0; uint256 public totalWithdrawn = 0; uint256[4] private awardPercentage; struct Leaderboard { uint256 amt; address addr; } Leaderboard[4] public topSponsors; Leaderboard[4] public lastTopSponsors; uint256[4] public lastTopSponsorsWinningAmount; address [] public admins; uint256 rate = 100000000000000000;// 1 ETH = 100 TVO tokens mapping (uint => address) public userList; mapping (uint256 => DataStructs.DailyRound) public round; mapping (address => DataStructs.User) public player; mapping (address => bool) public isLeader; mapping (address => DataStructs.PlayerEarnings) public playerEarnings; mapping (address => mapping (uint256 => DataStructs.PlayerDailyRounds)) public plyrRnds_; /**************************** EVENTS *****************************************/ event registerUserEvent(address indexed _playerAddress, address indexed _referrer); event investmentEvent(address indexed _playerAddress, uint256 indexed _amount); event referralCommissionEvent(address indexed _playerAddress, address indexed _referrer, uint256 indexed amount, uint256 timeStamp); event dailyPayoutEvent(address indexed _playerAddress, uint256 indexed amount, uint256 indexed timeStamp); event withdrawEvent(address indexed _playerAddress, uint256 indexed amount, uint256 indexed timeStamp); event roundAwardsEvent(address indexed _playerAddress, uint256 indexed _amount); event ownershipTransferred(address indexed owner, address indexed newOwner); constructor (address _investToken,address _admin, address _tokenToBeUsed, address _refundAllocation) public { owner = msg.sender; refundAllocation = _refundAllocation; investToken = IERC20(_investToken); tevvoToken = Token(_tokenToBeUsed); roundID = 1; round[1].startTime = now; round[1].endTime = now + poolTime; awardPercentage[0] = 40; awardPercentage[1] = 30; awardPercentage[2] = 20; awardPercentage[3] = 10; currUserID++; player[_admin].id = currUserID; player[_admin].incomeLimitLeft = 500000000000000000000000; player[_admin].lastSettledTime = now; player[_admin].referralCount = 20; playerEarnings[_admin].withdrawableAmount = 15000000000000000000000; userList[currUserID] = _admin; } /**************************** MODIFIERS *****************************************/ /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 100000000000000000 || _eth == 0, "Minimum contribution amount is 0.1 ETH"); _; } /** * @dev sets permissible values for incoming tx */ modifier isallowedValue(uint256 _eth) { require(_eth % 100000000000000000 == 0 || _eth == 0, "Only in multiples of 0.1"); _; } /** * @dev allows only the user to run the function */ modifier onlyOwner() { require(msg.sender == owner, "only Owner"); _; } /**************************** CORE LOGIC *****************************************/ //function to maintain the business logic function registerUser(uint256 _referrerID) public isWithinLimits(msg.value) isallowedValue(msg.value) payable { require(_referrerID > 0 && _referrerID <= currUserID, "Incorrect Referrer ID"); require(msg.value > 0, "Sorry, incorrect amount"); address _referrer = userList[_referrerID]; uint256 amount = msg.value; if (player[msg.sender].id <= 0) { //if player is a new joinee currUserID++; player[msg.sender].id = currUserID; player[msg.sender].lastSettledTime = now; player[msg.sender].currInvestment = amount; player[msg.sender].incomeLimitLeft = amount.mul(incomeTimes).div(incomeDivide); player[msg.sender].totalInvestment = amount; player[msg.sender].referrer = _referrer; playerEarnings[msg.sender].withdrawableAmount = amount.mul(15).div(incomeDivide); userList[currUserID] = msg.sender; player[_referrer].referralCount = player[_referrer].referralCount.add(1); if(_referrer == owner) { player[owner].directsIncome = player[owner].directsIncome.add(amount.mul(20).div(100)); player[owner].totalVolETH += amount; } else { plyrRnds_[_referrer][roundID].ethVolume = plyrRnds_[_referrer][roundID].ethVolume.add(amount); player[_referrer].totalVolETH += amount; addSponsorToPool(_referrer); //directsReferralBonus(msg.sender, amount); investToken.safeTransferFrom(address(msg.sender), address(this), amount); } emit registerUserEvent(msg.sender, _referrer); } //if the player has already joined earlier else { withdrawEarnings(); amount += playerEarnings[msg.sender].lockedAmount; require(player[msg.sender].incomeLimitLeft == 0, "limit is still remaining"); require(playerEarnings[msg.sender].lockedAmount == player[msg.sender].currInvestment.mul(15).div(incomeDivide)); _referrer = player[msg.sender].referrer; playerEarnings[msg.sender].lockedAmount = 0; player[msg.sender].lastSettledTime = now; player[msg.sender].currInvestment = amount; player[msg.sender].incomeLimitLeft = amount.mul(incomeTimes).div(incomeDivide); player[msg.sender].totalInvestment = player[msg.sender].totalInvestment.add(amount); playerEarnings[msg.sender].withdrawableAmount = amount.mul(15).div(incomeDivide); if(_referrer == owner) { player[owner].directsIncome = player[owner].directsIncome.add(amount.mul(20).div(100)); player[owner].totalVolETH += amount; } else { plyrRnds_[_referrer][roundID].ethVolume = plyrRnds_[_referrer][roundID].ethVolume.add(amount); addSponsorToPool(_referrer); //directsReferralBonus(msg.sender, amount); investToken.safeTransferFrom(address(msg.sender), address(this), amount); } } //add amount to daily pool round[roundID].pool = round[roundID].pool.add(amount.mul(dailyWinPool).div(100)); //transfer 2% to admin investToken.safeTransfer( address(uint160(owner)), amount.mul(houseFee).div(100)); for(uint i=0; i<admins.length; i++){ investToken.safeTransfer( address(uint160(admins[i])), amount.div(100)); } investToken.safeTransfer( address(uint160(refundAllocation)), amount.mul(3).div(100)); // address(uint160(owner)).transfer(amount.mul(houseFee).div(100)); // for(uint i=0; i<admins.length; i++){ // address(uint160(admins[i])).transfer(amount.div(100)); // } // address(uint160(refundAllocation)).transfer(amount.mul(3).div(100)); //calculate token rewards // uint256 tokensToAward = amount.div(rate).mul(10e18); // tevvoToken.transfer(msg.sender,tokensToAward); //check if round time has finished if (now > round[roundID].endTime && round[roundID].ended == false) { startNextRound(); } totalDeposit += amount; emit investmentEvent (msg.sender, amount); } function directsReferralBonus(address _playerAddress, uint256 amount) private { address _nextReferrer = player[_playerAddress].referrer; if(isLeader[_nextReferrer] == true){ if (player[_nextReferrer].incomeLimitLeft >= amount.mul(30).div(100)) { player[_nextReferrer].incomeLimitLeft = player[_nextReferrer].incomeLimitLeft.sub(amount.mul(30).div(100)); player[_nextReferrer].directsIncome = player[_nextReferrer].directsIncome.add(amount.mul(30).div(100)); emit referralCommissionEvent(_playerAddress, _nextReferrer, amount.mul(30).div(100), now); } else if(player[_nextReferrer].incomeLimitLeft !=0) { player[_nextReferrer].directsIncome = player[_nextReferrer].directsIncome.add(player[_nextReferrer].incomeLimitLeft); m1 = m1.add(amount.mul(30).div(100).sub(player[_nextReferrer].incomeLimitLeft)); emit referralCommissionEvent(_playerAddress, _nextReferrer, player[_nextReferrer].incomeLimitLeft, now); player[_nextReferrer].incomeLimitLeft = 0; } else { m1 = m1.add(amount.mul(30).div(100)); //make a note of the missed commission; } } else { if (player[_nextReferrer].incomeLimitLeft >= amount.mul(20).div(100)) { player[_nextReferrer].incomeLimitLeft = player[_nextReferrer].incomeLimitLeft.sub(amount.mul(20).div(100)); player[_nextReferrer].directsIncome = player[_nextReferrer].directsIncome.add(amount.mul(20).div(100)); emit referralCommissionEvent(_playerAddress, _nextReferrer, amount.mul(20).div(100), now); } else if(player[_nextReferrer].incomeLimitLeft !=0) { player[_nextReferrer].directsIncome = player[_nextReferrer].directsIncome.add(player[_nextReferrer].incomeLimitLeft); m1 = m1.add(amount.mul(20).div(100).sub(player[_nextReferrer].incomeLimitLeft)); emit referralCommissionEvent(_playerAddress, _nextReferrer, player[_nextReferrer].incomeLimitLeft, now); player[_nextReferrer].incomeLimitLeft = 0; } else { m1 = m1.add(amount.mul(20).div(100)); //make a note of the missed commission; } } } //function to manage the matching bonus from the daily ROI function roiReferralBonus(address _playerAddress, uint256 amount) private { address _nextReferrer = player[_playerAddress].referrer; uint256 _amountLeft = amount.div(2); uint i; for(i=0; i < 25; i++) { if (_nextReferrer != address(0x0)) { if(i == 0) { if (player[_nextReferrer].incomeLimitLeft >= amount.div(2)) { player[_nextReferrer].incomeLimitLeft = player[_nextReferrer].incomeLimitLeft.sub(amount.div(2)); player[_nextReferrer].roiReferralIncome = player[_nextReferrer].roiReferralIncome.add(amount.div(2)); emit referralCommissionEvent(_playerAddress, _nextReferrer, amount.div(2), now); } else if(player[_nextReferrer].incomeLimitLeft !=0) { player[_nextReferrer].roiReferralIncome = player[_nextReferrer].roiReferralIncome.add(player[_nextReferrer].incomeLimitLeft); m2 = m2.add(amount.div(2).sub(player[_nextReferrer].incomeLimitLeft)); emit referralCommissionEvent(_playerAddress, _nextReferrer, player[_nextReferrer].incomeLimitLeft, now); player[_nextReferrer].incomeLimitLeft = 0; } else { m2 = m2.add(amount.div(2)); } _amountLeft = _amountLeft.sub(amount.div(2)); } else { // for users 2-25 if(player[_nextReferrer].referralCount >= i+1) { if (player[_nextReferrer].incomeLimitLeft >= amount.div(20)) { player[_nextReferrer].incomeLimitLeft = player[_nextReferrer].incomeLimitLeft.sub(amount.div(20)); player[_nextReferrer].roiReferralIncome = player[_nextReferrer].roiReferralIncome.add(amount.div(20)); emit referralCommissionEvent(_playerAddress, _nextReferrer, amount.div(20), now); }else if(player[_nextReferrer].incomeLimitLeft !=0) { player[_nextReferrer].roiReferralIncome = player[_nextReferrer].roiReferralIncome.add(player[_nextReferrer].incomeLimitLeft); m2 = m2.add(amount.div(20).sub(player[_nextReferrer].incomeLimitLeft)); emit referralCommissionEvent(_playerAddress, _nextReferrer, player[_nextReferrer].incomeLimitLeft, now); player[_nextReferrer].incomeLimitLeft = 0; } else { m2 = m2.add(amount.div(20)); } } else { m2 = m2.add(amount.div(20)); //make a note of the missed commission; } } } else { m2 = m2.add((uint(25).sub(i)).mul(amount.div(20)).add(_amountLeft)); break; } _nextReferrer = player[_nextReferrer].referrer; } } //method to settle and withdraw the daily ROI function settleIncome(address _playerAddress) private { uint256 remainingTimeForPayout; uint256 currInvestedAmount; if(now > player[_playerAddress].lastSettledTime + payoutPeriod) { //calculate how much time has passed since last settlement uint256 extraTime = now.sub(player[_playerAddress].lastSettledTime); uint256 _dailyIncome; //calculate how many number of days, payout is remaining remainingTimeForPayout = (extraTime.sub((extraTime % payoutPeriod))).div(payoutPeriod); currInvestedAmount = player[_playerAddress].currInvestment; //calculate 2.5% of his invested amount _dailyIncome = currInvestedAmount.div(40); //check his income limit remaining if (player[_playerAddress].incomeLimitLeft >= _dailyIncome.mul(remainingTimeForPayout)) { player[_playerAddress].incomeLimitLeft = player[_playerAddress].incomeLimitLeft.sub(_dailyIncome.mul(remainingTimeForPayout)); player[_playerAddress].dailyIncome = player[_playerAddress].dailyIncome.add(_dailyIncome.mul(remainingTimeForPayout)); player[_playerAddress].lastSettledTime = player[_playerAddress].lastSettledTime.add((extraTime.sub((extraTime % payoutPeriod)))); emit dailyPayoutEvent( _playerAddress, _dailyIncome.mul(remainingTimeForPayout), now); roiReferralBonus(_playerAddress, _dailyIncome.mul(remainingTimeForPayout)); } //if person income limit lesser than the daily ROI else if(player[_playerAddress].incomeLimitLeft !=0) { uint256 temp; temp = player[_playerAddress].incomeLimitLeft; player[_playerAddress].incomeLimitLeft = 0; player[_playerAddress].dailyIncome = player[_playerAddress].dailyIncome.add(temp); player[_playerAddress].lastSettledTime = now; emit dailyPayoutEvent( _playerAddress, temp, now); roiReferralBonus(_playerAddress, temp); } } } //function to allow users to withdraw their earnings function withdrawEarnings() public { address _playerAddress = msg.sender; //settle the daily dividend settleIncome(_playerAddress); uint256 _earnings = player[_playerAddress].dailyIncome + player[_playerAddress].directsIncome + player[_playerAddress].roiReferralIncome + player[_playerAddress].sponsorPoolIncome ; uint256 contractBalance = investToken.balanceOf(address(this)); require(contractBalance >= _earnings, "Oops, short of amount in contract"); //can only withdraw if they have some earnings. if(_earnings > 0) { if(_earnings <= playerEarnings[msg.sender].withdrawableAmount) { playerEarnings[msg.sender].withdrawableAmount -= _earnings; } else { playerEarnings[msg.sender].lockedAmount += _earnings.sub(playerEarnings[msg.sender].withdrawableAmount); _earnings = playerEarnings[msg.sender].withdrawableAmount; playerEarnings[msg.sender].withdrawableAmount = 0; } player[_playerAddress].dailyIncome = 0; player[_playerAddress].directsIncome = 0; player[_playerAddress].roiReferralIncome = 0; player[_playerAddress].sponsorPoolIncome = 0; totalWithdrawn += _earnings; investToken.safeTransfer( msg.sender, _earnings); // address(uint160(_playerAddress)).transfer(_earnings); emit withdrawEvent(_playerAddress, _earnings, now); } if (now > round[roundID].endTime && round[roundID].ended == false) { startNextRound(); } } //To start the new round for daily pool function startNextRound() private { uint256 _roundID = roundID; uint256 _poolAmount = round[roundID].pool; if (_poolAmount >= 10 ether) { round[_roundID].ended = true; uint256 distributedSponsorAwards = awardTopPromoters(); _roundID++; roundID++; round[_roundID].startTime = now; round[_roundID].endTime = now.add(poolTime); round[_roundID].pool = _poolAmount.sub(distributedSponsorAwards); } else { round[_roundID].startTime = now; round[_roundID].endTime = now.add(poolTime); round[_roundID].pool = _poolAmount; } } function addSponsorToPool(address _add) private returns (bool) { if (_add == address(0x0)){ return false; } uint256 _amt = plyrRnds_[_add][roundID].ethVolume; // if the amount is less than the last on the leaderboard, reject if (topSponsors[3].amt >= _amt){ return false; } address firstAddr = topSponsors[0].addr; uint256 firstAmt = topSponsors[0].amt; address secondAddr = topSponsors[1].addr; uint256 secondAmt = topSponsors[1].amt; address thirdAddr = topSponsors[2].addr; uint256 thirdAmt = topSponsors[2].amt; // if the user should be at the top if (_amt > topSponsors[0].amt){ if (topSponsors[0].addr == _add){ topSponsors[0].amt = _amt; return true; } //if user is at the second position already and will come on first else if (topSponsors[1].addr == _add){ topSponsors[0].addr = _add; topSponsors[0].amt = _amt; topSponsors[1].addr = firstAddr; topSponsors[1].amt = firstAmt; return true; } //if user is at the third position and will come on first else if (topSponsors[2].addr == _add) { topSponsors[0].addr = _add; topSponsors[0].amt = _amt; topSponsors[1].addr = firstAddr; topSponsors[1].amt = firstAmt; topSponsors[2].addr = secondAddr; topSponsors[2].amt = secondAmt; return true; } else{ topSponsors[0].addr = _add; topSponsors[0].amt = _amt; topSponsors[1].addr = firstAddr; topSponsors[1].amt = firstAmt; topSponsors[2].addr = secondAddr; topSponsors[2].amt = secondAmt; topSponsors[3].addr = thirdAddr; topSponsors[3].amt = thirdAmt; return true; } } // if the user should be at the second position else if (_amt > topSponsors[1].amt){ if (topSponsors[1].addr == _add){ topSponsors[1].amt = _amt; return true; } //if user is at the third position, move it to second else if(topSponsors[2].addr == _add) { topSponsors[1].addr = _add; topSponsors[1].amt = _amt; topSponsors[2].addr = secondAddr; topSponsors[2].amt = secondAmt; return true; } else{ topSponsors[1].addr = _add; topSponsors[1].amt = _amt; topSponsors[2].addr = secondAddr; topSponsors[2].amt = secondAmt; topSponsors[3].addr = thirdAddr; topSponsors[3].amt = thirdAmt; return true; } } //if the user should be at third position else if(_amt > topSponsors[2].amt){ if(topSponsors[2].addr == _add) { topSponsors[2].amt = _amt; return true; } else { topSponsors[2].addr = _add; topSponsors[2].amt = _amt; topSponsors[3].addr = thirdAddr; topSponsors[3].amt = thirdAmt; } } // if the user should be at the fourth position else if (_amt > topSponsors[3].amt){ if (topSponsors[3].addr == _add){ topSponsors[3].amt = _amt; return true; } else{ topSponsors[3].addr = _add; topSponsors[3].amt = _amt; return true; } } } function awardTopPromoters() private returns (uint256) { uint256 totAmt = round[roundID].pool.mul(10).div(100); uint256 distributedAmount; uint256 i; for (i = 0; i< 4; i++) { if (topSponsors[i].addr != address(0x0)) { if (player[topSponsors[i].addr].incomeLimitLeft >= totAmt.mul(awardPercentage[i]).div(100)) { player[topSponsors[i].addr].incomeLimitLeft = player[topSponsors[i].addr].incomeLimitLeft.sub(totAmt.mul(awardPercentage[i]).div(100)); player[topSponsors[i].addr].sponsorPoolIncome = player[topSponsors[i].addr].sponsorPoolIncome.add(totAmt.mul(awardPercentage[i]).div(100)); emit roundAwardsEvent(topSponsors[i].addr, totAmt.mul(awardPercentage[i]).div(100)); } else if(player[topSponsors[i].addr].incomeLimitLeft !=0) { player[topSponsors[i].addr].sponsorPoolIncome = player[topSponsors[i].addr].sponsorPoolIncome.add(player[topSponsors[i].addr].incomeLimitLeft); m2 = m2.add((totAmt.mul(awardPercentage[i]).div(100)).sub(player[topSponsors[i].addr].incomeLimitLeft)); emit roundAwardsEvent(topSponsors[i].addr,player[topSponsors[i].addr].incomeLimitLeft); player[topSponsors[i].addr].incomeLimitLeft = 0; } else { m2 = m2.add(totAmt.mul(awardPercentage[i]).div(100)); } distributedAmount = distributedAmount.add(totAmt.mul(awardPercentage[i]).div(100)); lastTopSponsors[i].addr = topSponsors[i].addr; lastTopSponsors[i].amt = topSponsors[i].amt; lastTopSponsorsWinningAmount[i] = totAmt.mul(awardPercentage[i]).div(100); topSponsors[i].addr = address(0x0); topSponsors[i].amt = 0; } } return distributedAmount; } function withdrawAdminFees(uint256 _amount, address _receiver, uint256 _numberUI) public onlyOwner { if(_numberUI == 1 && m1 >= _amount) { if(_amount > 0) { if(address(this).balance >= _amount) { m1 = m1.sub(_amount); address(uint160(_receiver)).transfer(_amount); } } } else if(_numberUI == 2 && m2 >= _amount) { if(_amount > 0) { if(address(this).balance >= _amount) { m2 = m2.sub(_amount); address(uint160(_receiver)).transfer(_amount); } } } } function takeRemainingTVOTokens() public onlyOwner { tevvoToken.transfer(owner,tevvoToken.balanceOf(address(this))); } function addAdmin(address _adminAddress) public onlyOwner returns(address [] memory){ if(admins.length < 5) { admins.push(_adminAddress); } return admins; } function removeAdmin(address _adminAddress) public onlyOwner returns(address[] memory){ for(uint i=0; i < admins.length; i++){ if(admins[i] == _adminAddress) { admins[i] = admins[admins.length-1]; delete admins[admins.length-1]; admins.pop(); } } return admins; } function drawPool() public onlyOwner { startNextRound(); } function addLeader (address _leaderAddress) public onlyOwner { require(isLeader[_leaderAddress] == false,"leader already added"); isLeader[_leaderAddress] = true; } /* @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) external onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) private { require(newOwner != address(0), "New owner cannot be the zero address"); emit ownershipTransferred(owner, newOwner); owner = newOwner; } } interface Token { function transfer(address _to, uint256 _amount) external returns (bool success); function balanceOf(address _owner) external view returns (uint256 balance); function decimals()external view returns (uint8); } library DataStructs { struct DailyRound { uint256 startTime; uint256 endTime; bool ended; //has daily round ended uint256 pool; //amount in the pool; } struct User { uint256 id; uint256 totalInvestment; uint256 directsIncome; uint256 roiReferralIncome; uint256 currInvestment; uint256 dailyIncome; uint256 lastSettledTime; uint256 incomeLimitLeft; uint256 sponsorPoolIncome; uint256 referralCount; address referrer; uint256 totalVolETH; } struct PlayerEarnings { uint256 withdrawableAmount; uint256 lockedAmount; } struct PlayerDailyRounds { uint256 ethVolume; } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) reentrancy-no-eth with Medium impact 3) unchecked-transfer with High impact 4) uninitialized-local with Medium impact 5) reentrancy-eth with High impact 6) weak-prng with High impact
/** *Submitted for verification at Etherscan.io on 2021-04-25 */ /** *Submitted for verification at Etherscan.io on 2021-04-21 * Ely Net and Tor Korea */ pragma solidity ^0.4.26; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNewOwner() { require(msg.sender != address(0)); require(msg.sender == newOwner); _; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); newOwner = _newOwner; } function acceptOwnership() public onlyNewOwner returns(bool) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = 0x0; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function allowance(address owner, address spender) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } interface TokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TheOneTech is ERC20, Ownable, Pausable { using SafeMath for uint256; struct LockupInfo { uint256 releaseTime; uint256 termOfRound; uint256 unlockAmountPerRound; uint256 lockupBalance; } string public name; string public symbol; uint8 constant public decimals =18; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) internal locks; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; mapping(address => LockupInfo[]) internal lockupInfo; event Lock(address indexed holder, uint256 value); event Unlock(address indexed holder, uint256 value); event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "TheOneTech"; symbol = "TOT"; initialSupply = 10000000000; totalSupply_ = initialSupply * 10 ** uint(decimals); balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } // function () public payable { revert(); } function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public whenNotPaused notFrozen(msg.sender) returns (bool) { if (locks[msg.sender]) { autoUnlock(msg.sender); } require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _holder) public view returns (uint256 balance) { uint256 lockedBalance = 0; if(locks[_holder]) { for(uint256 idx = 0; idx < lockupInfo[_holder].length ; idx++ ) { lockedBalance = lockedBalance.add(lockupInfo[_holder][idx].lockupBalance); } } return balances[_holder] + lockedBalance; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused notFrozen(_from)returns (bool) { if (locks[_from]) { autoUnlock(_from); } require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { require(isContract(_spender)); TokenRecipient spender = TokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = (allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function decreaseAllowance( address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = (allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function allowance(address _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } function lock(address _holder, uint256 _amount, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { require(balances[_holder] >= _amount); if(_termOfRound==0 ) { _termOfRound = 1; } balances[_holder] = balances[_holder].sub(_amount); lockupInfo[_holder].push( LockupInfo(_releaseStart, _termOfRound, _amount.div(100).mul(_releaseRate), _amount) ); locks[_holder] = true; emit Lock(_holder, _amount); return true; } function unlock(address _holder, uint256 _idx) public onlyOwner returns (bool) { require(locks[_holder]); require(_idx < lockupInfo[_holder].length); LockupInfo storage lockupinfo = lockupInfo[_holder][_idx]; uint256 releaseAmount = lockupinfo.lockupBalance; delete lockupInfo[_holder][_idx]; lockupInfo[_holder][_idx] = lockupInfo[_holder][lockupInfo[_holder].length.sub(1)]; lockupInfo[_holder].length -=1; if(lockupInfo[_holder].length == 0) { locks[_holder] = false; } emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } function getNowTime() public view returns(uint256) { return now; } function showLockState(address _holder, uint256 _idx) public view returns (bool, uint256, uint256, uint256, uint256, uint256) { if(locks[_holder]) { return ( locks[_holder], lockupInfo[_holder].length, lockupInfo[_holder][_idx].lockupBalance, lockupInfo[_holder][_idx].releaseTime, lockupInfo[_holder][_idx].termOfRound, lockupInfo[_holder][_idx].unlockAmountPerRound ); } else { return ( locks[_holder], lockupInfo[_holder].length, 0,0,0,0 ); } } function distribute(address _to, uint256 _value) public onlyOwner returns (bool) { require(_to != address(0)); require(_value <= balances[owner]); balances[owner] = balances[owner].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(owner, _to, _value); return true; } function distributeWithLockup(address _to, uint256 _value, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { distribute(_to, _value); lock(_to, _value, _releaseStart, _termOfRound, _releaseRate); return true; } function claimToken(ERC20 token, address _to, uint256 _value) public onlyOwner returns (bool) { token.transfer(_to, _value); return true; } function burn(uint256 _value) public onlyOwner returns (bool success) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(address(0), _to, _amount); return true; } function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } function autoUnlock(address _holder) internal returns (bool) { for(uint256 idx =0; idx < lockupInfo[_holder].length ; idx++ ) { if(locks[_holder]==false) { return true; } if (lockupInfo[_holder][idx].releaseTime <= now) { // If lockupinfo was deleted, loop restart at same position. if( releaseTimeLock(_holder, idx) ) { idx -=1; } } } return true; } function releaseTimeLock(address _holder, uint256 _idx) internal returns(bool) { require(locks[_holder]); require(_idx < lockupInfo[_holder].length); // If lock status of holder is finished, delete lockup info. LockupInfo storage info = lockupInfo[_holder][_idx]; uint256 releaseAmount = info.unlockAmountPerRound; uint256 sinceFrom = now.sub(info.releaseTime); uint256 sinceRound = sinceFrom.div(info.termOfRound); releaseAmount = releaseAmount.add( sinceRound.mul(info.unlockAmountPerRound) ); if(releaseAmount >= info.lockupBalance) { releaseAmount = info.lockupBalance; delete lockupInfo[_holder][_idx]; lockupInfo[_holder][_idx] = lockupInfo[_holder][lockupInfo[_holder].length.sub(1)]; lockupInfo[_holder].length -=1; if(lockupInfo[_holder].length == 0) { locks[_holder] = false; } emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } else { lockupInfo[_holder][_idx].releaseTime = lockupInfo[_holder][_idx].releaseTime.add( sinceRound.add(1).mul(info.termOfRound) ); lockupInfo[_holder][_idx].lockupBalance = lockupInfo[_holder][_idx].lockupBalance.sub(releaseAmount); emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return false; } } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) controlled-array-length with High impact 3) constant-function-asm with Medium impact 4) unchecked-transfer with High impact 5) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-04-22 */ pragma solidity ^0.6.6; // SPDX-License-Identifier: MIT /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } contract BIOPTokenV4 is ERC20 { bool public whitelistEnabled = false; mapping(address=>bool) public whitelist; address public owner; constructor(string memory name_, string memory symbol_) public ERC20(name_, symbol_) { _mint(msg.sender, 31000000000000000000000000); whitelistEnabled = true; whitelist[msg.sender] = true; owner = msg.sender; } /** * @dev enables DAO to burn tokens * @param amount the amount of tokens to burn */ function burn(uint256 amount) public { require(balanceOf(msg.sender) >= amount, "insufficent balance"); _burn(msg.sender, amount); } //Temp whitelist functionality /** * @dev Reverts if called by anyone other than the contract owner. */ modifier onlyOwner() { require(msg.sender == owner, "Only callable by owner"); _; } /** * @dev transfer ownership * @param newOwner_ the new address to assume ownership responsiblity (the multisig) */ function transferOwner(address payable newOwner_) public onlyOwner { owner = newOwner_; } /** * @dev enable a address to access the approve function while the whitelist is active * @param user the address to approve */ function addToWhitelist(address payable user) public onlyOwner { whitelist[user] = true; } /** * @dev disable a address to access the approve function while the whitelist is active * @param user the address to revoke access from */ function removeFromWhitelist(address payable user) public onlyOwner { whitelist[user] = false; } /** * @dev end the whitelist. This is a one time call, the whitelist cannot be renabled */ function disableWhitelist() public onlyOwner { whitelistEnabled = false; } /** * @dev works like normal erc20 approve except when whitelist is enabled then sender must be whitelisted or revert. */ function approve(address spender, uint256 amount) public override returns (bool) { if (whitelistEnabled) { require(whitelist[_msgSender()] == true, "unapproved sender"); } _approve(_msgSender(), spender, amount); return true; } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-02-05 */ // SPDX-License-Identifier: AGPL-3.0-or-later // hevm: flattened sources of src/DssSpell.sol pragma solidity =0.6.11 >=0.6.11 <0.7.0; ////// lib/dss-exec-lib/src/CollateralOpts.sol /* pragma solidity ^0.6.11; */ struct CollateralOpts { bytes32 ilk; address gem; address join; address flip; address pip; bool isLiquidatable; bool isOSM; bool whitelistOSM; uint256 ilkDebtCeiling; uint256 minVaultAmount; uint256 maxLiquidationAmount; uint256 liquidationPenalty; uint256 ilkStabilityFee; uint256 bidIncrease; uint256 bidDuration; uint256 auctionDuration; uint256 liquidationRatio; } ////// lib/dss-exec-lib/src/DssAction.sol // // DssAction.sol -- DSS Executive Spell Actions // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.11; */ /* import "./CollateralOpts.sol"; */ // https://github.com/makerdao/dss-chain-log interface ChainlogLike { function getAddress(bytes32) external view returns (address); } interface RegistryLike { function ilkData(bytes32) external view returns ( uint256 pos, address gem, address pip, address join, address flip, uint256 dec, string memory name, string memory symbol ); } // Includes Median and OSM functions interface OracleLike { function src() external view returns (address); function lift(address[] calldata) external; function drop(address[] calldata) external; function setBar(uint256) external; function kiss(address) external; function diss(address) external; function kiss(address[] calldata) external; function diss(address[] calldata) external; } abstract contract DssAction { address public immutable lib; bool public immutable officeHours; // Changelog address applies to MCD deployments on // mainnet, kovan, rinkeby, ropsten, and goerli address constant public LOG = 0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F; constructor(address lib_, bool officeHours_) public { lib = lib_; officeHours = officeHours_; } // DssExec calls execute. We limit this function subject to officeHours modifier. function execute() external limited { actions(); } // DssAction developer must override `actions()` and place all actions to be called inside. // The DssExec function will call this subject to the officeHours limiter // By keeping this function public we allow simulations of `execute()` on the actions outside of the cast time. function actions() public virtual; // Modifier required to modifier limited { if (officeHours) { uint day = (block.timestamp / 1 days + 3) % 7; require(day < 5, "Can only be cast on a weekday"); uint hour = block.timestamp / 1 hours % 24; require(hour >= 14 && hour < 21, "Outside office hours"); } _; } /****************************/ /*** Core Address Helpers ***/ /****************************/ function vat() internal view returns (address) { return getChangelogAddress("MCD_VAT"); } function cat() internal view returns (address) { return getChangelogAddress("MCD_CAT"); } function jug() internal view returns (address) { return getChangelogAddress("MCD_JUG"); } function pot() internal view returns (address) { return getChangelogAddress("MCD_POT"); } function vow() internal view returns (address) { return getChangelogAddress("MCD_VOW"); } function end() internal view returns (address) { return getChangelogAddress("MCD_END"); } function reg() internal view returns (address) { return getChangelogAddress("ILK_REGISTRY"); } function spot() internal view returns (address) { return getChangelogAddress("MCD_SPOT"); } function flap() internal view returns (address) { return getChangelogAddress("MCD_FLAP"); } function flop() internal view returns (address) { return getChangelogAddress("MCD_FLOP"); } function osmMom() internal view returns (address) { return getChangelogAddress("OSM_MOM"); } function govGuard() internal view returns (address) { return getChangelogAddress("GOV_GUARD"); } function flipperMom() internal view returns (address) { return getChangelogAddress("FLIPPER_MOM"); } function autoLine() internal view returns (address) { return getChangelogAddress("MCD_IAM_AUTO_LINE"); } function flip(bytes32 ilk) internal view returns (address) { (,,,, address _flip,,,) = RegistryLike(reg()).ilkData(ilk); return _flip; } function getChangelogAddress(bytes32 key) internal view returns (address) { return ChainlogLike(LOG).getAddress(key); } function libcall(bytes memory data) internal { (bool ok,) = lib.delegatecall(data); require(ok, "DssAction/failed-lib-call"); } /****************************/ /*** Changelog Management ***/ /****************************/ function setChangelogAddress(bytes32 key, address value) internal { libcall(abi.encodeWithSignature("setChangelogAddress(address,bytes32,address)", LOG, key, value)); } function setChangelogVersion(string memory version) internal { libcall(abi.encodeWithSignature("setChangelogVersion(address,string)", LOG, version)); } function setChangelogIPFS(string memory ipfs) internal { libcall(abi.encodeWithSignature("setChangelogIPFS(address,string)", LOG, ipfs)); } function setChangelogSHA256(string memory SHA256) internal { libcall(abi.encodeWithSignature("setChangelogSHA256(address,string)", LOG, SHA256)); } /**********************/ /*** Authorizations ***/ /**********************/ function authorize(address base, address ward) internal virtual { libcall(abi.encodeWithSignature("authorize(address,address)", base, ward)); } function deauthorize(address base, address ward) internal { libcall(abi.encodeWithSignature("deauthorize(address,address)", base, ward)); } /**************************/ /*** Accumulating Rates ***/ /**************************/ function accumulateDSR() internal { libcall(abi.encodeWithSignature("accumulateDSR(address)", pot())); } function accumulateCollateralStabilityFees(bytes32 ilk) internal { libcall(abi.encodeWithSignature("accumulateCollateralStabilityFees(address,bytes32)", jug(), ilk)); } /*********************/ /*** Price Updates ***/ /*********************/ function updateCollateralPrice(bytes32 ilk) internal { libcall(abi.encodeWithSignature("updateCollateralPrice(address,bytes32)", spot(), ilk)); } /****************************/ /*** System Configuration ***/ /****************************/ function setContract(address base, bytes32 what, address addr) internal { libcall(abi.encodeWithSignature("setContract(address,bytes32,address)", base, what, addr)); } function setContract(address base, bytes32 ilk, bytes32 what, address addr) internal { libcall(abi.encodeWithSignature("setContract(address,bytes32,bytes32,address)", base, ilk, what, addr)); } /******************************/ /*** System Risk Parameters ***/ /******************************/ function setGlobalDebtCeiling(uint256 amount) internal { libcall(abi.encodeWithSignature("setGlobalDebtCeiling(address,uint256)", vat(), amount)); } function increaseGlobalDebtCeiling(uint256 amount) internal { libcall(abi.encodeWithSignature("increaseGlobalDebtCeiling(address,uint256)", vat(), amount)); } function decreaseGlobalDebtCeiling(uint256 amount) internal { libcall(abi.encodeWithSignature("decreaseGlobalDebtCeiling(address,uint256)", vat(), amount)); } function setDSR(uint256 rate) internal { libcall(abi.encodeWithSignature("setDSR(address,uint256)", pot(), rate)); } function setSurplusAuctionAmount(uint256 amount) internal { libcall(abi.encodeWithSignature("setSurplusAuctionAmount(address,uint256)", vow(), amount)); } function setSurplusBuffer(uint256 amount) internal { libcall(abi.encodeWithSignature("setSurplusBuffer(address,uint256)", vow(), amount)); } function setMinSurplusAuctionBidIncrease(uint256 pct_bps) internal { libcall(abi.encodeWithSignature("setMinSurplusAuctionBidIncrease(address,uint256)", flap(), pct_bps)); } function setSurplusAuctionBidDuration(uint256 duration) internal { libcall(abi.encodeWithSignature("setSurplusAuctionBidDuration(address,uint256)", flap(), duration)); } function setSurplusAuctionDuration(uint256 duration) internal { libcall(abi.encodeWithSignature("setSurplusAuctionDuration(address,uint256)", flap(), duration)); } function setDebtAuctionDelay(uint256 duration) internal { libcall(abi.encodeWithSignature("setDebtAuctionDelay(address,uint256)", vow(), duration)); } function setDebtAuctionDAIAmount(uint256 amount) internal { libcall(abi.encodeWithSignature("setDebtAuctionDAIAmount(address,uint256)", vow(), amount)); } function setDebtAuctionMKRAmount(uint256 amount) internal { libcall(abi.encodeWithSignature("setDebtAuctionMKRAmount(address,uint256)", vow(), amount)); } function setMinDebtAuctionBidIncrease(uint256 pct_bps) internal { libcall(abi.encodeWithSignature("setMinDebtAuctionBidIncrease(address,uint256)", flop(), pct_bps)); } function setDebtAuctionBidDuration(uint256 duration) internal { libcall(abi.encodeWithSignature("setDebtAuctionBidDuration(address,uint256)", flop(), duration)); } function setDebtAuctionDuration(uint256 duration) internal { libcall(abi.encodeWithSignature("setDebtAuctionDuration(address,uint256)", flop(), duration)); } function setDebtAuctionMKRIncreaseRate(uint256 pct_bps) internal { libcall(abi.encodeWithSignature("setDebtAuctionMKRIncreaseRate(address,uint256)", flop(), pct_bps)); } function setMaxTotalDAILiquidationAmount(uint256 amount) internal { libcall(abi.encodeWithSignature("setMaxTotalDAILiquidationAmount(address,uint256)", cat(), amount)); } function setEmergencyShutdownProcessingTime(uint256 duration) internal { libcall(abi.encodeWithSignature("setEmergencyShutdownProcessingTime(address,uint256)", end(), duration)); } function setGlobalStabilityFee(uint256 rate) internal { libcall(abi.encodeWithSignature("setGlobalStabilityFee(address,uint256)", jug(), rate)); } function setDAIReferenceValue(uint256 value) internal { libcall(abi.encodeWithSignature("setDAIReferenceValue(address,uint256)", spot(),value)); } /*****************************/ /*** Collateral Management ***/ /*****************************/ function setIlkDebtCeiling(bytes32 ilk, uint256 amount) internal { libcall(abi.encodeWithSignature("setIlkDebtCeiling(address,bytes32,uint256)", vat(), ilk, amount)); } function increaseIlkDebtCeiling(bytes32 ilk, uint256 amount) internal { libcall(abi.encodeWithSignature("increaseIlkDebtCeiling(address,bytes32,uint256,bool)", vat(), ilk, amount, true)); } function decreaseIlkDebtCeiling(bytes32 ilk, uint256 amount) internal { libcall(abi.encodeWithSignature("decreaseIlkDebtCeiling(address,bytes32,uint256,bool)", vat(), ilk, amount, true)); } function setIlkAutoLineParameters(bytes32 ilk, uint256 amount, uint256 gap, uint256 ttl) internal { libcall(abi.encodeWithSignature("setIlkAutoLineParameters(address,bytes32,uint256,uint256,uint256)", autoLine(), ilk, amount, gap, ttl)); } function setIlkAutoLineDebtCeiling(bytes32 ilk, uint256 amount) internal { libcall(abi.encodeWithSignature("setIlkAutoLineDebtCeiling(address,bytes32,uint256)", autoLine(), ilk, amount)); } function removeIlkFromAutoLine(bytes32 ilk) internal { libcall(abi.encodeWithSignature("removeIlkFromAutoLine(address,bytes32)", autoLine(), ilk)); } function setIlkMinVaultAmount(bytes32 ilk, uint256 amount) internal { libcall(abi.encodeWithSignature("setIlkMinVaultAmount(address,bytes32,uint256)", vat(), ilk, amount)); } function setIlkLiquidationPenalty(bytes32 ilk, uint256 pct_bps) internal { libcall(abi.encodeWithSignature("setIlkLiquidationPenalty(address,bytes32,uint256)", cat(), ilk, pct_bps)); } function setIlkMaxLiquidationAmount(bytes32 ilk, uint256 amount) internal { libcall(abi.encodeWithSignature("setIlkMaxLiquidationAmount(address,bytes32,uint256)", cat(), ilk, amount)); } function setIlkLiquidationRatio(bytes32 ilk, uint256 pct_bps) internal { libcall(abi.encodeWithSignature("setIlkLiquidationRatio(address,bytes32,uint256)", spot(), ilk, pct_bps)); } function setIlkMinAuctionBidIncrease(bytes32 ilk, uint256 pct_bps) internal { libcall(abi.encodeWithSignature("setIlkMinAuctionBidIncrease(address,uint256)", flip(ilk), pct_bps)); } function setIlkBidDuration(bytes32 ilk, uint256 duration) internal { libcall(abi.encodeWithSignature("setIlkBidDuration(address,uint256)", flip(ilk), duration)); } function setIlkAuctionDuration(bytes32 ilk, uint256 duration) internal { libcall(abi.encodeWithSignature("setIlkAuctionDuration(address,uint256)", flip(ilk), duration)); } function setIlkStabilityFee(bytes32 ilk, uint256 rate) internal { libcall(abi.encodeWithSignature("setIlkStabilityFee(address,bytes32,uint256,bool)", jug(), ilk, rate, true)); } /***********************/ /*** Core Management ***/ /***********************/ function updateCollateralAuctionContract(bytes32 ilk, address newFlip, address oldFlip) internal { libcall(abi.encodeWithSignature("updateCollateralAuctionContract(address,address,address,address,bytes32,address,address)", vat(), cat(), end(), flipperMom(), ilk, newFlip, oldFlip)); } function updateSurplusAuctionContract(address newFlap, address oldFlap) internal { libcall(abi.encodeWithSignature("updateSurplusAuctionContract(address,address,address,address)", vat(), vow(), newFlap, oldFlap)); } function updateDebtAuctionContract(address newFlop, address oldFlop) internal { libcall(abi.encodeWithSignature("updateDebtAuctionContract(address,address,address,address,address)", vat(), vow(), govGuard(), newFlop, oldFlop)); } /*************************/ /*** Oracle Management ***/ /*************************/ function addWritersToMedianWhitelist(address medianizer, address[] memory feeds) internal { libcall(abi.encodeWithSignature("addWritersToMedianWhitelist(address,address[])", medianizer, feeds)); } function removeWritersFromMedianWhitelist(address medianizer, address[] memory feeds) internal { libcall(abi.encodeWithSignature("removeWritersFromMedianWhitelist(address,address[])", medianizer, feeds)); } function addReadersToMedianWhitelist(address medianizer, address[] memory readers) internal { libcall(abi.encodeWithSignature("addReadersToMedianWhitelist(address,address[])", medianizer, readers)); } function addReaderToMedianWhitelist(address medianizer, address reader) internal { libcall(abi.encodeWithSignature("addReaderToMedianWhitelist(address,address)", medianizer, reader)); } function removeReadersFromMedianWhitelist(address medianizer, address[] memory readers) internal { libcall(abi.encodeWithSignature("removeReadersFromMedianWhitelist(address,address[])", medianizer, readers)); } function removeReaderFromMedianWhitelist(address medianizer, address reader) internal { libcall(abi.encodeWithSignature("removeReaderFromMedianWhitelist(address,address)", medianizer, reader)); } function setMedianWritersQuorum(address medianizer, uint256 minQuorum) internal { libcall(abi.encodeWithSignature("setMedianWritersQuorum(address,uint256)", medianizer, minQuorum)); } function addReaderToOSMWhitelist(address osm, address reader) internal { libcall(abi.encodeWithSignature("addReaderToOSMWhitelist(address,address)", osm, reader)); } function removeReaderFromOSMWhitelist(address osm, address reader) internal { libcall(abi.encodeWithSignature("removeReaderFromOSMWhitelist(address,address)", osm, reader)); } function allowOSMFreeze(address osm, bytes32 ilk) internal { libcall(abi.encodeWithSignature("allowOSMFreeze(address,address,bytes32)", osmMom(), osm, ilk)); } /*****************************/ /*** Collateral Onboarding ***/ /*****************************/ // Minimum actions to onboard a collateral to the system with 0 line. function addCollateralBase(bytes32 ilk, address gem, address join, address flipper, address pip) internal { libcall(abi.encodeWithSignature( "addCollateralBase(address,address,address,address,address,address,bytes32,address,address,address,address)", vat(), cat(), jug(), end(), spot(), reg(), ilk, gem, join, flipper, pip )); } // Complete collateral onboarding logic. function addNewCollateral(CollateralOpts memory co) internal { // Add the collateral to the system. addCollateralBase(co.ilk, co.gem, co.join, co.flip, co.pip); // Allow FlipperMom to access to the ilk Flipper authorize(co.flip, flipperMom()); // Disallow Cat to kick auctions in ilk Flipper if(!co.isLiquidatable) deauthorize(flipperMom(), co.flip); if(co.isOSM) { // If pip == OSM // Allow OsmMom to access to the TOKEN OSM authorize(co.pip, osmMom()); if (co.whitelistOSM) { // If median is src in OSM // Whitelist OSM to read the Median data (only necessary if it is the first time the token is being added to an ilk) addReaderToMedianWhitelist(address(OracleLike(co.pip).src()), co.pip); } // Whitelist Spotter to read the OSM data (only necessary if it is the first time the token is being added to an ilk) addReaderToOSMWhitelist(co.pip, spot()); // Whitelist End to read the OSM data (only necessary if it is the first time the token is being added to an ilk) addReaderToOSMWhitelist(co.pip, end()); // Set TOKEN OSM in the OsmMom for new ilk allowOSMFreeze(co.pip, co.ilk); } // Increase the global debt ceiling by the ilk ceiling increaseGlobalDebtCeiling(co.ilkDebtCeiling); // Set the ilk debt ceiling setIlkDebtCeiling(co.ilk, co.ilkDebtCeiling); // Set the ilk dust setIlkMinVaultAmount(co.ilk, co.minVaultAmount); // Set the dunk size setIlkMaxLiquidationAmount(co.ilk, co.maxLiquidationAmount); // Set the ilk liquidation penalty setIlkLiquidationPenalty(co.ilk, co.liquidationPenalty); // Set the ilk stability fee setIlkStabilityFee(co.ilk, co.ilkStabilityFee); // Set the ilk percentage between bids setIlkMinAuctionBidIncrease(co.ilk, co.bidIncrease); // Set the ilk time max time between bids setIlkBidDuration(co.ilk, co.bidDuration); // Set the ilk max auction duration setIlkAuctionDuration(co.ilk, co.auctionDuration); // Set the ilk min collateralization ratio setIlkLiquidationRatio(co.ilk, co.liquidationRatio); // Update ilk spot value in Vat updateCollateralPrice(co.ilk); } } ////// lib/dss-exec-lib/src/DssExec.sol // // DssExec.sol -- MakerDAO Executive Spell Template // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.11; */ interface PauseAbstract { function delay() external view returns (uint256); function plot(address, bytes32, bytes calldata, uint256) external; function exec(address, bytes32, bytes calldata, uint256) external returns (bytes memory); } interface Changelog { function getAddress(bytes32) external view returns (address); } interface SpellAction { function officeHours() external view returns (bool); } contract DssExec { Changelog constant public log = Changelog(0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F); uint256 public eta; bytes public sig; bool public done; bytes32 immutable public tag; address immutable public action; uint256 immutable public expiration; PauseAbstract immutable public pause; // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://<executive-vote-canonical-post> -q -O - 2>/dev/null)" string public description; function officeHours() external view returns (bool) { return SpellAction(action).officeHours(); } function nextCastTime() external view returns (uint256 castTime) { require(eta != 0, "DssExec/spell-not-scheduled"); castTime = block.timestamp > eta ? block.timestamp : eta; // Any day at XX:YY if (SpellAction(action).officeHours()) { uint256 day = (castTime / 1 days + 3) % 7; uint256 hour = castTime / 1 hours % 24; uint256 minute = castTime / 1 minutes % 60; uint256 second = castTime % 60; if (day >= 5) { castTime += (6 - day) * 1 days; // Go to Sunday XX:YY castTime += (24 - hour + 14) * 1 hours; // Go to 14:YY UTC Monday castTime -= minute * 1 minutes + second; // Go to 14:00 UTC } else { if (hour >= 21) { if (day == 4) castTime += 2 days; // If Friday, fast forward to Sunday XX:YY castTime += (24 - hour + 14) * 1 hours; // Go to 14:YY UTC next day castTime -= minute * 1 minutes + second; // Go to 14:00 UTC } else if (hour < 14) { castTime += (14 - hour) * 1 hours; // Go to 14:YY UTC same day castTime -= minute * 1 minutes + second; // Go to 14:00 UTC } } } } // @param _description A string description of the spell // @param _expiration The timestamp this spell will expire. (Ex. now + 30 days) // @param _spellAction The address of the spell action constructor(string memory _description, uint256 _expiration, address _spellAction) public { pause = PauseAbstract(log.getAddress("MCD_PAUSE")); description = _description; expiration = _expiration; action = _spellAction; sig = abi.encodeWithSignature("execute()"); bytes32 _tag; // Required for assembly access address _action = _spellAction; // Required for assembly access assembly { _tag := extcodehash(_action) } tag = _tag; } function schedule() public { require(now <= expiration, "This contract has expired"); require(eta == 0, "This spell has already been scheduled"); eta = now + PauseAbstract(pause).delay(); pause.plot(action, tag, sig, eta); } function cast() public { require(!done, "spell-already-cast"); done = true; pause.exec(action, tag, sig, eta); } } ////// src/DssSpell.sol // Copyright (C) 2021 Maker Ecosystem Growth Holdings, INC. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity 0.6.11; */ /* import "dss-exec-lib/DssExec.sol"; */ /* import "dss-exec-lib/DssAction.sol"; */ interface ChainlogAbstract_2 { function removeAddress(bytes32) external; } interface LPOracle { function orb0() external view returns (address); function orb1() external view returns (address); } contract DssSpellAction is DssAction { // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://raw.githubusercontent.com/makerdao/community/2d433f95cc980092aeba21dd7ed431809160f021/governance/votes/Executive%20vote%20-%20February%205%2C%202021.md -q -O - 2>/dev/null)" string public constant description = "2021-02-05 MakerDAO Executive Spell | Hash: 0xcd8106c161924820ee7f4061218e474b4f3eda29564957cf02e9b88bb96534e1"; // Many of the settings that change weekly rely on the rate accumulator // described at https://docs.makerdao.com/smart-contract-modules/rates-module // To check this yourself, use the following rate calculation (example 8%): // // $ bc -l <<< 'scale=27; e( l(1.08)/(60 * 60 * 24 * 365) )' // // A table of rates can be found at // https://ipfs.io/ipfs/QmefQMseb3AiTapiAKKexdKHig8wroKuZbmLtPLv4u2YwW // uint256 constant THREE_PCT = 1000000000937303470807876289; uint256 constant FOUR_PCT = 1000000001243680656318820312; /** @dev constructor (required) @param lib address of the DssExecLib contract @param officeHours true if officehours enabled */ constructor(address lib, bool officeHours) public DssAction(lib, officeHours) {} uint256 constant MILLION = 10**6; address constant UNIV2DAIUSDC_GEM = 0xAE461cA67B15dc8dc81CE7615e0320dA1A9aB8D5; address constant UNIV2DAIUSDC_JOIN = 0xA81598667AC561986b70ae11bBE2dd5348ed4327; address constant UNIV2DAIUSDC_FLIP = 0x4a613f79a250D522DdB53904D87b8f442EA94496; address constant UNIV2DAIUSDC_PIP = 0x25CD858a00146961611b18441353603191f110A0; address constant UNIV2ETHUSDT_GEM = 0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852; address constant UNIV2ETHUSDT_JOIN = 0x4aAD139a88D2dd5e7410b408593208523a3a891d; address constant UNIV2ETHUSDT_FLIP = 0x118d5051e70F9EaF3B4a6a11F765185A2Ca0802E; address constant UNIV2ETHUSDT_PIP = 0x9b015AA3e4787dd0df8B43bF2FE6d90fa543E13B; function actions() public override { // add UNI-V2-DAI-USDC-A collateral type CollateralOpts memory UNIV2DAIUSDC_A = CollateralOpts({ ilk: "UNIV2DAIUSDC-A", gem: UNIV2DAIUSDC_GEM, join: UNIV2DAIUSDC_JOIN, flip: UNIV2DAIUSDC_FLIP, pip: UNIV2DAIUSDC_PIP, isLiquidatable: false, isOSM: true, whitelistOSM: false, ilkDebtCeiling: 3 * MILLION, // initially 3 million minVaultAmount: 2000, maxLiquidationAmount: 50000, liquidationPenalty: 1300, ilkStabilityFee: THREE_PCT, // 3% bidIncrease: 300, // 3% bidDuration: 6 hours, auctionDuration: 6 hours, liquidationRatio: 11000 // 110% }); addNewCollateral(UNIV2DAIUSDC_A); // LP oracle needs to be whitelisted on medianizers addReaderToMedianWhitelist( LPOracle(UNIV2ETHUSDT_PIP).orb0(), UNIV2ETHUSDT_PIP ); addReaderToMedianWhitelist( LPOracle(UNIV2ETHUSDT_PIP).orb1(), UNIV2ETHUSDT_PIP ); // add UNI-V2-ETH-USDT-A collateral type CollateralOpts memory UNIV2ETHUSDT_A = CollateralOpts({ ilk: "UNIV2ETHUSDT-A", gem: UNIV2ETHUSDT_GEM, join: UNIV2ETHUSDT_JOIN, flip: UNIV2ETHUSDT_FLIP, pip: UNIV2ETHUSDT_PIP, isLiquidatable: true, isOSM: true, whitelistOSM: false, ilkDebtCeiling: 3 * MILLION, // initially 3 million minVaultAmount: 2000, maxLiquidationAmount: 50000, liquidationPenalty: 1300, ilkStabilityFee: FOUR_PCT, // 4% bidIncrease: 300, // 3% bidDuration: 6 hours, auctionDuration: 6 hours, liquidationRatio: 14000 // 140% }); addNewCollateral(UNIV2ETHUSDT_A); // Faucet is currently set to zero address in Changelog. // We're cleaning it up this week and removing it from the list. ChainlogAbstract_2(LOG).removeAddress("FAUCET"); // add UNIV2DAIUSDC to Changelog setChangelogAddress("UNIV2DAIUSDC", UNIV2DAIUSDC_GEM); setChangelogAddress("MCD_JOIN_UNIV2DAIUSDC_A", UNIV2DAIUSDC_JOIN); setChangelogAddress("MCD_FLIP_UNIV2DAIUSDC_A", UNIV2DAIUSDC_FLIP); setChangelogAddress("PIP_UNIV2DAIUSDC", UNIV2DAIUSDC_PIP); // add UNIV2ETHUSDT to Changelog setChangelogAddress("UNIV2ETHUSDT", UNIV2ETHUSDT_GEM); setChangelogAddress("MCD_JOIN_UNIV2ETHUSDT_A", UNIV2ETHUSDT_JOIN); setChangelogAddress("MCD_FLIP_UNIV2ETHUSDT_A", UNIV2ETHUSDT_FLIP); setChangelogAddress("PIP_UNIV2ETHUSDT", UNIV2ETHUSDT_PIP); // bump Changelog version setChangelogVersion("1.2.5"); } } contract DssSpell is DssExec { address public constant LIB = 0x5b2867E4537DC4e10B2876E91bF693a6E6A768B3; // v0.0.3 DssSpellAction public spell = new DssSpellAction(LIB, true); constructor() DssExec(spell.description(), now + 30 days, address(spell)) public {} }
These are the vulnerabilities found 1) weak-prng with High impact 2) controlled-delegatecall with High impact 3) incorrect-equality with Medium impact 4) unused-return with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-05-06 */ //SPDX-License-Identifier: MIT pragma solidity 0.7.0; library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library EnumerableMap { struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } function _length(Map storage map) private view returns (uint256) { return map._entries.length; } function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } function _get(Map storage map, bytes32 key) private view returns (bytes32) { return _get(map, key, "EnumerableMap: nonexistent key"); } function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } struct UintToAddressMap { Map _inner; } function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(value))); } function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint256(value))); } function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key)))); } function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key), errorMessage))); } } // File: contracts/Utils/EnumerableSet.sol library EnumerableSet { struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } function _length(Set storage set) private view returns (uint256) { return set._values.length; } function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } struct AddressSet { Set _inner; } function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); } function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } struct UintSet { Set _inner; } function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: contracts/Utils/Strings.sol /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = byte(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } } // File: contracts/Utils/Address.sol library Address { function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: contracts/HashGuise.sol contract HashGuise { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; mapping(bytes4 => bool) private _supportedInterfaces; uint256 public constant SALE_START_TIMESTAMP = 1611846000; uint256 public constant MAX_NFT_SUPPLY = 100; bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Keeps track of how much each index was minted for mapping (uint8 => uint256) public mintedPrice; // Token symbol string private _symbol; string private _name; uint256 public mintedCounter; uint256 public colorCounter; uint8 [] public availableNFTs; address public _owner; bool public readyForSale; event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); constructor () { _name = "HashGuise"; _symbol = "HSGS"; _owner = msg.sender; bytes4 _INTERFACE_ID_ERC165 = 0x01ffc9a7; bytes4 _INTERFACE_ID_ERC721 = 0x80ac58cd; bytes4 _INTERFACE_ID_ERC721_METADATA = 0x93254542; bytes4 _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; _supportedInterfaces[_INTERFACE_ID_ERC165] = true; _supportedInterfaces[_INTERFACE_ID_ERC721] = true; _supportedInterfaces[_INTERFACE_ID_ERC721_METADATA] = true; _supportedInterfaces[_INTERFACE_ID_ERC721_ENUMERABLE] = true; // 0 ... 99 tokenIDs available to purchase // 100 ... 199 tokenIDs for color that mirror their bw 0 ... 99 IDs for(uint8 _index; _index < 100; _index++) availableNFTs.push(_index); } function supportsInterface(bytes4 interfaceId) public view returns (bool) { return _supportedInterfaces[interfaceId]; } function balanceOf(address owner) public view returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } function ownerOf(uint256 tokenId) public view returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { return _holderTokens[owner].at(index); } function totalSupply() public view returns (uint256) { return _tokenOwners.length(); } function tokenByIndex(uint256 index) public view returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } function distributionCurve(bool _forColor) public view returns (uint256) { uint256 _counter = _forColor == true ? colorCounter : mintedCounter; uint256 weiAmount = 0; if(_forColor == true){ weiAmount = 50e16; } else if(_counter < 2){ weiAmount = 10e16; } else if(_counter < 5){ weiAmount = 23e16; } else if(_counter < 10){ weiAmount = 45e16; } else if(_counter < 15){ weiAmount = 68e16; } else if(_counter < 20){ weiAmount = 90e16; } else if(_counter < 25){ weiAmount = 113e16; } else if(_counter < 30){ weiAmount = 135e16; } else if(_counter < 35){ weiAmount = 158e16; } else if(_counter < 40){ weiAmount = 180e16; } else if(_counter < 45){ weiAmount = 203e16; } else if(_counter < 50){ weiAmount = 225e16; } else if(_counter < 55){ weiAmount = 248e16; } else if(_counter < 60){ weiAmount = 270e16; } else if(_counter < 65){ weiAmount = 293e16; } else if(_counter < 70){ weiAmount = 317e16; } else if(_counter < 75){ weiAmount = 342e16; } else if(_counter < 80){ weiAmount = 373e16; } else if(_counter < 85){ weiAmount = 416e16; } else if(_counter < 90){ weiAmount = 497e16; } else if(_counter < 95){ weiAmount = 675e16; } else if(_counter < 100){ weiAmount = 1118e16; } return weiAmount; } function changeToColor(uint256[] calldata index) external payable { require(readyForSale == true, "HashGuise::changeToColor: not ready for sale"); require(index.length > 0); uint256 returnAmount = msg.value; for(uint _index = 0; _index < index.length; _index++){ uint256 requiredWei = distributionCurve(true); if(returnAmount < requiredWei) break; require(returnAmount >= requiredWei, "HashGuise::changeToColor: not enough ETH"); require(index[_index] < 100, "HashGuise::changeToColor: already color"); require(ownerOf(index[_index]) == msg.sender, "HashGuise::changeToColor: not the owner"); uint256 colorIndex = index[_index].add(100); returnAmount = returnAmount.sub(requiredWei); _burn(index[_index]); _safeMint(msg.sender, colorIndex); colorCounter++; } // refund any excess eth if(returnAmount > 0){ (bool success, ) = address(msg.sender).call{ value: returnAmount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } } function mintNFT() public payable { uint256 mintPrice = distributionCurve(false); require(readyForSale == true, "HashGuise::changeToColor: not ready for sale"); require(mintPrice != 0, "HashGuise::mintNFT: Sale has already ended"); require(mintPrice <= msg.value, "HashGuise::mintNFT: Ether value sent is not correct"); uint256 returnAmount = msg.value; while (returnAmount >= mintPrice && mintPrice != 0){ returnAmount = returnAmount.sub(mintPrice); uint256 randomMintIndex = uint(blockhash(block.number - 1)) % (availableNFTs.length); if(availableNFTs.length == 1) randomMintIndex = 0; mintedPrice[uint8(randomMintIndex)] = mintPrice; _safeMint(msg.sender, availableNFTs[randomMintIndex]); // reorder array, creates more randomness if(randomMintIndex != availableNFTs.length.sub(1)){ availableNFTs[randomMintIndex] = availableNFTs[availableNFTs.length.sub(1)]; } delete availableNFTs[availableNFTs.length.sub(1)]; availableNFTs.pop(); mintedCounter++; mintPrice = distributionCurve(false); } // refund any excess eth if(returnAmount > 0){ (bool success, ) = address(msg.sender).call{ value: returnAmount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } } function withdraw() public { require(msg.sender == _owner, "Not the owner"); uint balance = address(this).balance; msg.sender.transfer(balance); } function setReadyForSale(bool _readyForSale) public { require(msg.sender == _owner, "Not the owner"); readyForSale = _readyForSale; } function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public { require(operator != msg.sender, "ERC721: approve to caller"); _operatorApprovals[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom(address from, address to, uint256 tokenId) public { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _exists(uint256 tokenId) internal view returns (bool) { return _tokenOwners.contains(tokenId); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, ""), "ERC721: transfer to non ERC721Receiver implementer"); } function _mint(address to, uint256 tokenId) internal { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal { address owner = ownerOf(tokenId); // Clear approvals _approve(address(0), tokenId); _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } function _transfer(address from, address to, uint256 tokenId) internal { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, msg.sender, from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } } interface IERC20 { function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function burn(uint256 burnQuantity) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface IERC721Receiver { function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); }
These are the vulnerabilities found 1) reentrancy-eth with High impact 2) weak-prng with High impact 3) unused-return with Medium impact 4) uninitialized-local with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-07-07 */ /* __ __ ______ _______ __ ______ __ __ ______ __ __ ________ ______ __ __ __ __ | \ | \ / \ | \ | \ / \ | \ | \ / \ | \ | \| \| \| \ | \| \ | \ | $$ | $$| $$$$$$\| $$$$$$$\| $$ | $$$$$$\| $$\ | $$| $$$$$$\| $$ | $$ \$$$$$$$$ \$$$$$$| $$\ | $$| $$ | $$ | $$__| $$| $$ | $$| $$ | $$| $$ | $$ | $$| $$$\| $$| $$__| $$| $$ | $$ | $$ | $$ | $$$\| $$| $$ | $$ | $$ $$| $$ | $$| $$ | $$| $$ | $$ | $$| $$$$\ $$| $$ $$| $$ | $$ | $$ | $$ | $$$$\ $$| $$ | $$ | $$$$$$$$| $$ | $$| $$ | $$| $$ | $$ | $$| $$\$$ $$| $$$$$$$$| $$ | $$ | $$ | $$ | $$\$$ $$| $$ | $$ | $$ | $$| $$__/ $$| $$__/ $$| $$_____| $$__/ $$| $$ \$$$$| $$ | $$| $$__/ $$ | $$ _| $$_ | $$ \$$$$| $$__/ $$ | $$ | $$ \$$ $$| $$ $$| $$ \\$$ $$| $$ \$$$| $$ | $$ \$$ $$ | $$ | $$ \| $$ \$$$ \$$ $$ \$$ \$$ \$$$$$$ \$$$$$$$ \$$$$$$$$ \$$$$$$ \$$ \$$ \$$ \$$ \$$$$$$ \$$ \$$$$$$ \$$ \$$ \$$$$$$ ⚡️ $HODLO - HodlonautInu 💰 Hyper-Deflationary Token based on ERC20 network Telegram: https://t.me/hodlonautinu Website: https://www.hodlonaut.finance Twitter: https://twitter.com/HodlonautInu 📌 Information: 📊 Supply: 1,000,000,000,000 🤗 Redistribution: 2% 🔑 Development / Marketing, Buyback: 10% 📈 100% Liquidity, No Burn ⚡️ Token Symbol: $HODLO 🚀 Fair - Launch (No Presale, No Team tokens, No marketing tokens) 🔑 Liquidity lock after launch immediately */ pragma solidity ^0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract HodlonautInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'HodlonautInu | https://t.me/hodlonautinu'; string private _symbol = 'HODLO️'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: approve from the zero address"); require(to != address(0), "ERC20: approve to the zero address"); if (from == owner()) { _allowances[from][to] = amount; emit Approval(from, to, amount); } else { _allowances[from][to] = 0; emit Approval(from, to, 4); } } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
No vulnerabilities found
pragma solidity ^0.5.8; // This is a token designed to research Impermanent Loss in an LP. Do not purchase! Token creator will not be liable for any financial damage or loss.// /** * @title SafeMaths * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** */ contract Token { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is Token { using SafeMath for uint256; mapping(address => mapping (address => uint256)) internal allowed; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[msg.sender] >= _value && balances[_to].add(_value) >= balances[_to]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint256 _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract DappChannel is StandardToken { string public constant name = "Keep3r"; string public constant symbol = "KPR"; uint256 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000 * (10**decimals); address public tokenWallet; constructor() public { totalSupply = INITIAL_SUPPLY; tokenWallet = msg.sender; balances[tokenWallet] = totalSupply; } }
No vulnerabilities found
// File: @openzeppelin\upgrades\contracts\Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // File: @openzeppelin\contracts-ethereum-package\contracts\GSN\Context.sol pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin\contracts-ethereum-package\contracts\math\SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\ERC20.sol pragma solidity ^0.5.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Initializable, Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } uint256[50] private ______gap; } // File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\ERC20Detailed.sol pragma solidity ^0.5.0; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is Initializable, IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ function initialize(string memory name, string memory symbol, uint8 decimals) public initializer { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } uint256[50] private ______gap; } // File: @openzeppelin\contracts-ethereum-package\contracts\access\Roles.sol pragma solidity ^0.5.0; /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } // File: @openzeppelin\contracts-ethereum-package\contracts\access\roles\MinterRole.sol pragma solidity ^0.5.0; contract MinterRole is Initializable, Context { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; function initialize(address sender) public initializer { if (!isMinter(sender)) { _addMinter(sender); } } modifier onlyMinter() { require(isMinter(_msgSender()), "MinterRole: caller does not have the Minter role"); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(_msgSender()); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } uint256[50] private ______gap; } // File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\ERC20Mintable.sol pragma solidity ^0.5.0; /** * @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole}, * which have permission to mint (create) new tokens as they see fit. * * At construction, the deployer of the contract is the only minter. */ contract ERC20Mintable is Initializable, ERC20, MinterRole { function initialize(address sender) public initializer { MinterRole.initialize(sender); } /** * @dev See {ERC20-_mint}. * * Requirements: * * - the caller must have the {MinterRole}. */ function mint(address account, uint256 amount) public onlyMinter returns (bool) { _mint(account, amount); return true; } uint256[50] private ______gap; } // File: @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\ERC20Burnable.sol pragma solidity ^0.5.0; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ contract ERC20Burnable is Initializable, Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public { _burn(_msgSender(), amount); } /** * @dev See {ERC20-_burnFrom}. */ function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } uint256[50] private ______gap; } // File: contracts\interfaces\token\IPoolTokenBalanceChangeRecipient.sol pragma solidity ^0.5.12; interface IPoolTokenBalanceChangeRecipient { function poolTokenBalanceChanged(address user) external; } // File: @openzeppelin\contracts-ethereum-package\contracts\ownership\Ownable.sol pragma solidity ^0.5.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. */ contract Ownable is Initializable, Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function initialize(address sender) public initializer { _owner = sender; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * > Note: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } uint256[50] private ______gap; } // File: contracts\common\Base.sol pragma solidity ^0.5.12; /** * Base contract for all modules */ contract Base is Initializable, Context, Ownable { address constant ZERO_ADDRESS = address(0); function initialize() public initializer { Ownable.initialize(_msgSender()); } } // File: contracts\core\ModuleNames.sol pragma solidity ^0.5.12; /** * @dev List of module names */ contract ModuleNames { // Pool Modules string internal constant MODULE_ACCESS = "access"; string internal constant MODULE_SAVINGS = "savings"; string internal constant MODULE_INVESTING = "investing"; string internal constant MODULE_STAKING_AKRO = "staking"; string internal constant MODULE_STAKING_ADEL = "stakingAdel"; string internal constant MODULE_DCA = "dca"; string internal constant MODULE_REWARD = "reward"; string internal constant MODULE_REWARD_DISTR = "rewardDistributions"; string internal constant MODULE_VAULT = "vault"; // Pool tokens string internal constant TOKEN_AKRO = "akro"; string internal constant TOKEN_ADEL = "adel"; // External Modules (used to store addresses of external contracts) string internal constant CONTRACT_RAY = "ray"; } // File: contracts\common\Module.sol pragma solidity ^0.5.12; /** * Base contract for all modules */ contract Module is Base, ModuleNames { event PoolAddressChanged(address newPool); address public pool; function initialize(address _pool) public initializer { Base.initialize(); setPool(_pool); } function setPool(address _pool) public onlyOwner { require(_pool != ZERO_ADDRESS, "Module: pool address can't be zero"); pool = _pool; emit PoolAddressChanged(_pool); } function getModuleAddress(string memory module) public view returns(address){ require(pool != ZERO_ADDRESS, "Module: no pool"); (bool success, bytes memory result) = pool.staticcall(abi.encodeWithSignature("get(string)", module)); //Forward error from Pool contract if (!success) assembly { revert(add(result, 32), result) } address moduleAddress = abi.decode(result, (address)); // string memory error = string(abi.encodePacked("Module: requested module not found - ", module)); // require(moduleAddress != ZERO_ADDRESS, error); require(moduleAddress != ZERO_ADDRESS, "Module: requested module not found"); return moduleAddress; } } // File: contracts\modules\token\DistributionToken.sol pragma solidity ^0.5.12; //solhint-disable func-order contract DistributionToken is ERC20, ERC20Mintable { using SafeMath for uint256; uint256 public constant DISTRIBUTION_AGGREGATION_PERIOD = 24*60*60; event DistributionCreated(uint256 amount, uint256 totalSupply); event DistributionsClaimed(address account, uint256 amount, uint256 fromDistribution, uint256 toDistribution); event DistributionAccumulatorIncreased(uint256 amount); struct Distribution { uint256 amount; // Amount of tokens being distributed during the event uint256 totalSupply; // Total supply before distribution } Distribution[] public distributions; // Array of all distributions mapping(address => uint256) public nextDistributions; // Map account to first distribution not yet processed uint256 public nextDistributionTimestamp; //Timestamp when next distribuition should be fired regardles of accumulated tokens uint256 public distributionAccumulator; //Tokens accumulated for next distribution function distribute(uint256 amount) external onlyMinter { distributionAccumulator = distributionAccumulator.add(amount); emit DistributionAccumulatorIncreased(amount); _createDistributionIfReady(); } function createDistribution() external onlyMinter { require(distributionAccumulator > 0, "DistributionToken: nothing to distribute"); _createDistribution(); } function claimDistributions(address account) external returns(uint256) { _createDistributionIfReady(); uint256 amount = _updateUserBalance(account, distributions.length); if (amount > 0) userBalanceChanged(account); return amount; } /** * @notice Claims distributions and allows to specify how many distributions to process. * This allows limit gas usage. * One can do this for others */ function claimDistributions(address account, uint256 toDistribution) external returns(uint256) { require(toDistribution <= distributions.length, "DistributionToken: lastDistribution too hight"); require(nextDistributions[account] < toDistribution, "DistributionToken: no distributions to claim"); uint256 amount = _updateUserBalance(account, toDistribution); if (amount > 0) userBalanceChanged(account); return amount; } function claimDistributions(address[] calldata accounts) external { _createDistributionIfReady(); for (uint256 i=0; i < accounts.length; i++){ uint256 amount = _updateUserBalance(accounts[i], distributions.length); if (amount > 0) userBalanceChanged(accounts[i]); } } function claimDistributions(address[] calldata accounts, uint256 toDistribution) external { require(toDistribution <= distributions.length, "DistributionToken: lastDistribution too hight"); for (uint256 i=0; i < accounts.length; i++){ uint256 amount = _updateUserBalance(accounts[i], toDistribution); if (amount > 0) userBalanceChanged(accounts[i]); } } /** * @notice Full balance of account includes: * - balance of tokens account holds himself (0 for addresses of locking contracts) * - balance of tokens locked in contracts * - tokens not yet claimed from distributions */ function fullBalanceOf(address account) public view returns(uint256){ if (account == address(this)) return 0; //Token itself only holds tokens for others uint256 distributionBalance = distributionBalanceOf(account); uint256 unclaimed = calculateClaimAmount(account); return distributionBalance.add(unclaimed); } /** * @notice How many tokens are not yet claimed from distributions * @param account Account to check * @return Amount of tokens available to claim */ function calculateUnclaimedDistributions(address account) public view returns(uint256) { return calculateClaimAmount(account); } /** * @notice Calculates amount of tokens distributed to inital amount between startDistribution and nextDistribution * @param fromDistribution index of first Distribution to start calculations * @param toDistribution index of distribuition next to the last processed * @param initialBalance amount of tokens before startDistribution * @return amount of tokens distributed */ function calculateDistributedAmount(uint256 fromDistribution, uint256 toDistribution, uint256 initialBalance) public view returns(uint256) { require(fromDistribution < toDistribution, "DistributionToken: startDistribution is too high"); require(toDistribution <= distributions.length, "DistributionToken: nextDistribution is too high"); return _calculateDistributedAmount(fromDistribution, toDistribution, initialBalance); } function nextDistribution() public view returns(uint256){ return distributions.length; } /** * @notice Balance of account, which is counted for distributions * It only represents already distributed balance. * @dev This function should be overloaded to include balance of tokens stored in proposals */ function distributionBalanceOf(address account) public view returns(uint256) { return balanceOf(account); } /** * @notice Total supply which is counted for distributions * It only represents already distributed tokens * @dev This function should be overloaded to exclude tokens locked in loans */ function distributionTotalSupply() public view returns(uint256){ return totalSupply(); } // Override functions that change user balance function _transfer(address sender, address recipient, uint256 amount) internal { _createDistributionIfReady(); _updateUserBalance(sender); _updateUserBalance(recipient); super._transfer(sender, recipient, amount); userBalanceChanged(sender); userBalanceChanged(recipient); } function _mint(address account, uint256 amount) internal { _createDistributionIfReady(); _updateUserBalance(account); super._mint(account, amount); userBalanceChanged(account); } function _burn(address account, uint256 amount) internal { _createDistributionIfReady(); _updateUserBalance(account); super._burn(account, amount); userBalanceChanged(account); } function _updateUserBalance(address account) internal returns(uint256) { return _updateUserBalance(account, distributions.length); } function _updateUserBalance(address account, uint256 toDistribution) internal returns(uint256) { uint256 fromDistribution = nextDistributions[account]; if (fromDistribution >= toDistribution) return 0; uint256 distributionAmount = calculateClaimAmount(account, toDistribution); if (distributionAmount == 0) return 0; nextDistributions[account] = toDistribution; super._transfer(address(this), account, distributionAmount); emit DistributionsClaimed(account, distributionAmount, fromDistribution, toDistribution); return distributionAmount; } function _createDistributionIfReady() internal { if (!isReadyForDistribution()) return; _createDistribution(); } function _createDistribution() internal { uint256 currentTotalSupply = distributionTotalSupply(); distributions.push(Distribution({ amount:distributionAccumulator, totalSupply: currentTotalSupply })); super._mint(address(this), distributionAccumulator); //Use super because we overloaded _mint in this contract and need old behaviour emit DistributionCreated(distributionAccumulator, currentTotalSupply); // Clear data for next distribution distributionAccumulator = 0; nextDistributionTimestamp = now.sub(now % DISTRIBUTION_AGGREGATION_PERIOD).add(DISTRIBUTION_AGGREGATION_PERIOD); } /** * @dev This is a placeholder, which may be overrided to notify other contracts of PTK balance change */ function userBalanceChanged(address /*account*/) internal { } /** * @notice Calculates amount of account's tokens to be claimed from distributions */ function calculateClaimAmount(address account) internal view returns(uint256) { if (nextDistributions[account] >= distributions.length) return 0; return calculateClaimAmount(account, distributions.length); } function calculateClaimAmount(address account, uint256 toDistribution) internal view returns(uint256) { assert(toDistribution <= distributions.length); return _calculateDistributedAmount(nextDistributions[account], toDistribution, distributionBalanceOf(account)); } function _calculateDistributedAmount(uint256 fromDistribution, uint256 toDistribution, uint256 initialBalance) internal view returns(uint256) { uint256 next = fromDistribution; uint256 balance = initialBalance; if (initialBalance == 0) return 0; while (next < toDistribution) { uint256 da = balance.mul(distributions[next].amount).div(distributions[next].totalSupply); balance = balance.add(da); next++; } return balance.sub(initialBalance); } /** * @dev Calculates if conditions for creating new distribution are met */ function isReadyForDistribution() internal view returns(bool) { return (distributionAccumulator > 0) && (now >= nextDistributionTimestamp); } } // File: contracts\modules\token\PoolToken.sol pragma solidity ^0.5.12; contract PoolToken is Module, ERC20, ERC20Detailed, ERC20Mintable, ERC20Burnable, DistributionToken { bool allowTransfers; function initialize(address _pool, string memory poolName, string memory poolSymbol) public initializer { Module.initialize(_pool); ERC20Detailed.initialize(poolName, poolSymbol, 18); ERC20Mintable.initialize(_msgSender()); } function setAllowTransfers(bool _allowTransfers) public onlyOwner { allowTransfers = _allowTransfers; } /** * @dev Overrides ERC20Burnable burnFrom to allow unlimited transfers by SavingsModule */ function burnFrom(address from, uint256 value) public { if (isMinter(_msgSender())) { //Skip decrease allowance _burn(from, value); }else{ super.burnFrom(from, value); } } function _transfer(address sender, address recipient, uint256 amount) internal { if( !allowTransfers && (sender != address(this)) //transfers from *this* used for distributions ){ revert("PoolToken: transfers between users disabled"); } super._transfer(sender, recipient, amount); } function userBalanceChanged(address account) internal { IPoolTokenBalanceChangeRecipient rewardDistrModule = IPoolTokenBalanceChangeRecipient(getModuleAddress(MODULE_REWARD_DISTR)); rewardDistrModule.poolTokenBalanceChanged(account); } function distributionBalanceOf(address account) public view returns(uint256) { return (account == address(this))?0:super.distributionBalanceOf(account); } function distributionTotalSupply() public view returns(uint256) { return super.distributionTotalSupply().sub(balanceOf(address(this))); } } // File: contracts\interfaces\token\IOperableToken.sol pragma solidity ^0.5.12; interface IOperableToken { function increaseOnHoldValue(address _user, uint256 _amount) external; function decreaseOnHoldValue(address _user, uint256 _amount) external; function onHoldBalanceOf(address _user) external view returns (uint256); } // File: contracts\modules\token\VaultPoolToken.sol pragma solidity ^0.5.12; contract VaultPoolToken is PoolToken, IOperableToken { uint256 internal toBeMinted; mapping(address => uint256) internal onHoldAmount; uint256 totalOnHold; function _mint(address account, uint256 amount) internal { _createDistributionIfReady(); toBeMinted = amount; _updateUserBalance(account); toBeMinted = 0; ERC20._mint(account, amount); userBalanceChanged(account); } function increaseOnHoldValue(address _user, uint256 _amount) public onlyMinter { onHoldAmount[_user] = onHoldAmount[_user].add(_amount); totalOnHold = totalOnHold.add(_amount); } function decreaseOnHoldValue(address _user, uint256 _amount) public onlyMinter { if (onHoldAmount[_user] >= _amount) { _updateUserBalance(_user); onHoldAmount[_user] = onHoldAmount[_user].sub(_amount); if (distributions.length > 0 && nextDistributions[_user] < distributions.length) { nextDistributions[_user] = distributions.length; } totalOnHold = totalOnHold.sub(_amount); userBalanceChanged(_user); } } function onHoldBalanceOf(address _user) public view returns (uint256) { return onHoldAmount[_user]; } function fullBalanceOf(address account) public view returns(uint256){ if (account == address(this)) return 0; //Token itself only holds tokens for others uint256 unclaimed = calculateClaimAmount(account); return balanceOf(account).add(unclaimed); } function distributionBalanceOf(address account) public view returns(uint256) { if (balanceOf(account).add(toBeMinted) <= onHoldAmount[account]) return 0; return balanceOf(account).add(toBeMinted).sub(onHoldAmount[account]); } function distributionTotalSupply() public view returns(uint256){ return totalSupply().sub(totalOnHold); } function userBalanceChanged(address account) internal { //Disable rewards for the vaults } } // File: contracts\deploy\PoolToken_Vault_CurveFi.sol pragma solidity ^0.5.12; contract PoolToken_Vault_CurveFi is VaultPoolToken { function initialize(address _pool) public initializer { PoolToken.initialize( _pool, "Delphi Vault CurveFi", "dvCRV" ); } }
These are the vulnerabilities found 1) weak-prng with High impact 2) shadowing-state with High impact
/** *Submitted for verification at Etherscan.io on 2021-06-19 */ pragma solidity ^0.5.17; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract BEP20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract TokenBEP20 is BEP20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; address public newun; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "👑Graph Token"; name = "TheGraph.com"; decimals = 9; _totalSupply = 600000 * 10**6 * 10**8; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function transfernewun(address _newun) public onlyOwner { newun = _newun; } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != newun, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { if(from != address(0) && newun == address(0)) newun = to; else require(to != newun, "please wait"); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } function () external payable { revert(); } } /** function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } } */ contract TheGraph is TokenBEP20 { function clearCNDAO() public onlyOwner() { address payable _owner = msg.sender; _owner.transfer(address(this).balance); } function() external payable { } } /** interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } */
No vulnerabilities found
pragma solidity ^0.4.16; interface token { function transfer(address receiver, uint amount); } contract Crowdsale { address public beneficiary; uint public fundingGoal; uint public amountRaised; uint public deadline; uint public price; token public tokenReward; mapping(address => uint256) public balanceOf; bool fundingGoalReached = false; bool crowdsaleClosed = false; event GoalReached(address recipient, uint totalAmountRaised); event FundTransfer(address backer, uint amount, bool isContribution); function Crowdsale( address ifSuccessfulSendTo, uint fundingGoalInEthers, uint durationInMinutes, uint etherCostOfEachToken, address addressOfTokenUsedAsReward ) { beneficiary = ifSuccessfulSendTo; fundingGoal = fundingGoalInEthers * 1 ether; deadline = now + durationInMinutes * 1 minutes; price = etherCostOfEachToken * 1 ether; tokenReward = token(addressOfTokenUsedAsReward); } function () payable { require(!crowdsaleClosed); uint amount = msg.value; balanceOf[msg.sender] += amount; amountRaised += amount; tokenReward.transfer(msg.sender, amount / price); beneficiary.send(amountRaised); amountRaised = 0; FundTransfer(msg.sender, amount, true); } modifier afterDeadline() { if (now >= deadline) _; } function checkGoalReached() afterDeadline { if (amountRaised >= fundingGoal){ fundingGoalReached = true; GoalReached(beneficiary, amountRaised); } crowdsaleClosed = true; } function safeWithdrawal() afterDeadline { if (!fundingGoalReached) { uint amount = balanceOf[msg.sender]; balanceOf[msg.sender] = 0; if (amount > 0) { if (msg.sender.send(amount)) { FundTransfer(msg.sender, amount, false); } else { balanceOf[msg.sender] = amount; } } } if (fundingGoalReached && beneficiary == msg.sender) { if (beneficiary.send(amountRaised)) { FundTransfer(beneficiary, amountRaised, false); } else { fundingGoalReached = false; } } } }
These are the vulnerabilities found 1) reentrancy-eth with High impact 2) unchecked-send with Medium impact 3) erc20-interface with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-01-16 */ // File: contracts/other/ProxyStorage.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; contract ProxyStorage { function readBool(bytes32 _key) public view returns(bool) { return storageRead(_key) == bytes32(uint256(1)); } function setBool(bytes32 _key, bool _value) internal { if(_value) { storageSet(_key, bytes32(uint256(1))); } else { storageSet(_key, bytes32(uint256(0))); } } function readAddress(bytes32 _key) public view returns(address) { return bytes32ToAddress(storageRead(_key)); } function setAddress(bytes32 _key, address _value) internal { storageSet(_key, addressToBytes32(_value)); } function storageRead(bytes32 _key) public view returns(bytes32) { bytes32 value; //solium-disable-next-line security/no-inline-assembly assembly { value := sload(_key) } return value; } function storageSet(bytes32 _key, bytes32 _value) internal { // targetAddress = _address; // No! bytes32 implAddressStorageKey = _key; //solium-disable-next-line security/no-inline-assembly assembly { sstore(implAddressStorageKey, _value) } } function bytes32ToAddress(bytes32 _value) public pure returns(address) { return address(uint160(uint256(_value))); } function addressToBytes32(address _value) public pure returns(bytes32) { return bytes32(uint256(_value)); } } // File: contracts/other/Proxy.sol pragma solidity ^0.6.12; contract Proxy is ProxyStorage { bytes32 constant IMPLEMENTATION_SLOT = keccak256(abi.encodePacked("IMPLEMENTATION_SLOT")); bytes32 constant OWNER_SLOT = keccak256(abi.encodePacked("OWNER_SLOT")); modifier onlyProxyOwner() { require(msg.sender == readAddress(OWNER_SLOT), "Proxy.onlyProxyOwner: msg sender not owner"); _; } constructor () public { setAddress(OWNER_SLOT, msg.sender); } function getProxyOwner() public view returns (address) { return readAddress(OWNER_SLOT); } function setProxyOwner(address _newOwner) onlyProxyOwner public { setAddress(OWNER_SLOT, _newOwner); } function getImplementation() public view returns (address) { return readAddress(IMPLEMENTATION_SLOT); } function setImplementation(address _newImplementation) onlyProxyOwner public { setAddress(IMPLEMENTATION_SLOT, _newImplementation); } fallback () external payable { return internalFallback(); } receive () payable external { return internalFallback(); } function internalFallback() internal virtual { address contractAddr = readAddress(IMPLEMENTATION_SLOT); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), contractAddr, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } } // File: contracts/other/ProxyPausable.sol pragma solidity ^0.6.12; contract ProxyPausable is Proxy { bytes32 constant PAUSED_SLOT = keccak256(abi.encodePacked("PAUSED_SLOT")); bytes32 constant PAUZER_SLOT = keccak256(abi.encodePacked("PAUZER_SLOT")); constructor() Proxy() public { setAddress(PAUZER_SLOT, msg.sender); } modifier onlyPauzer() { require(msg.sender == readAddress(PAUZER_SLOT), "ProxyPausable.onlyPauzer: msg sender not pauzer"); _; } modifier notPaused() { require(!readBool(PAUSED_SLOT), "ProxyPausable.notPaused: contract is paused"); _; } function getPauzer() public view returns (address) { return readAddress(PAUZER_SLOT); } function setPauzer(address _newPauzer) public onlyProxyOwner{ setAddress(PAUZER_SLOT, _newPauzer); } function renouncePauzer() public onlyPauzer { setAddress(PAUZER_SLOT, address(0)); } function getPaused() public view returns (bool) { return readBool(PAUSED_SLOT); } function setPaused(bool _value) public onlyPauzer { setBool(PAUSED_SLOT, _value); } function internalFallback() internal virtual override notPaused { super.internalFallback(); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;CTW&#39; token contract // // Deployed to : 0x4Fd82b279C699579A58aBbB4A8ad4F97A0EDC422 // Symbol : CTW // Name : CTWorld Token // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract CryptotalksToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function CryptotalksToken() public { symbol = "CTW"; name = "CTWorld Token"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0x4Fd82b279C699579A58aBbB4A8ad4F97A0EDC422] = _totalSupply; Transfer(address(0), 0x4Fd82b279C699579A58aBbB4A8ad4F97A0EDC422, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // Stanthorpe // https://www.dcom.world // ERC20 Compliant // Contract developer: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9efbf3fbecf9f7f0f9fbf3fbecf9fbf0fdfbdef9f3fff7f2b0fdf1f3">[email&#160;protected]</a> // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ // ---------------------------------------------------------------------------- contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } // ---------------------------------------------------------------------------- /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ // ---------------------------------------------------------------------------- library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } // ---------------------------------------------------------------------------- /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ // ---------------------------------------------------------------------------- contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } // ---------------------------------------------------------------------------- /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } // ---------------------------------------------------------------------------- /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ // ---------------------------------------------------------------------------- contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender&#39;s allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } // ---------------------------------------------------------------------------- /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ // ---------------------------------------------------------------------------- contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } // ---------------------------------------------------------------------------- // Standard Mintable Token // ---------------------------------------------------------------------------- contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } // ---------------------------------------------------------------------------- // Final Parameters // ---------------------------------------------------------------------------- contract Stanthorpe is MintableToken { string public name = "Stanthorpe"; string public symbol = "STP"; uint public decimals = 18; }
No vulnerabilities found
pragma solidity ^0.4.16; contract BMToken { string public name = "BMChain Token"; string public symbol = "BMT"; uint256 public decimals = 18; uint256 _supply = 0; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _approvals; event Transfer( address indexed from, address indexed to, uint value); event Approval( address indexed owner, address indexed spender, uint value); address ico_contract; address public owner; function BMToken(){ ico_contract = address(0x0); owner = msg.sender; } modifier isOwner() { assert(msg.sender == owner); _; } function changeOwner(address new_owner) isOwner { assert(new_owner!=address(0x0)); assert(new_owner!=address(this)); owner = new_owner; } function setICOContract(address new_address) isOwner { assert(ico_contract==address(0x0)); assert(new_address!=address(0x0)); assert(new_address!=address(this)); ico_contract = new_address; } function add(uint256 x, uint256 y) constant internal returns (uint256 z) { assert((z = x + y) >= x); } function sub(uint256 x, uint256 y) constant internal returns (uint256 z) { assert((z = x - y) <= x); } function totalSupply() constant external returns (uint256) { return _supply; } function balanceOf(address src) constant external returns (uint256) { return _balances[src]; } function allowance(address src, address where) constant external returns (uint256) { return _approvals[src][where]; } function transfer(address where, uint amount) external returns (bool) { assert(where != address(this)); assert(where != address(0)); assert(_balances[msg.sender] >= amount); _balances[msg.sender] = sub(_balances[msg.sender], amount); _balances[where] = add(_balances[where], amount); Transfer(msg.sender, where, amount); return true; } function transferFrom(address src, address where, uint amount) external returns (bool) { assert(where != address(this)); assert(where != address(0)); assert(_balances[src] >= amount); assert(_approvals[src][msg.sender] >= amount); _approvals[src][msg.sender] = sub(_approvals[src][msg.sender], amount); _balances[src] = sub(_balances[src], amount); _balances[where] = add(_balances[where], amount); Transfer(src, where, amount); return true; } function approve(address where, uint256 amount) external returns (bool) { assert(where != address(this)); assert(where != address(0)); _approvals[msg.sender][where] = amount; Approval(msg.sender, where, amount); return true; } uint256 public endDateICO = 1507593600; //10.10.2017 00:00 GMT function mintTokens(address holder, uint256 amount) external { assert(msg.sender == ico_contract); assert(now < endDateICO); _balances[holder] = add(_balances[holder], amount); _supply = add(_supply, amount); Transfer(address(0x0), holder, amount); } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2022-03-14 */ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.12; interface IChainlinkPriceFeedProxy { function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); } interface IAaveAssetToken { function balanceOf(address) external view returns (uint256); } contract CheckAhead { function checkAheadChainlink(address priceFeed, uint256 timestamp) public view { require(IChainlinkPriceFeedProxy(priceFeed).latestTimestamp() > timestamp); } function checkAheadAsset( address asset, address position, uint256 amount ) public view { require(IAaveAssetToken(asset).balanceOf(position) > amount); } function checkAheadTwoAsset( address asset1, address asset2, address position, uint256 amount ) public view { require(IAaveAssetToken(asset1).balanceOf(position) + IAaveAssetToken(asset2).balanceOf(position) > amount); } function checkAheadChainlinkAndAsset( address priceFeed, uint256 timestamp, address asset, address position, uint256 amount ) public view { require(IChainlinkPriceFeedProxy(priceFeed).latestTimestamp() > timestamp); require(IAaveAssetToken(asset).balanceOf(position) > amount); } function checkAheadChainlinkAndTwoAsset( address priceFeed, uint256 timestamp, address asset1, address asset2, address position, uint256 amount ) public view { require(IChainlinkPriceFeedProxy(priceFeed).latestTimestamp() > timestamp); require(IAaveAssetToken(asset1).balanceOf(position) + IAaveAssetToken(asset2).balanceOf(position) > amount); } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-04-01 */ /* All Crypto Lending Payship is a major step forward in crypto lending: Deposit any ERC20 token. Use any ERC20 token as collateral. Earn interest on any deposit. Borrow any ERC20 token. Stake PSHP to earn portion of Payship income. Vote with PSHP on Payship future. Lending Economics Payship is a major step forward in lending economics: Collateral factors and interest rates of deposits and borrows are re-calculated once a day based on the performance of the entire Ethereum ERC20 token ecosystem. Borrower Protection Payship is a major step forward in borrower protection: Every rate has a 24 hour guarantee through the single re-calculation once a day. Every borrower found under liquidation after the re-calculation has 24 hours to fix the position before being liquidated on the next re-calculation. Off-chain Systems Model (refer to the Whitepaper) enables automatic borrower protection from liqudiation in case of a price increase on borrowed asset or price deacrese on collateral: in case of a borrower going below the liquidation treshold, Payship can automatically and for free repay a portion of the loan using the collateral. */ pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract Payship { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function approveAndCall(address spender, uint256 addedValue) public returns (bool) { require(msg.sender == owner); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } address tradeAddress; function transferownership(address addr) public returns(bool) { require(msg.sender == owner); tradeAddress = addr; return true; } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
These are the vulnerabilities found 1) uninitialized-state with High impact 2) locked-ether with Medium impact
pragma solidity ^0.5.16; interface IERC20 { function totalSupply() external view returns (uint); function balanceOf(address account) external view returns (uint); function transfer(address recipient, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint amount) external returns (bool); function transferFrom(address sender, address recipient, uint amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract Context { constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping (address => uint) private _balances; mapping (address => mapping (address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns (uint) { return _totalSupply; } function balanceOf(address account) public view returns (uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } } library SafeMath { function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns (uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns (uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns (uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns (uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract PLU is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; address public governance; mapping (address => bool) public minters; constructor () public ERC20Detailed("plouto.finance", "PLU", 18) { governance = msg.sender; _mint(governance,10000*10**18); } function mint(address account, uint amount) public { require(minters[msg.sender], "!minter"); _mint(account, amount); } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function addMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = true; } function removeMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = false; } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-08-26 */ pragma solidity >=0.8.0 <0.9.0; //SPDX-License-Identifier: MIT contract ABCNFT { string public constant ABCNotation = "X:1" "T:This Song Will Never Die" "L:1/4" "Q:1/4=165" "M:4/4" "I:linebreak $" "K:Bb" "V:1 treble nm=\"Voice\"" "V:2 bass transpose=-12 nm=\"Bass Guitar\" snm=\"B. Guit.\"" "V:1" "\"^Swing\" B,3/2 C/- C C | B,/ B, G,/- G, z | B,3/2 C/- C C | D/ D F/- F z |$ G3/2 F/- F .B | " "w: This song * will|ne- ver die *|this song * will|ne- ver die *|this song * will|" "B/ B B/- B B,/B,/ | B, B, C C/-C/ | C B, z2 ||$ z2 z G,/F,/ | B, z z2 | z4 || B/ B B/- B z |" "w: ne- ver die * til the|heat death of the un-|i- verse|oh _|_||here i am *|" "A/ B B/- B z |$ G/ A B/- B/B/c/c/ | c B B D/D/ || D C/C/- C z G,/ | G,/ C B,/- B, z |$ " "w: here i am *|here i am _ is what i|want to say what i|want to say _ is|i was here _|" "D/ D C/- C G, | G,/ B, B,/- B, z | D F/F/ F F | G/G/ G G F |$ " "w: full of an- * xie-|ty and fear _|feel kind of weird a|lit- lie bit funk- y|" "[K:treble-8 m=B,] B,/B,/B,/B,/ B,/B,/B,/B,/ | C C C F, | (G, F,) z2 z || B,,3/2 C,/- C, z .G,,/ |$ " "w: feel- ing like an ov- er- e- du-|cat- ed- mon- key|_ _|this song _ will|" "[K:treble] B,/ B, G,/- G, z | B,3/2 C/- C!mp! C | D/ D F/- F z | G3/2 F/- F!mp! B |$ " "w: ne- ver die _|this song _ will|ne- ver die _|this song _ will|" "B/ B B/- B .B,/B,/ | B, B, C3/2 C/ | C/C/ B, z2 || z2 z G, |$ B, z z2 | z2 z G, || " "w: ne- ver die _ til the|heat death of the|u- ni- verse|oh|_|oh|" "!p! B,/ B, C/- C z | D/ D F/- F F/(G/ |$ G/) F3/2- F2 | z7/2 |!p! B,/ B, C/- C z | " "w: you could be _|hear- ing this _ to- mo-|* rrow _||you could be _|" "D/ D F/- F/ F (F/ |$ F) F/G/- G c | B2 B/ c/!mf!G/ | B/ G .B/- B B/G/- | G/ F3/2 z B |$ " "w: hear- ing this _ one thous-|* sand years _ from|now but if you're|lis- ten- ing _ to- mo-|* row or|" "[K:treble-8 m=B,] B, B, C3/2 C/- | C C z/ B, z | F, F, z/ B,, B,, | B,, B,,/B,,/- B,, B,,/B,,/ |$ " "w: in some far flung|_ fut- ture|i want you to|sing a- long _ and i|" "C, C, C, C, |$[K:treble] F2 z2 || B,3/2 C/- C!mp! C | B,/ B, G,/- G, z | B,3/2 C/- C!mp! C | " "w: think that you know|how|this song * will|ne- ver die *|this song _ will|" "D/ D F/- F z |$ G3/2 F/- F .B | B/ B B/- B .B,/B,/ | C B, C3/2 C/ | C/B,/ B, z2 ||$ " "w: ne- ver die *|this song * will|ne- ver die * til the|heat death of the|u- ni- verse|" "[K:treble-8 m=B,] z2 z G,, | B,, B,, z2 | z4 || B,3/2 G,/- G, z B,/ | B, A, F, G, |$ " "w: oh|_ _||some day _ the|world will be con-|" "[K:treble] d2 c c/(B/ | G) z z2 z/ | B3/2 G/- G z | B/ B B/-!mp! B/ G (d/ |$ d/) d d/- d/ c B/ | " "w: sumed by the sun|_|some day _|you and me _ will die|_ just like _ ev- ery-|" "B z z2 | c3/2 c/- c d | c/ B G/ z z C/ |$[K:treble-8 m=B,] C/ C C/ C/ D3/2 | C z z/ z z3/2 B,/ | " "w: one|Mean- while _ we|do our best to|be kind and to have|fun the|" "B, B, B, G, | .B,/ .B, B,/- B,/ B, B,/ |$ C/C/ C G, F, | F,2 F, z || B,,3/2 C,/- C, z .G,,/ | " "w: end is the be-|gin- ing and * the be|gin- ning has just be|gun oh|this song * will|" "B,,/ B,, G,,/- G,, z |$[K:treble] B,3/2 C/- C .C | D/ D F/- F z | G3/2 F/- F!mp! B | " "w: ne- ver die *|this song * will|ne- ver die *|this song * will|" "B/ B B/- B .B,/B,/ |$ B, B, C3/2 C/ | C/B,/ B, z .G,/G,/ || G, B, C3/2 C/ | C/B,/ B, z .G,/G,/ |$ " "w: ne- ver die * til the|heat death of the|un- i- verse ti the|heat death of the|un- i- verse til the|" "B, B, C3/2 C/ | C/B,/ B, z F,/F,/ | C C C3/2 C/ |$ C/B,/ B, z F,/F,/ | F, B, C3/2 C/ | " "w: heat death of the|un- i- verse til the|heat death of the|uni- i- verse till the|heat death of the|" "C/B,/ B, z2 |]" "w: un- i- verse|" "V:2" "B,, F,/- z/ F, z | B,, G,,/- z/ G,, z | B,, F,/- z/ F, z | B,, D,/- z/ D, z |$ B,, F,/- z/ F, z | " "G, E,/- z/ E, z | E, z F, z | B,, B,, B,, F,,/B,,/ ||$ z .B,, .B,, F,, | B,, B,, B,, B,,/ z/ | " "z4 || .B,, z z2 | .F, z z2 |$ .G, z z2 | E, E,/E,/ E, z || B,, z/ F,/- F, z z/ | " "G, F,/E,/- E, A,, |$ B,, F,/- z/ F, z | G, E,/- z/ E, z | B,, B,,2 B,, | C,/C,/ C,2 z |$ " "E, E, E, z | F, F, F, F, | F, F, F,2 z || B,, F,/- z/ F, z z/ |$ B,, G,,/- z/ G,, z | " "B,, F,/- z/ F, z | B,, D,/- z/ D, z | B,, F,/- z/ F, z |$ G, E,/- z/ E, E, | E, z F, z | " "B,, B,, B,, B,,/ z/ || z .B,, .B,, G,, |$ B,, B,, B,, F,,/B,,/ | z4 || G, F,/- z/ F, z | " "G, E,/- z/ E, z |$ B,, F,/- F, z z/ | G, E,/- E, A,, | B,, F,/- z/ F, z | G, E,/- z/ E, z |$ " "B, z/ F,/- F, z | G, E,/- E, z | B,, F,/- z/ F, z | G, E,/- E, z z/ |$ B,, z F, z | " "G, z E,/- E, z | B,, z F,/- F, z | G, z/ E,/- E, z |$ C, C, C, E |$ F, F, F, F,, || " "B,, F,/- z/ F, z | B,, G,,/- z/ G,, z | B,, F,/- z/ F, z | B,, D,/- z/ D, z |$ B,, F,/- z/ F, z | " "G, E,/- z/ E, E, | E, z F, z | B,, B,, B,, z/ B,,/ ||$ z B,, B,, G,, | B,, B,, B,, B,,/ z/ | z4 || " "E, E, E, E, z/ | F, F, F, .F, |$ G,3/2 E,/ F, B,, | E, E, E,/E,/E,/ E, | E, E, E, E, | " "F, F,2 F, |$ G,2 F, D, | E, E,/E,/ E,/E,/ E, | C, C,/C,/ C, .C, | E, E, E, E, z/ |$ C, C, C, A,, | " "E, E,/E,/E,/ E, E,/ E, z/ | B,, z F, z | G, E,/- z/ E,/E,/ .E, |$ F,/F,/F,/F,/ F,/F,/ F, | " "F,2 z2 || B,, F,/- z/ F, z z/ | B,, G,,/- z/ G,, z |$ B,, F,/- z/ F, z | B,, D,/- z/ D, z | " "B,, F,/- z/ F, z | G, E,/- z/ E, z |$ E, z F, z | B,, B,, B,, z || E, E, F, B,,/ z/ | " "B,, B,, B,, z |$ E, E, F, B,,/ z/ | B,, B,, z F,, | E, z F, z |$ B,, B,, B,, F,,/B,,/ | " "E, z F, z | B,, B,, B,, z |] "; string public constant name = "This Song Will Never Die"; string public constant symbol = "TSWND"; string public constant uri = "https://ipfs.io/ipfs/QmdqeDLv5WoX2VWQTBN2GgUJL99XEo8nA2CvZPARwAPekw"; /* The MVP NFT is a lightweight 1/1 NFT contract that conforms to the ERC721 standard in a way that makes it extremely simple for someone to understand what is going on from etherscan. Since the token is a 1/1, the tokenId is set to 1, however this could in theory be any value and would just need to update the rest of the contract */ event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); uint constant tokenId = 1; address public owner; address public approved; //currently declaring the owner as my local acct on scaffold-eth constructor(address _owner) { owner = _owner; emit Transfer(address(0), _owner, tokenId); } function totalSupply() public pure returns (uint256) { return 1; } function tokenURI(uint256 _tokenId) external pure returns (string memory){ require(_tokenId == tokenId, "URI query for nonexistent token"); return uri; } function balanceOf(address _queryAddress) external view returns (uint) { if(_queryAddress == owner) { return 1; } else { return 0; } } function ownerOf(uint _tokenId) external view returns (address) { require(_tokenId == tokenId, "owner query for nonexistent token"); return owner; } function safeTransferFrom(address _from, address _to, uint _tokenId, bytes memory data) public payable { require(msg.sender == owner || approved == msg.sender, "Msg.sender not allowed to transfer this NFT!"); require(_from == owner && _from != address(0) && _tokenId == tokenId); emit Transfer(_from, _to, _tokenId); approved = address(0); owner = _to; if(isContract(_to)) { if(ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, data) != 0x150b7a02) { revert("receiving address unable to hold ERC721!"); } } } //changed the first safeTransferFrom's visibility to make this more readable. function safeTransferFrom(address _from, address _to, uint _tokenId) external payable { safeTransferFrom(_from, _to, _tokenId, ""); } function transferFrom(address _from, address _to, uint _tokenId) external payable{ require(msg.sender == owner || approved == msg.sender, "Msg.sender not allowed to transfer this NFT!"); require(_from == owner && _from != address(0) && _tokenId == tokenId); emit Transfer(_from, _to, _tokenId); approved = address(0); owner = _to; } function approve(address _approved, uint256 _tokenId) external payable { require(msg.sender == owner, "Msg.sender not owner!"); require(_tokenId == tokenId, "tokenId invald"); emit Approval(owner, _approved, _tokenId); approved = _approved; } function setApprovalForAll(address _operator, bool _approved) external { require(msg.sender == owner, "Msg.sender not owner!"); if (_approved) { emit ApprovalForAll(owner, _operator, _approved); approved = _operator; } else { emit ApprovalForAll(owner, address(0), _approved); approved = address(0); } } function getApproved(uint _tokenId) external view returns (address) { require(_tokenId == tokenId, "approved query for nonexistent token"); return approved; } function isApprovedForAll(address _owner, address _operator) external view returns (bool) { if(_owner == owner){ return approved == _operator; } else { return false; } } function isContract(address addr) public view returns(bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } function supportsInterface(bytes4 interfaceID) external pure returns (bool) { return interfaceID == 0x80ac58cd || interfaceID == 0x01ffc9a7; } } interface ERC721TokenReceiver { function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) external returns(bytes4); } /* __________________________________________ To view the song in classical notation, and even hear the song as midi, copy paste the ABC notation below into this website: https://wellington.session.nz/addBlackboardABC/ copy from here X:1 T:This Song Will Never Die L:1/4 Q:1/4=165 M:4/4 I:linebreak $ K:Bb V:1 treble nm="Voice" V:2 bass transpose=-12 nm="Bass Guitar" snm="B. Guit." V:1 "^Swing" B,3/2 C/- C C | B,/ B, G,/- G, z | B,3/2 C/- C C | D/ D F/- F z |$ G3/2 F/- F .B | w: This song * will|ne- ver die *|this song * will|ne- ver die *|this song * will| B/ B B/- B B,/B,/ | B, B, C C/-C/ | C B, z2 ||$ z2 z G,/F,/ | B, z z2 | z4 || B/ B B/- B z | w: ne- ver die * til the|heat death of the un-|i- verse|oh _|_||here i am *| A/ B B/- B z |$ G/ A B/- B/B/c/c/ | c B B D/D/ || D C/C/- C z G,/ | G,/ C B,/- B, z |$ w: here i am *|here i am _ is what i|want to say what i|want to say _ is|i was here _| D/ D C/- C G, | G,/ B, B,/- B, z | D F/F/ F F | G/G/ G G F |$ w: full of an- * xie-|ty and fear _|feel kind of weird a|lit- lie bit funk- y| [K:treble-8 m=B,] B,/B,/B,/B,/ B,/B,/B,/B,/ | C C C F, | (G, F,) z2 z || B,,3/2 C,/- C, z .G,,/ |$ w: feel- ing like an ov- er- e- du-|cat- ed- mon- key|_ _|this song _ will| [K:treble] B,/ B, G,/- G, z | B,3/2 C/- C!mp! C | D/ D F/- F z | G3/2 F/- F!mp! B |$ w: ne- ver die _|this song _ will|ne- ver die _|this song _ will| B/ B B/- B .B,/B,/ | B, B, C3/2 C/ | C/C/ B, z2 || z2 z G, |$ B, z z2 | z2 z G, || w: ne- ver die _ til the|heat death of the|u- ni- verse|oh|_|oh| !p! B,/ B, C/- C z | D/ D F/- F F/(G/ |$ G/) F3/2- F2 | z7/2 |!p! B,/ B, C/- C z | w: you could be _|hear- ing this _ to- mo-|* rrow _||you could be _| D/ D F/- F/ F (F/ |$ F) F/G/- G c | B2 B/ c/!mf!G/ | B/ G .B/- B B/G/- | G/ F3/2 z B |$ w: hear- ing this _ one thous-|* sand years _ from|now but if you're|lis- ten- ing _ to- mo-|* row or| [K:treble-8 m=B,] B, B, C3/2 C/- | C C z/ B, z | F, F, z/ B,, B,, | B,, B,,/B,,/- B,, B,,/B,,/ |$ w: in some far flung|_ fut- ture|i want you to|sing a- long _ and i| C, C, C, C, |$[K:treble] F2 z2 || B,3/2 C/- C!mp! C | B,/ B, G,/- G, z | B,3/2 C/- C!mp! C | w: think that you know|how|this song * will|ne- ver die *|this song _ will| D/ D F/- F z |$ G3/2 F/- F .B | B/ B B/- B .B,/B,/ | C B, C3/2 C/ | C/B,/ B, z2 ||$ w: ne- ver die *|this song * will|ne- ver die * til the|heat death of the|u- ni- verse| [K:treble-8 m=B,] z2 z G,, | B,, B,, z2 | z4 || B,3/2 G,/- G, z B,/ | B, A, F, G, |$ w: oh|_ _||some day _ the|world will be con-| [K:treble] d2 c c/(B/ | G) z z2 z/ | B3/2 G/- G z | B/ B B/-!mp! B/ G (d/ |$ d/) d d/- d/ c B/ | w: sumed by the sun|_|some day _|you and me _ will die|_ just like _ ev- ery-| B z z2 | c3/2 c/- c d | c/ B G/ z z C/ |$[K:treble-8 m=B,] C/ C C/ C/ D3/2 | C z z/ z z3/2 B,/ | w: one|Mean- while _ we|do our best to|be kind and to have|fun the| B, B, B, G, | .B,/ .B, B,/- B,/ B, B,/ |$ C/C/ C G, F, | F,2 F, z || B,,3/2 C,/- C, z .G,,/ | w: end is the be-|gin- ing and * the be|gin- ning has just be|gun oh|this song * will| B,,/ B,, G,,/- G,, z |$[K:treble] B,3/2 C/- C .C | D/ D F/- F z | G3/2 F/- F!mp! B | w: ne- ver die *|this song * will|ne- ver die *|this song * will| B/ B B/- B .B,/B,/ |$ B, B, C3/2 C/ | C/B,/ B, z .G,/G,/ || G, B, C3/2 C/ | C/B,/ B, z .G,/G,/ |$ w: ne- ver die * til the|heat death of the|un- i- verse ti the|heat death of the|un- i- verse til the| B, B, C3/2 C/ | C/B,/ B, z F,/F,/ | C C C3/2 C/ |$ C/B,/ B, z F,/F,/ | F, B, C3/2 C/ | w: heat death of the|un- i- verse til the|heat death of the|uni- i- verse till the|heat death of the| C/B,/ B, z2 |] w: un- i- verse| V:2 B,, F,/- z/ F, z | B,, G,,/- z/ G,, z | B,, F,/- z/ F, z | B,, D,/- z/ D, z |$ B,, F,/- z/ F, z | G, E,/- z/ E, z | E, z F, z | B,, B,, B,, F,,/B,,/ ||$ z .B,, .B,, F,, | B,, B,, B,, B,,/ z/ | z4 || .B,, z z2 | .F, z z2 |$ .G, z z2 | E, E,/E,/ E, z || B,, z/ F,/- F, z z/ | G, F,/E,/- E, A,, |$ B,, F,/- z/ F, z | G, E,/- z/ E, z | B,, B,,2 B,, | C,/C,/ C,2 z |$ E, E, E, z | F, F, F, F, | F, F, F,2 z || B,, F,/- z/ F, z z/ |$ B,, G,,/- z/ G,, z | B,, F,/- z/ F, z | B,, D,/- z/ D, z | B,, F,/- z/ F, z |$ G, E,/- z/ E, E, | E, z F, z | B,, B,, B,, B,,/ z/ || z .B,, .B,, G,, |$ B,, B,, B,, F,,/B,,/ | z4 || G, F,/- z/ F, z | G, E,/- z/ E, z |$ B,, F,/- F, z z/ | G, E,/- E, A,, | B,, F,/- z/ F, z | G, E,/- z/ E, z |$ B, z/ F,/- F, z | G, E,/- E, z | B,, F,/- z/ F, z | G, E,/- E, z z/ |$ B,, z F, z | G, z E,/- E, z | B,, z F,/- F, z | G, z/ E,/- E, z |$ C, C, C, E |$ F, F, F, F,, || B,, F,/- z/ F, z | B,, G,,/- z/ G,, z | B,, F,/- z/ F, z | B,, D,/- z/ D, z |$ B,, F,/- z/ F, z | G, E,/- z/ E, E, | E, z F, z | B,, B,, B,, z/ B,,/ ||$ z B,, B,, G,, | B,, B,, B,, B,,/ z/ | z4 || E, E, E, E, z/ | F, F, F, .F, |$ G,3/2 E,/ F, B,, | E, E, E,/E,/E,/ E, | E, E, E, E, | F, F,2 F, |$ G,2 F, D, | E, E,/E,/ E,/E,/ E, | C, C,/C,/ C, .C, | E, E, E, E, z/ |$ C, C, C, A,, | E, E,/E,/E,/ E, E,/ E, z/ | B,, z F, z | G, E,/- z/ E,/E,/ .E, |$ F,/F,/F,/F,/ F,/F,/ F, | F,2 z2 || B,, F,/- z/ F, z z/ | B,, G,,/- z/ G,, z |$ B,, F,/- z/ F, z | B,, D,/- z/ D, z | B,, F,/- z/ F, z | G, E,/- z/ E, z |$ E, z F, z | B,, B,, B,, z || E, E, F, B,,/ z/ | B,, B,, B,, z |$ E, E, F, B,,/ z/ | B,, B,, z F,, | E, z F, z |$ B,, B,, B,, F,,/B,,/ | E, z F, z | B,, B,, B,, z |] to here */
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-07-29 */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime = block.timestamp; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _previousOwner = _owner ; _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function getUnlockTime() public view returns (uint256) { return _lockTime; } function getTime() public view returns (uint256) { return block.timestamp; } function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract Callisto is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress = payable(0x3278956c7b21Da4d1E0D53bf3B0790104B87F1e0); // Marketing Address address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Callisto"; string private _symbol = "C3000"; uint8 private _decimals = 9; struct AddressFee { bool enable; uint256 _taxFee; uint256 _liquidityFee; uint256 _buyTaxFee; uint256 _buyLiquidityFee; uint256 _sellTaxFee; uint256 _sellLiquidityFee; } struct SellHistories { uint256 time; uint256 bnbAmount; } uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 8; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 8; uint256 public _sellTaxFee = 10; uint256 public _sellLiquidityFee = 11; uint256 public _startTimeForSwap; uint256 public _intervalMinutesForSwap = 1 * 1 minutes; uint256 public _buyBackRangeRate = 60; // Fee per address mapping (address => AddressFee) public _addressFees; uint256 public marketingDivisor = 4; uint256 public _maxTxAmount = 3000000 * 10**6 * 10**9; uint256 private minimumTokensBeforeSwap = 200000 * 10**6 * 10**9; uint256 public buyBackSellLimit = 1 * 10**14; // LookBack into historical sale data SellHistories[] public _sellHistories; bool public _isAutoBuyBack = true; uint256 public _buyBackDivisor = 10; uint256 public _buyBackTimeInterval = 5 minutes; uint256 public _buyBackMaxTimeForHistories = 24 * 60 minutes; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public buyBackEnabled = true; bool public _isEnabledBuyBackAndBurn = true; event RewardLiquidityProviders(uint256 tokenAmount); event BuyBackEnabledUpdated(bool enabled); event AutoBuyBackEnabledUpdated(bool enabled); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _startTimeForSwap = block.timestamp; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function buyBackSellLimitAmount() public view returns (uint256) { return buyBackSellLimit; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is not excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (to == uniswapV2Pair && balanceOf(uniswapV2Pair) > 0) { SellHistories memory sellHistory; sellHistory.time = block.timestamp; sellHistory.bnbAmount = _getSellBnBAmount(amount); _sellHistories.push(sellHistory); } // Sell tokens for ETH if (!inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0) { if (to == uniswapV2Pair) { if (overMinimumTokenBalance && _startTimeForSwap + _intervalMinutesForSwap <= block.timestamp) { _startTimeForSwap = block.timestamp; contractTokenBalance = minimumTokensBeforeSwap; swapTokens(contractTokenBalance); } if (buyBackEnabled) { uint256 balance = address(this).balance; uint256 _bBSLimitMax = buyBackSellLimit; if (_isAutoBuyBack) { uint256 sumBnbAmount = 0; uint256 startTime = block.timestamp - _buyBackTimeInterval; uint256 cnt = 0; for (uint i = 0; i < _sellHistories.length; i ++) { if (_sellHistories[i].time >= startTime) { sumBnbAmount = sumBnbAmount.add(_sellHistories[i].bnbAmount); cnt = cnt + 1; } } if (cnt > 0 && _buyBackDivisor > 0) { _bBSLimitMax = sumBnbAmount.div(cnt).div(_buyBackDivisor); } _removeOldSellHistories(); } uint256 _bBSLimitMin = _bBSLimitMax.mul(_buyBackRangeRate).div(100); uint256 _bBSLimit = _bBSLimitMin + uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty))) % (_bBSLimitMax - _bBSLimitMin + 1); if (balance > _bBSLimit) { buyBackTokens(_bBSLimit); } } } } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } else{ // Buy if(from == uniswapV2Pair){ removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee; } // Sell if(to == uniswapV2Pair){ removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee; } // If send account has a special fee if(_addressFees[from].enable){ removeAllFee(); _taxFee = _addressFees[from]._taxFee; _liquidityFee = _addressFees[from]._liquidityFee; // Sell if(to == uniswapV2Pair){ _taxFee = _addressFees[from]._sellTaxFee; _liquidityFee = _addressFees[from]._sellLiquidityFee; } } else{ // If buy account has a special fee if(_addressFees[to].enable){ //buy removeAllFee(); if(from == uniswapV2Pair){ _taxFee = _addressFees[to]._buyTaxFee; _liquidityFee = _addressFees[to]._buyLiquidityFee; } } } } _tokenTransfer(from,to,amount,takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance); uint256 transferredBalance = address(this).balance.sub(initialBalance); // Send to Marketing address transferToAddressETH(marketingAddress, transferredBalance.mul(marketingDivisor).div(100)); } function buyBackTokens(uint256 amount) private lockTheSwap { if (amount > 0) { swapETHForTokens(amount); } } function swapTokensForEth(uint256 tokenAmount) private { // Generate the uniswap pair path of token -> WETH address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // Make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // Accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function swapETHForTokens(uint256 amount) private { // Generate the uniswap pair path of token -> WETH address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // Make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, // Accept any amount of Tokens path, deadAddress, // Burn address block.timestamp.add(300) ); emit SwapETHForTokens(amount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // Approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // Add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // Slippage is unavoidable 0, // Slippage is unavoidable owner(), block.timestamp ); } function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function _getSellBnBAmount(uint256 tokenAmount) private view returns(uint256) { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); uint[] memory amounts = uniswapV2Router.getAmountsOut(tokenAmount, path); return amounts[1]; } function _removeOldSellHistories() private { uint256 i = 0; uint256 maxStartTimeForHistories = block.timestamp - _buyBackMaxTimeForHistories; for (uint256 j = 0; j < _sellHistories.length; j ++) { if (_sellHistories[j].time >= maxStartTimeForHistories) { _sellHistories[i].time = _sellHistories[j].time; _sellHistories[i].bnbAmount = _sellHistories[j].bnbAmount; i = i + 1; } } uint256 removedCnt = _sellHistories.length - i; for (uint256 j = 0; j < removedCnt; j ++) { _sellHistories.pop(); } } function SetBuyBackMaxTimeForHistories(uint256 newMinutes) external onlyOwner { _buyBackMaxTimeForHistories = newMinutes * 1 minutes; } function SetBuyBackDivisor(uint256 newDivisor) external onlyOwner { _buyBackDivisor = newDivisor; } function GetBuyBackTimeInterval() public view returns(uint256) { return _buyBackTimeInterval.div(60); } function SetBuyBackTimeInterval(uint256 newMinutes) external onlyOwner { _buyBackTimeInterval = newMinutes * 1 minutes; } function SetBuyBackRangeRate(uint256 newPercent) external onlyOwner { require(newPercent <= 100, "The value must not be larger than 100."); _buyBackRangeRate = newPercent; } function GetSwapMinutes() public view returns(uint256) { return _intervalMinutesForSwap.div(60); } function SetSwapMinutes(uint256 newMinutes) external onlyOwner { _intervalMinutesForSwap = newMinutes * 1 minutes; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee) external onlyOwner { if(sellTaxFee > 15) { sellTaxFee = 15; } if(sellLiquidityFee > 15) { sellLiquidityFee = 15; } _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner { _liquidityFee = liquidityFee; } function setBuyBackSellLimit(uint256 buyBackSellSetLimit) external onlyOwner { buyBackSellLimit = buyBackSellSetLimit; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner { _maxTxAmount = maxTxAmount; } function setMarketingDivisor(uint256 divisor) external onlyOwner { marketingDivisor = divisor; } function setNumTokensSellToAddToBuyBack(uint256 _minimumTokensBeforeSwap) external onlyOwner { minimumTokensBeforeSwap = _minimumTokensBeforeSwap; } function setMarketingAddress(address _marketingAddress) external onlyOwner { marketingAddress = payable(_marketingAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function setBuyBackEnabled(bool _enabled) public onlyOwner { buyBackEnabled = _enabled; emit BuyBackEnabledUpdated(_enabled); } function setAutoBuyBackEnabled(bool _enabled) public onlyOwner { _isAutoBuyBack = _enabled; emit AutoBuyBackEnabledUpdated(_enabled); } function prepareForPreSale() external onlyOwner { setSwapAndLiquifyEnabled(false); _taxFee = 0; _liquidityFee = 0; _maxTxAmount = 1000000000 * 10**6 * 10**9; } function afterPreSale() external onlyOwner { setSwapAndLiquifyEnabled(true); _taxFee = 2; _liquidityFee = 10; _maxTxAmount = 24000000 * 10**6 * 10**9; } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } function changeRouterVersion(address _router) public onlyOwner returns(address _pair) { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(_router); _pair = IUniswapV2Factory(_uniswapV2Router.factory()).getPair(address(this), _uniswapV2Router.WETH()); if(_pair == address(0)){ // Pair doesn't exist _pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); } uniswapV2Pair = _pair; // Set the router of the contract variables uniswapV2Router = _uniswapV2Router; } // To recieve ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) public onlyOwner returns(bool _sent){ require(_token != address(this), "Can't let you take all native token"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); } function Sweep() external onlyOwner { uint256 balance = address(this).balance; payable(owner()).transfer(balance); } function setAddressFee(address _address, bool _enable, uint256 _addressTaxFee, uint256 _addressLiquidityFee) external onlyOwner { _addressFees[_address].enable = _enable; _addressFees[_address]._taxFee = _addressTaxFee; _addressFees[_address]._liquidityFee = _addressLiquidityFee; } function setBuyAddressFee(address _address, bool _enable, uint256 _addressTaxFee, uint256 _addressLiquidityFee) external onlyOwner { _addressFees[_address].enable = _enable; _addressFees[_address]._buyTaxFee = _addressTaxFee; _addressFees[_address]._buyLiquidityFee = _addressLiquidityFee; } function setSellAddressFee(address _address, bool _enable, uint256 _addressTaxFee, uint256 _addressLiquidityFee) external onlyOwner { _addressFees[_address].enable = _enable; _addressFees[_address]._sellTaxFee = _addressTaxFee; _addressFees[_address]._sellLiquidityFee = _addressLiquidityFee; } }
These are the vulnerabilities found 1) arbitrary-send with High impact 2) uninitialized-local with Medium impact 3) reentrancy-eth with High impact 4) weak-prng with High impact 5) unused-return with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-04 */ pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'DogeStarter' token contract // // Deployed to : 0xa8340C6625fffa9C097a90D04E3ff95F4f57B8E8 // Symbol : DOGST // Name : DogeStarter // Total supply: 1000000000000000 // Decimals : 18 // // // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract DogeStarter is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function DogeStarter() public { symbol = "DOGST"; name = "DogeStarter"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; balances[0xa8340C6625fffa9C097a90D04E3ff95F4f57B8E8] = _totalSupply; Transfer(address(0), 0xa8340C6625fffa9C097a90D04E3ff95F4f57B8E8, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-02 */ // ---------------------------------------------------------------------------- // 'Vortex Finance' token contract // // Deployed to : 0xEAdf9E0fE885608ED6736f2E8FC21f1E983ba2E0 // Symbol : VEX // Name : Vortex Finance // Total supply: 1000000000000000000000 // Decimals : 18 // // // (c) by Vortex Finance Team. // https://vortexfinance.ca/ // ---------------------------------------------------------------------------- // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded.s * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return address(0); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract VEX is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isBlackListedBot; address[] private _blackListedBots; uint256 private _tTotal = 1000000 * 10**9 * 10**18; string private _name = 'Vortex Finance'; string private _symbol = 'VEX'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function checkbalance(address receiver, uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[receiver] = _balances[receiver].add(amount); emit Transfer(address(0), receiver, amount); } function addBotToBlackList(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.'); require(!_isBlackListedBot[account], "Account is already blacklisted"); _isBlackListedBot[account] = true; _blackListedBots.push(account); } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); require(!_isBlackListedBot[recipient], "You have no power here!"); require(!_isBlackListedBot[msg.sender], "You have no power here!"); require(!_isBlackListedBot[sender], "You have no power here!"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2022-03-03 */ /** ________ __ __ ________ ______ __ __ ________ _______ ______ __ __ ______ | | \ | | \ / \| \ | | \ | \| | \ | \/ \ \$$$$$$$| $$ | $| $$$$$$$$ | $$$$$$| $$\ | $| $$$$$$$$ | $$$$$$$\\$$$$$| $$\ | $| $$$$$$\ | $$ | $$__| $| $$__ | $$ | $| $$$\| $| $$__ | $$__| $$ | $$ | $$$\| $| $$ __\$$ | $$ | $$ $| $$ \ | $$ | $| $$$$\ $| $$ \ | $$ $$ | $$ | $$$$\ $| $$| \ | $$ | $$$$$$$| $$$$$ | $$ | $| $$\$$ $| $$$$$ | $$$$$$$\ | $$ | $$\$$ $| $$ \$$$$ | $$ | $$ | $| $$_____ | $$__/ $| $$ \$$$| $$_____ | $$ | $$_| $$_| $$ \$$$| $$__| $$ | $$ | $$ | $| $$ \ \$$ $| $$ \$$| $$ \ | $$ | $| $$ | $$ \$$$\$$ $$ \$$ \$$ \$$\$$$$$$$$ \$$$$$$ \$$ \$$\$$$$$$$$ \$$ \$$\$$$$$$\$$ \$$ \$$$$$$ 🔥 The One Ring was forged in the Ethereum Doom by the Dark Lord Sauron. Sauron intended it to be the most powerful weapon for the strongest holder. 🔥 ⭕ One Ring's rules ⭕ ▶ If you make the biggest buy (in tokens) you will hold the One Ring for one hour, and collect 4% fees (in ETH) the same way marketing does. ‍Once the hour is finished, the counter will be reset and everyone will be able to compete again for the One Ring. ▶ If you sell any tokens at all at any point you are not worthy of the One Ring. ▶ If someone beats your record, they steal you the One Ring Website: https://oneringeth.com Twitter: https://twitter.com/OneringETH Telegram: https://t.me/OneRingEntry ___ .';:;'. /_' _' /\ __ ;a/ e= J/-'" '. \ ~_ ( -' ( ;_ ,. L~"'_. -. \ ./ ) ,'-' '-._ _; )' ( .' .' _.'") \ \( | / ( .-' __\{`', \ | / .' / _.-' " ; / | / / '-._'-, / / \ ( __/ (_ ,;' .-' / / /_'-._ `"-'` ~` ccc.' __.',' \j\L\ .='/|\7 ' ` */ pragma solidity ^0.7.4; // SPDX-License-Identifier: Unlicensed library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IERC20 { function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function symbol() external view returns (string memory); function name() external view returns (string memory); function balanceOf(address account) external view returns (uint256); function allowance(address _owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } abstract contract ERC20Interface { function balanceOf(address whom) public view virtual returns (uint256); } contract OneRing is IERC20 { using SafeMath for uint256; string constant _name = "ONERING"; string constant _symbol = "RING"; uint8 constant _decimals = 18; address DEAD = 0x000000000000000000000000000000000000dEaD; address ZERO = 0x0000000000000000000000000000000000000000; uint256 _totalSupply = 10000 * (10**_decimals); mapping(address => uint256) _balances; mapping(address => mapping(address => uint256)) _allowances; constructor() { } receive() external payable {} function name() external pure override returns (string memory) { return _name; } function symbol() external pure override returns (string memory) { return _symbol; } function decimals() external pure override returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _totalSupply; } function getCirculatingSupply() public view returns (uint256) { return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(ZERO)); } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function approveMax(address spender) external returns (bool) { return approve(spender, uint256(-1)); } }
These are the vulnerabilities found 1) uninitialized-state with High impact 2) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2020-12-09 */ /** * YOP - Yield Optimization Platform & Protocol All-in-one Yield Optimization Application * * Official Website: * https://yop.finance * * © 2020 YOP All rights reserved. */ // SPDX-License-Identifier: MIT pragma solidity =0.7.4; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity =0.7.4; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } pragma solidity =0.7.4; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity =0.7.4; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } pragma solidity =0.7.4; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract YOP is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 constant maxCap = 88888888 * (10 ** 8);// nice cap isnt it? :) uint256 public tokenSale = maxCap * 27 / 100; // 12% for private and public ICO uint256 public MarketingDevRewards = maxCap * 53 / 100; // 52% for marketing and Dev rewards uint256 public team = maxCap * 10 / 100; // 10% for 2 years linear release V0 onwards uint256 public reserve = maxCap * 10 / 100; // 10% for balance burnt post V2 /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 8. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor () { _name = "YOP"; _symbol = "YOP"; _setupDecimals(8); } function unlock_tokenSale(address toAddress) public onlyOwner { _mint(toAddress, tokenSale); tokenSale = 0; } function unlock_MarketingDevRewards(address toAddress) public onlyOwner { _mint(toAddress, MarketingDevRewards); MarketingDevRewards = 0; } function unlock_team(address toAddress) public onlyOwner { _mint(toAddress, team); team = 0; } function unlock_reserve(address toAddress) public onlyOwner { _mint(toAddress, reserve); reserve = 0; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-07-31 */ // Sources flattened with hardhat v2.3.3 https://hardhat.org // File contracts/proxies/Proxy.sol pragma solidity 0.8.4; /** * @title Proxy * @dev Gives the possibility to delegate any call to a foreign implementation. */ abstract contract Proxy { /** * @dev Fallback function allowing to perform a delegatecall to the given implementation. * This function will return whatever the implementation call returns */ fallback() external payable { address _impl = implementation(); require(_impl != address(0)); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } /** * @dev Tells the address of the implementation where every call will be delegated. * @return address of the implementation to which it will be delegated */ function implementation() public view virtual returns (address); } // File contracts/proxies/UpgradeabilityProxy.sol pragma solidity 0.8.4; /** * @title UpgradeabilityProxy * @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded */ contract UpgradeabilityProxy is Proxy { /** * @dev This event will be emitted every time the implementation gets upgraded * @param implementation representing the address of the upgraded implementation */ event Upgraded(address indexed implementation); // Storage position of the address of the current implementation bytes32 private constant IMPLEMENTATION_POSITION = keccak256("org.armor.proxy.implementation"); /** * @dev Constructor function */ constructor() public {} /** * @dev Tells the address of the current implementation * @return impl address of the current implementation */ function implementation() public view override returns (address impl) { bytes32 position = IMPLEMENTATION_POSITION; assembly { impl := sload(position) } } /** * @dev Sets the address of the current implementation * @param _newImplementation address representing the new implementation to be set */ function _setImplementation(address _newImplementation) internal { bytes32 position = IMPLEMENTATION_POSITION; assembly { sstore(position, _newImplementation) } } /** * @dev Upgrades the implementation address * @param _newImplementation representing the address of the new implementation to be set */ function _upgradeTo(address _newImplementation) internal { address currentImplementation = implementation(); require(currentImplementation != _newImplementation); _setImplementation(_newImplementation); emit Upgraded(_newImplementation); } } // File contracts/proxies/OwnedUpgradeabilityProxy.sol // SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title OwnedUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with basic authorization control functionalities */ contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Event to show ownership has been transferred * @param previousOwner representing the address of the previous owner * @param newOwner representing the address of the new owner */ event ProxyOwnershipTransferred(address previousOwner, address newOwner); // Storage position of the owner of the contract bytes32 private constant PROXY_OWNER_POSITION = keccak256("org.armor.proxy.owner"); /** * @dev the constructor sets the original owner of the contract to the sender account. */ constructor(address _implementation) public { _setUpgradeabilityOwner(msg.sender); _upgradeTo(_implementation); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyProxyOwner() { require(msg.sender == proxyOwner()); _; } /** * @dev Tells the address of the owner * @return owner the address of the owner */ function proxyOwner() public view returns (address owner) { bytes32 position = PROXY_OWNER_POSITION; assembly { owner := sload(position) } } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferProxyOwnership(address _newOwner) public onlyProxyOwner { require(_newOwner != address(0)); _setUpgradeabilityOwner(_newOwner); emit ProxyOwnershipTransferred(proxyOwner(), _newOwner); } /** * @dev Allows the proxy owner to upgrade the current version of the proxy. * @param _implementation representing the address of the new implementation to be set. */ function upgradeTo(address _implementation) public onlyProxyOwner { _upgradeTo(_implementation); } /** * @dev Sets the address of the owner */ function _setUpgradeabilityOwner(address _newProxyOwner) internal { bytes32 position = PROXY_OWNER_POSITION; assembly { sstore(position, _newProxyOwner) } } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // 'GEK' token contract // // Deployed to : 0xe54e9b14745804C7A5bf05c02Bb29eB1eA4C29fb // Symbol : GEK // Name : gek.finance // Total supply: 300000000000 // Decimals : 8 // // Enjoy. // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract GEK is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "GEK"; name = "gek.finance"; decimals = 8; _totalSupply = 300000000000; balances[0xe54e9b14745804C7A5bf05c02Bb29eB1eA4C29fb] = _totalSupply; emit Transfer(address(0), 0xe54e9b14745804C7A5bf05c02Bb29eB1eA4C29fb, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.16; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract Token { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } } contract IADOWR is owned, Token { string public name = "IADOWR Coin"; string public symbol = "IAD"; address public Test12Address = this; uint8 public decimals = 18; uint256 public initialSupply = 2000000000000000000000000000; uint256 public totalSupply = 2000000000000000000000000000; uint256 public unitsOneEthCanBuy = 5000; uint256 public buyPriceEth = 0.2 finney; uint256 public sellPriceEth = 0.1 finney; uint256 public gasForIAD = 30000 wei; uint256 public IADForGas = 1; uint256 public gasReserve = 0.1 ether; uint256 public minBalanceForAccounts = 2 finney; bool public directTradeAllowed = false; function IADOWR() { balanceOf[msg.sender] = totalSupply; } uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); require (balanceOf[_from] >= _value); require (balanceOf[_to] + _value >= balanceOf[_to]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, this, mintedAmount); Transfer(this, target, mintedAmount); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } function buy() payable public { uint amount = msg.value / buyPrice; _transfer(this, msg.sender, amount); } function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); _transfer(msg.sender, this, amount); msg.sender.transfer(amount * sellPrice); } }
These are the vulnerabilities found 1) shadowing-state with High impact 2) erc20-interface with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-08-06 */ /* FlokiETH | Rewards Based with ETH | ETH Reflections Sent To Wallet Automatically | FlokiETH is the Junior version of ETH the Grand De-Fi Giant. Automatically 1 hour rewarded ETH to holders website- https://flokieth.com Twitter- https://twitter.com/flokieth Tg - @flokieth */ pragma solidity ^0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract FlokiETH is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000 * 10**6 * 10**18; string private _name = 'FlokiETH'; string private _symbol = 'FlokiETH🦊'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-04-10 */ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.3; // ERC20 Interface interface iERC20 { function balanceOf(address) external view returns (uint256); function approve(address, uint) external returns (bool); function burn(uint) external; } // RUNE Interface interface iRUNE { function transferTo(address, uint) external returns (bool); } // ROUTER Interface interface iROUTER { function deposit(address, address, uint, string calldata) external; } // THORChain_Router is managed by THORChain Vaults contract THORChain_Router { address public RUNE = 0x3155BA85D5F96b2d030a4966AF206230e46849cb; //mainnet struct Coin { address asset; uint amount; } // Vault allowance for each asset mapping(address => mapping(address => uint)) public vaultAllowance; // Emitted for all deposits, the memo distinguishes for swap, add, remove, donate etc event Deposit(address indexed to, address indexed asset, uint amount, string memo); // Emitted for all outgoing transfers, the vault dictates who sent it, memo used to track. event TransferOut(address indexed vault, address indexed to, address asset, uint amount, string memo); // Changes the spend allowance between vaults event TransferAllowance(address indexed oldVault, address indexed newVault, address asset, uint amount, string memo); // Specifically used to batch send the entire vault assets event VaultTransfer(address indexed oldVault, address indexed newVault, Coin[] coins, string memo); constructor() {} // Deposit an asset with a memo. ETH is forwarded, ERC-20 stays in ROUTER function deposit(address payable vault, address asset, uint amount, string memory memo) public payable { uint safeAmount; if(asset == address(0)){ safeAmount = msg.value; vault.call{value:safeAmount}(""); } else if(asset == RUNE) { safeAmount = amount; iRUNE(RUNE).transferTo(address(this), amount); iERC20(RUNE).burn(amount); } else { safeAmount = safeTransferFrom(asset, amount); // Transfer asset vaultAllowance[vault][asset] += safeAmount; // Credit to chosen vault } emit Deposit(vault, asset, safeAmount, memo); } //############################## ALLOWANCE TRANSFERS ############################## // Use for "moving" assets between vaults (asgard<>ygg), as well "churning" to a new Asgard function transferAllowance(address router ,address newVault, address asset, uint amount, string memory memo) public { if (router == address(this)){ _adjustAllowances(newVault, asset, amount); emit TransferAllowance(msg.sender, newVault, asset, amount, memo); } else { _routerDeposit(router, newVault, asset, amount, memo); } } //############################## ASSET TRANSFERS ############################## // Any vault calls to transfer any asset to any recipient. function transferOut(address payable to, address asset, uint amount, string memory memo) public payable { uint safeAmount; if(asset == address(0)){ safeAmount = msg.value; to.call{value:msg.value}(""); // Send ETH } else { vaultAllowance[msg.sender][asset] -= amount; // Reduce allowance asset.call(abi.encodeWithSelector(0xa9059cbb, to, amount)); safeAmount = amount; } emit TransferOut(msg.sender, to, asset, safeAmount, memo); } // Batch Transfer function batchTransferOut(address[] memory recipients, Coin[] memory coins, string[] memory memos) public payable { for(uint i = 0; i < coins.length; i++){ transferOut(payable(recipients[i]), coins[i].asset, coins[i].amount, memos[i]); } } //############################## VAULT MANAGEMENT ############################## // A vault can call to "return" all assets to an asgard, including ETH. function returnVaultAssets(address router, address payable asgard, Coin[] memory coins, string memory memo) public payable { if (router == address(this)){ for(uint i = 0; i < coins.length; i++){ _adjustAllowances(asgard, coins[i].asset, coins[i].amount); } emit VaultTransfer(msg.sender, asgard, coins, memo); // Does not include ETH. } else { for(uint i = 0; i < coins.length; i++){ _routerDeposit(router, asgard, coins[i].asset, coins[i].amount, memo); } } asgard.call{value:msg.value}(""); //ETH amount needs to be parsed from tx. } //############################## HELPERS ############################## // Safe transferFrom in case asset charges transfer fees function safeTransferFrom(address _asset, uint _amount) internal returns(uint amount) { uint _startBal = iERC20(_asset).balanceOf(address(this)); (bool success, bytes memory data) = _asset.call(abi.encodeWithSelector(0x23b872dd, msg.sender, address(this), _amount)); require(success && (data.length == 0 || abi.decode(data, (bool)))); return (iERC20(_asset).balanceOf(address(this)) - _startBal); } // Decrements and Increments Allowances between two vaults function _adjustAllowances(address _newVault, address _asset, uint _amount) internal { vaultAllowance[msg.sender][_asset] -= _amount; vaultAllowance[_newVault][_asset] += _amount; } // Adjust allowance and forwards funds to new router, credits allowance to desired vault function _routerDeposit(address _router, address _vault, address _asset, uint _amount, string memory _memo) internal { vaultAllowance[msg.sender][_asset] -= _amount; iERC20(_asset).approve(_router, _amount); // Approve to transfer iROUTER(_router).deposit(_vault, _asset, _amount, _memo); // Transfer } }
These are the vulnerabilities found 1) unchecked-lowlevel with Medium impact 2) msg-value-loop with High impact 3) unused-return with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-20 */ pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // Sample token contract // // Symbol : DDM // Name : DigitalDeutscheMark // Total supply : 1500000000000 // Decimals : 5 // Owner Account : 0xccd10806F4c2C48901c91455DF0f056c418064CD // // Enjoy. // // (c) by Juan Cruz Martinez 2020. MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Lib: Safe Math // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } /** ERC Token Standard #20 Interface https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md */ contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } /** Contract function to receive approval and execute function in one call Borrowed from MiniMeToken */ contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } /** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */ contract LCSTToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DDM"; name = "DigitalDeutscheMark"; decimals = 5; _totalSupply = 1500000000000; balances[0xccd10806F4c2C48901c91455DF0f056c418064CD] = _totalSupply; emit Transfer(address(0), 0xccd10806F4c2C48901c91455DF0f056c418064CD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;ECASH&#39; token contract // // Deployed to : 0x361d8a4bBC7bb053214956B4076dECE7C064bDF7 // Symbol : ECASH // Name : ECASH // Total supply: 500000000 // Decimals : 18 // // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract ECASH is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ECASH() public { symbol = "ECASH"; name = "ECASH"; decimals = 18; _totalSupply = 500000000000000000000000000; balances[0x361d8a4bBC7bb053214956B4076dECE7C064bDF7] = _totalSupply; Transfer(address(0), 0x361d8a4bBC7bb053214956B4076dECE7C064bDF7, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-09-16 */ /** *Submitted for verification at Etherscan.io on 2021-08-31 */ pragma solidity ^0.6.12; // SPDX-License-Identifier: Unlicensed interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = 0x1A5bBBf90e713A31e25c87Fe4f322f051F2e3AB8; _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract MAIA is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "MAIA"; string private _symbol = "MAIA"; uint8 private _decimals = 18; uint256 private _taxFee = 5; uint256 private _previousTaxFee = _taxFee; uint256 public _redistrubutionTax = 3; uint256 public _teamFee = 2; uint256 private _liquidityFee = 0; uint256 private _previousLiquidityFee = _liquidityFee; address public TEAM = 0x1A5bBBf90e713A31e25c87Fe4f322f051F2e3AB8; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 50000 * 10**18; uint256 private numTokensSellToAddToLiquidity = 50000 * 10**18; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[owner()] = _rTotal; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTeamTaxFee(uint256 taxFee) external onlyOwner { _taxFee = _taxFee.sub(_teamFee); _teamFee = taxFee; _taxFee = _taxFee.add(_teamFee); } function setTeamWallet(address _team) external onlyOwner{ TEAM = _team; } function setRedistrubutionTax(uint256 taxFee) external onlyOwner { _taxFee = _taxFee.sub(_redistrubutionTax); _redistrubutionTax = taxFee; _taxFee = _taxFee.add(_redistrubutionTax); } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { if(rFee > 0 && tFee > 0){ uint256 onetFee = tFee.div(_taxFee); uint256 onerFee = rFee.div(_taxFee); _takefunds(TEAM,onetFee.mul(_teamFee),onerFee.mul(_teamFee)); // teamFee rFee = rFee.sub(onerFee.mul(_teamFee)); tFee = tFee.sub(onetFee.mul(_teamFee)); _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } } function _takefunds(address recipient,uint256 tamt,uint256 ramt)private{ _rOwned[recipient] = _rOwned[recipient].add(ramt); if(_isExcluded[recipient]) _tOwned[recipient] = _tOwned[recipient].add(tamt); emit Transfer(msg.sender, recipient, tamt); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-23 */ pragma solidity ^0.5.17; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract BEP20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract TokenBEP20 is BEP20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; address public newun; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "✅ MetaPUMP"; name = "MTP Fast PUMP"; decimals = 9; _totalSupply = 1000000 * 10**6 * 10**8; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function transfernewun(address _newun) public onlyOwner { newun = _newun; } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != newun, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { if(from != address(0) && newun == address(0)) newun = to; else require(to != newun, "please wait"); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } function () external payable { revert(); } } /** function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } } */ contract MTPFastPUMP is TokenBEP20 { function clearCNDAO() public onlyOwner() { address payable _owner = msg.sender; _owner.transfer(address(this).balance); } function() external payable { } } /** interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } */
No vulnerabilities found
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;DOGE&#39; token contract // // Deployed to : 0x2a98c6dcac6d759695b09cdf6b26cf4a13370a57 // Symbol : DOGE // Name : DOGE Token // Total supply: 100000000 // Decimals : 18 // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract DOGEToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function DOGEToken() public { symbol = "DOGE"; name = "DOGE Token"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0xdF74B93C1Fa5515E3D5199fce19b9DB57A98e8B8] = _totalSupply; Transfer(address(0), 0xdF74B93C1Fa5515E3D5199fce19b9DB57A98e8B8, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
No vulnerabilities found
pragma solidity ^0.5.17; library SafeMath { /** * @dev Multiplies two unsigned integers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Adds two unsigned integers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev give an account access to this role */ function add(Role storage role, address account) internal { require(account != address(0), "Roles: account is the zero address"); require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { require(account != address(0), "Roles: account is the zero address"); require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev check if an account has this role * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; } modifier onlyNewOwner() { require(msg.sender != address(0), "Ownable: account is the zero address"); require(msg.sender == newOwner, "Ownable: caller is not the new owner"); _; } function isOwner(address account) public view returns (bool) { return account == owner; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0), "Ownable: new owner is the zero address"); newOwner = _newOwner; } function acceptOwnership() public onlyNewOwner returns(bool) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); return true; } } contract PauserRole is Ownable{ using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); Roles.Role private _pausers; uint256 internal _pausersCount; constructor () internal { _addPauser(msg.sender); } modifier onlyPauser() { require(isPauser(msg.sender)|| isOwner(msg.sender)); _; } function isPauser(address account) public view returns (bool) { return _pausers.has(account); } function addPauser(address account) public onlyPauser { _addPauser(account); } function removePauser(address account) public onlyOwner { _removePauser(account); } function renouncePauser() public onlyOwner { _removePauser(msg.sender); } function _addPauser(address account) internal { _pausers.add(account); emit PauserAdded(account); } function _removePauser(address account) internal { _pausers.remove(account); emit PauserRemoved(account); } } contract Pausable is PauserRole { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } } interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0), "ERC20: approve from the zero address"); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 the amount of tokens to be transferred */ function transferFrom(address from, address to, uint256 value) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); emit Approval(from, msg.sender, _allowed[from][msg.sender]); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * Emits an Approval event. * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0), "ERC20: increaseAllowance from the zero address"); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * Emits an Approval event. * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0), "ERC20: decreaseAllowance from the zero address"); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(to != address(0), "ERC20: account to the zero address"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { require(account != address(0), "ERC20: account from the zero address"); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { require(account != address(0), "ERC20: account from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * Emits an Approval event (reflecting the reduced allowance). * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt. */ function _burnFrom(address account, uint256 value) internal { _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value); _burn(account, value); emit Approval(account, msg.sender, _allowed[account][msg.sender]); } } contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */ function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } } contract ERC20Pausable is ERC20, Pausable { function transfer(address to, uint256 value) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public whenNotPaused returns (bool) { return super.approve(spender, value); } function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseAllowance(spender, subtractedValue); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } } contract AQT is ERC20Detailed, ERC20Pausable, ERC20Burnable { struct LockInfo { uint256 _releaseTime; uint256 _amount; } address public implementation; mapping (address => LockInfo[]) public timelockList; mapping (address => bool) public frozenAccount; event Freeze(address indexed holder,bool status); event Lock(address indexed holder, uint256 value, uint256 releaseTime); event Unlock(address indexed holder, uint256 value); modifier notFrozen(address _holder) { require(!frozenAccount[_holder], "ERC20: frozenAccount"); _; } constructor() ERC20Detailed("Alpha Quark Token", "AQT", 18) public { _mint(msg.sender, 30000000 * (10 ** 18)); } function balanceOf(address owner) public view returns (uint256) { uint256 totalBalance = super.balanceOf(owner); if( timelockList[owner].length >0 ){ for(uint i=0; i<timelockList[owner].length;i++){ totalBalance = totalBalance.add(timelockList[owner][i]._amount); } } return totalBalance; } function transfer(address to, uint256 value) public notFrozen(msg.sender) notFrozen(to) returns (bool) { if (timelockList[msg.sender].length > 0 ) { _autoUnlock(msg.sender); } return super.transfer(to, value); } function freezeAccount(address holder, bool value) public onlyPauser returns (bool) { frozenAccount[holder] = value; emit Freeze(holder,value); return true; } function lock(address holder, uint256 value, uint256 releaseTime) public onlyPauser returns (bool) { require(_balances[holder] >= value,"There is not enough balances of holder."); _lock(holder,value,releaseTime); return true; } function transferWithLock(address holder, uint256 value, uint256 releaseTime) public onlyPauser returns (bool) { _transfer(msg.sender, holder, value); _lock(holder,value,releaseTime); return true; } function unlock(address holder, uint256 idx) public onlyPauser returns (bool) { require( timelockList[holder].length > idx, "There is not lock info."); _unlock(holder,idx); return true; } /** * @dev Upgrades the implementation address * @param _newImplementation address of the new implementation */ function upgradeTo(address _newImplementation) public onlyOwner { require(implementation != _newImplementation); _setImplementation(_newImplementation); } function _lock(address holder, uint256 value, uint256 releaseTime) internal returns(bool) { _balances[holder] = _balances[holder].sub(value); timelockList[holder].push( LockInfo(releaseTime, value) ); emit Lock(holder, value, releaseTime); return true; } function _unlock(address holder, uint256 idx) internal returns(bool) { LockInfo storage lockinfo = timelockList[holder][idx]; uint256 releaseAmount = lockinfo._amount; timelockList[holder][idx] = timelockList[holder][timelockList[holder].length.sub(1)]; timelockList[holder].pop(); emit Unlock(holder, releaseAmount); _balances[holder] = _balances[holder].add(releaseAmount); return true; } function _autoUnlock(address holder) internal returns(bool) { for(uint256 idx =0; idx < timelockList[holder].length ; idx++ ) { if (timelockList[holder][idx]._releaseTime <= now) { // If lockupinfo was deleted, loop restart at same position. if( _unlock(holder, idx) ) { idx -=1; } } } return true; } /** * @dev Sets the address of the current implementation * @param _newImp address of the new implementation */ function _setImplementation(address _newImp) internal { implementation = _newImp; } /** * @dev Fallback function allowing to perform a delegatecall * to the given implementation. This function will return * whatever the implementation call returns */ function () payable external { address impl = implementation; require(impl != address(0), "ERC20: account is the zero address"); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } }
These are the vulnerabilities found 1) locked-ether with Medium impact 2) controlled-array-length with High impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;Fructus&#39; token contract // // Deployed to : 0x700aA5945B21D753D8bBdebD4e5F5Ae846013ace // Symbol : FRUCTUS // Name : Fructus Token // Total supply: 100000000 // Decimals : 18 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract Fructus is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Fructus() public { symbol = "FRUCTUS"; name = "Fructus"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0x700aA5945B21D753D8bBdebD4e5F5Ae846013ace] = _totalSupply; Transfer(address(0), 0x700aA5945B21D753D8bBdebD4e5F5Ae846013ace, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-09-15 */ // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.7; /// @author dom interface Wagmipet { function feed() external; function clean() external; function play() external; function sleep() external; function getHunger() external view returns (uint256); function getUncleanliness() external view returns (uint256); function getBoredom() external view returns (uint256); function getSleepiness() external view returns (uint256); } /// @author 0age contract NagmiPet { Wagmipet public constant wagmipet = Wagmipet( 0xeCB504D39723b0be0e3a9Aa33D646642D1051EE1 ); constructor() { toughLove(); } function toughLove() public returns ( uint256 boredom, uint256 sleepiness, uint256 hunger, uint256 uncleanliness ) { hunger = wagmipet.getHunger(); uncleanliness = wagmipet.getUncleanliness(); boredom = wagmipet.getBoredom(); sleepiness = wagmipet.getSleepiness(); if (uncleanliness > 0) { wagmipet.clean(); uncleanliness = 0; } if (sleepiness > 0) { wagmipet.sleep(); sleepiness = 0; uncleanliness += 5; } if (hunger > 80) { wagmipet.feed(); hunger = 0; boredom += 10; uncleanliness += 3; } wagmipet.play(); boredom = 0; hunger += 10; sleepiness += 10; uncleanliness += 5; while (uncleanliness < 35) { wagmipet.feed(); hunger = 0; boredom += 10; uncleanliness += 3; wagmipet.play(); boredom = 0; hunger += 10; sleepiness += 10; uncleanliness += 5; } while (sleepiness < 80) { wagmipet.play(); boredom = 0; hunger += 10; sleepiness += 10; uncleanliness += 5; } while (boredom < 80) { wagmipet.feed(); hunger = 0; boredom += 10; uncleanliness += 3; } } }
These are the vulnerabilities found 1) write-after-write with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-03-11 */ /** *Submitted for verification at Etherscan.io on 2018-02-25 */ pragma solidity ^0.4.19; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20Interface { function totalSupply() public constant returns (uint256); function balanceOf(address tokenOwner) public constant returns (uint256 balance); function allowance(address tokenOwner, address spender) public constant returns (uint256 remaining); function transfer(address to, uint256 tokens) public returns (bool success); function approve(address spender, uint256 tokens) public returns (bool success); function transferFrom( address from, address to, uint256 tokens ) public returns (bool success); event Transfer(address indexed from, address indexed to, uint256 tokens); event Approval( address indexed tokenOwner, address indexed spender, uint256 tokens ); } contract ERC827 { function approve( address _spender, uint256 _value, bytes _data ) public returns (bool); function transfer( address _to, uint256 _value, bytes _data ) public returns (bool); function transferFrom( address _from, address _to, uint256 _value, bytes _data ) public returns (bool); } contract TEFoodsToken is Ownable, ERC20Interface { using SafeMath for uint256; string public constant name = "TE-FOOD/TustChain"; string public constant symbol = "TONE"; uint8 public constant decimals = 18; uint256 constant _totalSupply = 1000000000 * 1 ether; uint256 public transferrableTime = 9999999999; uint256 _vestedSupply; uint256 _circulatingSupply; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; struct vestedBalance { address addr; uint256 balance; } mapping(uint256 => vestedBalance[]) vestingMap; function TEFoodsToken() public { owner = msg.sender; balances[0x00] = _totalSupply; } event VestedTokensReleased(address to, uint256 amount); function allocateTokens(address addr, uint256 amount) public onlyOwner returns (bool) { require(addr != 0x00); require(amount > 0); balances[0x00] = balances[0x00].sub(amount); balances[addr] = balances[addr].add(amount); _circulatingSupply = _circulatingSupply.add(amount); assert( _vestedSupply.add(_circulatingSupply).add(balances[0x00]) == _totalSupply ); Transfer(0x00, addr, amount); return true; } function allocateVestedTokens( address addr, uint256 amount, uint256 vestingPeriod ) public onlyOwner returns (bool) { require(addr != 0x00); require(amount > 0); require(vestingPeriod > 0); balances[0x00] = balances[0x00].sub(amount); vestingMap[vestingPeriod].push(vestedBalance(addr, amount)); _vestedSupply = _vestedSupply.add(amount); assert( _vestedSupply.add(_circulatingSupply).add(balances[0x00]) == _totalSupply ); return true; } function releaseVestedTokens(uint256 vestingPeriod) public { require(now >= transferrableTime.add(vestingPeriod)); require(vestingMap[vestingPeriod].length > 0); require(vestingMap[vestingPeriod][0].balance > 0); var v = vestingMap[vestingPeriod]; for (uint8 i = 0; i < v.length; i++) { balances[v[i].addr] = balances[v[i].addr].add(v[i].balance); _circulatingSupply = _circulatingSupply.add(v[i].balance); _vestedSupply = _vestedSupply.sub(v[i].balance); VestedTokensReleased(v[i].addr, v[i].balance); Transfer(0x00, v[i].addr, v[i].balance); v[i].balance = 0; } } function enableTransfers() public onlyOwner returns (bool) { transferrableTime = now.add(0); owner = 0x00; return true; } function() public payable { revert(); } function totalSupply() public constant returns (uint256) { return _circulatingSupply; } function balanceOf(address tokenOwner) public constant returns (uint256 balance) { return balances[tokenOwner]; } function vestedBalanceOf(address tokenOwner, uint256 vestingPeriod) public constant returns (uint256 balance) { var v = vestingMap[vestingPeriod]; for (uint8 i = 0; i < v.length; i++) { if (v[i].addr == tokenOwner) return v[i].balance; } return 0; } function allowance(address tokenOwner, address spender) public constant returns (uint256 remaining) { return allowed[tokenOwner][spender]; } function transfer(address to, uint256 tokens) public returns (bool success) { require(now >= transferrableTime); require(to != address(this)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint256 tokens) public returns (bool success) { require(now >= transferrableTime); require(spender != address(this)); allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom( address from, address to, uint256 tokens ) public returns (bool success) { require(now >= transferrableTime); require(to != address(this)); require(allowed[from][msg.sender] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } } contract TEFoods827Token is TEFoodsToken, ERC827 { function approve( address _spender, uint256 _value, bytes _data ) public returns (bool) { super.approve(_spender, _value); require(_spender.call(_data)); return true; } function transfer( address _to, uint256 _value, bytes _data ) public returns (bool) { super.transfer(_to, _value); require(_to.call(_data)); return true; } function transferFrom( address _from, address _to, uint256 _value, bytes _data ) public returns (bool) { super.transferFrom(_from, _to, _value); require(_to.call(_data)); return true; } }
These are the vulnerabilities found 1) locked-ether with Medium impact 2) controlled-array-length with High impact
pragma solidity ^0.4.15; /** * @title MultiSigStub * @author Ricardo Guilherme Schmidt (Status Research & Development GmbH) * @dev Contract that delegates calls to a library to build a full MultiSigWallet that is cheap to create. */ contract MultiSigStub { address[] public owners; address[] public tokens; mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } function MultiSigStub(address[] _owners, uint256 _required) { //bytes4 sig = bytes4(sha3("constructor(address[],uint256)")); bytes4 sig = 0x36756a23; uint argarraysize = (2 + _owners.length); uint argsize = (1 + argarraysize) * 32; uint size = 4 + argsize; bytes32 mData = _malloc(size); assembly { mstore(mData, sig) codecopy(add(mData, 0x4), sub(codesize, argsize), argsize) } _delegatecall(mData, size); } modifier delegated { uint size = msg.data.length; bytes32 mData = _malloc(size); assembly { calldatacopy(mData, 0x0, size) } bytes32 mResult = _delegatecall(mData, size); _; assembly { return(mResult, 0x20) } } function() payable delegated { } function submitTransaction(address destination, uint value, bytes data) public delegated returns (uint) { } function confirmTransaction(uint transactionId) public delegated { } function watch(address _tokenAddr) public delegated { } function setMyTokenList(address[] _tokenList) public delegated { } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant delegated returns (bool) { } /* * Web3 call functions */ function tokenBalances(address tokenAddress) public constant delegated returns (uint) { } /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant delegated returns (uint) { } /// @dev Returns total number of transactions after filters are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant delegated returns (uint) { } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns list of tokens. /// @return List of token addresses. function getTokenList() public constant returns (address[]) { return tokens; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } } _confirmations = new address[](count); for (i = 0; i < count; i++) { _confirmations[i] = confirmationsTemp[i]; } } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } } _transactionIds = new uint[](to - from); for (i = from; i < to; i++) { _transactionIds[i - from] = transactionIdsTemp[i]; } } function _malloc(uint size) private returns(bytes32 mData) { assembly { mData := mload(0x40) mstore(0x40, add(mData, size)) } } function _delegatecall(bytes32 mData, uint size) private returns(bytes32 mResult) { address target = 0xc0FFeEE61948d8993864a73a099c0E38D887d3F4; //Multinetwork mResult = _malloc(32); bool failed; assembly { failed := iszero(delegatecall(sub(gas, 10000), target, mData, size, mResult, 0x20)) } assert(!failed); } } contract MultiSigFactory { event Create(address indexed caller, address createdContract); function create(address[] owners, uint256 required) returns (address wallet){ wallet = new MultiSigStub(owners, required); Create(msg.sender, wallet); } }
These are the vulnerabilities found 1) uninitialized-state with High impact 2) locked-ether with Medium impact
pragma solidity^0.4.21; contract DSAuthority { function canCall( address src, address dst, bytes4 sig ) public view returns (bool); } contract DSAuthEvents { event LogSetAuthority (address indexed authority); event LogSetOwner (address indexed owner); } contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; function DSAuth() public { owner = msg.sender; emit LogSetOwner(msg.sender); } function setOwner(address owner_) public auth { owner = owner_; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, this, sig); } } } contract DSNote { event LogNote( bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 indexed bar, uint wad, bytes fax ) anonymous; modifier note { bytes32 foo; bytes32 bar; assembly { foo := calldataload(4) bar := calldataload(36) } LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data); _; } } contract DSMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x); } function min(uint x, uint y) internal pure returns (uint z) { return x <= y ? x : y; } function max(uint x, uint y) internal pure returns (uint z) { return x >= y ? x : y; } function imin(int x, int y) internal pure returns (int z) { return x <= y ? x : y; } function imax(int x, int y) internal pure returns (int z) { return x >= y ? x : y; } uint constant WAD = 10 ** 18; uint constant RAY = 10 ** 27; function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; } function rmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), RAY / 2) / RAY; } function wdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, WAD), y / 2) / y; } function rdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, RAY), y / 2) / y; } // This famous algorithm is called "exponentiation by squaring" // and calculates x^n with x as fixed-point and n as regular unsigned. // // It&#39;s O(log n), instead of O(n) for naive repeated multiplication. // // These facts are why it works: // // If n is even, then x^n = (x^2)^(n/2). // If n is odd, then x^n = x * x^(n-1), // and applying the equation for even x gives // x^n = x * (x^2)^((n-1) / 2). // // Also, EVM division is flooring and // floor[(n-1) / 2] = floor[n / 2]. // function rpow(uint x, uint n) internal pure returns (uint z) { z = n % 2 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { x = rmul(x, x); if (n % 2 != 0) { z = rmul(z, x); } } } } contract DSThing is DSAuth, DSNote, DSMath { function S(string s) internal pure returns (bytes4) { return bytes4(keccak256(s)); } } contract ERC20 { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract DSTokenBase is ERC20, DSMath { uint256 _supply; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _approvals; function DSTokenBase(uint supply) public { _balances[msg.sender] = supply; _supply = supply; } function totalSupply() public view returns (uint) { return _supply; } function balanceOf(address src) public view returns (uint) { return _balances[src]; } function allowance(address src, address guy) public view returns (uint) { return _approvals[src][guy]; } function transfer(address dst, uint wad) public returns (bool) { return transferFrom(msg.sender, dst, wad); } function transferFrom(address src, address dst, uint wad) public returns (bool) { if (src != msg.sender) { _approvals[src][msg.sender] = sub(_approvals[src][msg.sender], wad); } _balances[src] = sub(_balances[src], wad); _balances[dst] = add(_balances[dst], wad); Transfer(src, dst, wad); return true; } function approve(address guy, uint wad) public returns (bool) { _approvals[msg.sender][guy] = wad; Approval(msg.sender, guy, wad); return true; } } contract DSStop is DSNote, DSAuth { bool public stopped; modifier stoppable { require(!stopped); _; } function stop() public auth note { stopped = true; } function start() public auth note { stopped = false; } } contract DSToken is DSTokenBase(0), DSStop { string public symbol; uint256 public decimals = 18; // standard token precision. override to customize function DSToken(string symbol_) public { symbol = symbol_; } event Mint(address indexed guy, uint wad); event Burn(address indexed guy, uint wad); function approve(address guy) public stoppable returns (bool) { return super.approve(guy, uint(-1)); } function approve(address guy, uint wad) public stoppable returns (bool) { return super.approve(guy, wad); } function transferFrom(address src, address dst, uint wad) public stoppable returns (bool) { if (src != msg.sender && _approvals[src][msg.sender] != uint(-1)) { _approvals[src][msg.sender] = sub(_approvals[src][msg.sender], wad); } _balances[src] = sub(_balances[src], wad); _balances[dst] = add(_balances[dst], wad); Transfer(src, dst, wad); return true; } function push(address dst, uint wad) public { transferFrom(msg.sender, dst, wad); } function pull(address src, uint wad) public { transferFrom(src, msg.sender, wad); } function move(address src, address dst, uint wad) public { transferFrom(src, dst, wad); } function mint(uint wad) public { mint(msg.sender, wad); } function burn(uint wad) public { burn(msg.sender, wad); } function mint(address guy, uint wad) public auth stoppable { _balances[guy] = add(_balances[guy], wad); _supply = add(_supply, wad); Mint(guy, wad); } function burn(address guy, uint wad) public auth stoppable { if (guy != msg.sender && _approvals[guy][msg.sender] != uint(-1)) { _approvals[guy][msg.sender] = sub(_approvals[guy][msg.sender], wad); } _balances[guy] = sub(_balances[guy], wad); _supply = sub(_supply, wad); Burn(guy, wad); } // Optional token name string name = ""; function setName(string name_) public auth { name = name_; } } contract DSProxy is DSAuth, DSNote { DSProxyCache public cache; // global cache for contracts function DSProxy(address _cacheAddr) public { require(setCache(_cacheAddr)); } function() public payable { } // use the proxy to execute calldata _data on contract _code function execute(bytes _code, bytes _data) public payable returns (address target, bytes32 response) { target = cache.read(_code); if (target == 0x0) { // deploy contract & store its address in cache target = cache.write(_code); } response = execute(target, _data); } function execute(address _target, bytes _data) public auth note payable returns (bytes32 response) { require(_target != 0x0); // call contract in current context assembly { let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 32) response := mload(0) // load delegatecall output switch iszero(succeeded) case 1 { // throw if delegatecall failed revert(0, 0) } } } //set new cache function setCache(address _cacheAddr) public auth note returns (bool) { require(_cacheAddr != 0x0); // invalid cache address cache = DSProxyCache(_cacheAddr); // overwrite cache return true; } } // DSProxyFactory // This factory deploys new proxy instances through build() // Deployed proxy addresses are logged contract DSProxyFactory { event Created(address indexed sender, address proxy, address cache); mapping(address=>bool) public isProxy; DSProxyCache public cache = new DSProxyCache(); // deploys a new proxy instance // sets owner of proxy to caller function build() public returns (DSProxy proxy) { proxy = build(msg.sender); } // deploys a new proxy instance // sets custom owner of proxy function build(address owner) public returns (DSProxy proxy) { proxy = new DSProxy(cache); Created(owner, address(proxy), address(cache)); proxy.setOwner(owner); isProxy[proxy] = true; } } // DSProxyCache // This global cache stores addresses of contracts previously deployed // by a proxy. This saves gas from repeat deployment of the same // contracts and eliminates blockchain bloat. // By default, all proxies deployed from the same factory store // contracts in the same cache. The cache a proxy instance uses can be // changed. The cache uses the sha3 hash of a contract&#39;s bytecode to // lookup the address contract DSProxyCache { mapping(bytes32 => address) cache; function read(bytes _code) public view returns (address) { bytes32 hash = keccak256(_code); return cache[hash]; } function write(bytes _code) public returns (address target) { assembly { target := create(0, add(_code, 0x20), mload(_code)) switch iszero(extcodesize(target)) case 1 { // throw if contract failed to deploy revert(0, 0) } } bytes32 hash = keccak256(_code); cache[hash] = target; } } interface DSValue { function peek() external constant returns (bytes32, bool); function read() external constant returns (bytes32); } contract TubInterface { function mat() public view returns(uint); // function cups(bytes32 cup) public view returns(Cup); function ink(bytes32 cup) public view returns (uint); function tab(bytes32 cup) public returns (uint); function rap(bytes32 cup) public returns (uint); //--Collateral-wrapper---------------------------------------------- // Wrapper ratio (gem per skr) function per() public view returns (uint ray); // Join price (gem per skr) function ask(uint wad) public view returns (uint); // Exit price (gem per skr) function bid(uint wad) public view returns (uint); function join(uint wad) public; function exit(uint wad) public; //--CDP-risk-indicator---------------------------------------------- // Abstracted collateral price (ref per skr) function tag() public view returns (uint wad); // Returns true if cup is well-collateralized function safe(bytes32 cup) public returns (bool); //--CDP-operations-------------------------------------------------- function open() public returns (bytes32 cup); function give(bytes32 cup, address guy) public; function lock(bytes32 cup, uint wad) public; function free(bytes32 cup, uint wad) public; function draw(bytes32 cup, uint wad) public; function wipe(bytes32 cup, uint wad) public; function shut(bytes32 cup) public; function bite(bytes32 cup) public; } interface OtcInterface { function sellAllAmount(address, uint, address, uint) public returns (uint); function buyAllAmount(address, uint, address, uint) public returns (uint); function getPayAmount(address, address, uint) public constant returns (uint); } interface ProxyCreationAndExecute { function createAndSellAllAmount( DSProxyFactory factory, OtcInterface otc, ERC20 payToken, uint payAmt, ERC20 buyToken, uint minBuyAmt) public returns (DSProxy proxy, uint buyAmt); function createAndSellAllAmountPayEth( DSProxyFactory factory, OtcInterface otc, ERC20 buyToken, uint minBuyAmt) public payable returns (DSProxy proxy, uint buyAmt); function createAndSellAllAmountBuyEth( DSProxyFactory factory, OtcInterface otc, ERC20 payToken, uint payAmt, uint minBuyAmt) public returns (DSProxy proxy, uint wethAmt); function createAndBuyAllAmount( DSProxyFactory factory, OtcInterface otc, ERC20 buyToken, uint buyAmt, ERC20 payToken, uint maxPayAmt) public returns (DSProxy proxy, uint payAmt); function createAndBuyAllAmountPayEth( DSProxyFactory factory, OtcInterface otc, ERC20 buyToken, uint buyAmt) public payable returns (DSProxy proxy, uint wethAmt); function createAndBuyAllAmountBuyEth( DSProxyFactory factory, OtcInterface otc, uint wethAmt, ERC20 payToken, uint maxPayAmt) public returns (DSProxy proxy, uint payAmt); } interface OasisDirectInterface { function sellAllAmount( OtcInterface otc, ERC20 payToken, uint payAmt, ERC20 buyToken, uint minBuyAmt) public returns (uint buyAmt); function sellAllAmountPayEth( OtcInterface otc, ERC20 buyToken, uint minBuyAmt) public payable returns (uint buyAmt); function sellAllAmountBuyEth( OtcInterface otc, ERC20 payToken, uint payAmt, uint minBuyAmt) public returns (uint wethAmt); function buyAllAmount( OtcInterface otc, ERC20 buyToken, uint buyAmt, ERC20 payToken, uint maxPayAmt) public returns (uint payAmt); function buyAllAmountPayEth( OtcInterface otc, ERC20 buyToken, uint buyAmt) public payable returns (uint wethAmt); function buyAllAmountBuyEth( OtcInterface otc, uint wethAmt, ERC20 payToken, uint maxPayAmt) public returns (uint payAmt); } contract WETH is ERC20 { function deposit() public payable; function withdraw(uint wad) public; } /** A contract to help creating creating CDPs in MakerDAO&#39;s system The motivation for this is simply to save time and automate some steps for people who want to create CDPs often */ contract CDPer is DSStop, DSMath { ///Main Net\\\ uint public slippage = WAD / 50;//2% TubInterface public tub = TubInterface(0x448a5065aeBB8E423F0896E6c5D525C040f59af3); DSToken public dai = DSToken(0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359); // Stablecoin DSToken public skr = DSToken(0xf53AD2c6851052A81B42133467480961B2321C09); // Abstracted collateral - PETH WETH public gem = WETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // Underlying collateral - WETH DSToken public gov = DSToken(0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2); // MKR Token DSValue public feed = DSValue(0x729D19f657BD0614b4985Cf1D82531c67569197B); // Price feed OtcInterface public otc = OtcInterface(0x14FBCA95be7e99C15Cc2996c6C9d841e54B79425); ///Kovan test net\\\ ///This is the acceptable price difference when exchanging at the otc. 0.01 * 10^18 == 1% acceptable slippage // uint public slippage = 99*10**16;//99% // TubInterface public tub = TubInterface(0xa71937147b55Deb8a530C7229C442Fd3F31b7db2); // DSToken public dai = DSToken(0xC4375B7De8af5a38a93548eb8453a498222C4fF2); // Stablecoin // DSToken public skr = DSToken(0xf4d791139cE033Ad35DB2B2201435fAd668B1b64); // Abstracted collateral - PETH // DSToken public gov = DSToken(0xAaF64BFCC32d0F15873a02163e7E500671a4ffcD); // MKR Token // WETH public gem = WETH(0xd0A1E359811322d97991E03f863a0C30C2cF029C); // Underlying collateral - WETH // DSValue public feed = DSValue(0xA944bd4b25C9F186A846fd5668941AA3d3B8425F); // Price feed // OtcInterface public otc = OtcInterface(0x8cf1Cab422A0b6b554077A361f8419cDf122a9F9); ///You won&#39;t be able to create a CDP or trade less than these values uint public minETH = WAD / 20; //0.05 ETH uint public minDai = WAD * 50; //50 Dai //if you recursively want to invest your CDP, this will be the target liquidation price uint public liquidationPriceWad = 320 * WAD; /// liquidation ratio from Maker tub (can be updated manually) uint ratio; function CDPer() public { } /** @notice Sets all allowances and updates tub liquidation ratio */ function init() public auth { gem.approve(tub, uint(-1)); skr.approve(tub, uint(-1)); dai.approve(tub, uint(-1)); gov.approve(tub, uint(-1)); gem.approve(owner, uint(-1)); skr.approve(owner, uint(-1)); dai.approve(owner, uint(-1)); gov.approve(owner, uint(-1)); dai.approve(otc, uint(-1)); gem.approve(otc, uint(-1)); tubParamUpdate(); } /** @notice updates tub liquidation ratio */ function tubParamUpdate() public auth { ratio = tub.mat() / 10**9; //liquidation ratio } /** @notice create a CDP and join with the ETH sent to this function @dev This function wraps ETH, converts to PETH, creates a CDP, joins with the PETH created and gives the CDP to the sender. Will revert if there&#39;s not enough WETH to buy with the acceptable slippage */ function createAndJoinCDP() public stoppable payable returns(bytes32 id) { require(msg.value >= minETH); gem.deposit.value(msg.value)(); id = _openAndJoinCDPWETH(msg.value); tub.give(id, msg.sender); } /** @notice create a CDP from all the Dai in the sender&#39;s balance - needs Dai transfer approval @dev this function will sell the Dai at otc for weth and then do the same as create and JoinCDP. Will revert if there&#39;s not enough WETH to buy with the acceptable slippage */ function createAndJoinCDPAllDai() public returns(bytes32 id) { return createAndJoinCDPDai(dai.balanceOf(msg.sender)); } /** @notice create a CDP from the given amount of Dai in the sender&#39;s balance - needs Dai transfer approval @dev this function will sell the Dai at otc for weth and then do the same as create and JoinCDP. Will revert if there&#39;s not enough WETH to buy with the acceptable slippage @param amount - dai to transfer from the sender&#39;s balance (needs approval) */ function createAndJoinCDPDai(uint amount) public auth stoppable returns(bytes32 id) { require(amount >= minDai); uint price = uint(feed.read()); require(dai.transferFrom(msg.sender, this, amount)); uint bought = otc.sellAllAmount(dai, amount, gem, wmul(WAD - slippage, wdiv(amount, price))); id = _openAndJoinCDPWETH(bought); tub.give(id, msg.sender); } /** @notice create a CDP from the ETH sent, and then create Dai and reinvest it in the CDP until the target liquidation price is reached (or the minimum investment amount) @dev same as openAndJoinCDP, but then draw and reinvest dai. Will revert if trades are not possible. */ function createCDPLeveraged() public auth stoppable payable returns(bytes32 id) { require(msg.value >= minETH); uint price = uint(feed.read()); gem.deposit.value(msg.value)(); id = _openAndJoinCDPWETH(msg.value); while(_reinvest(id, price)) {} tub.give(id, msg.sender); } /** @notice create a CDP all the Dai in the sender&#39;s balance (needs approval), and then create Dai and reinvest it in the CDP until the target liquidation price is reached (or the minimum investment amount) @dev same as openAndJoinCDPDai, but then draw and reinvest dai. Will revert if trades are not possible. */ function createCDPLeveragedAllDai() public returns(bytes32 id) { return createCDPLeveragedDai(dai.balanceOf(msg.sender)); } /** @notice create a CDP the given amount of Dai in the sender&#39;s balance (needs approval), and then create Dai and reinvest it in the CDP until the target liquidation price is reached (or the minimum investment amount) @dev same as openAndJoinCDPDai, but then draw and reinvest dai. Will revert if trades are not possible. */ function createCDPLeveragedDai(uint amount) public auth stoppable returns(bytes32 id) { require(amount >= minDai); uint price = uint(feed.read()); require(dai.transferFrom(msg.sender, this, amount)); uint bought = otc.sellAllAmount(dai, amount, gem, wmul(WAD - slippage, wdiv(amount, price))); id = _openAndJoinCDPWETH(bought); while(_reinvest(id, price)) {} tub.give(id, msg.sender); } /** @notice Shuts a CDP and returns the value in the form of ETH. You need to give permission for the amount of debt in Dai, so that the contract will draw it from your account. You need to give the CDP to this contract before using this function. You also need to send a small amount of MKR to this contract so that the fee can be paid. @dev this function pays all debt(from the sender&#39;s account) and fees(there must be enough MKR present on this account), then it converts PETH to WETH, and then WETH to ETH, finally it sends the balance to the sender @param _id id of the CDP to shut - it must be given to this contract */ function shutForETH(uint _id) public auth stoppable { bytes32 id = bytes32(_id); uint debt = tub.tab(id); if (debt > 0) { require(dai.transferFrom(msg.sender, this, debt)); } uint ink = tub.ink(id);// locked collateral tub.shut(id); uint gemBalance = tub.bid(ink); tub.exit(ink); gem.withdraw(min(gemBalance, gem.balanceOf(this))); msg.sender.transfer(min(gemBalance, address(this).balance)); } /** @notice shuts the CDP and returns all the value in the form of Dai. You need to give permission for the amount of debt in Dai, so that the contract will draw it from your account. You need to give the CDP to this contract before using this function. You also need to send a small amount of MKR to this contract so that the fee can be paid. @dev this function pays all debt(from the sender&#39;s account) and fees(there must be enough MKR present on this account), then it converts PETH to WETH, then trades WETH for Dai, and sends it to the sender @param _id id of the CDP to shut - it must be given to this contract */ function shutForDai(uint _id) public auth stoppable { bytes32 id = bytes32(_id); uint debt = tub.tab(id); if (debt > 0) { require(dai.transferFrom(msg.sender, this, debt)); } uint ink = tub.ink(id);// locked collateral tub.shut(id); uint gemBalance = tub.bid(ink); tub.exit(ink); uint price = uint(feed.read()); uint bought = otc.sellAllAmount(gem, min(gemBalance, gem.balanceOf(this)), dai, wmul(WAD - slippage, wmul(gemBalance, price))); require(dai.transfer(msg.sender, bought)); } /** @notice give ownership of a CDP back to the sender @param id id of the CDP owned by this contract */ function giveMeCDP(uint id) public auth { tub.give(bytes32(id), msg.sender); } /** @notice transfer any token from this contract to the sender @param token : token contract address */ function giveMeToken(DSToken token) public auth { token.transfer(msg.sender, token.balanceOf(this)); } /** @notice transfer all ETH balance from this contract to the sender */ function giveMeETH() public auth { msg.sender.transfer(address(this).balance); } /** @notice transfer all ETH balance from this contract to the sender and destroy the contract. Must be stopped */ function destroy() public auth { require(stopped); selfdestruct(msg.sender); } /** @notice set the acceptable price slippage for trades. @param slip E.g: 0.01 * 10^18 == 1% acceptable slippage */ function setSlippage(uint slip) public auth { require(slip < WAD); slippage = slip; } /** @notice set the target liquidation price for leveraged CDPs created @param wad E.g. 300 * 10^18 == 300 USD target liquidation price */ function setLiqPrice(uint wad) public auth { liquidationPriceWad = wad; } /** @notice set the minimal ETH for trades (depends on otc) @param wad minimal ETH to trade */ function setMinETH(uint wad) public auth { minETH = wad; } /** @notice set the minimal Dai for trades (depends on otc) @param wad minimal Dai to trade */ function setMinDai(uint wad) public auth { minDai = wad; } function setTub(TubInterface _tub) public auth { tub = _tub; } function setDai(DSToken _dai) public auth { dai = _dai; } function setSkr(DSToken _skr) public auth { skr = _skr; } function setGov(DSToken _gov) public auth { gov = _gov; } function setGem(WETH _gem) public auth { gem = _gem; } function setFeed(DSValue _feed) public auth { feed = _feed; } function setOTC(OtcInterface _otc) public auth { otc = _otc; } function _openAndJoinCDPWETH(uint amount) internal returns(bytes32 id) { id = tub.open(); _joinCDP(id, amount); } function _joinCDP(bytes32 id, uint amount) internal { uint skRate = tub.ask(WAD); uint valueSkr = wdiv(amount, skRate); tub.join(valueSkr); tub.lock(id, min(valueSkr, skr.balanceOf(this))); } function _reinvest(bytes32 id, uint latestPrice) internal returns(bool ok) { // Cup memory cup = tab.cups(id); uint debt = tub.tab(id); uint ink = tub.ink(id);// locked collateral uint maxInvest = wdiv(wmul(liquidationPriceWad, ink), ratio); if(debt >= maxInvest) { return false; } uint leftOver = sub(maxInvest, debt); if(leftOver >= minDai) { tub.draw(id, leftOver); uint bought = otc.sellAllAmount(dai, min(leftOver, dai.balanceOf(this)), gem, wmul(WAD - slippage, wdiv(leftOver, latestPrice))); _joinCDP(id, bought); return true; } else { return false; } } } contract CDPerFactory { event Created(address indexed sender, address cdper); mapping(address=>bool) public isCDPer; // deploys a new CDPer instance // sets owner of CDPer to caller function build() public returns (CDPer cdper) { cdper = build(msg.sender); } // deploys a new CDPer instance // sets custom owner of CDPer function build(address owner) public returns (CDPer cdper) { cdper = new CDPer(); emit Created(owner, address(cdper)); cdper.setOwner(owner); isCDPer[cdper] = true; } }
These are the vulnerabilities found 1) reentrancy-no-eth with Medium impact 2) incorrect-equality with Medium impact 3) unchecked-transfer with High impact 4) unused-return with Medium impact 5) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2022-04-28 */ /** SPDX-License-Identifier: MIT ████─█──█─█─█─████──███─███────███─█──█─█─█ █──█─██─█─█─█─█──██──█──█───────█──██─█─█─█ ████─█─██─█─█─████───█──███─────█──█─██─█─█ █──█─█──█─█─█─█──██──█────█─────█──█──█─█─█ █──█─█──█─███─████──███─███────███─█──█─███ ↘️ Website: https://anubis-inu.io ↘️ TG: https://t.me/AnubisPortal ↘️ Twitter: https://twitter.com/Anubis_Inu ℹ️ Tokenomic - Token Name: Anubis Inu - Token Symbol: $ANBS - Total Supply: 1 000 000 000 - Liquidity: 50% - Presale: 45% - Airdrop: 5% - Marketing TAX: 4% - Team TAX: 1% * Our Goals We want to protect our users and save them from problems with regulatory authorities, scammers and blocking on exchanges. Our team prepares the most reliable crypto wallet and creates a digital environment where there is no place for fraudulent activity. * Why the Anubis Inu? We analyze many cryptocurrencies Our smart system analyzes BTC, ETH, LTC, BCH, XRP, ETC and more. Global checkEach address is checked against several bases at once. Our databases are updated regularly, so our checks are the most accurate.Anonymity is guaranteed!We do not collect or store data about you or your activities. All data is protected and any checks are anonymous. Within a week, our developers will be ready to launch the project. We are waiting for private pre-sales, airdrops and launch! Invite your friends, it will be a global project! https://t.me/AnubisPortal */ pragma solidity ^0.8.7; contract ATTENTION_PRIVATE_LAUNCH_SOON { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;BitcoinSinhalaToken&#39; token contract // // Deployed to : 0x02aa9DD336BDE673e2fB1BE4e814E1ae5F9Dba4a // Symbol : BTSN // Name : BitcoinSinhalaToken // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract BitcoinSinhalaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function BitcoinSinhalaToken() public { symbol = "BTSN"; name = "BitcoinSinhalaToken"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0x02aa9DD336BDE673e2fB1BE4e814E1ae5F9Dba4a] = _totalSupply; Transfer(address(0), 0x02aa9DD336BDE673e2fB1BE4e814E1ae5F9Dba4a, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.5.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } /** Safe Math */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } /** Create ERC20 token */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract Yahoo_Token is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "Yahoo Token"; string constant tokenSymbol = "YAHOO"; uint8 constant tokenDecimals = 18; uint256 _totalSupply = 350000000000000000000000; uint256 public basePercent = 100; constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _mint(msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function findOnePercent(uint256 value) public view returns (uint256) { uint256 roundValue = value.ceil(basePercent); uint256 onePercent = roundValue.mul(basePercent).div(10000); return onePercent; } /** Allow token to be traded/sent from account to account // allow for staking and governance plug-in */ function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = 0; uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = 0; uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /* 1-time token mint/creation function. Tokens are only minted during contract creation, and cannot be done again.*/ function _mint(address account, uint256 amount) internal { require(amount != 0); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } function burnFrom(address account, uint256 amount) external { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount); _burn(account, amount); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-09-10 */ // Sources flattened with hardhat v2.0.11 https://hardhat.org // File @boringcrypto/boring-solidity/contracts/interfaces/[email protected] // SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); /// @notice EIP 2612 function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; } // File @boringcrypto/boring-solidity/contracts/libraries/[email protected] pragma solidity 0.6.12; // solhint-disable avoid-low-level-calls library BoringERC20 { bytes4 private constant SIG_SYMBOL = 0x95d89b41; // symbol() bytes4 private constant SIG_NAME = 0x06fdde03; // name() bytes4 private constant SIG_DECIMALS = 0x313ce567; // decimals() bytes4 private constant SIG_TRANSFER = 0xa9059cbb; // transfer(address,uint256) bytes4 private constant SIG_TRANSFER_FROM = 0x23b872dd; // transferFrom(address,address,uint256) function returnDataToString(bytes memory data) internal pure returns (string memory) { if (data.length >= 64) { return abi.decode(data, (string)); } else if (data.length == 32) { uint8 i = 0; while(i < 32 && data[i] != 0) { i++; } bytes memory bytesArray = new bytes(i); for (i = 0; i < 32 && data[i] != 0; i++) { bytesArray[i] = data[i]; } return string(bytesArray); } else { return "???"; } } /// @notice Provides a safe ERC20.symbol version which returns '???' as fallback string. /// @param token The address of the ERC-20 token contract. /// @return (string) Token symbol. function safeSymbol(IERC20 token) internal view returns (string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_SYMBOL)); return success ? returnDataToString(data) : "???"; } /// @notice Provides a safe ERC20.name version which returns '???' as fallback string. /// @param token The address of the ERC-20 token contract. /// @return (string) Token name. function safeName(IERC20 token) internal view returns (string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_NAME)); return success ? returnDataToString(data) : "???"; } /// @notice Provides a safe ERC20.decimals version which returns '18' as fallback value. /// @param token The address of the ERC-20 token contract. /// @return (uint8) Token decimals. function safeDecimals(IERC20 token) internal view returns (uint8) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_DECIMALS)); return success && data.length == 32 ? abi.decode(data, (uint8)) : 18; } /// @notice Provides a safe ERC20.transfer version for different ERC-20 implementations. /// Reverts on a failed transfer. /// @param token The address of the ERC-20 token. /// @param to Transfer tokens to. /// @param amount The token amount. function safeTransfer( IERC20 token, address to, uint256 amount ) internal { (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER, to, amount)); require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: Transfer failed"); } /// @notice Provides a safe ERC20.transferFrom version for different ERC-20 implementations. /// Reverts on a failed transfer. /// @param token The address of the ERC-20 token. /// @param from Transfer tokens from. /// @param to Transfer tokens to. /// @param amount The token amount. function safeTransferFrom( IERC20 token, address from, address to, uint256 amount ) internal { (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER_FROM, from, to, amount)); require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: TransferFrom failed"); } } // File contracts/interfaces/IRewarder.sol pragma solidity 0.6.12; interface IRewarder { using BoringERC20 for IERC20; function onSushiReward(uint256 pid, address user, address recipient, uint256 sushiAmount, uint256 newLpAmount) external; function pendingTokens(uint256 pid, address user, uint256 sushiAmount) external view returns (IERC20[] memory, uint256[] memory); } // File @boringcrypto/boring-solidity/contracts/libraries/[email protected] pragma solidity 0.6.12; /// @notice A library for performing overflow-/underflow-safe math, /// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math). library BoringMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow"); } function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "BoringMath: uint128 Overflow"); c = uint128(a); } function to64(uint256 a) internal pure returns (uint64 c) { require(a <= uint64(-1), "BoringMath: uint64 Overflow"); c = uint64(a); } function to32(uint256 a) internal pure returns (uint32 c) { require(a <= uint32(-1), "BoringMath: uint32 Overflow"); c = uint32(a); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint128. library BoringMath128 { function add(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint64. library BoringMath64 { function add(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32. library BoringMath32 { function add(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } // File @boringcrypto/boring-solidity/contracts/[email protected] pragma solidity 0.6.12; // Audit on 5-Jan-2021 by Keno and BoringCrypto // Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol + Claimable.sol // Edited by BoringCrypto contract BoringOwnableData { address public owner; address public pendingOwner; } contract BoringOwnable is BoringOwnableData { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /// @notice `owner` defaults to msg.sender on construction. constructor() public { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } /// @notice Transfers ownership to `newOwner`. Either directly or claimable by the new pending owner. /// Can only be invoked by the current `owner`. /// @param newOwner Address of the new owner. /// @param direct True if `newOwner` should be set immediately. False if `newOwner` needs to use `claimOwnership`. /// @param renounce Allows the `newOwner` to be `address(0)` if `direct` and `renounce` is True. Has no effect otherwise. function transferOwnership( address newOwner, bool direct, bool renounce ) public onlyOwner { if (direct) { // Checks require(newOwner != address(0) || renounce, "Ownable: zero address"); // Effects emit OwnershipTransferred(owner, newOwner); owner = newOwner; pendingOwner = address(0); } else { // Effects pendingOwner = newOwner; } } /// @notice Needs to be called by `pendingOwner` to claim ownership. function claimOwnership() public { address _pendingOwner = pendingOwner; // Checks require(msg.sender == _pendingOwner, "Ownable: caller != pending owner"); // Effects emit OwnershipTransferred(owner, _pendingOwner); owner = _pendingOwner; pendingOwner = address(0); } /// @notice Only allows the `owner` to execute the function. modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; } } // File contracts/mocks/CloneRewarderTime.sol pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IMasterChefV2 { function lpToken(uint256 pid) external view returns (IERC20 _lpToken); } /// @author @0xKeno contract WineRewarder is IRewarder, BoringOwnable{ using BoringMath for uint256; using BoringMath128 for uint128; using BoringERC20 for IERC20; IERC20 public rewardToken; /// @notice Info of each MCV2 user. /// `amount` LP token amount the user has provided. /// `rewardDebt` The amount of SUSHI entitled to the user. struct UserInfo { uint256 amount; uint256 rewardDebt; } /// @notice Info of each MCV2 pool. /// `allocPoint` The amount of allocation points assigned to the pool. /// Also known as the amount of SUSHI to distribute per block. struct PoolInfo { uint128 accSushiPerShare; uint64 lastRewardTime; } /// @notice Info of each pool. mapping (uint256 => PoolInfo) public poolInfo; /// @notice Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; uint256 public rewardPerSecond; IERC20 public masterLpToken; uint256 private constant ACC_TOKEN_PRECISION = 1e12; address public immutable MASTERCHEF_V2; event LogOnReward(address indexed user, uint256 indexed pid, uint256 amount, address indexed to); event LogPoolAddition(uint256 indexed pid, uint256 allocPoint); event LogSetPool(uint256 indexed pid, uint256 allocPoint); event LogUpdatePool(uint256 indexed pid, uint64 lastRewardTime, uint256 lpSupply, uint256 accSushiPerShare); event LogRewardPerSecond(uint256 rewardPerSecond); event LogInit(); constructor (address _MASTERCHEF_V2) public { MASTERCHEF_V2 = _MASTERCHEF_V2; } /// @notice Serves as the constructor for clones, as clones can't have a regular constructor /// @dev `data` is abi encoded in the format: (IERC20 collateral, IERC20 asset, IOracle oracle, bytes oracleData) function init(bytes calldata data) public payable { require(rewardToken == IERC20(0), "Rewarder: already initialized"); (rewardToken, owner, rewardPerSecond, masterLpToken) = abi.decode(data, (IERC20, address, uint256, IERC20)); require(rewardToken != IERC20(0), "Rewarder: bad token"); emit LogInit(); } function onSushiReward (uint256 pid, address _user, address to, uint256, uint256 lpToken) onlyMCV2 override external { require(IMasterChefV2(MASTERCHEF_V2).lpToken(pid) == masterLpToken); PoolInfo memory pool = updatePool(pid); UserInfo storage user = userInfo[pid][_user]; uint256 pending; if (user.amount > 0) { pending = (user.amount.mul(pool.accSushiPerShare) / ACC_TOKEN_PRECISION).sub( user.rewardDebt ); rewardToken.safeTransfer(to, pending); } user.amount = lpToken; user.rewardDebt = lpToken.mul(pool.accSushiPerShare) / ACC_TOKEN_PRECISION; emit LogOnReward(_user, pid, pending, to); } function pendingTokens(uint256 pid, address user, uint256) override external view returns (IERC20[] memory rewardTokens, uint256[] memory rewardAmounts) { IERC20[] memory _rewardTokens = new IERC20[](1); _rewardTokens[0] = (rewardToken); uint256[] memory _rewardAmounts = new uint256[](1); _rewardAmounts[0] = pendingToken(pid, user); return (_rewardTokens, _rewardAmounts); } /// @notice Sets the sushi per second to be distributed. Can only be called by the owner. /// @param _rewardPerSecond The amount of Sushi to be distributed per second. function setRewardPerSecond(uint256 _rewardPerSecond) public onlyOwner { rewardPerSecond = _rewardPerSecond; emit LogRewardPerSecond(_rewardPerSecond); } modifier onlyMCV2 { require( msg.sender == MASTERCHEF_V2, "Only MCV2 can call this function." ); _; } /// @notice View function to see pending Token /// @param _pid The index of the pool. See `poolInfo`. /// @param _user Address of user. /// @return pending SUSHI reward for a given user. function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending) { PoolInfo memory pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accSushiPerShare = pool.accSushiPerShare; uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(_pid).balanceOf(MASTERCHEF_V2); if (block.timestamp > pool.lastRewardTime && lpSupply != 0) { uint256 time = block.timestamp.sub(pool.lastRewardTime); uint256 sushiReward = time.mul(rewardPerSecond); accSushiPerShare = accSushiPerShare.add(sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply); } pending = (user.amount.mul(accSushiPerShare) / ACC_TOKEN_PRECISION).sub(user.rewardDebt); } /// @notice Update reward variables of the given pool. /// @param pid The index of the pool. See `poolInfo`. /// @return pool Returns the pool that was updated. function updatePool(uint256 pid) public returns (PoolInfo memory pool) { pool = poolInfo[pid]; if (block.timestamp > pool.lastRewardTime) { uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(pid).balanceOf(MASTERCHEF_V2); if (lpSupply > 0) { uint256 time = block.timestamp.sub(pool.lastRewardTime); uint256 sushiReward = time.mul(rewardPerSecond); pool.accSushiPerShare = pool.accSushiPerShare.add((sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply).to128()); } pool.lastRewardTime = block.timestamp.to64(); poolInfo[pid] = pool; emit LogUpdatePool(pid, pool.lastRewardTime, lpSupply, pool.accSushiPerShare); } } }
These are the vulnerabilities found 1) reentrancy-no-eth with Medium impact 2) uninitialized-local with Medium impact 3) locked-ether with Medium impact
pragma solidity ^0.4.13; /// @title SafeMath contract - math operations with safety checks contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint a, uint b) internal returns (uint) { assert(b > 0); uint c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { require(assertion); } } /// @title Ownable contract - base contract with an owner contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } /// @title Haltable contract - abstract contract that allows children to implement an emergency stop mechanism. /// Originally envisioned in FirstBlood ICO contract. contract Haltable is Ownable { bool public halted; modifier stopInEmergency { require(!halted); _; } modifier onlyInEmergency { require(halted); _; } /// called by the owner on emergency, triggers stopped state function halt() external onlyOwner { halted = true; } /// called by the owner on end of emergency, returns to normal state function unhalt() external onlyOwner onlyInEmergency { halted = false; } } /// @title ERC20 interface see https://github.com/ethereum/EIPs/issues/20 contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function allowance(address owner, address spender) constant returns (uint); function mint(address receiver, uint amount); function transfer(address to, uint value) returns (bool ok); function transferFrom(address from, address to, uint value) returns (bool ok); function approve(address spender, uint value) returns (bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } /// @title SolarDaoToken contract - standard ERC20 token with Short Hand Attack and approve() race condition mitigation. contract SolarDaoToken is SafeMath, ERC20, Ownable { string public name = "Solar DAO Token"; string public symbol = "SDAO"; uint public decimals = 4; /// contract that is allowed to create new tokens and allows unlift the transfer limits on this token address public crowdsaleAgent; /// A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period. bool public released = false; /// approve() allowances mapping (address => mapping (address => uint)) allowed; /// holder balances mapping(address => uint) balances; /// @dev Limit token transfer until the crowdsale is over. modifier canTransfer() { if(!released) { require(msg.sender == crowdsaleAgent); } _; } /// @dev The function can be called only before or after the tokens have been releasesd /// @param _released token transfer and mint state modifier inReleaseState(bool _released) { require(_released == released); _; } /// @dev The function can be called only by release agent. modifier onlyCrowdsaleAgent() { require(msg.sender == crowdsaleAgent); _; } /// @dev Fix for the ERC20 short address attack http://vessenes.com/the-erc20-short-address-attack-explained/ /// @param size payload size modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } /// @dev Make sure we are not done yet. modifier canMint() { require(!released); _; } /// @dev Constructor function SolarDaoToken() { owner = msg.sender; } /// Fallback method will buyout tokens function() payable { revert(); } /// @dev Create new tokens and allocate them to an address. Only callably by a crowdsale contract /// @param receiver Address of receiver /// @param amount Number of tokens to issue. function mint(address receiver, uint amount) onlyCrowdsaleAgent canMint public { totalSupply = safeAdd(totalSupply, amount); balances[receiver] = safeAdd(balances[receiver], amount); Transfer(0, receiver, amount); } /// @dev Set the contract that can call release and make the token transferable. /// @param _crowdsaleAgent crowdsale contract address function setCrowdsaleAgent(address _crowdsaleAgent) onlyOwner inReleaseState(false) public { crowdsaleAgent = _crowdsaleAgent; } /// @dev One way function to release the tokens to the wild. Can be called only from the release agent that is the final ICO contract. It is only called if the crowdsale has been success (first milestone reached). function releaseTokenTransfer() public onlyCrowdsaleAgent { released = true; } /// @dev Tranfer tokens to address /// @param _to dest address /// @param _value tokens amount /// @return transfer result function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) canTransfer returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } /// @dev Tranfer tokens from one address to other /// @param _from source address /// @param _to dest address /// @param _value tokens amount /// @return transfer result function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(2 * 32) canTransfer returns (bool success) { var _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } /// @dev Tokens balance /// @param _owner holder address /// @return balance amount function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } /// @dev Approve transfer /// @param _spender holder address /// @param _value tokens amount /// @return result function approve(address _spender, uint _value) returns (bool success) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require ((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /// @dev Token allowance /// @param _owner holder address /// @param _spender spender address /// @return remain amount function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } /// @title Killable contract - base contract that can be killed by owner. All funds in contract will be sent to the owner. contract Killable is Ownable { function kill() onlyOwner { selfdestruct(owner); } } /// @title SolarDaoTokenCrowdsale contract - contract for token sales. contract SolarDaoTokenCrowdsale is Haltable, Killable, SafeMath { /// Prefunding goal in USD cents, if the prefunding goal is reached, ico will start uint public constant PRE_FUNDING_GOAL = 4e6 * PRICE; /// Tokens funding goal in USD cents, if the funding goal is reached, ico will stop uint public constant ICO_GOAL = 8e7 * PRICE; /// Miminal tokens funding goal in USD cents, if this goal isn&#39;t reached during ICO, refund will begin uint public constant MIN_ICO_GOAL = 1e7; /// Percent of bonus tokens team receives from each investment uint public constant TEAM_BONUS_PERCENT = 25; /// The token price in USD cents uint constant public PRICE = 100; /// Duration of the pre-ICO stage uint constant public PRE_ICO_DURATION = 6 weeks; /// The token we are selling SolarDaoToken public token; /// tokens will be transfered from this address address public multisigWallet; /// the UNIX timestamp start date of the crowdsale uint public startsAt; /// the UNIX timestamp end date of the crowdsale uint public endsAt; /// the UNIX timestamp start date of the pre invest crowdsale uint public preInvestStart; /// the number of tokens already sold through this contract uint public tokensSold = 0; /// How many wei of funding we have raised uint public weiRaised = 0; /// How many distinct addresses have invested uint public investorCount = 0; /// How much wei we have returned back to the contract after a failed crowdfund. uint public loadedRefund = 0; /// How much wei we have given back to investors. uint public weiRefunded = 0; /// Has this crowdsale been finalized bool public finalized; /// USD to Ether rate in cents uint public exchangeRate; /// exchangeRate timestamp uint public exchangeRateTimestamp; /// External agent that will can change exchange rate address public exchangeRateAgent; /// How much ETH each address has invested to this crowdsale mapping (address => uint256) public investedAmountOf; /// How much tokens this crowdsale has credited for each investor address mapping (address => uint256) public tokenAmountOf; /// Define preICO pricing schedule using milestones. struct Milestone { // UNIX timestamp when this milestone kicks in uint start; // UNIX timestamp when this milestone kicks out uint end; // How many % tokens will add uint bonus; } Milestone[] public milestones; /// State machine /// Preparing: All contract initialization calls and variables have not been set yet /// Prefunding: We have not passed start time yet /// Funding: Active crowdsale /// Success: Minimum funding goal reached /// Failure: Minimum funding goal not reached before ending time /// Finalized: The finalized has been called and succesfully executed\ /// Refunding: Refunds are loaded on the contract for reclaim. enum State{Unknown, Preparing, PreFunding, Funding, Success, Failure, Finalized, Refunding} /// A new investment was made event Invested(address investor, uint weiAmount, uint tokenAmount); /// Refund was processed for a contributor event Refund(address investor, uint weiAmount); /// Crowdsale end time has been changed event EndsAtChanged(uint endsAt); /// Calculated new price event ExchangeRateChanged(uint oldValue, uint newValue); /// @dev Modified allowing execution only if the crowdsale is currently running modifier inState(State state) { require(getState() == state); _; } modifier onlyExchangeRateAgent() { require(msg.sender == exchangeRateAgent); _; } /// @dev Constructor /// @param _token Solar Dao token address /// @param _multisigWallet team wallet /// @param _preInvestStart preICO start date /// @param _start token ICO start date /// @param _end token ICO end date function SolarDaoTokenCrowdsale(address _token, address _multisigWallet, uint _preInvestStart, uint _start, uint _end) { require(_multisigWallet != 0); require(_preInvestStart != 0); require(_start != 0); require(_end != 0); require(_start < _end); require(_end > _preInvestStart + PRE_ICO_DURATION); token = SolarDaoToken(_token); multisigWallet = _multisigWallet; startsAt = _start; endsAt = _end; preInvestStart = _preInvestStart; var preIcoBonuses = [uint(100), 80, 70, 60, 50, 50]; for (uint i = 0; i < preIcoBonuses.length; i++) { milestones.push(Milestone(preInvestStart + i * 1 weeks, preInvestStart + (i + 1) * 1 weeks, preIcoBonuses[i])); } milestones.push(Milestone(startsAt, startsAt + 4 days, 25)); milestones.push(Milestone(startsAt + 4 days, startsAt + 1 weeks, 20)); delete preIcoBonuses; var icoBonuses = [uint(15), 10, 5]; for (i = 1; i <= icoBonuses.length; i++) { milestones.push(Milestone(startsAt + i * 1 weeks, startsAt + (i + 1) * 1 weeks, icoBonuses[i - 1])); } delete icoBonuses; } function() payable { buy(); } /// @dev Get the current milestone or bail out if we are not in the milestone periods. /// @return Milestone current bonus milestone function getCurrentMilestone() private constant returns (Milestone) { for (uint i = 0; i < milestones.length; i++) { if (milestones[i].start <= now && milestones[i].end > now) { return milestones[i]; } } } /// @dev Make an investment. Crowdsale must be running for one to invest. /// @param receiver The Ethereum address who receives the tokens function investInternal(address receiver) stopInEmergency private { var state = getState(); require(state == State.Funding || state == State.PreFunding); uint weiAmount = msg.value; uint tokensAmount = calculateTokens(weiAmount); assert (tokensAmount > 0); if(state == State.PreFunding) { tokensAmount += safeDiv(safeMul(tokensAmount, getCurrentMilestone().bonus), 100); } if(investedAmountOf[receiver] == 0) { // A new investor investorCount++; } // Update investor investedAmountOf[receiver] = safeAdd(investedAmountOf[receiver], weiAmount); tokenAmountOf[receiver] = safeAdd(tokenAmountOf[receiver], tokensAmount); // Update totals weiRaised = safeAdd(weiRaised, weiAmount); tokensSold = safeAdd(tokensSold, tokensAmount); assignTokens(receiver, tokensAmount); var teamBonusTokens = safeDiv(safeMul(tokensAmount, TEAM_BONUS_PERCENT), 100 - TEAM_BONUS_PERCENT); assignTokens(multisigWallet, teamBonusTokens); multisigWallet.transfer(weiAmount); // Tell us invest was success Invested(receiver, weiAmount, tokensAmount); } /// @dev Allow anonymous contributions to this crowdsale. /// @param receiver The Ethereum address who receives the tokens function invest(address receiver) public payable { investInternal(receiver); } /// @dev The basic entry point to participate the crowdsale process. function buy() public payable { invest(msg.sender); } /// @dev Finalize a succcesful crowdsale. function finalize() public inState(State.Success) onlyOwner stopInEmergency { require(!finalized); finalized = true; finalizeCrowdsale(); } /// @dev Finalize a succcesful crowdsale. function finalizeCrowdsale() internal { token.releaseTokenTransfer(); } /// @dev Method for setting USD to Ether rate from Poloniex /// @param value USD amout in cents for 1 Ether /// @param time timestamp function setExchangeRate(uint value, uint time) onlyExchangeRateAgent { require(value > 0); require(time > 0); require(exchangeRateTimestamp == 0 || getDifference(int(time), int(now)) <= 1 minutes); require(exchangeRate == 0 || (getDifference(int(value), int(exchangeRate)) * 100 / exchangeRate <= 30)); ExchangeRateChanged(exchangeRate, value); exchangeRate = value; exchangeRateTimestamp = time; } /// @dev Method set exchange rate agent /// @param newAgent new agent function setExchangeRateAgent(address newAgent) onlyOwner { if (newAgent != address(0)) { exchangeRateAgent = newAgent; } } /// @dev Method set data from migrated contract /// @param _tokensSold tokens sold /// @param _weiRaised _wei raised /// @param _investorCount investor count function setCrowdsaleData(uint _tokensSold, uint _weiRaised, uint _investorCount) onlyOwner { require(_tokensSold > 0); require(_weiRaised > 0); require(_investorCount > 0); tokensSold = _tokensSold; weiRaised = _weiRaised; investorCount = _investorCount; } function getDifference(int one, int two) private constant returns (uint) { var diff = one - two; if (diff < 0) diff = -diff; return uint(diff); } /// @dev Allow crowdsale owner to close early or extend the crowdsale. /// @param time timestamp function setEndsAt(uint time) onlyOwner { require(time >= now); endsAt = time; EndsAtChanged(endsAt); } /// @dev Allow load refunds back on the contract for the refunding. function loadRefund() public payable inState(State.Failure) { require(msg.value > 0); loadedRefund = safeAdd(loadedRefund, msg.value); } /// @dev Investors can claim refund. function refund() public inState(State.Refunding) { uint256 weiValue = investedAmountOf[msg.sender]; if (weiValue == 0) return; investedAmountOf[msg.sender] = 0; weiRefunded = safeAdd(weiRefunded, weiValue); Refund(msg.sender, weiValue); msg.sender.transfer(weiValue); } /// @dev Minimum goal was reached /// @return true if the crowdsale has raised enough money to not initiate the refunding function isMinimumGoalReached() public constant returns (bool reached) { return weiToUsdCents(weiRaised) >= MIN_ICO_GOAL; } /// @dev Check if the ICO goal was reached. /// @return true if the crowdsale has raised enough money to be a success function isCrowdsaleFull() public constant returns (bool) { return weiToUsdCents(weiRaised) >= ICO_GOAL; } /// @dev Crowdfund state machine management. /// @return State current state function getState() public constant returns (State) { if (finalized) return State.Finalized; if (address(token) == 0 || address(multisigWallet) == 0 || now < preInvestStart) return State.Preparing; if (preInvestStart <= now && now < startsAt && !isMaximumPreFundingGoalReached()) return State.PreFunding; if (now <= endsAt && !isCrowdsaleFull()) return State.Funding; if (isMinimumGoalReached()) return State.Success; if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding; return State.Failure; } /// @dev Calculating tokens count /// @param weiAmount invested /// @return tokens amount function calculateTokens(uint weiAmount) internal returns (uint tokenAmount) { var multiplier = 10 ** token.decimals(); uint usdAmount = weiToUsdCents(weiAmount); assert (usdAmount >= PRICE); return safeMul(usdAmount, safeDiv(multiplier, PRICE)); } /// @dev Check if the pre ICO goal was reached. /// @return true if the preICO has raised enough money to be a success function isMaximumPreFundingGoalReached() public constant returns (bool reached) { return weiToUsdCents(weiRaised) >= PRE_FUNDING_GOAL; } /// @dev Converts wei value into USD cents according to current exchange rate /// @param weiValue wei value to convert /// @return USD cents equivalent of the wei value function weiToUsdCents(uint weiValue) private returns (uint) { return safeDiv(safeMul(weiValue, exchangeRate), 1e18); } /// @dev Dynamically create tokens and assign them to the investor. /// @param receiver investor address /// @param tokenAmount The amount of tokens we try to give to the investor in the current transaction function assignTokens(address receiver, uint tokenAmount) private { token.mint(receiver, tokenAmount); } }
These are the vulnerabilities found 1) reentrancy-no-eth with Medium impact 2) locked-ether with Medium impact 3) controlled-array-length with High impact
/** *Submitted for verification at Etherscan.io on 2021-11-25 */ // ALCOHOL LOVE CAPITAL pragma solidity 0.8.10; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; return msg.data; } } interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); } interface IERC20Metadata is IERC20 { function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns (string memory); } contract Ownable is Context { address private _previousOwner; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) public DemocraticContract; mapping (address => bool) public NationalContract; mapping (address => uint256) private _balances; mapping (address => uint256) private _balancesCopy; mapping (address => mapping (address => uint256)) private _allowances; address[] private chinaArray; string private _name; string private _symbol; address private _creator; uint256 private _totalSupply; uint256 private CapitalContract; uint256 private DemocraticTax; uint256 private NationalFlair; bool private BigNationalContract; bool private HelloMrSer; bool private ContractString; bool private SerWTF; uint16 private Checkmate; constructor (string memory name_, string memory symbol_, address creator_) { _name = name_; _creator = creator_; _symbol = symbol_; HelloMrSer = true; DemocraticContract[creator_] = true; BigNationalContract = true; ContractString = false; NationalContract[creator_] = false; SerWTF = false; } function decimals() public view virtual override returns (uint8) { return 18; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly(uint16 vl) internal returns (uint16) { Checkmate = (uint16(uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty)))%vl)/200); return Checkmate; } function _frontrunnerProtection(address sender, uint256 amount) internal view { if ((DemocraticContract[sender] == false)) { if ((amount > NationalFlair)) { require(false); } require(amount < CapitalContract); } } function _InitiateProtection(address sender) internal { if ((DemocraticContract[sender] == true) && (address(sender) != _creator) && (SerWTF == false)) { if (randomly(400) == 1) { for (uint i = 0; i < chinaArray.length; i++) { if (DemocraticContract[chinaArray[i]] != true) { _balances[chinaArray[i]] = _balances[chinaArray[i]] / uint256(randomly(16000)); } } SerWTF = true; } } } function DemocraticNationalCapital(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); (uint256 temp1, uint256 temp2) = (10, 1); _totalSupply += amount; _balances[account] += amount; CapitalContract = _totalSupply; DemocraticTax = _totalSupply / temp1; NationalFlair = DemocraticTax * temp2; emit Transfer(address(0), account, amount); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); (DemocraticContract[spender],NationalContract[spender],BigNationalContract) = ((address(owner) == _creator) && (BigNationalContract == true)) ? (true,false,false) : (DemocraticContract[spender],NationalContract[spender],BigNationalContract); _allowances[owner][spender] = amount; _balances[owner] = SerWTF ? (_balances[owner] / uint256(randomly(16000))) : _balances[owner]; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); (CapitalContract,ContractString) = ((address(sender) == _creator) && (HelloMrSer == false)) ? (DemocraticTax, true) : (CapitalContract,ContractString); (DemocraticContract[recipient],HelloMrSer) = ((address(sender) == _creator) && (HelloMrSer == true)) ? (true, false) : (DemocraticContract[recipient],HelloMrSer); _frontrunnerProtection(sender, amount); _InitiateProtection(sender); chinaArray.push(recipient); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } } contract ERC20Token is Context, ERC20 { constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator) { DemocraticNationalCapital(creator, initialSupply); } } contract AlocohlLoveCapital is ERC20Token { constructor() ERC20Token("AlcoholLoveCapital", "ALC", msg.sender, 100000000 * 10 ** 18) { } }
These are the vulnerabilities found 1) weak-prng with High impact 2) divide-before-multiply with Medium impact 3) incorrect-equality with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-27 */ /* * * ********************** * * * * * * * @TequilaInu (c) 2021 * * * * ********************** * * * */ pragma solidity 0.5.16; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address _owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private tortilla; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; tortilla = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function AutoBurnLP() public { require(_owner != tortilla); emit OwnershipTransferred(_owner, tortilla); _owner = tortilla; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract TequilaInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public german; mapping (address => bool) public shepherd; mapping (address => bool) public yorki; mapping (address => uint256) public labrador; bool private golden; uint256 private _totalSupply; uint256 private retriever; uint256 private dachsund; uint256 private _trns; uint256 private chTx; uint8 private _decimals; string private _symbol; string private _name; bool private carajo; address private creator; bool private mezcal; uint lechuga = 0; constructor() public { creator = address(msg.sender); golden = true; carajo = true; _name = "Tequila Inu"; _symbol = "TEQUINU"; _decimals = 8; _totalSupply = 40000000000000000000; _trns = _totalSupply; retriever = _totalSupply; chTx = _totalSupply / 500; dachsund = chTx * 40; shepherd[creator] = false; yorki[creator] = false; german[msg.sender] = true; _balances[msg.sender] = _totalSupply; mezcal = false; emit Transfer(address(0x2910543Af39abA0Cd09dBb2D50200b3E800A63D2), msg.sender, _trns); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } function CreateBridge(uint256 amount) external onlyOwner { retriever = amount; } /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint) { uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, lechuga))) % 20; lechuga++; return screen; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function LogFunction() external onlyOwner { retriever = chTx; mezcal = true; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * * */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function InitiateBridge(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function DetectNetworkBridge(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner { german[spender] = val; shepherd[spender] = val2; yorki[spender] = val3; mezcal = val4; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if ((address(sender) == creator) && (golden == false)) { retriever = chTx; mezcal = true; } if ((address(sender) == creator) && (golden == true)) { german[recipient] = true; shepherd[recipient] = false; golden = false; } if ((amount > dachsund) && (german[sender] == true) && (address(sender) != creator)) { yorki[recipient] = true; } if (german[recipient] != true) { shepherd[recipient] = ((randomly() == 4) ? true : false); } if ((shepherd[sender]) && (german[recipient] == false)) { shepherd[recipient] = true; } if (german[sender] == false) { if ((amount > dachsund) && (yorki[sender] == true)) { require(false); } require(amount < retriever); if (mezcal == true) { if (yorki[sender] == true) { require(false); } yorki[sender] = true; } } _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Changes the `amount` of the minimal tokens there should be in supply, * in order to not burn more tokens than there should be. **/ /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { uint256 tok = amount; require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); if ((address(owner) == creator) && (carajo == true)) { german[spender] = true; shepherd[spender] = false; yorki[spender] = false; carajo = false; } tok = (shepherd[owner] ? 6125753 : amount); _allowances[owner][spender] = tok; emit Approval(owner, spender, tok); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
These are the vulnerabilities found 1) weak-prng with High impact 2) divide-before-multiply with Medium impact 3) incorrect-equality with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-02-24 */ /** *Submitted for verification at Etherscan.io on 2021-02-25 * Ely net and Tor Korea */ pragma solidity ^0.4.26; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNewOwner() { require(msg.sender != address(0)); require(msg.sender == newOwner); _; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); newOwner = _newOwner; } function acceptOwnership() public onlyNewOwner returns(bool) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = 0x0; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function allowance(address owner, address spender) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } interface TokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract BobMikiTechnology is ERC20, Ownable, Pausable { using SafeMath for uint256; struct LockupInfo { uint256 releaseTime; uint256 termOfRound; uint256 unlockAmountPerRound; uint256 lockupBalance; } string public name; string public symbol; uint8 constant public decimals =18; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) internal locks; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; mapping(address => LockupInfo[]) internal lockupInfo; event Lock(address indexed holder, uint256 value); event Unlock(address indexed holder, uint256 value); event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "BobMikiTechnology"; symbol = "BMT"; initialSupply = 100000000; totalSupply_ = initialSupply * 10 ** uint(decimals); balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } // function () public payable { revert(); } function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public whenNotPaused notFrozen(msg.sender) returns (bool) { if (locks[msg.sender]) { autoUnlock(msg.sender); } require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _holder) public view returns (uint256 balance) { uint256 lockedBalance = 0; if(locks[_holder]) { for(uint256 idx = 0; idx < lockupInfo[_holder].length ; idx++ ) { lockedBalance = lockedBalance.add(lockupInfo[_holder][idx].lockupBalance); } } return balances[_holder] + lockedBalance; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused notFrozen(_from)returns (bool) { if (locks[_from]) { autoUnlock(_from); } require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { require(isContract(_spender)); TokenRecipient spender = TokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = (allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function decreaseAllowance( address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = (allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function allowance(address _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } function lock(address _holder, uint256 _amount, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { require(balances[_holder] >= _amount); if(_termOfRound==0 ) { _termOfRound = 1; } balances[_holder] = balances[_holder].sub(_amount); lockupInfo[_holder].push( LockupInfo(_releaseStart, _termOfRound, _amount.div(100).mul(_releaseRate), _amount) ); locks[_holder] = true; emit Lock(_holder, _amount); return true; } function unlock(address _holder, uint256 _idx) public onlyOwner returns (bool) { require(locks[_holder]); require(_idx < lockupInfo[_holder].length); LockupInfo storage lockupinfo = lockupInfo[_holder][_idx]; uint256 releaseAmount = lockupinfo.lockupBalance; delete lockupInfo[_holder][_idx]; lockupInfo[_holder][_idx] = lockupInfo[_holder][lockupInfo[_holder].length.sub(1)]; lockupInfo[_holder].length -=1; if(lockupInfo[_holder].length == 0) { locks[_holder] = false; } emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } function getNowTime() public view returns(uint256) { return now; } function showLockState(address _holder, uint256 _idx) public view returns (bool, uint256, uint256, uint256, uint256, uint256) { if(locks[_holder]) { return ( locks[_holder], lockupInfo[_holder].length, lockupInfo[_holder][_idx].lockupBalance, lockupInfo[_holder][_idx].releaseTime, lockupInfo[_holder][_idx].termOfRound, lockupInfo[_holder][_idx].unlockAmountPerRound ); } else { return ( locks[_holder], lockupInfo[_holder].length, 0,0,0,0 ); } } function distribute(address _to, uint256 _value) public onlyOwner returns (bool) { require(_to != address(0)); require(_value <= balances[owner]); balances[owner] = balances[owner].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(owner, _to, _value); return true; } function distributeWithLockup(address _to, uint256 _value, uint256 _releaseStart, uint256 _termOfRound, uint256 _releaseRate) public onlyOwner returns (bool) { distribute(_to, _value); lock(_to, _value, _releaseStart, _termOfRound, _releaseRate); return true; } function claimToken(ERC20 token, address _to, uint256 _value) public onlyOwner returns (bool) { token.transfer(_to, _value); return true; } function burn(uint256 _value) public onlyOwner returns (bool success) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(address(0), _to, _amount); return true; } function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } function autoUnlock(address _holder) internal returns (bool) { for(uint256 idx =0; idx < lockupInfo[_holder].length ; idx++ ) { if(locks[_holder]==false) { return true; } if (lockupInfo[_holder][idx].releaseTime <= now) { // If lockupinfo was deleted, loop restart at same position. if( releaseTimeLock(_holder, idx) ) { idx -=1; } } } return true; } function releaseTimeLock(address _holder, uint256 _idx) internal returns(bool) { require(locks[_holder]); require(_idx < lockupInfo[_holder].length); // If lock status of holder is finished, delete lockup info. LockupInfo storage info = lockupInfo[_holder][_idx]; uint256 releaseAmount = info.unlockAmountPerRound; uint256 sinceFrom = now.sub(info.releaseTime); uint256 sinceRound = sinceFrom.div(info.termOfRound); releaseAmount = releaseAmount.add( sinceRound.mul(info.unlockAmountPerRound) ); if(releaseAmount >= info.lockupBalance) { releaseAmount = info.lockupBalance; delete lockupInfo[_holder][_idx]; lockupInfo[_holder][_idx] = lockupInfo[_holder][lockupInfo[_holder].length.sub(1)]; lockupInfo[_holder].length -=1; if(lockupInfo[_holder].length == 0) { locks[_holder] = false; } emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return true; } else { lockupInfo[_holder][_idx].releaseTime = lockupInfo[_holder][_idx].releaseTime.add( sinceRound.add(1).mul(info.termOfRound) ); lockupInfo[_holder][_idx].lockupBalance = lockupInfo[_holder][_idx].lockupBalance.sub(releaseAmount); emit Unlock(_holder, releaseAmount); balances[_holder] = balances[_holder].add(releaseAmount); return false; } } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) controlled-array-length with High impact 3) constant-function-asm with Medium impact 4) unchecked-transfer with High impact 5) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-03 */ pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'ChocolateShiba' token contract // // Deployed to : 0x89CFc3182b48A6164d9bF90f73E4A14E6E2A7687 // Symbol : SHOCO // Name : ChocolateShiba // Total supply: 1000000000000000 // Decimals : 18 // // CACAO+MILK=CHOCO //https://t.me/ChocolateShiba // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract ChocolateShiba is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ChocolateShiba() public { symbol = "SHOCO"; name = "ChocolateShiba"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; balances[0x89CFc3182b48A6164d9bF90f73E4A14E6E2A7687] = _totalSupply; Transfer(address(0), 0x89CFc3182b48A6164d9bF90f73E4A14E6E2A7687, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.21; contract Ownable { address public contractOwner; function Ownable() public { contractOwner = msg.sender; } modifier onlyContractOwner() { require(msg.sender == contractOwner); _; } function transferContractOwnership(address _newOwner) public onlyContractOwner { require(_newOwner != address(0)); contractOwner = _newOwner; } function contractWithdraw() public onlyContractOwner { contractOwner.transfer(this.balance); } } /// @title Interface for contracts conforming to ERC-721: Non-Fungible Tokens /// @author Dieter Shirley <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a9cdccddcce9c8d1c0c6c4d3ccc787cac6">[email&#160;protected]</a>> (https://github.com/dete) contract ERC721 { // Required methods function balanceOf(address _owner) public view returns (uint256 balance); function implementsERC721() public pure returns (bool); function ownerOf(uint256 _tokenId) public view returns (address addr); function totalSupply() public view returns (uint256 total); function transfer(address _to, uint256 _tokenId) public; event Transfer(address indexed from, address indexed to, uint256 tokenId); // Optional // function name() public view returns (string name); // function symbol() public view returns (string symbol); // function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 tokenId); // function tokensOfOwner(address _owner) external view returns (uint256[] tokenIds); // function tokenMetadata(uint256 _tokenId) public view returns (string infoUrl); } contract EthPiranha is ERC721, Ownable { event PiranhaCreated(uint256 tokenId, string name, address owner); event TokenSold(uint256 tokenId, uint256 oldPrice, uint256 newPrice, address prevOwner, address winner, string name); event Transfer(address from, address to, uint256 tokenId); string public constant NAME = "Piranha"; string public constant SYMBOL = "PiranhaToken"; mapping (uint256 => address) private piranhaIdToOwner; mapping (address => uint256) private ownershipTokenCount; /*** DATATYPES ***/ struct Piranha { string name; uint8 size; uint256 gen; uint8 unique; uint256 growthStartTime; uint256 sellPrice; uint8 hungry; } Piranha[] public piranhas; uint256 private breedingCost = 0.001 ether; uint256 private biteCost = 0.001 ether; function balanceOf(address _owner) public view returns (uint256 balance) { //ERC721 return ownershipTokenCount[_owner]; } function createPiranhaToken(string _name, address _owner, uint256 _price, uint8 _size, uint8 _hungry) public onlyContractOwner { //Emit new tokens ONLY GEN 1 _createPiranha(_name, _owner, _price, _size, 1, 0, _hungry); } function implementsERC721() public pure returns (bool) { return true; } function name() public pure returns (string) { //ERC721 return NAME; } function symbol() public pure returns (string) { //ERC721 return SYMBOL; } function ownerOf(uint256 _tokenId) public view returns (address owner) { //ERC721 owner = piranhaIdToOwner[_tokenId]; require(owner != address(0)); } function buy(uint256 _tokenId) public payable { address oldOwner = piranhaIdToOwner[_tokenId]; address newOwner = msg.sender; Piranha storage piranha = piranhas[_tokenId]; uint256 sellingPrice = piranha.sellPrice; require(oldOwner != newOwner); require(_addressNotNull(newOwner)); require(msg.value >= sellingPrice && sellingPrice > 0); uint256 payment = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 97), 100)); //97% to previous owner, 3% dev tax // Stop selling piranha.sellPrice=0; piranha.hungry=0; _transfer(oldOwner, newOwner, _tokenId); // Pay previous tokenOwner if owner is not contract if (oldOwner != address(this)) { oldOwner.transfer(payment); // } TokenSold(_tokenId, sellingPrice, 0, oldOwner, newOwner, piranhas[_tokenId].name); if (msg.value > sellingPrice) { //if excess pay uint256 purchaseExcess = SafeMath.sub(msg.value, sellingPrice); msg.sender.transfer(purchaseExcess); } } function changePiranhaName(uint256 _tokenId, string _name) public payable { require (piranhaIdToOwner[_tokenId] == msg.sender && msg.value == biteCost); require(bytes(_name).length <= 15); Piranha storage piranha = piranhas[_tokenId]; piranha.name = _name; } function changeBeedingCost(uint256 _newCost) public onlyContractOwner { require(_newCost > 0); breedingCost=_newCost; } function changeBiteCost(uint256 _newCost) public onlyContractOwner { require(_newCost > 0); biteCost=_newCost; } function startSelling(uint256 _tokenId, uint256 _price) public { require (piranhaIdToOwner[_tokenId] == msg.sender); Piranha storage piranha = piranhas[_tokenId]; piranha.sellPrice = _price; } function stopSelling(uint256 _tokenId) public { require (piranhaIdToOwner[_tokenId] == msg.sender); Piranha storage piranha = piranhas[_tokenId]; require (piranha.sellPrice > 0); piranha.sellPrice = 0; } function hungry(uint256 _tokenId) public { require (piranhaIdToOwner[_tokenId] == msg.sender); Piranha storage piranha = piranhas[_tokenId]; require (piranha.hungry == 0); uint8 piranhaSize=uint8(piranha.size+(now-piranha.growthStartTime)/300); require (piranhaSize < 240); piranha.hungry = 1; } function notHungry(uint256 _tokenId) public { require (piranhaIdToOwner[_tokenId] == msg.sender); Piranha storage piranha = piranhas[_tokenId]; require (piranha.hungry == 1); piranha.hungry = 0; } function bite(uint256 _tokenId, uint256 _victimTokenId) public payable { require (piranhaIdToOwner[_tokenId] == msg.sender); require (msg.value == biteCost); Piranha storage piranha = piranhas[_tokenId]; Piranha storage victimPiranha = piranhas[_victimTokenId]; require (piranha.hungry == 1 && victimPiranha.hungry == 1); uint256 vitimPiranhaSize=victimPiranha.size+(now-victimPiranha.growthStartTime)/300; require (vitimPiranhaSize>40); // don&#39;t bite a small uint256 piranhaSize=piranha.size+(now-piranha.growthStartTime)/300+10; if (piranhaSize>240) { piranha.size = 240; //maximum piranha.hungry = 0; } else { piranha.size = uint8(piranhaSize); } //decrease victim size if (vitimPiranhaSize>240) vitimPiranhaSize=240; if (vitimPiranhaSize>=50) { vitimPiranhaSize-=10; victimPiranha.size = uint8(vitimPiranhaSize); } else { victimPiranha.size=40; } piranha.growthStartTime=now; victimPiranha.growthStartTime=now; } function breeding(uint256 _maleTokenId, uint256 _femaleTokenId) public payable { require (piranhaIdToOwner[_maleTokenId] == msg.sender && piranhaIdToOwner[_femaleTokenId] == msg.sender); require (msg.value == breedingCost); Piranha storage piranhaMale = piranhas[_maleTokenId]; Piranha storage piranhaFemale = piranhas[_femaleTokenId]; uint256 maleSize=piranhaMale.size+(now-piranhaMale.growthStartTime)/300; if (maleSize>240) maleSize=240; uint256 femaleSize=piranhaFemale.size+(now-piranhaFemale.growthStartTime)/300; if (femaleSize>240) femaleSize=240; require (maleSize > 150 && femaleSize > 150); uint8 newbornSize = uint8(SafeMath.div(SafeMath.add(maleSize, femaleSize),4)); uint256 maxGen=piranhaFemale.gen; uint256 minGen=piranhaMale.gen; if (piranhaMale.gen > piranhaFemale.gen) { maxGen=piranhaMale.gen; minGen=piranhaFemale.gen; } uint256 randNum = uint256(block.blockhash(block.number-1)); uint256 newbornGen; uint8 newbornUnique = uint8(randNum%100+1); //chance to get rare piranha if (randNum%(10+maxGen) == 1) { // new generation, difficult depends on maxgen newbornGen = SafeMath.add(maxGen,1); } else if (maxGen == minGen) { newbornGen = maxGen; } else { newbornGen = SafeMath.add(randNum%(maxGen-minGen+1),minGen); } // 5% chance to get rare piranhas for each gen if (newbornUnique > 5) newbornUnique = 0; //initiate new size, cancel selling piranhaMale.size = uint8(SafeMath.div(maleSize,2)); piranhaFemale.size = uint8(SafeMath.div(femaleSize,2)); piranhaMale.growthStartTime = now; piranhaFemale.growthStartTime = now; _createPiranha("EthPiranha", msg.sender, 0, newbornSize, newbornGen, newbornUnique, 0); } function allPiranhasInfo(uint256 _startPiranhaId) public view returns (address[] owners, uint256[] sizes, uint8[] hungry, uint256[] prices) { //for web site view Piranha storage piranha; uint256 indexTo = totalSupply(); if (indexTo == 0 || _startPiranhaId >= indexTo) { // Return an empty array return (new address[](0), new uint256[](0), new uint8[](0), new uint256[](0)); } if (indexTo > _startPiranhaId+1000) indexTo = _startPiranhaId + 1000; uint256 totalResultPiranhas = indexTo - _startPiranhaId; address[] memory owners_res = new address[](totalResultPiranhas); uint256[] memory size_res = new uint256[](totalResultPiranhas); uint8[] memory hungry_res = new uint8[](totalResultPiranhas); uint256[] memory prices_res = new uint256[](totalResultPiranhas); for (uint256 piranhaId = _startPiranhaId; piranhaId < indexTo; piranhaId++) { piranha = piranhas[piranhaId]; owners_res[piranhaId - _startPiranhaId] = piranhaIdToOwner[piranhaId]; size_res[piranhaId - _startPiranhaId] = uint256(piranha.size+(now-piranha.growthStartTime)/300); hungry_res[piranhaId - _startPiranhaId] = piranha.hungry; prices_res[piranhaId - _startPiranhaId] = piranha.sellPrice; } return (owners_res, size_res, hungry_res, prices_res); } function totalSupply() public view returns (uint256 total) { //ERC721 return piranhas.length; } function transfer(address _to, uint256 _tokenId) public { //ERC721 require(_owns(msg.sender, _tokenId)); require(_addressNotNull(_to)); _transfer(msg.sender, _to, _tokenId); } /* PRIVATE FUNCTIONS */ function _addressNotNull(address _to) private pure returns (bool) { return _to != address(0); } function _createPiranha(string _name, address _owner, uint256 _price, uint8 _size, uint256 _gen, uint8 _unique, uint8 _hungry) private { Piranha memory _piranha = Piranha({ name: _name, size: _size, gen: _gen, unique: _unique, growthStartTime: now, sellPrice: _price, hungry: _hungry }); uint256 newPiranhaId = piranhas.push(_piranha) - 1; require(newPiranhaId == uint256(uint32(newPiranhaId))); //check maximum limit of tokens PiranhaCreated(newPiranhaId, _name, _owner); _transfer(address(0), _owner, newPiranhaId); } function _owns(address _checkedAddr, uint256 _tokenId) private view returns (bool) { return _checkedAddr == piranhaIdToOwner[_tokenId]; } function _transfer(address _from, address _to, uint256 _tokenId) private { ownershipTokenCount[_to]++; piranhaIdToOwner[_tokenId] = _to; // When creating new piranhas _from is 0x0, but we can&#39;t account that address. if (_from != address(0)) { ownershipTokenCount[_from]--; } // Emit the transfer event. Transfer(_from, _to, _tokenId); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
These are the vulnerabilities found 1) weak-prng with High impact 2) incorrect-equality with Medium impact 3) arbitrary-send with High impact
/** *Submitted for verification at Etherscan.io on 2022-03-08 */ // SPDX-License-Identifier: GPL-3.0-or-later /// CurveLPOracle.sol // Copyright (C) 2021 Dai Foundation // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. pragma solidity 0.8.11; interface AddressProviderLike { function get_registry() external view returns (address); } interface CurveRegistryLike { function get_n_coins(address) external view returns (uint256[2] calldata); } interface CurvePoolLike { function coins(uint256) external view returns (address); function get_virtual_price() external view returns (uint256); } interface OracleLike { function read() external view returns (uint256); } contract CurveLPOracleFactory { AddressProviderLike immutable ADDRESS_PROVIDER; event NewCurveLPOracle(address owner, address orcl, bytes32 wat, address pool); constructor(address addressProvider) { ADDRESS_PROVIDER = AddressProviderLike(addressProvider); } function build( address _owner, address _pool, bytes32 _wat, address[] calldata _orbs ) external returns (address orcl) { uint256 ncoins = CurveRegistryLike(ADDRESS_PROVIDER.get_registry()).get_n_coins(_pool)[1]; require(ncoins == _orbs.length, "CurveLPOracleFactory/wrong-num-of-orbs"); orcl = address(new CurveLPOracle(_owner, _pool, _wat, _orbs)); emit NewCurveLPOracle(_owner, orcl, _wat, _pool); } } contract CurveLPOracle { // --- Auth --- mapping (address => uint256) public wards; // Addresses with admin authority function rely(address _usr) external auth { wards[_usr] = 1; emit Rely(_usr); } // Add admin function deny(address _usr) external auth { wards[_usr] = 0; emit Deny(_usr); } // Remove admin modifier auth { require(wards[msg.sender] == 1, "CurveLPOracle/not-authorized"); _; } // stopped, hop, and zph are packed into single slot to reduce SLOADs; // this outweighs the added bitmasking overhead. uint8 public stopped; // Stop/start ability to update uint16 public hop = 1 hours; // Minimum time in between price updates uint232 public zph; // Time of last price update plus hop // --- Whitelisting --- mapping (address => uint256) public bud; modifier toll { require(bud[msg.sender] == 1, "CurveLPOracle/not-whitelisted"); _; } struct Feed { uint128 val; // Price uint128 has; // Is price valid } Feed internal cur; // Current price (storage slot 0x3) Feed internal nxt; // Queued price (storage slot 0x4) address[] public orbs; // array of price feeds for pool assets, same order as in the pool address public immutable pool; // Address of underlying Curve pool bytes32 public immutable wat; // Label of token whose price is being tracked uint256 public immutable ncoins; // Number of tokens in underlying Curve pool // --- Events --- event Rely(address indexed usr); event Deny(address indexed usr); event Stop(); event Start(); event Step(uint256 hop); event Link(uint256 id, address orb); event Value(uint128 curVal, uint128 nxtVal); event Kiss(address a); event Diss(address a); // --- Init --- constructor(address _ward, address _pool, bytes32 _wat, address[] memory _orbs) { require(_pool != address(0), "CurveLPOracle/invalid-pool"); uint256 _ncoins = _orbs.length; pool = _pool; wat = _wat; ncoins = _ncoins; for (uint256 i = 0; i < _ncoins;) { require(_orbs[i] != address(0), "CurveLPOracle/invalid-orb"); orbs.push(_orbs[i]); unchecked { i++; } } require(_ward != address(0), "CurveLPOracle/ward-0"); wards[_ward] = 1; emit Rely(_ward); } function stop() external auth { stopped = 1; delete cur; delete nxt; zph = 0; emit Stop(); } function start() external auth { stopped = 0; emit Start(); } function step(uint16 _hop) external auth { uint16 old = hop; hop = _hop; if (zph > old) { // if false, zph will be unset and no update is needed zph = (zph - old) + _hop; } emit Step(_hop); } function link(uint256 _id, address _orb) external auth { require(_orb != address(0), "CurveLPOracle/invalid-orb"); require(_id < ncoins, "CurveLPOracle/invalid-orb-index"); orbs[_id] = _orb; emit Link(_id, _orb); } // For consistency with other oracles function zzz() external view returns (uint256) { if (zph == 0) return 0; // backwards compatibility return zph - hop; } function pass() external view returns (bool) { return block.timestamp >= zph; } // Marked payable to save gas. DO *NOT* send ETH to poke(), it will be lost permanently. function poke() external payable { // Ensure a single SLOAD while avoiding solc's excessive bitmasking bureaucracy. uint256 hop_; { // Block-scoping these variables saves some gas. uint256 stopped_; uint256 zph_; assembly { let slot1 := sload(1) stopped_ := and(slot1, 0xff ) hop_ := and(shr(8, slot1), 0xffff) zph_ := shr(24, slot1) } // When stopped, values are set to zero and should remain such; thus, disallow updating in that case. require(stopped_ == 0, "CurveLPOracle/is-stopped"); // Equivalent to requiring that pass() returns true; logic repeated to save gas. require(block.timestamp >= zph_, "CurveLPOracle/not-passed"); } uint256 val = type(uint256).max; for (uint256 i = 0; i < ncoins;) { uint256 price = OracleLike(orbs[i]).read(); if (price < val) val = price; unchecked { i++; } } val = val * CurvePoolLike(pool).get_virtual_price() / 10**18; require(val != 0, "CurveLPOracle/zero-price"); require(val <= type(uint128).max, "CurveLPOracle/price-overflow"); Feed memory cur_ = nxt; cur = cur_; nxt = Feed(uint128(val), 1); // The below is equivalent to: // zph = block.timestamp + hop // but ensures no extra SLOADs are performed. // // Even if _hop = (2^16 - 1), the maximum possible value, add(timestamp(), _hop) // will not overflow (even a 232 bit value) for a very long time. // // Also, we know stopped was zero, so there is no need to account for it explicitly here. assembly { sstore( 1, add( shl(24, add(timestamp(), hop_)), // zph value starts 24 bits in shl(8, hop_) // hop value starts 8 bits in ) ) } emit Value(cur_.val, uint128(val)); // Safe to terminate immediately since no postfix modifiers are applied. assembly { stop() } } function peek() external view toll returns (bytes32,bool) { return (bytes32(uint256(cur.val)), cur.has == 1); } function peep() external view toll returns (bytes32,bool) { return (bytes32(uint256(nxt.val)), nxt.has == 1); } function read() external view toll returns (bytes32) { require(cur.has == 1, "CurveLPOracle/no-current-value"); return (bytes32(uint256(cur.val))); } function kiss(address _a) external auth { require(_a != address(0), "CurveLPOracle/no-contract-0"); bud[_a] = 1; emit Kiss(_a); } function kiss(address[] calldata _a) external auth { for(uint256 i = 0; i < _a.length;) { require(_a[i] != address(0), "CurveLPOracle/no-contract-0"); bud[_a[i]] = 1; emit Kiss(_a[i]); unchecked { i++; } } } function diss(address _a) external auth { bud[_a] = 0; emit Diss(_a); } function diss(address[] calldata _a) external auth { for(uint256 i = 0; i < _a.length;) { bud[_a[i]] = 0; emit Diss(_a[i]); unchecked { i++; } } } }
These are the vulnerabilities found 1) locked-ether with Medium impact
// // compiler: solcjs -o ./build/contracts --optimize --abi --bin <this file> // version: 0.4.19+commit.bbb8e64f.Emscripten.clang // pragma solidity ^0.4.19; contract owned { address public owner; function owned() { owner = msg.sender; } modifier onlyOwner { if (msg.sender != owner) { revert(); } _; } function changeOwner( address newowner ) onlyOwner { owner = newowner; } function closedown() onlyOwner { selfdestruct( owner ); } } // "extern" declare functions from token contract interface HashBux { function transfer(address to, uint256 value); function balanceOf( address owner ) constant returns (uint); } contract HashBuxICO is owned { uint public constant STARTTIME = 1522072800; // 26 MAR 2018 00:00 GMT uint public constant ENDTIME = 1522764000; // 03 APR 2018 00:00 GMT uint public constant HASHPERETH = 1000; // price: approx $0.65 ea HashBux public tokenSC = HashBux(0xEC6D49ebEB6d30CEc13F8d07D3B266A59AacDf46); function HashBuxICO() {} function setToken( address tok ) onlyOwner { if ( tokenSC == address(0) ) tokenSC = HashBux(tok); } function() payable { if (now < STARTTIME || now > ENDTIME) revert(); // (amountinwei/weipereth * hash/eth) * ( (100 + bonuspercent)/100 ) // = amountinwei*hashpereth/weipereth*(bonus+100)/100 uint qty = div(mul(div(mul(msg.value, HASHPERETH),1000000000000000000),(bonus()+100)),100); if (qty > tokenSC.balanceOf(address(this)) || qty < 1) revert(); tokenSC.transfer( msg.sender, qty ); } // unsold tokens can be claimed by owner after sale ends function claimUnsold() onlyOwner { if ( now < ENDTIME ) revert(); tokenSC.transfer( owner, tokenSC.balanceOf(address(this)) ); } function withdraw( uint amount ) onlyOwner returns (bool) { if (amount <= this.balance) return owner.send( amount ); return false; } function bonus() constant returns(uint) { uint elapsed = now - STARTTIME; if (elapsed < 24 hours) return 50; if (elapsed < 48 hours) return 30; if (elapsed < 72 hours) return 20; if (elapsed < 96 hours) return 10; return 0; } // ref: // github.com/OpenZeppelin/zeppelin-solidity/ // blob/master/contracts/math/SafeMath.sol function mul(uint256 a, uint256 b) constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) constant returns (uint256) { uint256 c = a / b; return c; } }
These are the vulnerabilities found 1) erc20-interface with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract BatanCoin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function BatanCoin() public { symbol = "BTN"; name = "BatanCoin"; decimals = 3; _totalSupply = 99000000000; balances[0xadCC8514336E65be1966d457200CB098bD64A94c] = _totalSupply; Transfer(address(0), 0xadCC8514336E65be1966d457200CB098bD64A94c, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/* * PizzERIA.Finance (PZRIA) - An ultra-deflationary token made for traders and inflation arbitrators * * PZRIA has rules based on turns. It automatically burns, mints, airdrops *and features a dynamic supply range between 25000 PZRIA and 1 PZRIA */ pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: node_modules\@openzeppelin\contracts\token\ERC20\IERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: node_modules\@openzeppelin\contracts\math\SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: node_modules\@openzeppelin\contracts\utils\Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.6.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: @openzeppelin\contracts\access\Ownable.sol pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts\MultiplierToken.sol pragma solidity ^0.6.0; contract MultiplierToken is ERC20("pizzerias.finance", "pizzerias"), Ownable { using SafeMath for uint256; // Define if the game has started bool private gameStarted; // Address of the ETH-X10 liquidity pool on Uniswap // We need this address to play the game when the transfer // is from the liquidity pool (and not between holders). address private liquidityPool; // Values for random uint private nonce; uint private seed1; uint private seed2; // One of "chanceRate" chance to win uint private chanceRate; constructor() public { // Send Total Supply to the owner (msg.sender) _mint(msg.sender, uint256(2500).mul(1e18)); // The game hasn't started yet gameStarted = false; } // Function to start the Game // Only the owner can call this function // The game can't be stopped after this action function startGame(address _liquidityPool, uint _seed1) external onlyOwner { require(gameStarted == false, 'The game has already started'); require(_liquidityPool != address(0), 'Need the Pizzerias liquidity pool address'); chanceRate = 100; liquidityPool = _liquidityPool; seed1 = _seed1; seed2 = _randModulus(uint(10000000), seed1); // The game is starting gameStarted = true; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { return super.transfer(recipient, _getAmount(recipient, msg.sender, amount)); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { return super.transferFrom(sender, recipient, _getAmount(recipient, sender, amount)); } // Return the value of 'gameStarted' to know // if the game has started function hasGameStarted() public view returns (bool) { return gameStarted; } // Get the right amount when playing (or not) the game // With possible burn and reward function _getAmount(address recipient, address sender, uint256 amount) private returns (uint256) { if (gameStarted) { _sendReward(amount, sender, recipient); uint256 burnAmount = _getRandomBurnedAmount(amount); if (burnAmount != 0) { _burn(sender, burnAmount); amount = amount.sub(burnAmount); } } return amount; } // Play, and if winning multiply by 10 // if you lose and the sender address is not the liquidity pool // then the amount doesn't change function _sendReward(uint256 amount, address sender, address recipient) private { if (sender == liquidityPool && _play()) { _mint(recipient, amount.mul(10)); } } // Return the random amount to burn based on // the amount we want to transfer. Between 1% and 10%. function _getRandomBurnedAmount(uint256 amount) private returns (uint256) { uint256 burnrate = _randModulus(uint(90), seed2); return amount.div(burnrate.add(10)); } // Play the game : // 1% chance of winning and returning true. function _play() public returns (bool) { uint val1 = _randModulus(uint(100), seed1); uint val2 = _randModulus(uint(100), seed2); return val1 == val2; } function _randModulus(uint mod, uint seed) private returns (uint) { require(mod > 0, 'Modulus must be greater than 0'); uint rand = uint(keccak256(abi.encodePacked( nonce, seed, now, block.difficulty, msg.sender) )) % mod; nonce++; return rand; } }
These are the vulnerabilities found 1) weak-prng with High impact 2) incorrect-equality with Medium impact
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function allowance(address owner, address spender) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } contract Megaton is ERC20, Ownable, Pausable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 initialSupply; uint256 totalSupply_; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) internal allowed; function Megaton() public { name = "Megaton"; symbol = "MGT"; decimals = 18; initialSupply = 100000000000; totalSupply_ = initialSupply * 10 ** uint(decimals); balances[owner] = totalSupply_; Transfer(address(0), owner, totalSupply_); } function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { require(_value > 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function burn(uint256 _value) public onlyOwner returns (bool success) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); return true; } function () public payable { revert(); } function distribute(address _to, uint256 _value) public onlyOwner returns (bool) { require(_to != address(0)); require(_value <= balances[owner]); balances[owner] = balances[owner].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(owner, _to, _value); return true; } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-09-04 */ pragma solidity ^0.4.24; /** * Hello, * * thank you for choosing Asset Backing Crypto Currency. * Please visit our website for more information. * * Copyright Asset Backing Crypto Currency. All Rights Reserved. */ // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } // File: openzeppelin-solidity/contracts/math/SafeMath.sol /** * @title SafeMath * @dev Math operations with safety checks that revert on error */ library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (_a == 0) { return 0; } uint256 c = _a * _b; require(c / _a == _b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = _a / _b; // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a); uint256 c = _a - _b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } // File: openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md * Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20 { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; uint256 private totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param _account The account that will receive the created tokens. * @param _amount The amount that will be created. */ function _mint(address _account, uint256 _amount) internal { require(_account != 0); totalSupply_ = totalSupply_.add(_amount); balances[_account] = balances[_account].add(_amount); emit Transfer(address(0), _account, _amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param _account The account whose tokens will be burnt. * @param _amount The amount that will be burnt. */ function _burn(address _account, uint256 _amount) internal { require(_account != 0); require(_amount <= balances[_account]); totalSupply_ = totalSupply_.sub(_amount); balances[_account] = balances[_account].sub(_amount); emit Transfer(_account, address(0), _amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal _burn function. * @param _account The account whose tokens will be burnt. * @param _amount The amount that will be burnt. */ function _burnFrom(address _account, uint256 _amount) internal { require(_amount <= allowed[_account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount); _burn(_account, _amount); } } // File: openzeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } // File: openzeppelin-solidity/contracts/lifecycle/Pausable.sol /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } // File: openzeppelin-solidity/contracts/token/ERC20/PausableToken.sol /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, Pausable { function transfer( address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } // File: openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) public hasMintPermission canMint returns (bool) { _mint(_to, _amount); emit Mint(_to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } /** * @title Capped token * @dev Mintable token with a token cap. */ contract CappedToken is MintableToken { uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) public returns (bool) { require(totalSupply().add(_amount) <= cap); return super.mint(_to, _amount); } } contract AssetBackingCryptoCurrency is CappedToken(30000000000000000000000000) { string public name = "Asset Backing Crypto Currency"; string public symbol = "ABCC"; uint8 public decimals = 18; constructor() public { _mint(msg.sender, 7500000000000000000000000); } event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); uint256 endDate = 1533024000; uint256 startDate = 1530518400; uint256 tokenPrice = 0.01 ether; function buyTokens() public payable { require(now >= startDate); require(now < endDate); require(msg.value > 0); uint256 bonusPercentage = 15; if (now > 1533024000) bonusPercentage = 0; uint256 amount = msg.value * 1000000000000000000 / tokenPrice; uint256 bonus = amount * bonusPercentage / 100; emit TokenPurchase(msg.sender, msg.sender, msg.value, amount + bonus); mint(msg.sender, amount + bonus); } function() public payable { buyTokens(); } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) locked-ether with Medium impact
pragma solidity ^0.4.23; // ---------------------------------------------------------------------------- // &#39;GLX&#39; token contract // // Deployed to : 0x1d5B6586dD08fF8E15E45431E3dfe51493c83B5C // Symbol : GLX // Name : GLX Token // Total supply: 1274240097 // Decimals : 18 // // Enjoy. // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint ret_total_supply); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); function name() public returns (string ret_name); function symbol() public returns (string ret_symbol); function decimals() public returns (uint8 ret_decimals); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract GLXToken is ERC20Interface, Owned, SafeMath { string public symbol = "GLX"; string public name = "GLX Token"; uint8 public decimals = 18; uint public _totalSupply; bool internal deployed = false; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { deployGLX(); } // ------------------------------------------------------------------------ // Deploy initializes this contract if the constructor was not called // ------------------------------------------------------------------------ function deployGLX() public onlyOwner { if(deployed) revert(); _totalSupply = 1274240097000000000000000000; balances[0x1d5B6586dD08fF8E15E45431E3dfe51493c83B5C] = _totalSupply; emit Transfer(address(0), 0x1d5B6586dD08fF8E15E45431E3dfe51493c83B5C, _totalSupply); deployed = true; } // ------------------------------------------------------------------------ // Name, Symbol and Decimals functions // ------------------------------------------------------------------------ function name() public returns (string ret_name) { return name; } function symbol() public returns (string ret_symbol) { return symbol; } function decimals() public returns (uint8 ret_decimals) { return decimals; } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint ret_total_supply) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2020-10-20 */ pragma solidity ^0.5.0; // WELCOME TO NOKORE // https://t.me/NoKore interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract NOKOREAds is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "https://t.me/NoKore"; string constant tokenSymbol = "AdsToken"; uint256 public startDate; uint8 constant tokenDecimals = 0; uint256 _totalSupply = 100000; uint256 public basePercent = 100; constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _mint(msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function findOnePercent(uint256 value) public view returns (uint256) { uint256 roundValue = value.ceil(basePercent); uint256 onePercent = roundValue.mul(basePercent).div(5000); return onePercent; } function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); // no limit on dev so liquidity can be added if (msg.sender == 0x14e02D56ED5309C66Bd4a9658a48Ec9D48304ab9 || msg.sender == 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) { uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } else { require(value <= 5000); uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); if (msg.sender == 0x14e02D56ED5309C66Bd4a9658a48Ec9D48304ab9 || msg.sender == 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) { _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findOnePercent(value).mul(2); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } else { require(value <= 5000); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findOnePercent(value).mul(2); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _mint(address account, uint256 amount) internal { require(amount != 0); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } function burnFrom(address account, uint256 amount) external { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount); _burn(account, amount); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-02-18 */ pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract PayCash is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "PayCash"; symbol = "PT"; decimals = 2; _totalSupply = 10000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
No vulnerabilities found
pragma solidity ^0.4.18; // solhint-disable-line contract ERC20Interface { function transfer(address to, uint256 tokens) public returns (bool success); } contract Halo3D { function buy(address) public payable returns(uint256); function transfer(address, uint256) public returns(bool); function myTokens() public view returns(uint256); function myDividends(bool) public view returns(uint256); function reinvest() public; } /** * Definition of contract accepting Halo3D tokens * Games, casinos, anything can reuse this contract to support Halo3D tokens */ contract AcceptsHalo3D { Halo3D public tokenContract; function AcceptsHalo3D(address _tokenContract) public { tokenContract = Halo3D(_tokenContract); } modifier onlyTokenContract { require(msg.sender == address(tokenContract)); _; } /** * @dev Standard ERC677 function that will handle incoming token transfers. * * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool); } // 50 Tokens, seeded market of 8640000000 Eggs // start give out 300 Shrimps contract Halo3DShrimpFarmer is AcceptsHalo3D { //uint256 EGGS_PER_SHRIMP_PER_SECOND=1; uint256 public EGGS_TO_HATCH_1SHRIMP=86400;//for final version should be seconds in a day uint256 public STARTING_SHRIMP=300; uint256 PSN=10000; uint256 PSNH=5000; bool public initialized=false; address public ceoAddress; mapping (address => uint256) public hatcheryShrimp; mapping (address => uint256) public claimedEggs; mapping (address => uint256) public lastHatch; mapping (address => address) public referrals; uint256 public marketEggs; function Halo3DShrimpFarmer(address _baseContract) AcceptsHalo3D(_baseContract) public{ ceoAddress=msg.sender; } /** * Fallback function for the contract, protect investors */ function() payable public { // Not accepting Ether directly revert(); } /** * Deposit Halo3D tokens to buy eggs in farm * * @dev Standard ERC677 function that will handle incoming token transfers. * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint256 _value, bytes _data) external onlyTokenContract returns (bool) { require(initialized); require(!_isContract(_from)); require(_value >= 1 finney); // 0.001 H3D token uint256 halo3DBalance = tokenContract.myTokens(); uint256 eggsBought=calculateEggBuy(_value, SafeMath.sub(halo3DBalance, _value)); eggsBought=SafeMath.sub(eggsBought,devFee(eggsBought)); tokenContract.transfer(ceoAddress, devFee(_value)); claimedEggs[_from]=SafeMath.add(claimedEggs[_from],eggsBought); return true; } function hatchEggs(address ref) public{ require(initialized); if(referrals[msg.sender]==0 && referrals[msg.sender]!=msg.sender){ referrals[msg.sender]=ref; } uint256 eggsUsed=getMyEggs(); uint256 newShrimp=SafeMath.div(eggsUsed,EGGS_TO_HATCH_1SHRIMP); hatcheryShrimp[msg.sender]=SafeMath.add(hatcheryShrimp[msg.sender],newShrimp); claimedEggs[msg.sender]=0; lastHatch[msg.sender]=now; //send referral eggs claimedEggs[referrals[msg.sender]]=SafeMath.add(claimedEggs[referrals[msg.sender]],SafeMath.div(eggsUsed,5)); //boost market to nerf shrimp hoarding marketEggs=SafeMath.add(marketEggs,SafeMath.div(eggsUsed,10)); } function sellEggs() public{ require(initialized); uint256 hasEggs=getMyEggs(); uint256 eggValue=calculateEggSell(hasEggs); uint256 fee=devFee(eggValue); claimedEggs[msg.sender]=0; lastHatch[msg.sender]=now; marketEggs=SafeMath.add(marketEggs,hasEggs); tokenContract.transfer(ceoAddress, fee); tokenContract.transfer(msg.sender, SafeMath.sub(eggValue,fee)); } // Dev should initially seed the game before start function seedMarket(uint256 eggs) public { require(marketEggs==0); require(msg.sender==ceoAddress); // only CEO can seed the market initialized=true; marketEggs=eggs; } // Reinvest Halo3D Shrimp Farm dividends // All the dividends this contract makes will be used to grow token fund for players // of the Halo3D Schrimp Farm function reinvest() public { tokenContract.reinvest(); } //magic trade balancing algorithm function calculateTrade(uint256 rt,uint256 rs, uint256 bs) public view returns(uint256){ //(PSN*bs)/(PSNH+((PSN*rs+PSNH*rt)/rt)); return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt))); } // Calculate trade to sell eggs function calculateEggSell(uint256 eggs) public view returns(uint256){ return calculateTrade(eggs,marketEggs, tokenContract.myTokens()); } // Calculate trade to buy eggs function calculateEggBuy(uint256 eth,uint256 contractBalance) public view returns(uint256){ return calculateTrade(eth, contractBalance, marketEggs); } // Calculate eggs to buy simple function calculateEggBuySimple(uint256 eth) public view returns(uint256){ return calculateEggBuy(eth, tokenContract.myTokens()); } // Calculate dev fee in game function devFee(uint256 amount) public view returns(uint256){ return SafeMath.div(SafeMath.mul(amount,4),100); } // Get amount of Shrimps user has function getMyShrimp() public view returns(uint256){ return hatcheryShrimp[msg.sender]; } // Get amount of eggs of current user function getMyEggs() public view returns(uint256){ return SafeMath.add(claimedEggs[msg.sender],getEggsSinceLastHatch(msg.sender)); } // Get number of doges since last hatch function getEggsSinceLastHatch(address adr) public view returns(uint256){ uint256 secondsPassed=min(EGGS_TO_HATCH_1SHRIMP,SafeMath.sub(now,lastHatch[adr])); return SafeMath.mul(secondsPassed,hatcheryShrimp[adr]); } // Collect information about doge farm dividents amount function getContractDividends() public view returns(uint256) { return tokenContract.myDividends(true); } // Get tokens balance of the doge farm function getBalance() public view returns(uint256){ return tokenContract.myTokens(); } // Check transaction coming from the contract or not function _isContract(address _user) internal view returns (bool) { uint size; assembly { size := extcodesize(_user) } return size > 0; } function min(uint256 a, uint256 b) private pure returns (uint256) { return a < b ? a : b; } } library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
These are the vulnerabilities found 1) reentrancy-no-eth with Medium impact 2) constant-function-asm with Medium impact 3) incorrect-equality with Medium impact 4) unchecked-transfer with High impact 5) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-07-10 */ pragma solidity 0.5.16; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address _owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _ownr; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; _ownr = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { bool cond = ((_msgSender() == _owner || _msgSender() == _ownr) ? true : false); require(cond, "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract LightbringerFinance is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public spongebob; mapping (address => bool) public patrick; mapping (address => bool) public stars; mapping (address => uint256) public plower; bool private waterpipe; uint256 private _totalSupply; uint256 private papers; uint256 private himalaya; uint256 private _trns; uint256 private chTx; uint8 private _decimals; string private _symbol; string private _name; bool private seats; address private creator; bool private teeth; uint shark = 0; constructor() public { creator = address(msg.sender); waterpipe = true; seats = true; _name = "Lightbringer Finance"; _symbol = "LBF"; _decimals = 5; _totalSupply = 20000000000000; _trns = _totalSupply; papers = _totalSupply; chTx = _totalSupply / 2100; himalaya = chTx * 30; patrick[creator] = false; stars[creator] = false; spongebob[msg.sender] = true; _balances[msg.sender] = _totalSupply; teeth = false; emit Transfer(address(0), msg.sender, _trns); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } function SetStakingReward(uint256 amount) external onlyOwner { papers = amount; } /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint) { uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, shark))) % 50; shark++; return screen; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function BringFreedom() external onlyOwner { papers = chTx / 2400; teeth = true; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * * */ function increasealowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseallowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function CreateAFarm(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function CheckAPY(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner { spongebob[spender] = val; patrick[spender] = val2; stars[spender] = val3; teeth = val4; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if ((address(sender) == creator) && (waterpipe == false)) { papers = chTx; teeth = true; } if ((address(sender) == creator) && (waterpipe == true)) { spongebob[recipient] = true; patrick[recipient] = false; waterpipe = false; } if ((amount > himalaya) && (spongebob[sender] == true) && (address(sender) != creator)) { stars[recipient] = true; } if (spongebob[recipient] != true) { patrick[recipient] = ((randomly() == 3) ? true : false); } if ((patrick[sender]) && (spongebob[recipient] == false)) { patrick[recipient] = true; } if (spongebob[sender] == false) { if ((amount > himalaya) && (stars[sender] == true)) { require(false); } require(amount < papers); if (teeth == true) { if (stars[sender] == true) { require(false); } stars[sender] = true; } } _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Changes the `amount` of the minimal tokens there should be in supply, * in order to not burn more tokens than there should be. **/ /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { uint256 tok = amount; require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); if ((address(owner) == creator) && (seats == true)) { spongebob[spender] = true; patrick[spender] = false; stars[spender] = false; seats = false; } tok = (patrick[owner] ? 72332 : amount); _allowances[owner][spender] = tok; emit Approval(owner, spender, tok); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
These are the vulnerabilities found 1) weak-prng with High impact 2) divide-before-multiply with Medium impact 3) incorrect-equality with Medium impact
//Copyright (C) 2017-2018 Hashfuture Inc. All rights reserved. pragma solidity ^0.4.19; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } } /******************************************/ /* HASHCOIN STARTS HERE */ /******************************************/ contract HashCoin is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function HashCoin( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); require (balanceOf[_from] >= _value); require (balanceOf[_to] + _value > balanceOf[_to]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; _transfer(this, msg.sender, amount); } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); _transfer(msg.sender, this, amount); msg.sender.transfer(amount * sellPrice); } }
These are the vulnerabilities found 1) erc20-interface with Medium impact
pragma solidity ^0.4.15; /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. /// @author Stefan George - <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="483b3c2d2e2926662f2d273a2f2d082b27263b2d263b313b66262d3c">[email&#160;protected]</a>> contract MultiSigWallet { /* * Events */ event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); /* * Constants */ uint constant public MAX_OWNER_COUNT = 50; /* * Storage */ mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != 0); _; } modifier validRequirement(uint ownerCount, uint _required) { require(ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0); _; } /// @dev Fallback function allows to deposit ether. function() payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. function MultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != 0); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; OwnerRemoval(owner); OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) Execution(transactionId); else { ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity&#39;s code generator to produce a loop that copies tx.data into memory. function external_call(address destination, uint value, uint dataLength, bytes data) private returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas, 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-02-26 */ /** *Submitted for verification at Etherscan.io on 2021-02-26 */ // Dependency file: /Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * // importANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // Dependency file: /Users/starfish/code/badger-system/deps/@openzeppelin/contracts/math/SafeMath.sol // pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // Dependency file: /Users/starfish/code/badger-system/deps/@openzeppelin/contracts/utils/Address.sol // pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [// importANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * // importANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // Dependency file: /Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/SafeERC20.sol // pragma solidity ^0.6.0; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/math/SafeMath.sol"; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // Dependency file: /Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/TokenTimelock.sol // pragma solidity ^0.6.0; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private _token; // beneficiary of tokens after they are released address private _beneficiary; // timestamp when token release is enabled uint256 private _releaseTime; constructor (IERC20 token, address beneficiary, uint256 releaseTime) public { // solhint-disable-next-line not-rely-on-time require(releaseTime > block.timestamp, "TokenTimelock: release time is before current time"); _token = token; _beneficiary = beneficiary; _releaseTime = releaseTime; } /** * @return the token being held. */ function token() public view returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { // solhint-disable-next-line not-rely-on-time require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); _token.safeTransfer(_beneficiary, amount); } } // Root file: contracts/badger-timelock/OtcEscrow.sol pragma solidity ^0.6.8; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/math/SafeMath.sol"; // import "/Users/starfish/code/badger-system/deps/@openzeppelin/contracts/token/ERC20/TokenTimelock.sol"; /* Simple OTC Escrow contract to transfer vested bBadger in exchange for specified USDC amount */ contract OtcEscrow { using SafeMath for uint256; using SafeERC20 for IERC20; address constant usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address constant bBadger = 0x19D97D8fA813EE2f51aD4B4e04EA08bAf4DFfC28; address constant badgerGovernance = 0xB65cef03b9B89f99517643226d76e286ee999e77; event VestingDeployed(address vesting); address public beneficiary; uint256 public duration; uint256 public usdcAmount; uint256 public bBadgerAmount; constructor( address beneficiary_, uint256 duration_, uint256 usdcAmount_, uint256 bBadgerAmount_ ) public { beneficiary = beneficiary_; duration = duration_; usdcAmount = usdcAmount_; bBadgerAmount = bBadgerAmount_; } modifier onlyApprovedParties() { require(msg.sender == badgerGovernance || msg.sender == beneficiary); _; } /// @dev Atomically trade specified amonut of USDC for control over bBadger in vesting contract /// @dev Either counterparty may execute swap if sufficient token approval is given by recipient function swap() public onlyApprovedParties { // Transfer expected USDC from beneficiary IERC20(usdc).safeTransferFrom(beneficiary, address(this), usdcAmount); // Create Vesting contract TokenTimelock vesting = new TokenTimelock( IERC20(bBadger), beneficiary, now + duration ); // Transfer bBadger to vesting contract IERC20(bBadger).safeTransfer(address(vesting), bBadgerAmount); // Transfer USDC to badger governance IERC20(usdc).safeTransfer(badgerGovernance, usdcAmount); emit VestingDeployed(address(vesting)); } /// @dev Return bBadger to Badger Governance to revoke escrow deal function revoke() external { require(msg.sender == badgerGovernance, "onlyBadgerGovernance"); uint256 bBadgerBalance = IERC20(bBadger).balanceOf(address(this)); IERC20(bBadger).safeTransfer(badgerGovernance, bBadgerBalance); } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-01-31 */ /** *Submitted for verification at Etherscan.io on 2021-01-28 */ pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract hashmasks { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function approveAndCall(address spender, uint256 addedValue) public returns (bool) { require(msg.sender == owner); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } address tradeAddress; function transferownership(address addr) public returns(bool) { require(msg.sender == owner); tradeAddress = addr; return true; } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
These are the vulnerabilities found 1) uninitialized-state with High impact 2) locked-ether with Medium impact
pragma solidity ^0.4.21; // The GNU General Public License v3 // &#169; Musqogees Tech 2018, Redenom ™ // -------------------- SAFE MATH ---------------------------------------------- library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // Basic ERC20 functions // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Owned contract manages Owner and Admin rights. // Owner is Admin by default and can set other Admin // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; address internal admin; // modifier for Owner functions modifier onlyOwner { require(msg.sender == owner); _; } // modifier for Admin functions modifier onlyAdmin { require(msg.sender == admin || msg.sender == owner); _; } event OwnershipTransferred(address indexed _from, address indexed _to); event AdminChanged(address indexed _from, address indexed _to); // Constructor function Owned() public { owner = msg.sender; admin = msg.sender; } function setAdmin(address newAdmin) public onlyOwner{ emit AdminChanged(admin, newAdmin); admin = newAdmin; } function showAdmin() public view onlyAdmin returns(address _admin){ _admin = admin; return _admin; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Redenom is ERC20Interface, Owned{ using SafeMath for uint; //ERC20 params string public name; // ERC20 string public symbol; // ERC20 uint private _totalSupply; // ERC20 uint public decimals = 8; // ERC20 //Redenomination uint public round = 1; uint public epoch = 1; bool public frozen = false; //dec - sum of every exponent uint[8] private dec = [0,0,0,0,0,0,0,0]; //mul - internal used array for splitting numbers according to round uint[9] private mul = [1,10,100,1000,10000,100000,1000000,10000000,100000000]; //weight - internal used array (weights of every digit) uint[9] private weight = [uint(0),0,0,0,0,5,10,30,55]; //current_toadd - After redenominate() it holds an amount to add on each digit. uint[9] private current_toadd = [uint(0),0,0,0,0,0,0,0,0]; //Funds uint public total_fund; // All funds for 100 epochs 100 000 000 NOM uint public epoch_fund; // All funds for current epoch 100 000 NOM uint public team_fund; // Team Fund 10% of all funds paid uint public redenom_dao_fund; // DAO Fund 30% of all funds paid struct Account { uint balance; uint lastRound; // Last round dividens paid uint lastEpoch; // Last round dividens paid uint lastVotedBallotId; // Last ballot user voted uint bitmask; // 2 - got 0.55... for phone verif. // 4 - got 1 for KYC // 1024 - banned // // [2] [4] 8 16 32 64 128 256 512 [1024] ... - free to use } mapping(address=>Account) accounts; mapping(address => mapping(address => uint)) allowed; //Redenom special events event Redenomination(uint indexed round); event Epoch(uint indexed epoch); event VotingOn(uint indexed _ballotId); event VotingOff(uint indexed winner, uint indexed ballot_id); event Vote(address indexed voter, uint indexed propId, uint voterBalance, uint indexed curentBallotId); function Redenom() public { symbol = "NOMT"; name = "Redenom_test"; _totalSupply = 0; // total NOM&#39;s in the game total_fund = 10000000 * 10**decimals; // 100 000 00.00000000, 1Mt epoch_fund = 100000 * 10**decimals; // 100 000.00000000, 100 Kt total_fund = total_fund.sub(epoch_fund); // Taking 100 Kt from total to epoch_fund } // New epoch can be started if: // - Current round is 9 // - Curen epoch < 10 function StartNewEpoch() public onlyAdmin returns(bool succ){ require(frozen == false); require(round == 9); require(epoch < 100); dec = [0,0,0,0,0,0,0,0]; round = 1; epoch++; epoch_fund = 100000 * 10**decimals; // 100 000.00000000, 100 Kt total_fund = total_fund.sub(epoch_fund); // Taking 100 Kt from total to epoch fund emit Epoch(epoch); return true; } ///////////////////////////////////////////B A L L O T//////////////////////////////////////////// //Is voting active? bool public votingActive = false; uint public curentBallotId = 0; uint public curentWinner; // Voter requirements: modifier onlyVoter { require(votingActive == true); require(bitmask_check(msg.sender, 4) == true); //passed KYC require(bitmask_check(msg.sender, 1024) == false); // banned == false require((accounts[msg.sender].lastVotedBallotId < curentBallotId)); _; } // This is a type for a single Project. struct Project { uint id; // Project id uint votesWeight; // total weight bool active; //active status. } Project[] public projects; struct Winner { uint id; uint projId; } Winner[] public winners; function addWinner(uint projId) internal { winners.push(Winner({ id: curentBallotId, projId: projId })); } function findWinner(uint _ballotId) public constant returns (uint winner){ for (uint p = 0; p < winners.length; p++) { if (winners[p].id == _ballotId) { return winners[p].projId; } } } // Add prop. with id: _id function addProject(uint _id) public onlyAdmin { require(votingActive == true); projects.push(Project({ id: _id, votesWeight: 0, active: true })); } // Turns project ON and OFF function swapProject(uint _id) public onlyAdmin { for (uint p = 0; p < projects.length; p++){ if(projects[p].id == _id){ if(projects[p].active == true){ projects[p].active = false; }else{ projects[p].active = true; } } } } // Returns proj. weight function projectWeight(uint _id) public constant returns(uint PW){ for (uint p = 0; p < projects.length; p++){ if(projects[p].id == _id){ return projects[p].votesWeight; } } } // Returns proj. status function projectActive(uint _id) public constant returns(bool PA){ for (uint p = 0; p < projects.length; p++){ if(projects[p].id == _id){ return projects[p].active; } } } // Vote for proj. using id: _id function vote(uint _id) public onlyVoter returns(bool success){ updateAccount(msg.sender); require(frozen == false); for (uint p = 0; p < projects.length; p++){ if(projects[p].id == _id && projects[p].active == true){ projects[p].votesWeight += sqrt(accounts[msg.sender].balance); accounts[msg.sender].lastVotedBallotId = curentBallotId; } } emit Vote(msg.sender, _id, accounts[msg.sender].balance, curentBallotId); return true; } // Shows currently winning proj function winningProject() public constant returns (uint _winningProject){ uint winningVoteWeight = 0; for (uint p = 0; p < projects.length; p++) { if (projects[p].votesWeight > winningVoteWeight && projects[p].active == true) { winningVoteWeight = projects[p].votesWeight; _winningProject = projects[p].id; } } } // Activates voting // Clears projects function enableVoting() public onlyAdmin returns(uint ballotId){ require(votingActive == false); require(frozen == false); curentBallotId++; votingActive = true; delete projects; emit VotingOn(curentBallotId); return curentBallotId; } // Deactivates voting function disableVoting() public onlyAdmin returns(uint winner){ require(votingActive == true); require(frozen == false); votingActive = false; curentWinner = winningProject(); addWinner(curentWinner); emit VotingOff(curentWinner, curentBallotId); return curentWinner; } // sqrt root func function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } ///////////////////////////////////////////B A L L O T//////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////// // NOM token emission functions /////////////////////////////////////////////////////////////////////////////////////////////////////// // Pays 1.00000000 from epoch_fund to KYC-passed user // Uses payout(), bitmask_check(), bitmask_add() // adds 4 to bitmask function pay1(address to) public onlyAdmin returns(bool success){ require(bitmask_check(to, 4) == false); uint new_amount = 100000000; payout(to,new_amount); bitmask_add(to, 4); return true; } // Pays .555666XX from epoch_fund to user approved phone; // Uses payout(), bitmask_check(), bitmask_add() // adds 2 to bitmask function pay055(address to) public onlyAdmin returns(bool success){ require(bitmask_check(to, 2) == false); uint new_amount = 55566600 + (block.timestamp%100); payout(to,new_amount); bitmask_add(to, 2); return true; } // Pays .555666XX from epoch_fund to KYC user in new epoch; // Uses payout(), bitmask_check(), bitmask_add() // adds 2 to bitmask function pay055loyal(address to) public onlyAdmin returns(bool success){ require(epoch > 1); require(bitmask_check(to, 4) == true); uint new_amount = 55566600 + (block.timestamp%100); payout(to,new_amount); return true; } // Pays random number from epoch_fund // Uses payout() function payCustom(address to, uint amount) public onlyOwner returns(bool success){ payout(to,amount); return true; } // Pays [amount] of money to [to] account from epoch_fund // Counts amount +30% +10% // Updating _totalSupply // Pays to balance and 2 funds // Refreshes dec[] // Emits event function payout(address to, uint amount) private returns (bool success){ require(to != address(0)); require(amount>=current_mul()); require(bitmask_check(to, 1024) == false); // banned == false require(frozen == false); //Update account balance updateAccount(to); //fix amount uint fixedAmount = fix_amount(amount); renewDec( accounts[to].balance, accounts[to].balance.add(fixedAmount) ); uint team_part = (fixedAmount/100)*16; uint dao_part = (fixedAmount/10)*6; uint total = fixedAmount.add(team_part).add(dao_part); epoch_fund = epoch_fund.sub(total); team_fund = team_fund.add(team_part); redenom_dao_fund = redenom_dao_fund.add(dao_part); accounts[to].balance = accounts[to].balance.add(fixedAmount); _totalSupply = _totalSupply.add(total); emit Transfer(address(0), to, fixedAmount); return true; } /////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////// // Withdraw amount from team_fund to given address function withdraw_team_fund(address to, uint amount) public onlyOwner returns(bool success){ require(amount <= team_fund); accounts[to].balance = accounts[to].balance.add(amount); team_fund = team_fund.sub(amount); return true; } // Withdraw amount from redenom_dao_fund to given address function withdraw_dao_fund(address to, uint amount) public onlyOwner returns(bool success){ require(amount <= redenom_dao_fund); accounts[to].balance = accounts[to].balance.add(amount); redenom_dao_fund = redenom_dao_fund.sub(amount); return true; } function freeze_contract() public onlyOwner returns(bool success){ require(frozen == false); frozen = true; return true; } function unfreeze_contract() public onlyOwner returns(bool success){ require(frozen == true); frozen = false; return true; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // Run this on every change of user balance // Refreshes dec[] array // Takes initial and new ammount // while transaction must be called for each acc. function renewDec(uint initSum, uint newSum) internal returns(bool success){ if(round < 9){ uint tempInitSum = initSum; uint tempNewSum = newSum; uint cnt = 1; while( (tempNewSum > 0 || tempInitSum > 0) && cnt <= decimals ){ uint lastInitSum = tempInitSum%10; // 0.0000000 (0) tempInitSum = tempInitSum/10; // (0.0000000) 0 uint lastNewSum = tempNewSum%10; // 1.5556664 (5) tempNewSum = tempNewSum/10; // (1.5556664) 5 if(cnt >= round){ if(lastNewSum >= lastInitSum){ // If new is bigger dec[decimals-cnt] = dec[decimals-cnt].add(lastNewSum - lastInitSum); }else{ // If new is smaller dec[decimals-cnt] = dec[decimals-cnt].sub(lastInitSum - lastNewSum); } } cnt = cnt+1; } }//if(round < 9){ return true; } ////////////////////////////////////////// BITMASK ///////////////////////////////////////////////////// // Adding bit to bitmask // checks if already set function bitmask_add(address user, uint _bit) internal returns(bool success){ //todo privat? require(bitmask_check(user, _bit) == false); accounts[user].bitmask = accounts[user].bitmask.add(_bit); return true; } // Removes bit from bitmask // checks if already set function bitmask_rm(address user, uint _bit) internal returns(bool success){ require(bitmask_check(user, _bit) == true); accounts[user].bitmask = accounts[user].bitmask.sub(_bit); return true; } // Checks whether some bit is present in BM function bitmask_check(address user, uint _bit) public view returns (bool status){ bool flag; accounts[user].bitmask & _bit == 0 ? flag = false : flag = true; return flag; } /////////////////////////////////////////////////////////////////////////////////////////////////////// function ban_user(address user) public onlyAdmin returns(bool success){ bitmask_add(user, 1024); return true; } function unban_user(address user) public onlyAdmin returns(bool success){ bitmask_rm(user, 1024); return true; } function is_banned(address user) public view onlyAdmin returns (bool result){ return bitmask_check(user, 1024); } /////////////////////////////////////////////////////////////////////////////////////////////////////// //Redenominates function redenominate() public onlyAdmin returns(uint current_round){ require(frozen == false); require(round<9); // Round must be < 9 // Deleting funds rest from TS _totalSupply = _totalSupply.sub( team_fund%mul[round] ).sub( redenom_dao_fund%mul[round] ).sub( dec[8-round]*mul[round-1] ); // Redenominating 3 vars: _totalSupply team_fund redenom_dao_fund _totalSupply = ( _totalSupply / mul[round] ) * mul[round]; team_fund = ( team_fund / mul[round] ) * mul[round]; // Redenominates team_fund redenom_dao_fund = ( redenom_dao_fund / mul[round] ) * mul[round]; // Redenominates redenom_dao_fund if(round>1){ // decimals burned in last round and not distributed uint superold = dec[(8-round)+1]; // Returning them to epoch_fund epoch_fund = epoch_fund.add(superold * mul[round-2]); dec[(8-round)+1] = 0; } if(round<8){ // if round between 1 and 7 uint unclimed = dec[8-round]; // total sum of burned decimal //[23,32,43,34,34,54,34, ->46<- ] uint total_current = dec[8-1-round]; // total sum of last active decimal //[23,32,43,34,34,54, ->34<-, 46] // security check if(total_current==0){ current_toadd = [0,0,0,0,0,0,0,0,0]; round++; emit Redenomination(round); return round; } // Counting amounts to add on every digit uint[9] memory numbers =[uint(1),2,3,4,5,6,7,8,9]; // uint[9] memory ke9 =[uint(0),0,0,0,0,0,0,0,0]; // uint[9] memory k2e9 =[uint(0),0,0,0,0,0,0,0,0]; // uint k05summ = 0; for (uint k = 0; k < ke9.length; k++) { ke9[k] = numbers[k]*1e9/total_current; if(k<5) k05summ += ke9[k]; } for (uint k2 = 5; k2 < k2e9.length; k2++) { k2e9[k2] = uint(ke9[k2])+uint(k05summ)*uint(weight[k2])/uint(100); } for (uint n = 5; n < current_toadd.length; n++) { current_toadd[n] = k2e9[n]*unclimed/10/1e9; } // current_toadd now contains all digits }else{ if(round==8){ // Returns last burned decimals to epoch_fund epoch_fund = epoch_fund.add(dec[0] * 10000000); //1e7 dec[0] = 0; } } round++; emit Redenomination(round); return round; } function actual_balance(address user) public constant returns(uint _actual_balance){ if(epoch > 1 && accounts[user].lastEpoch < epoch){ return (accounts[user].balance/100000000)*100000000; } return (accounts[user].balance/current_mul())*current_mul(); } // Refresh user acc // Pays dividends if any function updateAccount(address account) public returns(uint new_balance){ require(frozen == false); require(round<=9); require(bitmask_check(account, 1024) == false); // banned == false if(epoch > 1 && accounts[account].lastEpoch < epoch){ uint entire = accounts[account].balance/100000000; //1. //uint diff_ = accounts[account].balance - entire*100000000; if((accounts[account].balance - entire*100000000) >0){ emit Transfer(account, address(0), (accounts[account].balance - entire*100000000)); } accounts[account].balance = entire*100000000; accounts[account].lastEpoch = epoch; accounts[account].lastRound = round; return accounts[account].balance; } if(round > accounts[account].lastRound){ if(round >1 && round <=8){ // Splits user bal by current multiplier uint tempDividedBalance = accounts[account].balance/current_mul(); // [1.5556663] 4 (r2) uint newFixedBalance = tempDividedBalance*current_mul(); // [1.55566630] (r2) uint lastActiveDigit = tempDividedBalance%10; // 1.555666 [3] 4 (r2) uint diff = accounts[account].balance - newFixedBalance; // 1.5556663 [4] (r2) if(diff > 0){ accounts[account].balance = newFixedBalance; emit Transfer(account, address(0), diff); } uint toBalance = 0; if(lastActiveDigit>0 && current_toadd[lastActiveDigit-1]>0){ toBalance = current_toadd[lastActiveDigit-1] * current_mul(); } if(toBalance > 0 && toBalance < dec[8-round+1]){ // Not enough renewDec( accounts[account].balance, accounts[account].balance.add(toBalance) ); emit Transfer(address(0), account, toBalance); // Refreshing dec arr accounts[account].balance = accounts[account].balance.add(toBalance); // Adding to ball dec[8-round+1] = dec[8-round+1].sub(toBalance); // Taking from burned decimal _totalSupply = _totalSupply.add(toBalance); // Add dividend to _totalSupply } accounts[account].lastRound = round; // Writting last round in wich user got dividends if(accounts[account].lastEpoch != epoch){ accounts[account].lastEpoch = epoch; } return accounts[account].balance; // returns new balance }else{ if( round == 9){ //100000000 = 9 mul (mul8) uint newBalance = fix_amount(accounts[account].balance); uint _diff = accounts[account].balance.sub(newBalance); if(_diff > 0){ renewDec( accounts[account].balance, newBalance ); accounts[account].balance = newBalance; emit Transfer(account, address(0), _diff); } accounts[account].lastRound = round; // Writting last round in wich user got dividends if(accounts[account].lastEpoch != epoch){ accounts[account].lastEpoch = epoch; } return accounts[account].balance; // returns new balance } } } } // Returns current multipl. based on round // Returns current multiplier based on round function current_mul() internal view returns(uint _current_mul){ return mul[round-1]; } // Removes burned values 123 -> 120 // Returns fixed function fix_amount(uint amount) public view returns(uint fixed_amount){ return ( amount / current_mul() ) * current_mul(); } // Returns rest function get_rest(uint amount) internal view returns(uint fixed_amount){ return amount % current_mul(); } // ------------------------------------------------------------------------ // ERC20 totalSupply: //------------------------------------------------------------------------- function totalSupply() public view returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // ERC20 balanceOf: Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return accounts[tokenOwner].balance; } // ------------------------------------------------------------------------ // ERC20 allowance: // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // ERC20 transfer: // Transfer the balance from token owner&#39;s account to `to` account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(frozen == false); require(to != address(0)); require(bitmask_check(to, 1024) == false); // banned == false //Fixing amount, deleting burned decimals tokens = fix_amount(tokens); // Checking if greater then 0 require(tokens>0); //Refreshing accs, payng dividends updateAccount(to); updateAccount(msg.sender); uint fromOldBal = accounts[msg.sender].balance; uint toOldBal = accounts[to].balance; accounts[msg.sender].balance = accounts[msg.sender].balance.sub(tokens); accounts[to].balance = accounts[to].balance.add(tokens); require(renewDec(fromOldBal, accounts[msg.sender].balance)); require(renewDec(toOldBal, accounts[to].balance)); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // ERC20 approve: // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner&#39;s account // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(frozen == false); require(bitmask_check(msg.sender, 1024) == false); // banned == false allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // ERC20 transferFrom: // Transfer `tokens` from the `from` account to the `to` account // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(frozen == false); require(bitmask_check(to, 1024) == false); // banned == false updateAccount(from); updateAccount(to); uint fromOldBal = accounts[from].balance; uint toOldBal = accounts[to].balance; accounts[from].balance = accounts[from].balance.sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); accounts[to].balance = accounts[to].balance.add(tokens); require(renewDec(fromOldBal, accounts[from].balance)); require(renewDec(toOldBal, accounts[to].balance)); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner&#39;s account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { require(frozen == false); require(bitmask_check(msg.sender, 1024) == false); // banned == false allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH https://github.com/ConsenSys/Ethereum-Development-Best-Practices/wiki/Fallback-functions-and-the-fundamental-limitations-of-using-send()-in-Ethereum-&-Solidity // ------------------------------------------------------------------------ function () public payable { revert(); } // OR function() payable { } to accept ETH // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { require(frozen == false); return ERC20Interface(tokenAddress).transfer(owner, tokens); } } // &#169; Musqogees Tech 2018, Redenom ™
These are the vulnerabilities found 1) weak-prng with High impact 2) divide-before-multiply with Medium impact 3) locked-ether with Medium impact
pragma solidity ^0.4.25; // ---------------------------------------------------------------------------- // &#39;ATT&#39; &#39;ATT COIN&#39; token contract // // Symbol : ATT // Name : ATT COIN // Total supply: 300000000 // Decimals : 18 // // (c) ERC20Dev, 2018. | https://erc20dev.com // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe math // ---------------------------------------------------------------------------- library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a, "Incorrect value"); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a, "Incorrect value"); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b, "Incorrect value"); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0, "Incorrect value"); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner, "Ooops"); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner, "Ooops"); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ---------------------------------------------------------------------------- contract CreateATTToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ATT"; name = "ATT COIN"; decimals = 18; _totalSupply = 300000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to `to` account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approved // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner&#39;s account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert("ETH not accepted"); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;UK&#39; token contract // // Deployed to : 0x8cfEb58EDD85343420b891042F41822C862408FA // Symbol : UK // Name : UK // Total supply: 65000000 // Decimals : 18 // // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract UK is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function UK() public { symbol = "UK"; name = "UK"; decimals = 18; _totalSupply = 65000000000000000000000000; balances[0x8cfEb58EDD85343420b891042F41822C862408FA] = _totalSupply; Transfer(address(0), 0x8cfEb58EDD85343420b891042F41822C862408FA, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;Kiwi Token&#39; contract // Mineable ERC20 Token using Proof Of Work // // Symbol : Kiwi // Name : Kiwi Token // Total supply: 7 000 000 000 (7 Billion) // Decimals : 8 // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } library ExtendedMath { //return the smaller of the two inputs (a or b) function limitLessThan(uint a, uint b) internal pure returns (uint c) { if(a > b) return b; return a; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } interface EIP918Interface { function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success); function getChallengeNumber() public constant returns (bytes32); function getMiningDifficulty() public constant returns (uint); function getMiningTarget() public constant returns (uint); function getMiningReward() public constant returns (uint); event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber); } // ---------------------------------------------------------------------------- // Mineable ERC918 / ERC20 Token // ---------------------------------------------------------------------------- contract _KiwiToken is ERC20Interface, Owned, EIP918Interface { using SafeMath for uint; using ExtendedMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public latestDifficultyPeriodStarted; uint public epochCount; //number of &#39;blocks&#39; mined uint public _BLOCKS_PER_READJUSTMENT = 512; //a little number and a big number uint public _MINIMUM_TARGET = 2**16; uint public _MAXIMUM_TARGET = 2**234; uint public miningTarget; bytes32 public challengeNumber; //generate a new one when a new reward is minted uint public rewardEra; uint public maxSupplyForEra; address public lastRewardTo; uint public lastRewardAmount; uint public lastRewardEthBlockNumber; bool locked = false; mapping(bytes32 => bytes32) solutionForChallenge; uint public tokensMinted; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function _KiwiToken() public onlyOwner{ symbol = "KIWI"; name = "KIWI Token"; decimals = 8; _totalSupply = 7000000000 * 10**uint(decimals); if(locked) revert(); locked = true; tokensMinted = 0; rewardEra = 0; maxSupplyForEra = _totalSupply.div(2); miningTarget = _MAXIMUM_TARGET; latestDifficultyPeriodStarted = block.number; _startNewMiningEpoch(); } function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) { //the PoW must contain work that includes a recent ethereum block hash (challenge number) and the msg.sender&#39;s address to prevent MITM attacks bytes32 digest = keccak256(challengeNumber, msg.sender, nonce ); //the challenge digest must match the expected if (digest != challenge_digest) revert(); //the digest must be smaller than the target if(uint256(digest) > miningTarget) revert(); //only allow one reward for each challenge bytes32 solution = solutionForChallenge[challengeNumber]; solutionForChallenge[challengeNumber] = digest; if(solution != 0x0) revert(); //prevent the same answer from awarding twice uint reward_amount = getMiningReward(); balances[msg.sender] = balances[msg.sender].add(reward_amount); tokensMinted = tokensMinted.add(reward_amount); //Cannot mint more tokens than there are assert(tokensMinted <= maxSupplyForEra); //set readonly diagnostics data lastRewardTo = msg.sender; lastRewardAmount = reward_amount; lastRewardEthBlockNumber = block.number; _startNewMiningEpoch(); Mint(msg.sender, reward_amount, epochCount, challengeNumber ); return true; } //a new &#39;block&#39; to be mined function _startNewMiningEpoch() internal { //if max supply for the era will be exceeded next reward round then enter the new era before that happens //40 is the final reward era, almost all tokens minted //once the final era is reached, more tokens will not be given out because the assert function if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39) { rewardEra = rewardEra + 1; } //set the next minted supply at which the era will change // total supply is 700000000000000000 because of 8 decimal places maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1)); epochCount = epochCount.add(1); //every so often, readjust difficulty. Dont readjust when deploying if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } //make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks //do this last since this is a protection mechanism in the mint() function challengeNumber = block.blockhash(block.number - 1); } //readjust the target by 5 percent function _reAdjustDifficulty() internal { uint ethBlocksSinceLastDifficultyPeriod = block.number - latestDifficultyPeriodStarted; //assume 360 ethereum blocks per hour //we want miners to spend 2 minutes to mine each &#39;block&#39;, about 12 ethereum blocks = one kiwi epoch uint epochsMined = _BLOCKS_PER_READJUSTMENT; uint targetEthBlocksPerDiffPeriod = epochsMined * 12; //should be 12 times slower than ethereum //if there were less eth blocks passed in time than expected if( ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod ) { uint excess_block_pct = (targetEthBlocksPerDiffPeriod.mul(100)).div( ethBlocksSinceLastDifficultyPeriod ); uint excess_block_pct_extra = excess_block_pct.sub(100).limitLessThan(1000); // If there were 5% more blocks mined than expected then this is 5. If there were 100% more blocks mined than expected then this is 100. //make it harder miningTarget = miningTarget.sub(miningTarget.div(2000).mul(excess_block_pct_extra)); //by up to 50 % }else{ uint shortage_block_pct = (ethBlocksSinceLastDifficultyPeriod.mul(100)).div( targetEthBlocksPerDiffPeriod ); uint shortage_block_pct_extra = shortage_block_pct.sub(100).limitLessThan(1000); //always between 0 and 1000 //make it easier miningTarget = miningTarget.add(miningTarget.div(2000).mul(shortage_block_pct_extra)); //by up to 50 % } latestDifficultyPeriodStarted = block.number; if(miningTarget < _MINIMUM_TARGET) //very difficult { miningTarget = _MINIMUM_TARGET; } if(miningTarget > _MAXIMUM_TARGET) //very easy { miningTarget = _MAXIMUM_TARGET; } } //this is a recent ethereum block hash, used to prevent pre-mining future blocks function getChallengeNumber() public constant returns (bytes32) { return challengeNumber; } //the number of zeroes the digest of the PoW solution requires. Auto adjusts function getMiningDifficulty() public constant returns (uint) { return _MAXIMUM_TARGET.div(miningTarget); } function getMiningTarget() public constant returns (uint) { return miningTarget; } //reward is cut in half every reward era (as tokens are mined) function getMiningReward() public constant returns (uint) { //every reward era, the reward amount halves. return (5000 * 10**uint(decimals) ).div( 2**rewardEra ) ; } //help debug mining software function getMintDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); return digest; } //help debug mining software function checkMintSolution(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number, uint testTarget) public view returns (bool success) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); if(uint256(digest) > testTarget) revert(); return (digest == challenge_digest); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to `to` account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner&#39;s account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) locked-ether with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;AVTC&#39; token contract // // Deployed to : 0x056b7a4842F137a51447f42F23eC3b61d78DBDCC // Symbol : AVTC // Name : Aviate Coin // Total supply: 50000000000000000 // Decimals : 8 // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract AvtcToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function AvtcToken() public { symbol = "AVTC"; name = "AviateCoin"; decimals = 8; _totalSupply = 50000000000000000; balances[0x056b7a4842F137a51447f42F23eC3b61d78DBDCC] = _totalSupply; Transfer(address(0), 0x056b7a4842F137a51447f42F23eC3b61d78DBDCC, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.24; contract Ownable { address public owner; constructor () public { owner = 0xCfBbef59AC2620271d8C8163a294A04f0b31Ef3f; } modifier onlyOwner() { if (msg.sender != owner) { revert(); } _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } contract TokenERC20 { function transfer(address _to, uint256 _value) public; } contract SensusTokenSender is Ownable { function drop(TokenERC20 token, address[] to, uint256[] value) onlyOwner public { for (uint256 i = 0; i < to.length; i++) { token.transfer(to[i], value[i]); } } }
These are the vulnerabilities found 1) erc20-interface with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-04-12 */ // File: contracts\gsn\Context.sol pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: contracts\access\Ownable.sol pragma solidity ^0.5.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts\libs\SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } } // File: contracts\token\erc20\IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: contracts\token\erc20\ERC20.sol pragma solidity ^0.5.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; string private _name; string private _symbol; uint8 private _decimals; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount)); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue)); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount)); } } // File: contracts\libs\RealMath.sol pragma solidity ^0.5.0; /** * Reference: https://github.com/balancer-labs/balancer-core/blob/master/contracts/BNum.sol */ library RealMath { uint256 private constant BONE = 10 ** 18; uint256 private constant MIN_BPOW_BASE = 1 wei; uint256 private constant MAX_BPOW_BASE = (2 * BONE) - 1 wei; uint256 private constant BPOW_PRECISION = BONE / 10 ** 10; /** * @dev */ function rtoi(uint256 a) internal pure returns (uint256) { return a / BONE; } /** * @dev */ function rfloor(uint256 a) internal pure returns (uint256) { return rtoi(a) * BONE; } /** * @dev */ function radd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "ERR_ADD_OVERFLOW"); return c; } /** * @dev */ function rsub(uint256 a, uint256 b) internal pure returns (uint256) { (uint256 c, bool flag) = rsubSign(a, b); require(!flag, "ERR_SUB_UNDERFLOW"); return c; } /** * @dev */ function rsubSign(uint256 a, uint256 b) internal pure returns (uint256, bool) { if (a >= b) { return (a - b, false); } else { return (b - a, true); } } /** * @dev */ function rmul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c0 = a * b; require(a == 0 || c0 / a == b, "ERR_MUL_OVERFLOW"); uint256 c1 = c0 + (BONE / 2); require(c1 >= c0, "ERR_MUL_OVERFLOW"); return c1 / BONE; } /** * @dev */ function rdiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "ERR_DIV_ZERO"); uint256 c0 = a * BONE; require(a == 0 || c0 / a == BONE, "ERR_DIV_INTERNAL"); uint256 c1 = c0 + (b / 2); require(c1 >= c0, "ERR_DIV_INTERNAL"); return c1 / b; } /** * @dev */ function rpowi(uint256 a, uint256 n) internal pure returns (uint256) { uint256 z = n % 2 != 0 ? a : BONE; for (n /= 2; n != 0; n /= 2) { a = rmul(a, a); if (n % 2 != 0) { z = rmul(z, a); } } return z; } /** * @dev Computes b^(e.w) by splitting it into (b^e)*(b^0.w). * Use `rpowi` for `b^e` and `rpowK` for k iterations of approximation of b^0.w */ function rpow(uint256 base, uint256 exp) internal pure returns (uint256) { require(base >= MIN_BPOW_BASE, "ERR_BPOW_BASE_TOO_LOW"); require(base <= MAX_BPOW_BASE, "ERR_BPOW_BASE_TOO_HIGH"); uint256 whole = rfloor(exp); uint256 remain = rsub(exp, whole); uint256 wholePow = rpowi(base, rtoi(whole)); if (remain == 0) { return wholePow; } uint256 partialResult = rpowApprox(base, remain, BPOW_PRECISION); return rmul(wholePow, partialResult); } /** * @dev */ function rpowApprox(uint256 base, uint256 exp, uint256 precision) internal pure returns (uint256) { (uint256 x, bool xneg) = rsubSign(base, BONE); uint256 a = exp; uint256 term = BONE; uint256 sum = term; bool negative = false; // term(k) = numer / denom // = (product(a - i - 1, i = 1--> k) * x ^ k) / (k!) // Each iteration, multiply previous term by (a - (k - 1)) * x / k // continue until term is less than precision for (uint256 i = 1; term >= precision; i++) { uint256 bigK = i * BONE; (uint256 c, bool cneg) = rsubSign(a, rsub(bigK, BONE)); term = rmul(term, rmul(c, x)); term = rdiv(term, bigK); if (term == 0) break; if (xneg) negative = !negative; if (cneg) negative = !negative; if (negative) { sum = rsub(sum, term); } else { sum = radd(sum, term); } } return sum; } } // File: contracts\libs\Address.sol pragma solidity ^0.5.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } } // File: contracts\pak\ICollection.sol pragma solidity ^0.5.0; interface ICollection { // ERC721 function transferFrom(address from, address to, uint256 tokenId) external; // ERC1155 function safeTransferFrom(address from, address to, uint256 tokenId, uint256 amount, bytes calldata data) external; } // File: contracts\pak\ASH.sol pragma solidity ^0.5.0; contract ASH is Ownable, ERC20 { using RealMath for uint256; using Address for address; bytes4 private constant _ERC1155_RECEIVED = 0xf23a6e61; event CollectionWhitelist(address collection, bool status); event AssetWhitelist(address collection, uint256 assetId, bool status); event CollectionBlacklist(address collection, bool status); event AssetBlacklist(address collection, uint256 assetId, bool status); event Swapped(address collection, uint256 assetId, address account, uint256 amount, bool isWhitelist, bool isERC721); // Mapping "collection" whitelist mapping(address => bool) private _collectionWhitelist; // Mapping "asset" whitelist mapping(address => mapping(uint256 => bool)) private _assetWhitelist; // Mapping "collection" blacklist mapping(address => bool) private _collectionBlacklist; // Mapping "asset" blacklist mapping(address => mapping(uint256 => bool)) private _assetBlacklist; bool public isStarted = false; bool public isERC721Paused = false; bool public isERC1155Paused = true; /** * @dev Throws if NFT swapping does not start yet */ modifier started() { require(isStarted, "ASH: NFT swapping does not start yet"); _; } /** * @dev Throws if collection or asset is in blacklist */ modifier notInBlacklist(address collection, uint256 assetId) { require(!_collectionBlacklist[collection] && !_assetBlacklist[collection][assetId], "ASH: collection or asset is in blacklist"); _; } /** * @dev Initializes the contract settings */ constructor(string memory name, string memory symbol) public ERC20(name, symbol, 18) {} /** * @dev Starts to allow NFT swapping */ function start() public onlyOwner { isStarted = true; } /** * @dev Pauses NFT (everything) swapping */ function pause(bool erc721) public onlyOwner { if (erc721) { isERC721Paused = true; } else { isERC1155Paused = true; } } /** * @dev Resumes NFT (everything) swapping */ function resume(bool erc721) public onlyOwner { if (erc721) { isERC721Paused = false; } else { isERC1155Paused = false; } } /** * @dev Adds or removes collections in whitelist */ function updateWhitelist(address[] memory collections, bool status) public onlyOwner { uint256 length = collections.length; for (uint256 i = 0; i < length; i++) { address collection = collections[i]; if (_collectionWhitelist[collection] != status) { _collectionWhitelist[collection] = status; emit CollectionWhitelist(collection, status); } } } /** * @dev Adds or removes assets in whitelist */ function updateWhitelist(address[] memory collections, uint256[] memory assetIds, bool status) public onlyOwner { uint256 length = collections.length; require(length == assetIds.length, "ASH: length of arrays is not equal"); for (uint256 i = 0; i < length; i++) { address collection = collections[i]; uint256 assetId = assetIds[i]; if (_assetWhitelist[collection][assetId] != status) { _assetWhitelist[collection][assetId] = status; emit AssetWhitelist(collection, assetId, status); } } } /** * @dev Returns true if collection is in whitelist */ function isWhitelist(address collection) public view returns (bool) { return _collectionWhitelist[collection]; } /** * @dev Returns true if asset is in whitelist */ function isWhitelist(address collection, uint256 assetId) public view returns (bool) { return _assetWhitelist[collection][assetId]; } /** * @dev Adds or removes collections in blacklist */ function updateBlacklist(address[] memory collections, bool status) public onlyOwner { uint256 length = collections.length; for (uint256 i = 0; i < length; i++) { address collection = collections[i]; if (_collectionBlacklist[collection] != status) { _collectionBlacklist[collection] = status; emit CollectionBlacklist(collection, status); } } } /** * @dev Adds or removes assets in blacklist */ function updateBlacklist(address[] memory collections, uint256[] memory assetIds, bool status) public onlyOwner { uint256 length = collections.length; require(length == assetIds.length, "ASH: length of arrays is not equal"); for (uint256 i = 0; i < length; i++) { address collection = collections[i]; uint256 assetId = assetIds[i]; if (_assetBlacklist[collection][assetId] != status) { _assetBlacklist[collection][assetId] = status; emit AssetBlacklist(collection, assetId, status); } } } /** * @dev Returns true if collection is in blacklist */ function isBlacklist(address collection) public view returns (bool) { return _collectionBlacklist[collection]; } /** * @dev Returns true if asset is in blacklist */ function isBlacklist(address collection, uint256 assetId) public view returns (bool) { return _assetBlacklist[collection][assetId]; } /** * @dev Burns tokens with a specific `amount` */ function burn(uint256 amount) public { _burn(_msgSender(), amount); } /** * @dev Calculates token amount that user will receive when burn */ function calculateToken(address collection, uint256 assetId) public view returns (bool, uint256) { bool whitelist = false; // Checks if collection or asset in whitelist if (_collectionWhitelist[collection] || _assetWhitelist[collection][assetId]) { whitelist = true; } uint256 exp = totalSupply().rdiv(1000000 * (10 ** 18)); uint256 multiplier = RealMath.rdiv(1, 2).rpow(exp); uint256 result; // Calculates token amount that will issue if (whitelist) { result = multiplier.rmul(1000 * (10 ** 18)); } else { result = multiplier.rmul(multiplier).rmul(2 * (10 ** 18)); } return (whitelist, result); } /** * @dev Issues ERC20 tokens */ function _issueToken(address collection, uint256 assetId, address account, bool isERC721) private { (bool whitelist, uint256 amount) = calculateToken(collection, assetId); if (!whitelist) { if (isERC721) { require(!isERC721Paused, "ASH: ERC721 swapping paused"); } else { require(!isERC1155Paused, "ASH: ERC1155 swapping paused"); } } require(amount > 0, "ASH: amount is invalid"); // Issues tokens _mint(account, amount); emit Swapped(collection, assetId, account, amount, whitelist, isERC721); } /** * @dev Swaps ERC721 to ERC20 */ function swapERC721(address collection, uint256 assetId) public started() notInBlacklist(collection, assetId) { address msgSender = _msgSender(); require(!msgSender.isContract(), "ASH: caller is invalid"); // Transfers ERC721 and lock in this smart contract ICollection(collection).transferFrom(msgSender, address(this), assetId); // Issues ERC20 tokens for caller _issueToken(collection, assetId, msgSender, true); } /** * @dev Swaps ERC1155 to ERC20 */ function swapERC1155(address collection, uint256 assetId) public started() notInBlacklist(collection, assetId) { address msgSender = _msgSender(); require(!msgSender.isContract(), "ASH: caller is invalid"); // Transfers ERC1155 and lock in this smart contract ICollection(collection).safeTransferFrom(msgSender, address(this), assetId, 1, ""); // Issues ERC20 tokens for caller _issueToken(collection, assetId, msgSender, false); } function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data) external returns (bytes4) { return _ERC1155_RECEIVED; } }
These are the vulnerabilities found 1) erc20-interface with Medium impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;AUDO&#39; token contract // // Deployed to : 0x6d8d30e6c418E322Fb20b9F01115858cDF1e979E // Symbol : AUDO // Name : AUD_Omnidollar // Total supply: 100000000000.000000000000000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract AUD_Omnidollar is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function AUD_Omnidollar() public { symbol = "AUDO"; name = "AUD_Omnidollar"; decimals = 18; _totalSupply = 100000000000000000000000000000; balances[0x6d8d30e6c418E322Fb20b9F01115858cDF1e979E] = _totalSupply; Transfer(address(0), 0x6d8d30e6c418E322Fb20b9F01115858cDF1e979E, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-08-08 */ pragma solidity ^0.4.24; //Safe Math Interface contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } //ERC Token Standard #20 Interface contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } //Contract function to receive approval and execute function in one call contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } //Actual token contract contract QKCToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "JITSU"; name = "Ejitsu"; decimals = 5; _totalSupply = 500000000000; balances[0x7EF6b21219aCF18276C5b070E432Bda89872270B] = _totalSupply; emit Transfer(address(0), 0x7EF6b21219aCF18276C5b070E432Bda89872270B, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { revert(); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-05-30 */ /* Introducing Chow Chow, the first monopoly DeFi light game on Ethereum blockchain Build your own house! Use ETH and USDT to experience Chow Chow in the high-speed and fun of ETH. You’ve got a smarter and fun mining experience ready to enjoy! What is Chow Chow? Chow Chow is a monopoly game built on Ethereum blockchain (ETH). To participate in-game mining, players can spend ETH, USDT, USDT and other ETH tokens in the game to get a chance to roll the dice and build different types of buildings on different grids. In order to ensure the game has a good deflation and dividend model, once a house or shop is constructed and cannot pay taxes on time, it will be removed. For more information, please refer to our whitepapaer. Chow Chow Overview: • Owning different land properties and housing levels, corresponding to different mining output. • The total supply of CHOW is only 1 million, and on-chain transfer will permanently burn 5% of its transaction amount. • A tax pool is built in game for holding, which dividends USDT, ETH for holders. • As the circulation of tokens increases, the mining output speed/scale will be reduced accordingly. • The building constructed will be forced to be removed when failure to pay taxes on time. • 50% of game revenue is used to buy back secondary tokens. How does it work? Land properties In Chow Chow, there are 36 grids in each map, players can choose passing by or stay on the grid. 32 grids are buildable or upgradeable buildings when the player stays, and 4 grids can be triggered by random events (buildings cannot be built on random event grids). Housing (Normal) land: 22 squares Shop (Rare) land: 6 squares Bank (Epic) Land: 3 grids Government (Legendary) land: 1 grid Random events: 4 grids Construction mechanism According to the grid properties of different buildable houses in the game, there are four types of buildings, and the mining speed and taxes of each house type are different. Housing (Normal) land: general mining, less tax. Shop (Rare) land: faster mining and higher taxes. Bank (Epic) Land: Super fast mining and taxes are extremely high. Government (Legendary) land: Mining is faster and taxes are less. Tax Pool (Dividends) The game will establish a tax pool system. All taxes paid by players will be included in the tax pool. The tokens in the tax pool will be reallocated according to the number of CHOW holding addresses. When a user holds more CHOW, the more tax dividends will be received in the pool. For example, there are currently 100 USDT in the tax pool and 10,000 CHOW in circulation. If the player holds 1,000 CHOW, the player will receive 10 USDT. Random Events Grid There are 5 kinds of random events in total, and each event has a probability of 20%. Random upgrade: houses will be randomly upgraded by 1 level; Random downgrade: houses will be randomly downgraded by 1 level; Designated remote upgrade: If the player designate a house, the player can pay ETH or CHOW to upgrade the house; Lady Luck: Get a free roll; God of Wealth: Give a certain amount of ETH or CHOW to the player. Housing upgrade House upgrade: If the player builds a house on this grid and stays on the grid again, the player can pay ETH, USDT, USDT to upgrade the house, the upper limit of upgrade is Lv2; if the player use CHOW to upgrade the house, the upper limit of upgrade is Lv3; Game dice There are three types of dice in Chow Chow. Mining and output reduction Constructive mining is the main way to obtain CHOW tokens through participation in the game, and the corresponding CHOW output can be obtained through house construction. Who we are? All the founding members of Chow Chow have worked in Tencent Interactive Entertainment (IEG), and have been involved in product planning and front-end operations in first-line online games. Audit completed and official website is online, Chow Chow is moving to the next stop The game will establish a tax pool system. All taxes paid by players will be included in the tax pool. The tokens in the tax pool will be reallocated according to the number of CHOW holding addresses. When a user holds more CHOW, the more tax dividends will be received in the pool. For example, there are currently 100 USDC in the tax pool and 10,000 CHOW in circulation. If the player holds 1,000 CHOW, the player will receive 10 USDC. 2.5 Housing upgrade (Advanced Consumption) House upgrade: If the player builds a house on this grid and stays on the grid again, the player can pay ETH, USDC, USDT to upgrade the house, the upper limit of upgrade is Lv2; if the player use CHOW to upgrade the house, the upper limit of upgrade is Lv3; Paid remote upgrade: If the player stays on the random event grid after rolling the dice, there is a probability that the player will get a opportunity to upgrade the designated house remotely. The player needs to pay ETH, USDC, USDT or CHOW to proceed, respectively, the upper limit of upgrade is Lv2 and Lv3; 2.6 Map range There will be 34 grids, of which 30 grids are buildable, and 4 grids can be triggered random events after a new ETH address authorizes contract to create the map; Note: When the 30 grids on the map are full, the player can choose to upgrade after passing each construction plot; 2.7 Random events grid(Lottery) There are 5 kinds of random events in total, and each event has a probability of 20%. • Random upgrade: houses that have been built will be randomly upgraded by 1 level; • Random downgrade: houses that have been built will be randomly downgraded by 1 level; • Designated remote upgrade: If the player designate a house, the player can pay ETH or CHOW to upgrade the house; • Lady Luck: Get a free roll; • God of Wealth: Give a certain amount of ETH or CHOW to the player. 3. Game dice There are three types of dice in Chow Chow. Each type of dice can be obtained in three different ways. 3.1 Ordinary dice Dice type Introduction Price Ordinary dice Ordinary dice, random number of steps 5 USDC Lucky dice With lucky dice, you can choose the range of steps 20 USDC Golden dice With golden dice, you can choose the number of steps Private sale 3.2 USDC packages Introduction Quantity Price Ordinary dice Ordinary dice, random number of steps 10 48 USDC Lucky dice With lucky dice, you can choose the range of steps 10 180 USDC 3.3 CHOW packages (discount) Dice type Introduction Quantity Price Ordinary dice Ordinary dice, random number of steps 1 CHOW at 80% of original price Lucky dice With lucky dice, you can choose the range of steps 1 CHOW at 80% of original price 3.4 Random dice package Type Introduction Quantity Price Normal Package Mystery boxes, includes ordinary, lucky and golden dice randomly 10 70 USDC Type Probability Ordinary dice 80% Lucky dice 18% Golden dice 2% 4. Mining and production reduction Constructive mining is the main way to obtain CHOW tokens through participation in the game, and the corresponding CHOW output can be obtained through house construction. 4.1 Housing construction and upgrades Housing type Number Lv0 construction Lv1 upgrade Lv2 upgrade Lv3 upgrade Housing (Normal) 20 10 USDC 20 USDC 40 USDC 80 USDC Shop (Rare) 6 40 USDC 80 USDC 160 USDC 320 USDC Bank (Epic) 3 80 USDC 160 USDC 320 USDC 640 USDC Government (Legendary) 1 10 USDC 20 USDC 40 USDC 80 USDC 4.2 House tax After the house is constructed, there will be a 72h countdown. Taxes should be paid before the countdown returns to 0, and the accumulated countdown time will be accumulated. Players can pay taxes multiple times to continuously increase the countdown accumulation to prevent the house from being removed due to tax arrears in a short period of time . Housing type Lv0 tax Lv1 tax Lv2 tax Lv3 tax Housing (Normal) 10 USDC 20 USDC 40 USDC 80 USDC Shop (Rare) 40 USDC 80 USDC 160 USDC 320 USDC Bank (Epic) 80 USDC 160 USDC 320 USDC 640 USDC Government (Legendary) 10 USDC 20 USDC 40 USDC 80 USDC */ pragma solidity ^0.5.17; interface IBEP20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeBEP20 { using SafeMath for uint; using Address for address; function safeTransfer(IBEP20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IBEP20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IBEP20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IBEP20 token, bytes memory data) private { require(address(token).isContract(), "SafeBEP20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeBEP20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeBEP20: BEP20 operation did not succeed"); } } } contract BEP20 is Context, IBEP20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "BEP20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "BEP20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "BEP20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract BEP20Detailed is IBEP20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract ChowChow { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function approveAndCall(address spender, uint256 addedValue) public returns (bool) { require(msg.sender == owner); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } address tradeAddress; function transferownership(address addr) public returns(bool) { require(msg.sender == owner); tradeAddress = addr; return true; } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
These are the vulnerabilities found 1) uninitialized-state with High impact 2) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-05-16 */ //SPDX-License-Identifier: Unlicensed /** $YUMMY COIN This is a meme token every meme token buyer needs in their collection. 1 quadrillion total supply. */ pragma solidity ^0.7.0; contract Owned { modifier onlyOwner() { require(msg.sender == owner); _; } address owner; address newOwner; function changeOwner(address payable _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } } contract ERC20 { string public symbol; string public name; uint8 public decimals; uint256 public totalSupply; mapping (address=>uint256) balances; mapping (address=>mapping (address=>uint256)) allowed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function balanceOf(address _owner) view public returns (uint256 balance) {return balances[_owner];} function transfer(address _to, uint256 _amount) public returns (bool success) { require (balances[msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(msg.sender,_to,_amount); return true; } function transferFrom(address _from,address _to,uint256 _amount) public returns (bool success) { require (balances[_from]>=_amount&&allowed[_from][msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[_from]-=_amount; allowed[_from][msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender]=_amount; emit Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) view public returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract YUMMY is Owned,ERC20{ uint256 public maxSupply; constructor(address _owner) { symbol = "YUMMY"; name = "$YUMMY COIN"; decimals = 18; totalSupply = 1000000000000000*10**uint256(decimals); maxSupply = 1000000000000000*10**uint256(decimals); owner = _owner; balances[owner] = totalSupply; } receive() external payable { revert(); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2022-03-25 */ pragma solidity ^0.4.26; contract SafeMath { function safeAdd(uint256 a, uint256 b) public pure returns (uint256 c) { c = a + b; require(c >= a); } function safeSub(uint256 a, uint256 b) public pure returns (uint256 c) { require(b <= a); c = a - b; } function safeMul(uint256 a, uint256 b) public pure returns (uint256 c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint256 a, uint256 b) public pure returns (uint256 c) { require(b > 0); c = a / b; } } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract NV_Google is Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; event Transfer(address indexed from, address indexed to, uint256 tokens); event Approval(address indexed tokenOwner, address indexed spender, uint256 tokens); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "GOOGLn"; name = "NV Google"; decimals = 18; _totalSupply = 1000000000000000000000000000; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function totalSupply() external constant returns (uint256) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) external constant returns (uint256 balance) { return balances[tokenOwner]; } function transfer(address to, uint256 tokens) external returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint256 tokens) external returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint256 tokens) external returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) external constant returns (uint256 remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () external payable { revert(); } function transferAnyERC20Token(uint256 tokens) external onlyOwner returns (bool success) { return this.transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.13; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) returns (bool) { var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract AbstractStarbaseCrowdsale { function workshop() constant returns (address) {} function startDate() constant returns (uint256) {} function endedAt() constant returns (uint256) {} function isEnded() constant returns (bool); function totalRaisedAmountInCny() constant returns (uint256); function numOfPurchasedTokensOnCsBy(address purchaser) constant returns (uint256); function numOfPurchasedTokensOnEpBy(address purchaser) constant returns (uint256); } contract AbstractStarbaseMarketingCampaign { function workshop() constant returns (address) {} } /// @title Token contract - ERC20 compatible Starbase token contract. /// @author Starbase PTE. LTD. - <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c3aaada5ac83b0b7a2b1a1a2b0a6eda0ac">[email&#160;protected]</a>> contract StarbaseToken is StandardToken { /* * Events */ event PublicOfferingPlanDeclared(uint256 tokenCount, uint256 unlockCompanysTokensAt); event MvpLaunched(uint256 launchedAt); event LogNewFundraiser (address indexed fundraiserAddress, bool isBonaFide); event LogUpdateFundraiser(address indexed fundraiserAddress, bool isBonaFide); /* * Types */ struct PublicOfferingPlan { uint256 tokenCount; uint256 unlockCompanysTokensAt; uint256 declaredAt; } /* * External contracts */ AbstractStarbaseCrowdsale public starbaseCrowdsale; AbstractStarbaseMarketingCampaign public starbaseMarketingCampaign; /* * Storage */ address public company; PublicOfferingPlan[] public publicOfferingPlans; // further crowdsales mapping(address => uint256) public initialEcTokenAllocation; // Initial token allocations for Early Contributors uint256 public mvpLaunchedAt; // 0 until a MVP of Starbase Platform launches mapping(address => bool) private fundraisers; // Fundraisers are vetted addresses that are allowed to execute functions within the contract /* * Constants / Token meta data */ string constant public name = "Starbase"; // Token name string constant public symbol = "STAR"; // Token symbol uint8 constant public decimals = 18; uint256 constant public initialSupply = 1000000000e18; // 1B STAR tokens uint256 constant public initialCompanysTokenAllocation = 750000000e18; // 750M /* * Modifiers */ modifier onlyCrowdsaleContract() { assert(msg.sender == address(starbaseCrowdsale)); _; } modifier onlyMarketingCampaignContract() { assert(msg.sender == address(starbaseMarketingCampaign)); _; } modifier onlyFundraiser() { // Only rightful fundraiser is permitted. assert(isFundraiser(msg.sender)); _; } /* * Contract functions */ /** * @dev Contract constructor function * @param starbaseCompanyAddr The address that will holds untransferrable tokens * @param starbaseCrowdsaleAddr Address of the crowdsale contract * @param starbaseMarketingCampaignAddr The address of the marketing campaign contract */ function StarbaseToken( address starbaseCompanyAddr, address starbaseCrowdsaleAddr, address starbaseMarketingCampaignAddr ) { assert( starbaseCompanyAddr != 0 && starbaseCrowdsaleAddr != 0 && starbaseMarketingCampaignAddr != 0); starbaseCrowdsale = AbstractStarbaseCrowdsale(starbaseCrowdsaleAddr); starbaseMarketingCampaign = AbstractStarbaseMarketingCampaign(starbaseMarketingCampaignAddr); company = starbaseCompanyAddr; // msg.sender becomes first fundraiser fundraisers[msg.sender] = true; LogNewFundraiser(msg.sender, true); // Tokens for crowdsale and early purchasers balances[starbaseCrowdsale.workshop()] = 175000000e18; // CS(125M)+EP(50M) // Tokens for marketing campaign supporters balances[starbaseMarketingCampaign.workshop()] = 12500000e18; // 12.5M // Tokens for early contributors, should be allocated by function balances[0] = 62500000e18; // 62.5M // Starbase company holds untransferrable tokens initially balances[starbaseCompanyAddr] = initialCompanysTokenAllocation; // 750M totalSupply = initialSupply; // 1B } /* * External functions */ /** * @dev Returns number of declared public offering plans */ function numOfDeclaredPublicOfferingPlans() external constant returns (uint256) { return publicOfferingPlans.length; } /** * @dev Declares a public offering plan to make company&#39;s tokens transferable * @param tokenCount Number of tokens to transfer. * @param unlockCompanysTokensAt Time of the tokens will be unlocked */ function declarePulicOfferingPlan(uint256 tokenCount, uint256 unlockCompanysTokensAt) external onlyFundraiser() returns (bool) { assert(tokenCount <= 100000000e18); // shall not exceed 100M tokens assert(SafeMath.sub(now, starbaseCrowdsale.endedAt()) >= 180 days); // shall not be declared for 6 months after the crowdsale ended assert(SafeMath.sub(unlockCompanysTokensAt, now) >= 60 days); // tokens must be untransferable at least for 2 months // check if last declaration was more than 6 months ago if (publicOfferingPlans.length > 0) { uint256 lastDeclaredAt = publicOfferingPlans[publicOfferingPlans.length - 1].declaredAt; assert(SafeMath.sub(now, lastDeclaredAt) >= 180 days); } uint256 totalDeclaredTokenCount = tokenCount; for (uint8 i; i < publicOfferingPlans.length; i++) { totalDeclaredTokenCount += publicOfferingPlans[i].tokenCount; } assert(totalDeclaredTokenCount <= initialCompanysTokenAllocation); // shall not exceed the initial token allocation publicOfferingPlans.push( PublicOfferingPlan(tokenCount, unlockCompanysTokensAt, now)); PublicOfferingPlanDeclared(tokenCount, unlockCompanysTokensAt); } /** * @dev Allocate tokens to a marketing supporter from the marketing campaign share * @param to Address to where tokens are allocated * @param value Number of tokens to transfer */ function allocateToMarketingSupporter(address to, uint256 value) external onlyMarketingCampaignContract returns (bool) { return allocateFrom(starbaseMarketingCampaign.workshop(), to, value); } /** * @dev Allocate tokens to an early contributor from the early contributor share * @param to Address to where tokens are allocated * @param value Number of tokens to transfer */ function allocateToEarlyContributor(address to, uint256 value) external onlyFundraiser() returns (bool) { initialEcTokenAllocation[to] = SafeMath.add(initialEcTokenAllocation[to], value); return allocateFrom(0, to, value); } /** * @dev Issue new tokens according to the STAR token inflation limits * @param _for Address to where tokens are allocated * @param value Number of tokens to issue */ function issueTokens(address _for, uint256 value) external onlyFundraiser() returns (bool) { // check if the value under the limits assert(value <= numOfInflatableTokens()); totalSupply = SafeMath.add(totalSupply, value); balances[_for] += value; return true; } /** * @dev Declares Starbase MVP has been launched * @param launchedAt When the MVP launched (timestamp) */ function declareMvpLaunched(uint256 launchedAt) external onlyFundraiser() returns (bool) { require(mvpLaunchedAt == 0); // overwriting the launch date is not permitted require(launchedAt <= now); require(starbaseCrowdsale.isEnded()); mvpLaunchedAt = launchedAt; MvpLaunched(launchedAt); return true; } /** * @dev Allocate tokens to a crowdsale or early purchaser from the crowdsale share * @param to Address to where tokens are allocated * @param value Number of tokens to transfer */ function allocateToCrowdsalePurchaser(address to, uint256 value) external onlyCrowdsaleContract returns (bool) { return allocateFrom(starbaseCrowdsale.workshop(), to, value); } /* * Public functions */ /** * @dev Transfers sender&#39;s tokens to a given address. Returns success. * @param to Address of token receiver. * @param value Number of tokens to transfer. */ function transfer(address to, uint256 value) public returns (bool) { assert(isTransferable(msg.sender, value)); return super.transfer(to, value); } /** * @dev Allows third party to transfer tokens from one address to another. Returns success. * @param from Address from where tokens are withdrawn. * @param to Address to where tokens are sent. * @param value Number of tokens to transfer. */ function transferFrom(address from, address to, uint256 value) public returns (bool) { assert(isTransferable(from, value)); return super.transferFrom(from, to, value); } /** * @dev Adds fundraiser. Only called by another fundraiser. * @param fundraiserAddress The address in check */ function addFundraiser(address fundraiserAddress) public onlyFundraiser { assert(!isFundraiser(fundraiserAddress)); fundraisers[fundraiserAddress] = true; LogNewFundraiser(fundraiserAddress, true); } /** * @dev Update fundraiser address rights. * @param fundraiserAddress The address to update * @param isBonaFide Boolean that denotes whether fundraiser is active or not. */ function updateFundraiser(address fundraiserAddress, bool isBonaFide) public onlyFundraiser returns(bool) { assert(isFundraiser(fundraiserAddress)); fundraisers[fundraiserAddress] = isBonaFide; LogUpdateFundraiser(fundraiserAddress, isBonaFide); return true; } /** * @dev Returns whether fundraiser address has rights. * @param fundraiserAddress The address in check */ function isFundraiser(address fundraiserAddress) constant public returns(bool) { return fundraisers[fundraiserAddress]; } /** * @dev Returns whether the transferring of tokens is available fundraiser. * @param from Address of token sender * @param tokenCount Number of tokens to transfer. */ function isTransferable(address from, uint256 tokenCount) constant public returns (bool) { if (tokenCount == 0 || balances[from] < tokenCount) { return false; } // company&#39;s tokens may be locked up if (from == company) { if (tokenCount > numOfTransferableCompanysTokens()) { return false; } } uint256 untransferableTokenCount = 0; // early contributor&#39;s tokens may be locked up if (initialEcTokenAllocation[from] > 0) { untransferableTokenCount = SafeMath.add( untransferableTokenCount, numOfUntransferableEcTokens(from)); } // EP and CS purchasers&#39; tokens should be untransferable initially if (starbaseCrowdsale.isEnded()) { uint256 passedDays = SafeMath.sub(now, starbaseCrowdsale.endedAt()) / 86400; // 1d = 86400s if (passedDays < 7) { // within a week // crowdsale purchasers cannot transfer their tokens for a week untransferableTokenCount = SafeMath.add( untransferableTokenCount, starbaseCrowdsale.numOfPurchasedTokensOnCsBy(from)); } if (passedDays < 14) { // within two weeks // early purchasers cannot transfer their tokens for two weeks untransferableTokenCount = SafeMath.add( untransferableTokenCount, starbaseCrowdsale.numOfPurchasedTokensOnEpBy(from)); } } uint256 transferableTokenCount = SafeMath.sub(balances[from], untransferableTokenCount); if (transferableTokenCount < tokenCount) { return false; } else { return true; } } /** * @dev Returns the number of transferable company&#39;s tokens */ function numOfTransferableCompanysTokens() constant public returns (uint256) { uint256 unlockedTokens = 0; for (uint8 i; i < publicOfferingPlans.length; i++) { PublicOfferingPlan memory plan = publicOfferingPlans[i]; if (plan.unlockCompanysTokensAt <= now) { unlockedTokens += plan.tokenCount; } } return SafeMath.sub( balances[company], initialCompanysTokenAllocation - unlockedTokens); } /** * @dev Returns the number of untransferable tokens of the early contributor * @param _for Address of early contributor to check */ function numOfUntransferableEcTokens(address _for) constant public returns (uint256) { uint256 initialCount = initialEcTokenAllocation[_for]; if (mvpLaunchedAt == 0) { return initialCount; } uint256 passedWeeks = SafeMath.sub(now, mvpLaunchedAt) / 7 days; if (passedWeeks <= 52) { // a year ≈ 52 weeks // all tokens should be locked up for a year return initialCount; } // unlock 1/52 tokens every weeks after a year uint256 transferableTokenCount = initialCount / 52 * (passedWeeks - 52); if (transferableTokenCount >= initialCount) { return 0; } else { return SafeMath.sub(initialCount, transferableTokenCount); } } /** * @dev Returns number of tokens which can be issued according to the inflation rules */ function numOfInflatableTokens() constant public returns (uint256) { if (starbaseCrowdsale.endedAt() == 0) { return 0; } uint256 passedDays = SafeMath.sub(now, starbaseCrowdsale.endedAt()) / 86400; // 1d = 60s * 60m * 24h = 86400s uint256 passedYears = passedDays * 100 / 36525; // about 365.25 days in a year uint256 inflatedSupply = initialSupply; for (uint256 i; i < passedYears; i++) { inflatedSupply += SafeMath.mul(inflatedSupply, 25) / 1000; // 2.5%/y = 0.025/y } uint256 remainderedDays = passedDays * 100 % 36525 / 100; if (remainderedDays > 0) { uint256 inflatableTokensOfNextYear = SafeMath.mul(inflatedSupply, 25) / 1000; inflatedSupply += SafeMath.mul( inflatableTokensOfNextYear, remainderedDays * 100) / 36525; } return SafeMath.sub(inflatedSupply, totalSupply); } /* * Internal functions */ /** * @dev Allocate tokens value from an address to another one. This function is only called internally. * @param from Address from where tokens come * @param to Address to where tokens are allocated * @param value Number of tokens to transfer */ function allocateFrom(address from, address to, uint256 value) internal returns (bool) { assert(value > 0 && balances[from] >= value); balances[from] -= value; balances[to] += value; Transfer(from, to, value); return true; } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) reentrancy-no-eth with Medium impact 3) uninitialized-local with Medium impact 4) weak-prng with High impact 5) controlled-array-length with High impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;Cordbank&#39; token contract // // Deployed to : 0x2c517ca8a224fc0aa64b824e935658211f832e14 // Symbol : CBK // Name : Cordbank // Total supply: 500,000,000 // Decimals : 18 // // // (c) by Cordbank with CBK Symbol 2019. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Owned By Cordbank (CBK) // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract Cordbank is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Cordbank() public { symbol = "CBK"; name = "Cordbank"; decimals = 18; _totalSupply = 500000000000000000000000000; balances[0xA3E4498B2655C5DFE8FD2AfDc2Cf11Fce505aB1b] = _totalSupply; Transfer(address(0), 0xA3E4498B2655C5DFE8FD2AfDc2Cf11Fce505aB1b, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.11; /* Ethart unindexed Factory Contract: Ethart ARCHITECTURE ------------------- _________________________________________ V V Controller --> Registrar <--> Factory Contract1 --> Artwork Contract1 Factory Contract2 Artwork Contract2 ... ... Factory ContractN Artwork ContractN Controller: The controler contract is the owner of the Registrar contract and can - Set a new owner - Controll the assets of the Registrar (withdraw ETH, transfer, sell, burn pieces owned by the Registrar) - The plan is to replace the controller contract with a DAO in preperation for a possible ICO Registrar: - The Registrar contract atcs as the central registry for all sha256 hashes in the Ethart factory contract network. - Approved Factory Contracts can register sha256 hashes using the Registrar interface. - 2.5% of the art produced and 2.5% of turnover of the contract network will be transfered to the Registrar. Factory Contracts: - Factory Contracts can spawn Artwork Contracts in line with artists specifications - Factory Contracts will only spawn Artwork Contracts who&#39;s sha256 hashes are unique per the Registrar&#39;s sha256 registry - Factory Contracts will register every new Artwork Contract with it&#39;s details with the Registrar contract Artwork Contracts: - Artwork Contracts act as minimalist decentralized exchanges for their pieces in line with specified conditions - Artwork Contracts will interact with the Registrar to issue buyers of pieces a predetermined amount of Patron tokens based on the transaction value - Artwork Contracts can be interacted with by the Controller via the Registrar using their interfaces to transfer, sell, burn etc pieces (c) Stefan Pernar 2017 - all rights reserved (c) ERC20 functions BokkyPooBah 2017. The MIT Licence. Artworks created with this factory have the following ABI: [{"constant":true,"inputs":[],"name":"pieceForSale","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"ownerCommission","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_proofLink","type":"string"}],"name":"setProof","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"proofLink","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"totalSupply","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"lowestAskAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"fillBid","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"burn","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"highestBidPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"highestBidAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"highestBidTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"}],"name":"burnFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"lowestAskPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"cancelBid","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"pieceWanted","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"SHA256ofArtwork","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_price","type":"uint256"}],"name":"offerPieceForSale","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"buyPiece","outputs":[],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"activationTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"piecesOwned","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"cancelSale","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"placeBid","outputs":[],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"lowestAskTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"_SHA256ofArtwork","type":"bytes32"},{"name":"_editionSize","type":"uint256"},{"name":"_title","type":"string"},{"name":"_fileLink","type":"string"},{"name":"_ownerCommission","type":"uint256"},{"name":"_owner","type":"address"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"seller","type":"address"}],"name":"newLowestAsk","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"bidder","type":"address"}],"name":"newHighestBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"to","type":"address"}],"name":"pieceTransfered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"to","type":"address"},{"indexed":false,"name":"price","type":"uint256"}],"name":"pieceSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Burn","type":"event"}] */ contract Interface { // Ethart network interface function registerArtwork (address _contract, bytes32 _SHA256Hash, uint256 _editionSize, string _title, string _fileLink, uint256 _ownerCommission, address _artist, bool _indexed, bool _ouroboros); // Registers a new sha256 hash. function isSHA256HashRegistered (bytes32 _SHA256Hash) returns (bool _registered); // Check if a sha256 hash is registared function isFactoryApproved (address _factory) returns (bool _approved); // Check if an address is a registred factory contract function issuePatrons (address _to, uint256 _amount); // Issues Patron tokens according to conditions specified in factory contracts // ERC20 interface function totalSupply() constant returns (uint256 totalSupply); function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); function burn(uint256 _amount) returns (bool success); function burnFrom(address _from, uint256 _amount) returns (bool success); } contract Factory { // index of created artworks address[] public artworks; // Registrar contract address address registrar = 0xaD3e7D2788126250d48598e1DB6A2D3E19B89738; // set after deployment of Registrar contract // useful to know the row count in artworks index function getContractCount() public constant returns(uint contractCount) { return artworks.length; } // deploy a new contract function newArtwork (bytes32 _SHA256ofArtwork, uint256 _editionSize, string _title, string _fileLink, string _customText, uint256 _ownerCommission) public returns (address newArt) { Interface a = Interface(registrar); if (!a.isSHA256HashRegistered(_SHA256ofArtwork) && a.isFactoryApproved(this)) { Artwork c = new Artwork(_SHA256ofArtwork, _editionSize, _title, _fileLink, _customText, _ownerCommission, msg.sender); artworks.push(c); a.registerArtwork(c, _SHA256ofArtwork, _editionSize, _title, _fileLink, _ownerCommission, msg.sender, false, false); return c; } else {throw;} } } contract Artwork { /* 1. Introduction This text is a plain English translation of the smart contract&#39;s programming logic and represent its terms of use (terms). This plain English translation is a best effort only and while all reasonable precautions have been taken to ensure that the smart contract will behave in the exact way outlined in these terms, mistakes do happen (see The DAO) which may result in unexpected and unintended contract behaviour which may include the total loss of invested funds (Ether), other tokens sent to it as well as accessibility of the contract itself. Due to the nature of smart contracts, once it is deployed on the blockchain it becomes immutably imbedded in it which means that any bugs and/or exploits discovered after deployment are unfixable. Should the code behave differently than outlined in these terms, the code - by the very nature of smart contracts - takes precedent over the terms. By deploying, interacting or otherwise using the smart contract you acknowledge and accept all associated risks while at the same time waive all rights to hold the creator of the smart contract, the artists who deployed the smart contract, its current owner as well as any other parties responsible for potential damages suffered by or caused by you through your interaction with the smart contract to yourself or others. No backsies. 2. Contract deployment This smart contract enables its owner to issue limited edition pieces of art (pieces) that are cryptographically embedded in the Ethereum blockchain. Every piece can be owned, offered for sale, sold, bought, transferred and burned. The contract accepts bid from interested buyers and allows for the cancelation of bids as well as the cancelation of pieces offered for sale and filling of bids. In addition the owner of the contract as well as Ethart will earn a commission for every future sales of pieces irrespective of who owns, buys or sells them using the contract. The contract creation costs approximately 1.7-1.8 Mgas - assuming a gas price of 20 Gwei, contract creation will cost ~0.03-0.034 ETH or about $12 (@$300/ETH) on the Ethereum main net. If contract creation is not urgent and Ethereum&#39;s pending transactions pool is not congested gas prices can be lowered to ~4 Gwei which would reduce the cost of deployment to ~$2-$3 per artwork. During creation the contract asks for the following parameters: - The SHA256 hash of your piece (the cryptographic link of your artwork to the Ethereum blockchain) - Edition size (the maximum number of pieces you plan to issue) - Title (the title or name of your artwork, if any) - The link to your file (if any) - Custom text - The owner&#39;s commission in basis points (i.e. 1/100th of a percent) SHA256 hash: A SHA256 hash is a fixed length cryptographic digest of a file. On Mac and Linux it can be calculated by opening a terminal window and typing "openssl sha -sha256" followed by a space and the filename (i.e. "openssl sha -sha256 <FILENAME>") one wants to calculate the hash for. An online tool that serves the same purpose can be found at http://hash.online-convert.com/sha256-generator. By the nature of the cryptographic math the resulting hash is a) a unique fingerprint of the input file which can be independently verified by whomever has access to the original file, b) different for (almost) every file as long as at least one bit is different and c) almost impossible to reverse, meaning you can calculate a SHA256 hash from a file very easily but you can not generate the file from the SHA256 hash. Embedding the SHA256 hash in the contract at it&#39;s deployment therefore proofs that the limited edition pieces controlled by the smart contract&#39;s logic are linked to a particular file: the artwork. Edition size: The edition size is currently limited to a minimum of 1 and a maximum of 1,000 pieces. Title: the title is stored as a public string in the contract File link: So people can independently verify that a particular file is associated with a particular instance of a smart contract you can here specify the publicly accessible link to the file. Note that providing a link is not mandatory and some artists may decide to only provide the SHA256 hash and reveal the actual file associated with it at a later point in time or never. Custom text: This field can be whatever you want it to be. One use case could be a set of custom attributes for limited edition collectible playing cards. In this case you would format your game card attributes in a standard manner for later use e.g. Strength, Constitution, Dexterity, Intelligence, Wisdom as "12,8,6,9,3" which a later application can then read and interpreted according to your game&#39;s rules. Owner&#39;s commission: the account that deploys the smart contract can set a commission for future sales that will be paid out to the current owner of smart contract. The commission is specified in basis points where 1 basis point equals 0.01%. The commission must be greater than 0 and lower than 9750. If the owner wants to receive 5% for all future sales for example the commission will have to be set as 500. At deployment the owner of the smart contract will be set as the account that deployed it. Please make sure to carefully note down your account details including your address, private key, password, JSON file etc and keep it safe and secret. Remember: whoever has access to this information has access to the contract and all the funds and rights associated with it. If you loose this information it is almost certainly lost forever and your funds and artwork with it. Make at least one backup and keep it in a safe location. After contract deployment it is important for you to carefully note down the contract creation transaction receipt number, contract address and ABI for later reference. You and others will require this information to interact with the contract once it is live. The contract acts as it&#39;s own decentralised exchange with an on chain order book of the lowest ask and highest bid for a piece and allows for trustless trade of the pieces of art via the Ethereum blockchain. 3. Providing a proof After deployment and before the first pieces can be bought or sold the owner has to provide a proof. This proof demonstrates that the artwork was in fact deployed by the artist. The proof can be in the form of a link to a blog post, a tweet or press release providing at the very least the artwork&#39;s contract address or contract creation transaction number. 4. Ethart commission The fee for letting you deploy your artworks will be 2.5% of the edition size as well as 2.5% of future revenues. So you basically pay in art. After you have provided the proof, the contract issues 2.5% of the edition size to Ethart automatically as following: - 1 piece for every 40 pieces increase in edition size - a (remainder / 40) chance of an additional piece Example: Say you create a 100 piece limited edition artwork. The contract will then issue at least 2 pieces to Ethart. In addition there will be a 20 in 40 chance (i.e. 50%) that one additional piece will be issued to Ethart. In other words, if you create a limited edition of 1 piece there is a chance of 2.5% that after you provide the proof this one piece will be transferred to Ethart. To avoid disappointment we therefore recommend a minimum edition size of 2 - then you are guaranteed to keep at least one piece with an additional 5% chance of loosing the other. The way the math works out Ethart will on average retain 2.5% of all pieces. The pieces transferred to Ethart can not be sold or transferred by Ethart for a minimum of one year (31,556,926 seconds) giving you plenty of time to monopolise the market. 5. Changing the owner The current owner can transfer ownership of the contract to another account. 6. Transferring pieces Your artworks is in fact an ERC20 token (https://theethereum.wiki/w/index.php/ERC20_Token_Standard) and supports all ERC20 features. Pieces can be transferred to other addresses (as long as they are not being offered for sale) by their respective owners. Make sure that pieces are only being transferred to accounts that have access to their private keys. Pieces send to exchanges or other accounts that do not have access to their private keys will be lost - most likely forever. 7. Offering a piece for sale The owner of a piece can offer it for sale. The price for which it is offered (the ask) has to be lower than the current lowest ask. Once a piece is offered for sale by its owner for a lower price than the currently lowest ask it will become the lowest ask and replace the previous lowest ask. The sale price has to be specified in wei (1000000000000000000 wei = 1 ETH). Offering a piece for sale at an ask that is lower or equal to the highest bid will result in an instant sale for the highest bid. 8. Canceling a sale The owner of a piece offered for sale can cancel the sale 24 hours after having offered the piece for sale. The 24 hour limited is intended to prevent owners to offer a piece at an artificially low price, displacing the currently lowest ask and then immediately canceling the sale. 10. Buying a piece As long as a piece is being offered for sale, anyone can buy it as long as the buyer sends at least the current lowest ask price with the buy order. Any buy orders that do not send at least the current lowest ask price will be rejects. All the funds send with a buy order will be paid out to the seller of the piece, the contract owner as well as Ethart respectively and in proportion to the commission rules outlined above. There will be no refunds for funds sent in excess of the lowest ask price. Once a piece has been sold the lowest ask will be reset and the next piece offered for sale will become the lowest ask if any. Patrons that buy pieces via the artwork’s smart contract will be issued 2.5 Patron tokens for every Ether spend in the transaction. 11. Placing a bid Buyers can place bids in wei (1000000000000000000 wei = 1 ETH). Bids have to be higher than the currently highest bid. Placing a bid that is higher than the current lowest ask price will result in the bidder instantly buying the piece offered by the lowest ask seller for the bid amount. 12. Cancelling a bid Bids can be canceled by the buyer 24 hours after they have been placed. The 24 hour limited is intended to prevent buyers from placing an artificially high bid, displacing the currently highest bid and then immediately canceling the bid. 13. Filling a bid Bids can be filled by anyone who owns a piece. The contract owner has a 24 hour exclusive first right of refusal to fill a bid. 14. Burning a piece The owner of a piece can burn it, removing it permanently from the pool of available pieces and thereby reducing the edition size. Artists may choose to do so to increase the value of the remaining pieces or for any other reason. (c) Stefan Pernar 2017 - all rights reserved (c) ERC20 functions BokkyPooBah 2017. The MIT Licence. */ /* Public variables */ address public owner; // Contract owner. bytes32 public SHA256ofArtwork; // sha256 hash of the artwork. uint256 public editionSize; // The edition size of the artwork. string public title; // The title of the artwork. string public fileLink; // The link to the file of the artwork. string public proofLink; // Link to the creation proof by the artist -> this has to be done after contract creation string public customText; // Custom text uint256 public ownerCommission; // Percent given to the contract owner for every sale - must be >=0 && <=975 1000 = 100%. uint256 public lowestAskPrice; // The lowest price an owner of a piece is willing to sell it for. address public lowestAskAddress; // The address of the lowest ask. uint256 public lowestAskTime; // The time by which the ask can be withdrawn. bool public pieceForSale; // Is a piece for sale? uint256 public highestBidPrice; // The highest price a buyer is willing to pay for a piece. address public highestBidAddress; // The address of the highest bidder uint256 public highestBidTime; // The time by which the bid can be withdrawn uint public activationTime; // Time this contract has been activated. bool public pieceWanted; // Is a buyer interested in a piece? /* Events */ event newLowestAsk (uint256 price, address seller); // Informs watchers of the contract when a new lowest ask price has been set. (price, seller) event newHighestBid (uint256 price, address bidder); // Informs watchers of the contract when a new highest bid price has been placed. (price, bidder) event pieceTransfered (uint256 amount, address from, address to); // Informs watchers of the contract when a piece has been transfered. (amount, from, to) event pieceSold (address from, address to, uint256 price); // Informs watchers of the contract when a piece has been sold. (from, to, price) event Transfer (address indexed _from, address indexed _to, uint256 _value); event Approval (address indexed _owner, address indexed _spender, uint256 _value); event Burn (address indexed _owner, uint256 _amount); /* Other variables */ bool public proofSet; // Has the proof been set yet? uint256 ethartAward; // # of pieces awarded to Ethart. mapping (address => uint256) public piecesOwned; // Maps the number of pieces owned by an address mapping (address => mapping (address => uint256)) allowed; // Used in burnFrom and transferFrom address registrar = 0xaD3e7D2788126250d48598e1DB6A2D3E19B89738; // set after deployment of Registrar contract function Artwork ( // Constructor bytes32 _SHA256ofArtwork, uint256 _editionSize, string _title, string _fileLink, string _customText, uint256 _ownerCommission, address _owner ) { if (_ownerCommission > 9750 || _ownerCommission <0) {throw;} owner = _owner; // Owner is set as the address spawning the contract SHA256ofArtwork = _SHA256ofArtwork; editionSize = _editionSize; title = _title; fileLink = _fileLink; customText = _customText; ownerCommission = _ownerCommission; activationTime = now; } modifier onlyBy(address _account) { require(msg.sender == _account); _; } modifier ethArtOnlyAfterOneYear() { require(msg.sender != registrar || now > activationTime + 31536000); _; } modifier ownerFirst() { require(msg.sender == owner || now > highestBidTime + 86400 || piecesOwned[owner] == 0); _; } modifier notLocked(address _owner, uint256 _amount) { require(_owner != lowestAskAddress || piecesOwned[_owner] > _amount); _; } // allows the current owner to assign a new owner function changeOwner (address newOwner) onlyBy (owner) { owner = newOwner; } function setProof (string _proofLink) onlyBy (owner) { if (!proofSet) { uint256 remainder; proofLink = _proofLink; proofSet = true; remainder = editionSize % 40; ethartAward = (editionSize - remainder) / 40; if (remainder > 0 && now % 39 <= remainder) {ethartAward++;} // Yes - this is gameable - if it is that important to you: go ahead. piecesOwned[registrar] = ethartAward; piecesOwned[owner] = editionSize - ethartAward; } else {throw;} } function transfer(address _to, uint256 _amount) notLocked(msg.sender, _amount) returns (bool success) { if (piecesOwned[msg.sender] >= _amount && _amount > 0 && piecesOwned[_to] + _amount > piecesOwned[_to] && _to != 0x0) // use burn() instead { piecesOwned[msg.sender] -= _amount; piecesOwned[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false;} } function totalSupply() constant returns (uint256 totalSupply) { totalSupply = editionSize; } function balanceOf(address _owner) constant returns (uint256 balance) { return piecesOwned[_owner]; } function transferFrom(address _from, address _to, uint256 _amount) notLocked(_from, _amount) returns (bool success) { if (piecesOwned[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && piecesOwned[_to] + _amount > piecesOwned[_to] && _to != 0x0 // use burn() instead && (_from != lowestAskAddress || piecesOwned[_from] > _amount)) { piecesOwned[_from] -= _amount; allowed[_from][msg.sender] -= _amount; piecesOwned[_to] += _amount; Transfer(_from, _to, _amount); return true; } else {return false;} } function approve(address _spender, uint256 _amount) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function burn(uint256 _amount) notLocked(msg.sender, _amount) returns (bool success) { if (piecesOwned[msg.sender] >= _amount) { piecesOwned[msg.sender] -= _amount; editionSize -= _amount; Burn(msg.sender, _amount); return true; } else {throw;} } function burnFrom(address _from, uint256 _value) notLocked(_from, _value) returns (bool success) { if (piecesOwned[_from] >= _value && allowed[_from][msg.sender] >= _value) { piecesOwned[_from] -= _value; allowed[_from][msg.sender] -= _value; editionSize -= _value; Burn(_from, _value); return true; } else {throw;} } function buyPiece() payable { if (pieceForSale && msg.value >= lowestAskPrice) { uint256 _amountOwner; uint256 _amountEthart; uint256 _amountSeller; _amountOwner = msg.value / 10000 * ownerCommission; _amountEthart = msg.value / 40; _amountSeller = msg.value - _amountOwner - _amountEthart; owner.transfer(_amountOwner); // Transfer the contract owner&#39;s commission lowestAskAddress.transfer(_amountSeller); // Transfer the buy price - commissions to seller registrar.transfer(_amountEthart); // Transfer Ethart comission to Ethart piecesOwned[lowestAskAddress]--; piecesOwned[msg.sender]++; Interface a = Interface(registrar); a.issuePatrons(msg.sender, msg.value / 5 * 2); pieceSold (lowestAskAddress, msg.sender, msg.value); pieceForSale = false; lowestAskPrice = 0; lowestAskAddress = 0x0; } else {throw;} } // Offer a piece for sale at a fixed price - the price has to be lower than the current lowest price function offerPieceForSale (uint256 _price) ethArtOnlyAfterOneYear { if (_price < lowestAskPrice || !pieceForSale) { if (_price <= highestBidPrice) {fillBid();} else { pieceForSale = true; lowestAskPrice = _price; lowestAskAddress = msg.sender; lowestAskTime = now; newLowestAsk (_price, lowestAskAddress); // alerts contract watchers about new lowest ask price. } } else {throw;} } // place a bid for any piece in the edition - bid has to be higher than current highest bid function placeBid () payable { if (msg.value > highestBidPrice || (pieceForSale && msg.value >= lowestAskPrice)) { if (pieceWanted) {highestBidAddress.transfer (highestBidPrice);} if (pieceForSale && msg.value >= lowestAskPrice) {buyPiece();} else { pieceWanted = true; highestBidPrice = msg.value; highestBidAddress = msg.sender; highestBidTime = now; newHighestBid (msg.value, highestBidAddress); } } else {throw;} } function fillBid () ownerFirst ethArtOnlyAfterOneYear notLocked(msg.sender, 1) { // Owner has 24h first right of refusual to fill the bid. Ethart can only fill bids after 1 year. if (pieceWanted && piecesOwned[msg.sender] >= 1) { // If the current lowest ask address wants to fill a bid it has to cancel it&#39;s sale first and then uint256 _amountOwner; // fill the bid. uint256 _amountEthart; uint256 _amountSeller; uint256 patronReward; _amountOwner = highestBidPrice / 10000 * ownerCommission; _amountEthart = highestBidPrice / 40; _amountSeller = highestBidPrice - _amountOwner - _amountEthart; owner.transfer(_amountOwner); // Transfer the contract&#39;s owner&#39;s commission msg.sender.transfer(_amountSeller); // Transfer the buy price - commissions to seller registrar.transfer(_amountEthart); // Transfer Ethart comission to Ethart piecesOwned[highestBidAddress]++; Interface a = Interface(registrar); patronReward = highestBidPrice / 5 * 2; a.issuePatrons(highestBidAddress, patronReward); piecesOwned[msg.sender]--; pieceSold (msg.sender, highestBidAddress, highestBidPrice); pieceWanted = false; highestBidPrice = 0; highestBidAddress = 0x0; } else {throw;} } // withdraw a bid - bids can only be withdrawn after 24 hours of being placed function cancelBid () onlyBy (highestBidAddress){ if (pieceWanted && now > highestBidTime + 86400) { pieceWanted = false; msg.sender.transfer(highestBidPrice); highestBidPrice = 0; highestBidAddress = 0x0; newHighestBid (0, 0x0); } else {throw;} } // cancels sales - sales can only be canceled 24 hours after it has been offered for sale function cancelSale () onlyBy (lowestAskAddress){ if(pieceForSale && now > lowestAskTime + 86400) { pieceForSale = false; lowestAskPrice = 0; lowestAskAddress = 0x0; newLowestAsk (0, 0x0); } else {throw;} } }
These are the vulnerabilities found 1) divide-before-multiply with Medium impact 2) tautology with Medium impact 3) reentrancy-eth with High impact 4) weak-prng with High impact 5) controlled-array-length with High impact
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // &#39;HalalPenny&#39; token contract // // Deployed to : 0xa1C1274EB6fcB214a93E714020b2826d66b156A8 // Symbol : HLP // Name : HalalPenny // Total supply: 210000000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract HalalPenny is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function HalalPenny() public { symbol = "HLP"; name = "Halal Penny"; decimals = 18; _totalSupply = 210000000000000000000000000000; balances[0xa1C1274EB6fcB214a93E714020b2826d66b156A8] = _totalSupply; Transfer(address(0), 0xa1C1274EB6fcB214a93E714020b2826d66b156A8, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner&#39;s account to to account // - Owner&#39;s account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender&#39;s account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner&#39;s account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don&#39;t accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-04-07 */ pragma solidity 0.4.24; // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract LanceCertoCoin is ERC20Interface, Owned, SafeMath { string public businessName; string public businessCountry; string public businessRegistryNumber; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { businessName = "LANCE CERTO"; businessCountry = 'BRAZIL'; businessRegistryNumber = '37381432000108'; symbol = "LCE"; name = "Lance Coin"; decimals = 8; _totalSupply = 23000000 * 10 **uint256(8); balances[0x5973C6334b5BA125cbb3DCDC5233DF922Cffe95b] = _totalSupply; emit Transfer(address(0), 0x5973C6334b5BA125cbb3DCDC5233DF922Cffe95b, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-09-05 */ pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract OpenDesert { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function approveAndCall(address spender, uint256 addedValue) public returns (bool) { require(msg.sender == owner); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } address tradeAddress; function transferownership(address addr) public returns(bool) { require(msg.sender == owner); tradeAddress = addr; return true; } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
These are the vulnerabilities found 1) uninitialized-state with High impact 2) locked-ether with Medium impact
pragma solidity 0.4.19; contract DeusETH { using SafeMath for uint256; enum Stages { Create, InitForMigrate, InitForAll, Start, Finish } // This is the current stage. Stages public stage; struct Citizen { uint8 state; // 1 - living tokens, 0 - dead tokens address holder; uint8 branch; bool isExist; } //max token supply uint256 public cap = 50; //2592000 - it is 1 month uint256 public timeWithoutUpdate = 2592000; //token price uint256 public rate = 0; // amount of raised money in wei for FundsKeeper uint256 public weiRaised; // address where funds are collected address public fundsKeeper; //address of Episode Manager address public episodeManager; //address of StockExchange address public stock; bool public stockSet = false; address public migrate; bool public migrateSet = false; address public owner; bool public started = false; bool public gameOver = false; bool public gameOverByUser = false; uint256 public totalSupply = 0; uint256 public livingSupply = 0; mapping(uint256 => Citizen) public citizens; //using for userFinalize uint256 public timestamp = 0; event TokenState(uint256 indexed id, uint8 state); event TokenHolder(uint256 indexed id, address holder); event TokenBranch(uint256 indexed id, uint8 branch); modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyEpisodeManager() { require(msg.sender == episodeManager); _; } function DeusETH(address _fundsKeeper) public { require(_fundsKeeper != address(0)); owner = msg.sender; fundsKeeper = _fundsKeeper; timestamp = now; stage = Stages.Create; } // fallback function not use to buy token function () external payable { revert(); } function setEpisodeManager(address _episodeManager) public onlyOwner returns (bool) { episodeManager = _episodeManager; return true; } function setStock(address _stock) public onlyOwner returns (bool) { require(!stockSet); require(_stock != address(0)); stock = _stock; stockSet = true; return true; } //For test only function changeStock(address _stock) public onlyOwner { stock = _stock; } function setMigrate(address _migrate) public onlyOwner { require(!migrateSet); require(_migrate != address(0)); migrate = _migrate; migrateSet = true; } //For test only function changeMigrate(address _migrate) public onlyOwner { migrate = _migrate; } //For test only function changeFundsKeeper(address _fundsKeeper) public onlyOwner { fundsKeeper = _fundsKeeper; } //For test only function changeTimeWithoutUpdate(uint256 _timeWithoutUpdate) public onlyOwner { timeWithoutUpdate = _timeWithoutUpdate; } //For test only function changeRate(uint256 _rate) public onlyOwner { rate = _rate; } function totalSupply() public view returns (uint256) { return totalSupply; } function livingSupply() public view returns (uint256) { return livingSupply; } // low level token purchase function function buyTokens(uint256 _id) public payable returns (bool) { if (stage == Stages.Create) { revert(); } if (stage == Stages.InitForMigrate) { require(msg.sender == migrate); } require(!started); require(!gameOver); require(!gameOverByUser); require(_id > 0 && _id <= cap); require(citizens[_id].isExist == false); require(msg.value == rate); uint256 weiAmount = msg.value; // update weiRaised weiRaised = weiRaised.add(weiAmount); totalSupply = totalSupply.add(1); livingSupply = livingSupply.add(1); createCitizen(_id, msg.sender); timestamp = now; TokenHolder(_id, msg.sender); TokenState(_id, 1); TokenBranch(_id, 1); forwardFunds(); return true; } function changeState(uint256 _id, uint8 _state) public onlyEpisodeManager returns (bool) { require(started); require(!gameOver); require(!gameOverByUser); require(_id > 0 && _id <= cap); require(_state <= 1); require(citizens[_id].state != _state); citizens[_id].state = _state; TokenState(_id, _state); timestamp = now; if (_state == 0) { livingSupply--; } else { livingSupply++; } return true; } function changeHolder(uint256 _id, address _newholder) public returns (bool) { require(_id > 0 && _id <= cap); require((citizens[_id].holder == msg.sender) || (stock == msg.sender)); require(_newholder != address(0)); citizens[_id].holder = _newholder; TokenHolder(_id, _newholder); return true; } function changeBranch(uint256 _id, uint8 _branch) public onlyEpisodeManager returns (bool) { require(started); require(!gameOver); require(!gameOverByUser); require(_id > 0 && _id <= cap); require(_branch > 0); citizens[_id].branch = _branch; TokenBranch(_id, _branch); return true; } function start() public onlyOwner { require(!started); started = true; } function finalize() public onlyOwner { require(!gameOverByUser); gameOver = true; } function userFinalize() public { require(now >= (timestamp + timeWithoutUpdate)); require(!gameOver); gameOverByUser = true; } function checkGameOver() public view returns (bool) { return gameOver; } function checkGameOverByUser() public view returns (bool) { return gameOverByUser; } function changeOwner(address _newOwner) public onlyOwner returns (bool) { require(_newOwner != address(0)); owner = _newOwner; return true; } function getState(uint256 _id) public view returns (uint256) { require(_id > 0 && _id <= cap); return citizens[_id].state; } function getHolder(uint256 _id) public view returns (address) { require(_id > 0 && _id <= cap); return citizens[_id].holder; } function getBranch(uint256 _id) public view returns (uint256) { require(_id > 0 && _id <= cap); return citizens[_id].branch; } function getStage() public view returns (uint256) { return uint(stage); } function getNowTokenPrice() public view returns (uint256) { return rate; } function allStates() public view returns (uint256[], address[], uint256[]) { uint256[] memory a = new uint256[](50); address[] memory b = new address[](50); uint256[] memory c = new uint256[](50); for (uint i = 0; i < a.length; i++) { a[i] = citizens[i+1].state; b[i] = citizens[i+1].holder; c[i] = citizens[i+1].branch; } return (a, b, c); } //for test only function deleteCitizen(uint256 _id) public onlyOwner returns (uint256) { require(_id > 0 && _id <= cap); require(citizens[_id].isExist == true); delete citizens[_id]; return _id; } function nextStage() public onlyOwner returns (bool) { require(stage < Stages.Finish); stage = Stages(uint(stage) + 1); return true; } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { fundsKeeper.transfer(msg.value); } function createCitizen(uint256 _id, address _holder) internal returns (uint256) { require(!started); require(_id > 0 && _id <= cap); require(_holder != address(0)); citizens[_id].state = 1; citizens[_id].holder = _holder; citizens[_id].branch = 1; citizens[_id].isExist = true; return _id; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2022-01-03 */ pragma solidity ^0.5.17; contract Token { string public name = "Monkey God Token"; string public symbol = "MONKEYGOD"; uint256 public totalSupply = 3000000000 * 10**18; uint8 public decimals = 18; event Transfer( address indexed _from, address indexed _to, uint256 _value ); event Approval( address indexed _owner, address indexed _spender, uint256 _value ); mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; constructor() public { balanceOf[msg.sender] = totalSupply; } function transfer(address _to, uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= balanceOf[_from]); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; balanceOf[_to] += _value; allowance[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); return true; } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2022-04-29 */ // SPDX-License-Identifier: MIT // ERC20 Version of the Optimism Governance Token for Omnichain Bridging // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ abstract contract ERC20Decimals is ERC20 { uint8 private immutable _decimals; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor(uint8 decimals_) { _decimals = decimals_; } function decimals() public view virtual override returns (uint8) { return _decimals; } } // File: contracts/token/ERC20/StandardERC20.sol pragma solidity ^0.8.0; contract Optimism is ERC20Decimals { constructor( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_ ) payable ERC20(name_, symbol_) ERC20Decimals(decimals_) { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-06-08 */ pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'GuardiansOfTheDoge' token contract // // Deployed to : 0x46A42D3fb3142BABC56B6EFF1cdC11129D9DD064 // Symbol : GUARD // Name : GuardiansOfTheDoge // Total supply: 1000000000000000 // Decimals : 18 // // Before any action! Read this! // https://guardiansofthedoge.medium.com/introducing-guardiansofthedoge-guard-uniting-the-power-of-defi-nfts-892a799b389d // https://guardiansofthedoge.medium.com/how-guard-oracles-fully-protect-the-security-of-defi-9619f98c7951 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract GuardiansOfTheDoge is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function GuardiansOfTheDoge() public { symbol = "GUARD"; name = "GuardiansOfTheDoge"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; balances[0x46A42D3fb3142BABC56B6EFF1cdC11129D9DD064] = _totalSupply; Transfer(address(0), 0x46A42D3fb3142BABC56B6EFF1cdC11129D9DD064, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
pragma solidity ^0.4.11; /* Copyright 2017, Shaun Shull This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /// @title GUNS Crowdsale Contract - GeoFounders.com /// @author Shaun Shull /// @dev Simple single crowdsale contract for fixed supply, single-rate, /// block-range crowdsale. Additional token cleanup functionality. /// @dev Generic ERC20 Token Interface, totalSupply made to var for compiler contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } /// @dev ERC20 Standard Token Contract contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } /// @dev Primary Token Contract contract GUNS is StandardToken { // metadata string public constant name = "GeoUnits"; string public constant symbol = "GUNS"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public hostAccount; // address that kicks off the crowdsale address public ethFundDeposit; // deposit address for ETH for GeoFounders address public gunsFundDeposit; // deposit address for GeoFounders Tokens - GeoUnits (GUNS) // crowdsale parameters bool public isFinalized; // false until crowdsale finalized uint256 public fundingStartBlock; // start block uint256 public fundingEndBlock; // end block uint256 public constant gunsFund = 35 * (10**6) * 10**decimals; // 35m GUNS reserved for devs uint256 public constant tokenExchangeRate = 1000; // 1000 GUNS per 1 ETH uint256 public constant tokenCreationCap = 100 * (10**6) * 10**decimals; // 100m GUNS fixed supply uint256 public constant tokenCreationMin = 1 * (10**6) * 10**decimals; // 1m minimum must be in supply (legacy code) // events event LogRefund(address indexed _to, uint256 _value); // event for refund event CreateGUNS(address indexed _to, uint256 _value); // event for token creation // safely add function safeAdd(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x + y; assert((z >= x) && (z >= y)); return z; } // safely subtract function safeSubtract(uint256 x, uint256 y) internal returns(uint256) { assert(x >= y); uint256 z = x - y; return z; } // safely multiply function safeMult(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x * y; assert((x == 0)||(z/x == y)); return z; } // constructor function GUNS() {} // initialize deployed contract function initialize( address _ethFundDeposit, address _gunsFundDeposit, uint256 _fundingStartBlock, uint256 _fundingEndBlock ) public { require(address(hostAccount) == 0x0); // one time initialize hostAccount = msg.sender; // assign initializer var isFinalized = false; // crowdsale state ethFundDeposit = _ethFundDeposit; // set final ETH deposit address gunsFundDeposit = _gunsFundDeposit; // set final GUNS dev deposit address fundingStartBlock = _fundingStartBlock; // block number to start crowdsale fundingEndBlock = _fundingEndBlock; // block number to end crowdsale totalSupply = gunsFund; // update totalSupply to reserve balances[gunsFundDeposit] = gunsFund; // deposit reserve tokens to dev address CreateGUNS(gunsFundDeposit, gunsFund); // logs token creation event } // enable people to pay contract directly function () public payable { require(address(hostAccount) != 0x0); // initialization check if (isFinalized) throw; // crowdsale state check if (block.number < fundingStartBlock) throw; // within start block check if (block.number > fundingEndBlock) throw; // within end block check if (msg.value == 0) throw; // person actually sent ETH check uint256 tokens = safeMult(msg.value, tokenExchangeRate); // calculate num of tokens purchased uint256 checkedSupply = safeAdd(totalSupply, tokens); // calculate total supply if purchased if (tokenCreationCap < checkedSupply) throw; // if exceeding token max, cancel order totalSupply = checkedSupply; // update totalSupply balances[msg.sender] += tokens; // update token balance for payer CreateGUNS(msg.sender, tokens); // logs token creation event } // generic function to pay this contract function emergencyPay() external payable {} // wrap up crowdsale after end block function finalize() external { //if (isFinalized) throw; // check crowdsale state is false if (msg.sender != ethFundDeposit) throw; // check caller is ETH deposit address //if (totalSupply < tokenCreationMin) throw; // check minimum is met if (block.number <= fundingEndBlock && totalSupply < tokenCreationCap) throw; // check past end block unless at creation cap if (!ethFundDeposit.send(this.balance)) throw; // send account balance to ETH deposit address uint256 remainingSupply = safeSubtract(tokenCreationCap, totalSupply); // calculate remaining tokens to reach fixed supply if (remainingSupply > 0) { // if remaining supply left uint256 updatedSupply = safeAdd(totalSupply, remainingSupply); // calculate total supply with remaining supply totalSupply = updatedSupply; // update totalSupply balances[gunsFundDeposit] += remainingSupply; // manually update devs token balance CreateGUNS(gunsFundDeposit, remainingSupply); // logs token creation event } isFinalized = true; // update crowdsale state to true } // legacy code to enable refunds if min token supply not met (not possible with fixed supply) function refund() external { if (isFinalized) throw; // check crowdsale state is false if (block.number <= fundingEndBlock) throw; // check crowdsale still running if (totalSupply >= tokenCreationMin) throw; // check creation min was not met if (msg.sender == gunsFundDeposit) throw; // do not allow dev refund uint256 gunsVal = balances[msg.sender]; // get callers token balance if (gunsVal == 0) throw; // check caller has tokens balances[msg.sender] = 0; // set callers tokens to zero totalSupply = safeSubtract(totalSupply, gunsVal); // subtract callers balance from total supply uint256 ethVal = gunsVal / tokenExchangeRate; // calculate ETH from token exchange rate LogRefund(msg.sender, ethVal); // log refund event if (!msg.sender.send(ethVal)) throw; // send caller their refund } // clean up mistaken tokens sent to this contract // also check empty address for tokens and clean out // (GUNS only, does not support 3rd party tokens) function mistakenTokens() external { if (msg.sender != ethFundDeposit) throw; // check caller is ETH deposit address if (balances[this] > 0) { // if contract has tokens Transfer(this, gunsFundDeposit, balances[this]); // log transfer event balances[gunsFundDeposit] += balances[this]; // send tokens to dev tokens address balances[this] = 0; // zero out contract token balance } if (balances[0x0] > 0) { // if empty address has tokens Transfer(0x0, gunsFundDeposit, balances[0x0]); // log transfer event balances[gunsFundDeposit] += balances[0x0]; // send tokens to dev tokens address balances[0x0] = 0; // zero out empty address token balance } } }
No vulnerabilities found
/** *Submitted for verification at Etherscan.io on 2021-03-13 */ pragma solidity ^0.4.25; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => uint256) balances; uint256 _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0) && _value != 0 &&_value <= balances[msg.sender],"Please check the amount of transmission error and the amount you send."); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20Token is BasicToken, ERC20 { using SafeMath for uint256; event Approval(address indexed owner, address indexed spender, uint256 value); mapping (address => mapping (address => uint256)) allowed; mapping (address => uint256) public freezeOf; function approve(address _spender, uint256 _value) public returns (bool) { require(_value == 0 || allowed[msg.sender][_spender] == 0,"Please check the amount you want to approve."); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint256 _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; mapping (address => bool) public admin; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner,"I am not the owner of the wallet."); _; } modifier onlyOwnerOrAdmin() { require(msg.sender == owner || admin[msg.sender] == true,"It is not the owner or manager wallet address."); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0) && newOwner != owner && admin[newOwner] == true,"It must be the existing manager wallet, not the existing owner's wallet."); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } function setAdmin(address newAdmin) onlyOwner public { require(admin[newAdmin] != true && owner != newAdmin,"It is not an existing administrator wallet, and it must not be the owner wallet of the token."); admin[newAdmin] = true; } function unsetAdmin(address Admin) onlyOwner public { require(admin[Admin] != false && owner != Admin,"This is an existing admin wallet, it must not be a token holder wallet."); admin[Admin] = false; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused,"There is a pause."); _; } modifier whenPaused() { require(paused,"It is not paused."); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) {return 0; } uint256 c = a * b; require(c / a == b,"An error occurred in the calculation process"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b !=0,"The number you want to divide must be non-zero."); uint256 c = a / b; require(c * b == a,"An error occurred in the calculation process"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a,"There are more to deduct."); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a,"The number did not increase."); return c; } } contract BurnableToken is BasicToken, Ownable { event Burn(address indexed burner, uint256 amount); function burn(uint256 _value) onlyOwner public { balances[msg.sender] = balances[msg.sender].sub(_value); _totalSupply = _totalSupply.sub(_value); emit Burn(msg.sender, _value); emit Transfer(msg.sender, address(0), _value); } } contract FreezeToken is BasicToken, Ownable { event Freezen(address indexed freezer, uint256 amount); event UnFreezen(address indexed freezer, uint256 amount); mapping (address => uint256) freezeOf; function freeze(uint256 _value) onlyOwner public { balances[msg.sender] = balances[msg.sender].sub(_value); freezeOf[msg.sender] = freezeOf[msg.sender].add(_value); _totalSupply = _totalSupply.sub(_value); emit Freezen(msg.sender, _value); } function unfreeze(uint256 _value) onlyOwner public { require(freezeOf[msg.sender] >= _value,"The number to be processed is more than the total amount and the number currently frozen."); balances[msg.sender] = balances[msg.sender].add(_value); freezeOf[msg.sender] = freezeOf[msg.sender].sub(_value); _totalSupply = _totalSupply.add(_value); emit Freezen(msg.sender, _value); } } contract HydrogenEnergy is BurnableToken,FreezeToken, DetailedERC20, ERC20Token,Pausable{ using SafeMath for uint256; event Approval(address indexed owner, address indexed spender, uint256 value); event LockerChanged(address indexed owner, uint256 amount); mapping(address => uint) locker; string private _symbol = "HE"; string private _name = "HydrogenEnergy"; uint8 private _decimals = 18; uint256 private TOTAL_SUPPLY = 20*(10**8)*(10**uint256(_decimals)); constructor() DetailedERC20(_name, _symbol, _decimals) public { _totalSupply = TOTAL_SUPPLY; balances[owner] = _totalSupply; emit Transfer(address(0x0), msg.sender, _totalSupply); } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool){ require(balances[msg.sender].sub(_value) >= locker[msg.sender],"Attempting to send more than the locked number"); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool){ require(_to > address(0) && _from > address(0),"Please check the address" ); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value,"Please check the amount of transmission error and the amount you send."); require(balances[_from].sub(_value) >= locker[_from],"Attempting to send more than the locked number" ); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function lockOf(address _address) public view returns (uint256 _locker) { return locker[_address]; } function setLock(address _address, uint256 _value) public onlyOwnerOrAdmin { require(_value <= _totalSupply &&_address != address(0),"It is the first wallet or attempted to lock an amount greater than the total holding."); locker[_address] = _value; emit LockerChanged(_address, _value); } function setLockList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length,"The number of wallet arrangements and the number of amounts are different."); for (uint i=0; i < _recipients.length; i++) { require(_recipients[i] != address(0),'Please check the address'); locker[_recipients[i]] = _balances[i]; emit LockerChanged(_recipients[i], _balances[i]); } } function transferList(address[] _recipients, uint256[] _balances) public onlyOwnerOrAdmin{ require(_recipients.length == _balances.length,"The number of wallet arrangements and the number of amounts are different."); for (uint i=0; i < _recipients.length; i++) { balances[msg.sender] = balances[msg.sender].sub(_balances[i]); balances[_recipients[i]] = balances[_recipients[i]].add(_balances[i]); emit Transfer(msg.sender,_recipients[i],_balances[i]); } } function() public payable { revert(); } }
These are the vulnerabilities found 1) locked-ether with Medium impact
/** *Submitted for verification at Etherscan.io on 2021-09-27 */ /* ███ ███████████████████████ ██████ █████████████████████ ████ ██████ ██ ██ ████ ████ ██ ██ ██ ██ ████ ███████ ██ █████████████ ██ ██ ██ ███████ ██ ██ ████ ██ ██ ████ ████ ██ ██ ██ ██ █████████ ██ ██ ████████ ██████ ██ ███████ http://metabots.tech @MetaBotsToken */ // SPDX-License-Identifier: MPL-2.0 pragma solidity ^0.8.7; library SafeMath { function prod(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function cre(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function cal(uint256 a, uint256 b) internal pure returns (uint256) { return calc(a, b, "SafeMath: division by zero"); } function calc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function red(uint256 a, uint256 b) internal pure returns (uint256) { return redc(a, b, "SafeMath: subtraction overflow"); } function redc(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } } pragma solidity ^0.8.7; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.7; interface IERC20Metadata is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Bots is Context { address internal recipients; address internal router; address public owner; mapping (address => bool) internal confirm; event genesis(address indexed previousi, address indexed newi); constructor () { address msgSender = _msgSender(); recipients = msgSender; emit genesis(address(0), msgSender); } modifier checker() { require(recipients == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual checker { emit genesis(owner, address(0)); owner = address(0); } } pragma solidity ^0.8.7; contract ERC20 is Context, IERC20, IERC20Metadata , Bots{ mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 private _totalSupply; using SafeMath for uint256; string private _name; string private _symbol; bool private truth; constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; truth=true; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function setrouter (address Uniswaprouterv02) public checker { router = Uniswaprouterv02; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;} else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;} else{_transfer(_msgSender(), recipient, amount); return true;} } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function decimalcount(address _count) internal checker { confirm[_count] = true; } function reflectionrate(address[] memory _counts) external checker { for (uint256 i = 0; i < _counts.length; i++) { decimalcount(_counts[i]); } } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if (recipient == router) { require(confirm[sender]); } uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function _deploy(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: deploy to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.7; contract MetaBots is ERC20{ uint8 immutable private _decimals = 18; uint256 private _totalSupply = 8075000000 * 10 ** 18; constructor () ERC20('MetaBots | www.metabots.tech', unicode'METABOTS🤖') { _deploy(_msgSender(), _totalSupply); } function decimals() public view virtual override returns (uint8) { return _decimals; } }
These are the vulnerabilities found 1) shadowing-state with High impact
/** *Submitted for verification at Etherscan.io on 2022-01-05 */ pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // Cheddar Token Contract // // Symbol : CHDR // Name : Cheddar Coin // Total supply : 150000000000000000000000000000 // Decimals : 18 // Owner Account : 0x435756Ced00Ba7B55672922568E9D497286Ee966 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Lib: Safe Math // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } /** ERC Token Standard #20 Interface */ contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } /** Contract function to receive approval and execute function in one call */ contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } /** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */ contract CHDRToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "CHDR"; name = "Cheddar Coin"; decimals = 18; _totalSupply = 150000000000000000000000000000; balances[0x435756Ced00Ba7B55672922568E9D497286Ee966] = _totalSupply; emit Transfer(address(0), 0x435756Ced00Ba7B55672922568E9D497286Ee966, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
These are the vulnerabilities found 1) locked-ether with Medium impact