Spaces:
Runtime error
Runtime error
File size: 98,547 Bytes
61b52c0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | {"task_id":"FormalEval/0","completion":" uint256 private storedValue;\n address public owner;\n bool private locked;\n\n event ValueStored(uint256 indexed newValue, address indexed sender);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n storedValue = 0;\n }\n\n /// @notice Stores a new value in the contract\n /// @param _value The value to be stored\n function store(uint256 _value) public onlyOwner nonReentrant {\n storedValue = _value;\n emit ValueStored(_value, msg.sender);\n }\n\n /// @notice Retrieves the currently stored value\n /// @return The stored uint256 value\n function retrieve() public view returns (uint256) {\n return storedValue;\n }\n}"}
{"task_id":"FormalEval/0","completion":" uint256 private storedValue;\n address public owner;\n bool private locked;\n\n event ValueStored(uint256 indexed newValue, address indexed sender);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n storedValue = 0;\n }\n\n /// @notice Stores a new value in the contract\n /// @param _value The value to be stored\n function store(uint256 _value) public onlyOwner nonReentrant {\n storedValue = _value;\n emit ValueStored(_value, msg.sender);\n }\n\n /// @notice Retrieves the currently stored value\n /// @return The stored uint256 value\n function retrieve() public view returns (uint256) {\n return storedValue;\n }\n}"}
{"task_id":"FormalEval/0","completion":" uint256 private storedValue;\n address private immutable owner;\n\n event ValueStored(uint256 indexed newValue, address indexed sender);\n\n error Unauthorized();\n\n modifier onlyOwner() {\n if (msg.sender != owner) revert Unauthorized();\n _;\n }\n\n constructor() {\n owner = msg.sender;\n storedValue = 0;\n }\n\n /// @notice Stores a new value in the contract\n /// @param _value The uint256 value to be stored\n function store(uint256 _value) external {\n storedValue = _value;\n emit ValueStored(_value, msg.sender);\n }\n\n /// @notice Retrieves the currently stored value\n /// @return The current uint256 value\n function retrieve() external view returns (uint256) {\n return storedValue;\n }\n}"}
{"task_id":"FormalEval/1","completion":"\n uint256 private count;\n bool private locked;\n\n event CounterIncremented(uint256 newValue);\n event CounterDecremented(uint256 newValue);\n\n modifier noReentrancy() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n count = 0;\n locked = false;\n }\n\n /// @notice Increases the counter by 1\n function increment() external noReentrancy {\n count += 1;\n emit CounterIncremented(count);\n }\n\n /// @notice Decreases the counter by 1\n /// @dev Reverts if the counter is 0 to prevent underflow\n function decrement() external noReentrancy {\n require(count > 0, \"Counter: cannot decrement below zero\");\n count -= 1;\n emit CounterDecremented(count);\n }\n\n /// @notice Returns the current counter value\n /// @return The current count\n function getCount() external view returns (uint256) {\n return count;\n }\n}"}
{"task_id":"FormalEval/1","completion":"\n uint256 private count;\n bool private locked;\n\n event Incremented(uint256 newValue);\n event Decremented(uint256 newValue);\n\n modifier noReentrancy() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n count = 0;\n locked = false;\n }\n\n /// @notice Increases the counter by 1\n function increment() external noReentrancy {\n count += 1;\n emit Incremented(count);\n }\n\n /// @notice Decreases the counter by 1\n /// @dev Reverts if the counter is already 0\n function decrement() external noReentrancy {\n require(count > 0, \"Counter: cannot decrement below zero\");\n count -= 1;\n emit Decremented(count);\n }\n\n /// @notice Returns the current counter value\n /// @return The current count\n function getCount() external view returns (uint256) {\n return count;\n }\n}"}
{"task_id":"FormalEval/1","completion":"\n uint256 private count;\n bool private locked;\n\n event Incremented(uint256 newValue);\n event Decremented(uint256 newValue);\n\n modifier noReentrancy() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n count = 0;\n locked = false;\n }\n\n /// @notice Increases the counter by 1\n function increment() external noReentrancy {\n count += 1;\n emit Incremented(count);\n }\n\n /// @notice Decreases the counter by 1\n /// @dev Reverts if the counter is 0 to prevent underflow\n function decrement() external noReentrancy {\n require(count > 0, \"Counter: cannot decrement below 0\");\n count -= 1;\n emit Decremented(count);\n }\n\n /// @notice Returns the current counter value\n /// @return The current count\n function getCount() external view returns (uint256) {\n return count;\n }\n}"}
{"task_id":"FormalEval/2","completion":"\n /// @notice Event emitted when an addition is performed\n event Addition(uint256 a, uint256 b, uint256 result);\n /// @notice Event emitted when a subtraction is performed\n event Subtraction(uint256 a, uint256 b, uint256 result);\n /// @notice Event emitted when a multiplication is performed\n event Multiplication(uint256 a, uint256 b, uint256 result);\n /// @notice Event emitted when a division is performed\n event Division(uint256 a, uint256 b, uint256 result);\n\n /// @notice Adds two numbers\n /// @param a First number\n /// @param b Second number\n /// @return result The sum of a and b\n function add(uint256 a, uint256 b) external returns (uint256 result) {\n result = a + b;\n emit Addition(a, b, result);\n }\n\n /// @notice Subtracts b from a\n /// @param a Minuend\n /// @param b Subtrahend\n /// @return result The difference of a and b\n function subtract(uint256 a, uint256 b) external returns (uint256 result) {\n require(a >= b, \"Calculator: subtraction result would be negative\");\n result = a - b;\n emit Subtraction(a, b, result);\n }\n\n /// @notice Multiplies two numbers\n /// @param a First number\n /// @param b Second number\n /// @return result The product of a and b\n function multiply(uint256 a, uint256 b) external returns (uint256 result) {\n result = a * b;\n emit Multiplication(a, b, result);\n }\n\n /// @notice Divides a by b\n /// @param a Dividend\n /// @param b Divisor\n /// @return result The quotient of a and b\n function divide(uint256 a, uint256 b) external returns (uint256 result) {\n require(b != 0, \"Calculator: division by zero\");\n result = a / b;\n emit Division(a, b, result);\n }\n}"}
{"task_id":"FormalEval/2","completion":"\n /// @notice Event emitted when an addition is performed\n event Addition(uint256 a, uint256 b, uint256 result);\n /// @notice Event emitted when a subtraction is performed\n event Subtraction(uint256 a, uint256 b, uint256 result);\n /// @notice Event emitted when a multiplication is performed\n event Multiplication(uint256 a, uint256 b, uint256 result);\n /// @notice Event emitted when a division is performed\n event Division(uint256 a, uint256 b, uint256 result);\n\n /// @notice Adds two numbers\n /// @param a First operand\n /// @param b Second operand\n /// @return result The sum of a and b\n function add(uint256 a, uint256 b) external returns (uint256 result) {\n result = a + b;\n emit Addition(a, b, result);\n }\n\n /// @notice Subtracts b from a\n /// @param a First operand\n /// @param b Second operand\n /// @return result The difference of a and b\n function subtract(uint256 a, uint256 b) external returns (uint256 result) {\n require(a >= b, \"Calculator: subtraction underflow\");\n result = a - b;\n emit Subtraction(a, b, result);\n }\n\n /// @notice Multiplies two numbers\n /// @param a First operand\n /// @param b Second operand\n /// @return result The product of a and b\n function multiply(uint256 a, uint256 b) external returns (uint256 result) {\n result = a * b;\n emit Multiplication(a, b, result);\n }\n\n /// @notice Divides a by b\n /// @param a First operand\n /// @param b Second operand\n /// @return result The quotient of a divided by b\n function divide(uint256 a, uint256 b) external returns (uint256 result) {\n require(b != 0, \"Calculator: division by zero\");\n result = a / b;\n emit Division(a, b, result);\n }\n}"}
{"task_id":"FormalEval/2","completion":"\n /// @notice Event emitted when an addition is performed\n event Addition(uint256 a, uint256 b, uint256 result);\n\n /// @notice Event emitted when a subtraction is performed\n event Subtraction(uint256 a, uint256 b, uint256 result);\n\n /// @notice Event emitted when a multiplication is performed\n event Multiplication(uint256 a, uint256 b, uint256 result);\n\n /// @notice Event emitted when a division is performed\n event Division(uint256 a, uint256 b, uint256 result);\n\n /// @notice Adds two numbers\n /// @param a First operand\n /// @param b Second operand\n /// @return The sum of a and b\n function add(uint256 a, uint256 b) external returns (uint256) {\n uint256 result = a + b;\n emit Addition(a, b, result);\n return result;\n }\n\n /// @notice Subtracts b from a\n /// @param a First operand\n /// @param b Second operand\n /// @return The difference of a and b\n /// @dev Reverts if b > a to prevent underflow\n function subtract(uint256 a, uint256 b) external returns (uint256) {\n require(a >= b, \"Calculator: subtraction result would be negative\");\n uint256 result = a - b;\n emit Subtraction(a, b, result);\n return result;\n }\n\n /// @notice Multiplies two numbers\n /// @param a First operand\n /// @param b Second operand\n /// @return The product of a and b\n function multiply(uint256 a, uint256 b) external returns (uint256) {\n uint256 result = a * b;\n emit Multiplication(a, b, result);\n return result;\n }\n\n /// @notice Divides a by b\n /// @param a First operand\n /// @param b Second operand\n /// @return The quotient of a and b\n /// @dev Reverts if b is 0\n function divide(uint256 a, uint256 b) external returns (uint256) {\n require(b != 0, \"Calculator: division by zero\");\n uint256 result = a / b;\n emit Division(a, b, result);\n return result;\n }\n}"}
{"task_id":"FormalEval/3","completion":" uint256[] private values;\n\n /// @notice Event emitted when a new value is added to the array\n event ValueAdded(uint256 value);\n\n /// @notice Appends a value to the array\n /// @param _value The value to be added\n function push(uint256 _value) external {\n values.push(_value);\n emit ValueAdded(_value);\n }\n\n /// @notice Returns the minimum value in the array\n /// @dev Reverts if the array is empty\n /// @return min The smallest value found\n function getMin() external view returns (uint256 min) {\n require(values.length > 0, \"Array is empty\");\n min = values[0];\n for (uint256 i = 1; i < values.length; i++) {\n if (values[i] < min) {\n min = values[i];\n }\n }\n }\n\n /// @notice Returns the maximum value in the array\n /// @dev Reverts if the array is empty\n /// @return max The largest value found\n function getMax() external view returns (uint256 max) {\n require(values.length > 0, \"Array is empty\");\n max = values[0];\n for (uint256 i = 1; i < values.length; i++) {\n if (values[i] > max) {\n max = values[i];\n }\n }\n }\n\n /// @notice Returns the number of elements in the array\n /// @return The length of the array\n function getLength() external view returns (uint256) {\n return values.length;\n }\n}"}
{"task_id":"FormalEval/3","completion":" uint256[] private values;\n\n /// @notice Event emitted when a new value is added\n event ValueAdded(uint256 value);\n\n /// @notice Appends a value to the array\n /// @param _value The value to be added\n function push(uint256 _value) external {\n values.push(_value);\n emit ValueAdded(_value);\n }\n\n /// @notice Returns the minimum value in the array\n /// @return min The smallest value found\n function getMin() external view returns (uint256 min) {\n require(values.length > 0, \"Array is empty\");\n min = values[0];\n for (uint256 i = 1; i < values.length; i++) {\n if (values[i] < min) {\n min = values[i];\n }\n }\n }\n\n /// @notice Returns the maximum value in the array\n /// @return max The largest value found\n function getMax() external view returns (uint256 max) {\n require(values.length > 0, \"Array is empty\");\n max = values[0];\n for (uint256 i = 1; i < values.length; i++) {\n if (values[i] > max) {\n max = values[i];\n }\n }\n }\n\n /// @notice Returns the number of elements in the array\n /// @return length The total count of elements\n function getLength() external view returns (uint256 length) {\n return values.length;\n }\n}"}
{"task_id":"FormalEval/3","completion":" uint256[] private values;\n\n /// @notice Event emitted when a new value is added to the array\n event ValueAdded(uint256 indexed value);\n\n /// @notice Appends a value to the array\n /// @param _value The value to be added\n function push(uint256 _value) external {\n values.push(_value);\n emit ValueAdded(_value);\n }\n\n /// @notice Returns the minimum value in the array\n /// @return min The smallest value found\n function getMin() external view returns (uint256 min) {\n require(values.length > 0, \"Array is empty\");\n min = values[0];\n for (uint256 i = 1; i < values.length; i++) {\n if (values[i] < min) {\n min = values[i];\n }\n }\n }\n\n /// @notice Returns the maximum value in the array\n /// @return max The largest value found\n function getMax() external view returns (uint256 max) {\n require(values.length > 0, \"Array is empty\");\n max = values[0];\n for (uint256 i = 1; i < values.length; i++) {\n if (values[i] > max) {\n max = values[i];\n }\n }\n }\n\n /// @notice Returns the number of elements in the array\n /// @return length The total count of elements\n function getLength() external view returns (uint256 length) {\n return values.length;\n }\n}"}
{"task_id":"FormalEval/4","completion":" mapping(address => string) private _names;\n mapping(address => bool) private _registered;\n\n /// @notice Emitted when a new name is registered\n event Registered(address indexed user, string name);\n\n /// @notice Emitted when a registration is removed\n event Unregistered(address indexed user);\n\n /// @notice Registers the caller with a specific name\n /// @param _name The name to associate with the sender's address\n function register(string calldata _name) external {\n require(bytes(_name).length > 0, \"Name cannot be empty\");\n _names[msg.sender] = _name;\n _registered[msg.sender] = true;\n emit Registered(msg.sender, _name);\n }\n\n /// @notice Returns the name associated with an address\n /// @param _addr The address to query\n /// @return The registered name\n function getName(address _addr) external view returns (string memory) {\n return _names[_addr];\n }\n\n /// @notice Checks if an address is registered\n /// @param _addr The address to check\n /// @return True if registered, false otherwise\n function isRegistered(address _addr) external view returns (bool) {\n return _registered[_addr];\n }\n\n /// @notice Removes the registration for the caller\n function unregister() external {\n require(_registered[msg.sender], \"Address not registered\");\n delete _names[msg.sender];\n delete _registered[msg.sender];\n emit Unregistered(msg.sender);\n }\n}"}
{"task_id":"FormalEval/4","completion":" mapping(address => string) private _names;\n mapping(address => bool) private _registered;\n\n /// @notice Emitted when a new name is registered\n event Registered(address indexed user, string name);\n\n /// @notice Emitted when a registration is removed\n event Unregistered(address indexed user);\n\n /// @notice Registers the caller with a specific name\n /// @param _name The name to associate with the sender's address\n function register(string calldata _name) external {\n require(bytes(_name).length > 0, \"Name cannot be empty\");\n _names[msg.sender] = _name;\n _registered[msg.sender] = true;\n emit Registered(msg.sender, _name);\n }\n\n /// @notice Retrieves the name associated with an address\n /// @param _addr The address to query\n /// @return The registered name or an empty string\n function getName(address _addr) external view returns (string memory) {\n return _names[_addr];\n }\n\n /// @notice Checks if an address is registered\n /// @param _addr The address to check\n /// @return True if registered, false otherwise\n function isRegistered(address _addr) external view returns (bool) {\n return _registered[_addr];\n }\n\n /// @notice Removes the registration for the caller\n function unregister() external {\n require(_registered[msg.sender], \"Address not registered\");\n delete _names[msg.sender];\n delete _registered[msg.sender];\n emit Unregistered(msg.sender);\n }\n}"}
{"task_id":"FormalEval/4","completion":" mapping(address => string) private _names;\n mapping(address => bool) private _registered;\n\n event Registered(address indexed user, string name);\n event Unregistered(address indexed user);\n\n /// @notice Registers the caller with a specific name.\n /// @param _name The name to associate with the caller's address.\n function register(string calldata _name) external {\n require(bytes(_name).length > 0, \"Name cannot be empty\");\n _names[msg.sender] = _name;\n _registered[msg.sender] = true;\n emit Registered(msg.sender, _name);\n }\n\n /// @notice Retrieves the name associated with an address.\n /// @param _addr The address to query.\n /// @return The registered name or an empty string.\n function getName(address _addr) external view returns (string memory) {\n return _names[_addr];\n }\n\n /// @notice Checks if an address is registered.\n /// @param _addr The address to check.\n /// @return True if registered, false otherwise.\n function isRegistered(address _addr) external view returns (bool) {\n return _registered[_addr];\n }\n\n /// @notice Removes the registration for the caller.\n function unregister() external {\n require(_registered[msg.sender], \"Address not registered\");\n delete _names[msg.sender];\n delete _registered[msg.sender];\n emit Unregistered(msg.sender);\n }\n}"}
{"task_id":"FormalEval/5","completion":"\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n uint256 private _totalSupply;\n address private _owner;\n mapping(address => uint256) private _balances;\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n modifier onlyOwner() {\n require(msg.sender == _owner, \"BasicToken: caller is not the owner\");\n _;\n }\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_) {\n _name = name_;\n _symbol = symbol_;\n _decimals = decimals_;\n _owner = msg.sender;\n }\n\n function name() public view returns (string memory) {\n return _name;\n }\n\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n function decimals() public view returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() public view returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) public view returns (uint256) {\n return _balances[account];\n }\n\n function mint(address to, uint256 amount) public onlyOwner {\n require(to != address(0), \"BasicToken: mint to the zero address\");\n\n _totalSupply += amount;\n _balances[to] += amount;\n emit Transfer(address(0), to, amount);\n }\n\n function transfer(address to, uint256 amount) public returns (bool) {\n require(to != address(0), \"BasicToken: transfer to the zero address\");\n require(_balances[msg.sender] >= amount, \"BasicToken: insufficient balance\");\n\n _balances[msg.sender] -= amount;\n _balances[to] += amount;\n \n emit Transfer(msg.sender, to, amount);\n return true;\n }\n}"}
{"task_id":"FormalEval/5","completion":"\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n uint256 private _totalSupply;\n address private _owner;\n\n mapping(address => uint256) private _balances;\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n modifier onlyOwner() {\n require(msg.sender == _owner, \"BasicToken: caller is not the owner\");\n _;\n }\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_) {\n _name = name_;\n _symbol = symbol_;\n _decimals = decimals_;\n _owner = msg.sender;\n }\n\n function name() external view returns (string memory) {\n return _name;\n }\n\n function symbol() external view returns (string memory) {\n return _symbol;\n }\n\n function decimals() external view returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() external view returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) external view returns (uint256) {\n return _balances[account];\n }\n\n function mint(address to, uint256 amount) external onlyOwner {\n require(to != address(0), \"BasicToken: mint to the zero address\");\n\n _totalSupply += amount;\n _balances[to] += amount;\n emit Transfer(address(0), to, amount);\n }\n\n function transfer(address to, uint256 amount) external returns (bool) {\n require(to != address(0), \"BasicToken: transfer to the zero address\");\n require(_balances[msg.sender] >= amount, \"BasicToken: insufficient balance\");\n\n _balances[msg.sender] -= amount;\n _balances[to] += amount;\n \n emit Transfer(msg.sender, to, amount);\n return true;\n }\n}"}
{"task_id":"FormalEval/5","completion":"\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n uint256 private _totalSupply;\n address private _owner;\n mapping(address => uint256) private _balances;\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n modifier onlyOwner() {\n require(msg.sender == _owner, \"BasicToken: caller is not the owner\");\n _;\n }\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_) {\n _name = name_;\n _symbol = symbol_;\n _decimals = decimals_;\n _owner = msg.sender;\n }\n\n function name() external view returns (string memory) {\n return _name;\n }\n\n function symbol() external view returns (string memory) {\n return _symbol;\n }\n\n function decimals() external view returns (uint8) {\n return _decimals;\n }\n\n function totalSupply() external view returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) external view returns (uint256) {\n return _balances[account];\n }\n\n function mint(address to, uint256 amount) external onlyOwner {\n require(to != address(0), \"BasicToken: mint to the zero address\");\n \n _totalSupply += amount;\n _balances[to] += amount;\n \n emit Transfer(address(0), to, amount);\n }\n\n function transfer(address to, uint256 amount) external returns (bool) {\n require(to != address(0), \"BasicToken: transfer to the zero address\");\n require(_balances[msg.sender] >= amount, \"BasicToken: insufficient balance\");\n\n _balances[msg.sender] -= amount;\n _balances[to] += amount;\n\n emit Transfer(msg.sender, to, amount);\n return true;\n }\n}"}
{"task_id":"FormalEval/6","completion":"\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n error Unauthorized();\n error InvalidOwner();\n\n constructor() {\n _owner = msg.sender;\n emit OwnershipTransferred(address(0), msg.sender);\n }\n\n modifier onlyOwner() {\n if (msg.sender != _owner) revert Unauthorized();\n _;\n }\n\n /// @notice Returns the address of the current owner.\n function owner() public view returns (address) {\n return _owner;\n }\n\n /// @notice Transfers ownership of the contract to a new account (`newOwner`).\n /// @param newOwner The address to transfer ownership to.\n function transferOwnership(address newOwner) public onlyOwner {\n if (newOwner == address(0)) revert InvalidOwner();\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /// @notice Leaves the contract without owner. It will not be possible to call\n /// `onlyOwner` functions anymore.\n function renounceOwnership() public onlyOwner {\n address oldOwner = _owner;\n _owner = address(0);\n emit OwnershipTransferred(oldOwner, address(0));\n }\n}"}
{"task_id":"FormalEval/6","completion":"\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /// @notice Sets the initial owner of the contract as the deployer.\n constructor() {\n _owner = msg.sender;\n emit OwnershipTransferred(address(0), msg.sender);\n }\n\n /// @notice Returns the address of the current owner.\n function owner() public view returns (address) {\n return _owner;\n }\n\n /// @notice Throws if called by any account other than the owner.\n modifier onlyOwner() {\n require(msg.sender == _owner, \"Ownable: caller is not the owner\");\n _;\n }\n\n /// @notice Transfers ownership of the contract to a new account (`newOwner`).\n /// @param newOwner The address to transfer ownership to.\n function transferOwnership(address newOwner) public onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /// @notice Leaves the contract without owner. It will not be possible to call\n /// `onlyOwner` functions anymore.\n function renounceOwnership() public onlyOwner {\n address oldOwner = _owner;\n _owner = address(0);\n emit OwnershipTransferred(oldOwner, address(0));\n }\n}"}
{"task_id":"FormalEval/6","completion":"\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /// @notice Sets the initial owner of the contract as the deployer.\n constructor() {\n _owner = msg.sender;\n emit OwnershipTransferred(address(0), msg.sender);\n }\n\n /// @notice Returns the address of the current owner.\n function owner() public view returns (address) {\n return _owner;\n }\n\n /// @notice Throws if called by any account other than the owner.\n modifier onlyOwner() {\n require(msg.sender == _owner, \"Ownable: caller is not the owner\");\n _;\n }\n\n /// @notice Transfers ownership of the contract to a new account (`newOwner`).\n /// @param newOwner The address to transfer ownership to.\n function transferOwnership(address newOwner) public onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /// @notice Leaves the contract without owner. It will not be possible to call\n /// `onlyOwner` functions anymore.\n function renounceOwnership() public onlyOwner {\n address oldOwner = _owner;\n _owner = address(0);\n emit OwnershipTransferred(oldOwner, address(0));\n }\n}"}
{"task_id":"FormalEval/7","completion":"\n address public owner;\n uint256 public maxWhitelistedAddresses;\n uint256 public numWhitelistedCount;\n\n mapping(address => bool) public whitelistedAddresses;\n\n event AddedToWhitelist(address indexed account);\n event RemovedFromWhitelist(address indexed account);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n constructor(uint256 _maxWhitelistedAddresses) {\n require(_maxWhitelistedAddresses > 0, \"Max capacity must be greater than 0\");\n owner = msg.sender;\n maxWhitelistedAddresses = _maxWhitelistedAddresses;\n }\n\n /// @notice Adds the caller to the whitelist\n function addToWhitelist() external {\n require(!whitelistedAddresses[msg.sender], \"Address is already whitelisted\");\n require(numWhitelistedCount < maxWhitelistedAddresses, \"Whitelist is full\");\n\n whitelistedAddresses[msg.sender] = true;\n numWhitelistedCount += 1;\n\n emit AddedToWhitelist(msg.sender);\n }\n\n /// @notice Removes an address from the whitelist\n /// @param _addr The address to remove\n function removeFromWhitelist(address _addr) external onlyOwner {\n require(whitelistedAddresses[_addr], \"Address is not in the whitelist\");\n\n whitelistedAddresses[_addr] = false;\n numWhitelistedCount -= 1;\n\n emit RemovedFromWhitelist(_addr);\n }\n\n /// @notice Checks if an address is whitelisted\n /// @param _addr The address to check\n function isWhitelisted(address _addr) external view returns (bool) {\n return whitelistedAddresses[_addr];\n }\n\n /// @notice Returns the current number of whitelisted addresses\n function getNumWhitelisted() external view returns (uint256) {\n return numWhitelistedCount;\n }\n\n /// @notice Returns the maximum capacity\n function maxWhitelisted() external view returns (uint256) {\n return maxWhitelistedAddresses;\n }\n}"}
{"task_id":"FormalEval/7","completion":"\n address public owner;\n uint256 public maxWhitelistedAddresses;\n uint256 public numWhitelistedCount;\n\n mapping(address => bool) public whitelistedAddresses;\n\n event AddedToWhitelist(address indexed account);\n event RemovedFromWhitelist(address indexed account);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n constructor(uint256 _maxWhitelistedAddresses) {\n require(_maxWhitelistedAddresses > 0, \"Max capacity must be greater than 0\");\n owner = msg.sender;\n maxWhitelistedAddresses = _maxWhitelistedAddresses;\n }\n\n /// @notice Adds the caller to the whitelist\n function addToWhitelist() external {\n require(!whitelistedAddresses[msg.sender], \"Address is already whitelisted\");\n require(numWhitelistedCount < maxWhitelistedAddresses, \"Whitelist capacity reached\");\n\n whitelistedAddresses[msg.sender] = true;\n numWhitelistedCount += 1;\n\n emit AddedToWhitelist(msg.sender);\n }\n\n /// @notice Removes an address from the whitelist\n /// @param _addr The address to remove\n function removeFromWhitelist(address _addr) external onlyOwner {\n require(whitelistedAddresses[_addr], \"Address is not in the whitelist\");\n\n whitelistedAddresses[_addr] = false;\n numWhitelistedCount -= 1;\n\n emit RemovedFromWhitelist(_addr);\n }\n\n /// @notice Checks if an address is whitelisted\n function isWhitelisted(address _addr) external view returns (bool) {\n return whitelistedAddresses[_addr];\n }\n\n /// @notice Returns the current number of whitelisted addresses\n function getNumWhitelisted() external view returns (uint256) {\n return numWhitelistedCount;\n }\n\n /// @notice Returns the maximum capacity\n function maxWhitelisted() external view returns (uint256) {\n return maxWhitelistedAddresses;\n }\n}"}
{"task_id":"FormalEval/7","completion":"\n address public owner;\n uint256 public maxWhitelistedAddresses;\n uint256 public numWhitelistedCount;\n\n mapping(address => bool) public whitelistedAddresses;\n\n event AddedToWhitelist(address indexed account);\n event RemovedFromWhitelist(address indexed account);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n constructor(uint256 _maxWhitelistedAddresses) {\n require(_maxWhitelistedAddresses > 0, \"Max capacity must be greater than 0\");\n owner = msg.sender;\n maxWhitelistedAddresses = _maxWhitelistedAddresses;\n }\n\n /// @notice Adds the caller to the whitelist\n function addToWhitelist() external {\n require(!whitelistedAddresses[msg.sender], \"Address is already whitelisted\");\n require(numWhitelistedCount < maxWhitelistedAddresses, \"Whitelist is full\");\n\n whitelistedAddresses[msg.sender] = true;\n numWhitelistedCount += 1;\n\n emit AddedToWhitelist(msg.sender);\n }\n\n /// @notice Removes an address from the whitelist\n /// @param _addr The address to be removed\n function removeFromWhitelist(address _addr) external onlyOwner {\n require(whitelistedAddresses[_addr], \"Address is not in the whitelist\");\n\n whitelistedAddresses[_addr] = false;\n numWhitelistedCount -= 1;\n\n emit RemovedFromWhitelist(_addr);\n }\n\n /// @notice Checks if an address is whitelisted\n /// @param _addr The address to check\n function isWhitelisted(address _addr) external view returns (bool) {\n return whitelistedAddresses[_addr];\n }\n\n /// @notice Returns the current number of whitelisted addresses\n function getNumWhitelisted() external view returns (uint256) {\n return numWhitelistedCount;\n }\n\n /// @notice Returns the maximum capacity of the whitelist\n function maxWhitelisted() external view returns (uint256) {\n return maxWhitelistedAddresses;\n }\n}"}
{"task_id":"FormalEval/8","completion":" address private owner;\n bool private locked;\n\n struct LockInfo {\n uint256 amount;\n uint256 unlockTime;\n }\n\n mapping(address => LockInfo) private locks;\n\n event Deposit(address indexed sender, uint256 amount, uint256 unlockTime);\n event Withdrawal(address indexed sender, uint256 amount);\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n /// @notice Locks ETH until the specified unlockTime\n /// @param unlockTime The timestamp when the funds can be withdrawn\n function deposit(uint256 unlockTime) external payable {\n require(msg.value > 0, \"Amount must be greater than 0\");\n require(unlockTime > block.timestamp, \"Unlock time must be in the future\");\n require(locks[msg.sender].amount == 0, \"Existing lock found, withdraw first\");\n\n locks[msg.sender] = LockInfo({\n amount: msg.value,\n unlockTime: unlockTime\n });\n\n emit Deposit(msg.sender, msg.value, unlockTime);\n }\n\n /// @notice Withdraws all locked ETH if the unlock time has passed\n function withdraw() external nonReentrant {\n LockInfo storage userLock = locks[msg.sender];\n \n require(userLock.amount > 0, \"No locked funds\");\n require(block.timestamp >= userLock.unlockTime, \"Funds are still locked\");\n\n uint256 amountToWithdraw = userLock.amount;\n \n userLock.amount = 0;\n userLock.unlockTime = 0;\n\n (bool success, ) = payable(msg.sender).call{value: amountToWithdraw}(\"\");\n require(success, \"Transfer failed\");\n\n emit Withdrawal(msg.sender, amountToWithdraw);\n }\n\n /// @notice Returns the locked balance for a specific address\n /// @param _addr The address to query\n function getBalance(address _addr) external view returns (uint256) {\n return locks[_addr].amount;\n }\n\n /// @notice Returns the unlock time for a specific address\n /// @param _addr The address to query\n function getUnlockTime(address _addr) external view returns (uint256) {\n return locks[_addr].unlockTime;\n }\n}"}
{"task_id":"FormalEval/8","completion":" address private owner;\n bool private locked;\n\n mapping(address => uint256) private balances;\n mapping(address => uint256) private unlockTimes;\n\n event Deposit(address indexed sender, uint256 amount, uint256 unlockTime);\n event Withdrawal(address indexed sender, uint256 amount);\n\n modifier nonReentrant() {\n require(!locked, \"ReentrancyGuard: reentrant call\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n /// @notice Locks ETH until the specified unlock time.\n /// @param unlockTime The timestamp when the funds can be withdrawn.\n function deposit(uint256 unlockTime) external payable {\n require(msg.value > 0, \"Amount must be greater than 0\");\n require(unlockTime > block.timestamp, \"Unlock time must be in the future\");\n \n balances[msg.sender] += msg.value;\n unlockTimes[msg.sender] = unlockTime;\n\n emit Deposit(msg.sender, msg.value, unlockTime);\n }\n\n /// @notice Withdraws all locked ETH for the sender if the unlock time has passed.\n function withdraw() external nonReentrant {\n uint256 amount = balances[msg.sender];\n uint256 unlockTime = unlockTimes[msg.sender];\n\n require(amount > 0, \"No funds to withdraw\");\n require(block.timestamp >= unlockTime, \"Funds are still locked\");\n\n balances[msg.sender] = 0;\n unlockTimes[msg.sender] = 0;\n\n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n\n emit Withdrawal(msg.sender, amount);\n }\n\n /// @notice Returns the locked balance for a specific address.\n /// @param _addr The address to query.\n function getBalance(address _addr) external view returns (uint256) {\n return balances[_addr];\n }\n\n /// @notice Returns the unlock time for a specific address.\n /// @param _addr The address to query.\n function getUnlockTime(address _addr) external view returns (uint256) {\n return unlockTimes[_addr];\n }\n}"}
{"task_id":"FormalEval/8","completion":"\n address private owner;\n bool private locked;\n\n mapping(address => uint256) private balances;\n mapping(address => uint256) private unlockTimes;\n\n event Deposit(address indexed sender, uint256 amount, uint256 unlockTime);\n event Withdrawal(address indexed sender, uint256 amount);\n\n modifier nonReentrant() {\n require(!locked, \"ReentrancyGuard: reentrant call\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n /// @notice Locks ETH until the specified unlockTime\n /// @param unlockTime The timestamp when the funds can be withdrawn\n function deposit(uint256 unlockTime) external payable {\n require(msg.value > 0, \"Amount must be greater than 0\");\n require(unlockTime > block.timestamp, \"Unlock time must be in the future\");\n \n balances[msg.sender] += msg.value;\n unlockTimes[msg.sender] = unlockTime;\n\n emit Deposit(msg.sender, msg.value, unlockTime);\n }\n\n /// @notice Withdraws all locked ETH for the sender\n function withdraw() external nonReentrant {\n uint256 amount = balances[msg.sender];\n uint256 unlockTime = unlockTimes[msg.sender];\n\n require(amount > 0, \"No funds to withdraw\");\n require(block.timestamp >= unlockTime, \"Funds are still locked\");\n\n balances[msg.sender] = 0;\n unlockTimes[msg.sender] = 0;\n\n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n\n emit Withdrawal(msg.sender, amount);\n }\n\n /// @notice Returns the locked balance for a specific address\n /// @param _addr The address to query\n function getBalance(address _addr) external view returns (uint256) {\n return balances[_addr];\n }\n\n /// @notice Returns the unlock time for a specific address\n /// @param _addr The address to query\n function getUnlockTime(address _addr) external view returns (uint256) {\n return unlockTimes[_addr];\n }\n}"}
{"task_id":"FormalEval/9","completion":" address public owner;\n\n struct Proposal {\n string description;\n uint256 voteCount;\n }\n\n Proposal[] private proposals;\n mapping(uint256 => mapping(address => bool)) private votes;\n bool private locked;\n\n event ProposalCreated(uint256 indexed proposalId, string description);\n event Voted(uint256 indexed proposalId, address indexed voter);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n /// @notice Creates a new proposal\n /// @param description The text description of the proposal\n /// @return proposalId The index of the created proposal\n function createProposal(string calldata description) external onlyOwner returns (uint256) {\n uint256 proposalId = proposals.length;\n proposals.push(Proposal({\n description: description,\n voteCount: 0\n }));\n emit ProposalCreated(proposalId, description);\n return proposalId;\n }\n\n /// @notice Casts a vote for a specific proposal\n /// @param proposalId The ID of the proposal to vote for\n function vote(uint256 proposalId) external nonReentrant {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n require(!votes[proposalId][msg.sender], \"Already voted on this proposal\");\n\n votes[proposalId][msg.sender] = true;\n proposals[proposalId].voteCount += 1;\n\n emit Voted(proposalId, msg.sender);\n }\n\n /// @notice Retrieves proposal details\n /// @param proposalId The ID of the proposal\n /// @return description The proposal description\n /// @return voteCount The current number of votes\n function getProposal(uint256 proposalId) external view returns (string memory, uint256) {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n Proposal storage p = proposals[proposalId];\n return (p.description, p.voteCount);\n }\n\n /// @notice Returns the total number of proposals created\n function getProposalCount() external view returns (uint256) {\n return proposals.length;\n }\n\n /// @notice Checks if an address has already voted on a proposal\n /// @param proposalId The ID of the proposal\n /// @param voter The address to check\n function hasVoted(uint256 proposalId, address voter) external view returns (bool) {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n return votes[proposalId][voter];\n }\n}"}
{"task_id":"FormalEval/9","completion":" address public owner;\n\n struct Proposal {\n string description;\n uint256 voteCount;\n }\n\n Proposal[] private proposals;\n mapping(uint256 => mapping(address => bool)) private votes;\n bool private locked;\n\n event ProposalCreated(uint256 indexed proposalId, string description);\n event Voted(uint256 indexed proposalId, address indexed voter);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n /// @notice Creates a new proposal\n /// @param description The text description of the proposal\n /// @return proposalId The ID of the newly created proposal\n function createProposal(string calldata description) external onlyOwner returns (uint256) {\n uint256 proposalId = proposals.length;\n proposals.push(Proposal({\n description: description,\n voteCount: 0\n }));\n emit ProposalCreated(proposalId, description);\n return proposalId;\n }\n\n /// @notice Casts a vote for a specific proposal\n /// @param proposalId The ID of the proposal to vote for\n function vote(uint256 proposalId) external nonReentrant {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n require(!votes[proposalId][msg.sender], \"Already voted on this proposal\");\n\n votes[proposalId][msg.sender] = true;\n proposals[proposalId].voteCount += 1;\n\n emit Voted(proposalId, msg.sender);\n }\n\n /// @notice Retrieves proposal details\n /// @param proposalId The ID of the proposal\n /// @return description The proposal description\n /// @return voteCount The current number of votes\n function getProposal(uint256 proposalId) external view returns (string memory, uint256) {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n Proposal storage p = proposals[proposalId];\n return (p.description, p.voteCount);\n }\n\n /// @notice Returns the total number of proposals\n function getProposalCount() external view returns (uint256) {\n return proposals.length;\n }\n\n /// @notice Checks if an address has already voted on a proposal\n /// @param proposalId The ID of the proposal\n /// @param voter The address to check\n function hasVoted(uint256 proposalId, address voter) external view returns (bool) {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n return votes[proposalId][voter];\n }\n}"}
{"task_id":"FormalEval/9","completion":" address public owner;\n\n struct Proposal {\n string description;\n uint256 voteCount;\n }\n\n Proposal[] private proposals;\n mapping(uint256 => mapping(address => bool)) private votes;\n bool private locked;\n\n event ProposalCreated(uint256 indexed proposalId, string description);\n event Voted(uint256 indexed proposalId, address indexed voter);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the contract owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n /// @notice Creates a new proposal\n /// @param description The text description of the proposal\n /// @return proposalId The ID of the newly created proposal\n function createProposal(string calldata description) external onlyOwner returns (uint256) {\n uint256 proposalId = proposals.length;\n proposals.push(Proposal({\n description: description,\n voteCount: 0\n }));\n emit ProposalCreated(proposalId, description);\n return proposalId;\n }\n\n /// @notice Casts a vote for a specific proposal\n /// @param proposalId The ID of the proposal to vote for\n function vote(uint256 proposalId) external nonReentrant {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n require(!votes[proposalId][msg.sender], \"Already voted on this proposal\");\n\n votes[proposalId][msg.sender] = true;\n proposals[proposalId].voteCount += 1;\n\n emit Voted(proposalId, msg.sender);\n }\n\n /// @notice Retrieves details of a proposal\n /// @param proposalId The ID of the proposal\n /// @return description The proposal description\n /// @return voteCount The current number of votes\n function getProposal(uint256 proposalId) external view returns (string memory, uint256) {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n Proposal storage p = proposals[proposalId];\n return (p.description, p.voteCount);\n }\n\n /// @notice Returns the total number of proposals\n function getProposalCount() external view returns (uint256) {\n return proposals.length;\n }\n\n /// @notice Checks if an address has voted on a specific proposal\n /// @param proposalId The ID of the proposal\n /// @param voter The address to check\n function hasVoted(uint256 proposalId, address voter) external view returns (bool) {\n require(proposalId < proposals.length, \"Invalid proposal ID\");\n return votes[proposalId][voter];\n }\n}"}
{"task_id":"FormalEval/10","completion":"\n address[] public owners;\n mapping(address => bool) public isOwner;\n uint256 public numConfirmationsRequired;\n\n struct Transaction {\n address to;\n uint256 value;\n bytes data;\n bool executed;\n uint256 numConfirmations;\n }\n\n Transaction[] public transactions;\n mapping(uint256 => mapping(address => bool)) public isConfirmed;\n\n event SubmitTransaction(address indexed owner, uint256 indexed txIndex, address indexed to, uint256 value, bytes data);\n event ConfirmTransaction(address indexed owner, uint256 indexed txIndex);\n event RevokeConfirmation(address indexed owner, uint256 indexed txIndex);\n event ExecuteTransaction(address indexed owner, uint256 indexed txIndex);\n\n modifier onlyOwner() {\n require(isOwner[msg.sender], \"Not an owner\");\n _;\n }\n\n modifier txExists(uint256 _txIndex) {\n require(_txIndex < transactions.length, \"Transaction does not exist\");\n _;\n }\n\n modifier notExecuted(uint256 _txIndex) {\n require(!transactions[_txIndex].executed, \"Transaction already executed\");\n _;\n }\n\n modifier notConfirmed(uint256 _txIndex) {\n require(!isConfirmed[_txIndex][msg.sender], \"Transaction already confirmed\");\n _;\n }\n\n constructor(address[] memory _owners, uint256 _numConfirmationsRequired) {\n require(_owners.length > 0, \"Owners required\");\n require(_numConfirmationsRequired > 0 && _numConfirmationsRequired <= _owners.length, \"Invalid number of required confirmations\");\n\n for (uint256 i = 0; i < _owners.length; i++) {\n address owner = _owners[i];\n require(owner != address(0), \"Invalid owner\");\n require(!isOwner[owner], \"Owner not unique\");\n\n isOwner[owner] = true;\n owners.push(owner);\n }\n\n numConfirmationsRequired = _numConfirmationsRequired;\n }\n\n receive() external payable {}\n\n function submitTransaction(address _to, uint256 _value, bytes calldata _data) external onlyOwner {\n uint256 txIndex = transactions.length;\n transactions.push(Transaction({\n to: _to,\n value: _value,\n data: _data,\n executed: false,\n numConfirmations: 0\n }));\n emit SubmitTransaction(msg.sender, txIndex, _to, _value, _data);\n }\n\n function confirmTransaction(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) notConfirmed(_txIndex) {\n Transaction storage transaction = transactions[_txIndex];\n transaction.numConfirmations += 1;\n isConfirmed[_txIndex][msg.sender] = true;\n emit ConfirmTransaction(msg.sender, _txIndex);\n }\n\n function executeTransaction(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) {\n Transaction storage transaction = transactions[_txIndex];\n require(transaction.numConfirmations >= numConfirmationsRequired, \"Cannot execute: insufficient confirmations\");\n\n transaction.executed = true;\n (bool success, ) = transaction.to.call{value: transaction.value}(transaction.data);\n require(success, \"Transaction failed\");\n\n emit ExecuteTransaction(msg.sender, _txIndex);\n }\n\n function revokeConfirmation(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) {\n require(isConfirmed[_txIndex][msg.sender], \"Transaction not confirmed\");\n Transaction storage transaction = transactions[_txIndex];\n transaction.numConfirmations -= 1;\n isConfirmed[_txIndex][msg.sender] = false;\n emit RevokeConfirmation(msg.sender, _txIndex);\n }\n\n function getTransactionCount() external view returns (uint256) {\n return transactions.length;\n }\n\n function getTransaction(uint256 _txIndex) external view returns (address to, uint256 value, bytes memory data, bool executed, uint256 numConfirmations) {\n Transaction storage transaction = transactions[_txIndex];\n return (transaction.to, transaction.value, transaction.data, transaction.executed, transaction.numConfirmations);\n }\n\n function getOwners() external view returns (address[] memory) {\n return owners;\n }\n}"}
{"task_id":"FormalEval/10","completion":"\n address[] public owners;\n mapping(address => bool) public isOwner;\n uint256 public numConfirmationsRequired;\n\n struct Transaction {\n address to;\n uint256 value;\n bytes data;\n bool executed;\n uint256 numConfirmations;\n }\n\n Transaction[] public transactions;\n mapping(uint256 => mapping(address => bool)) public isConfirmed;\n\n event SubmitTransaction(address indexed owner, uint256 indexed txIndex, address indexed to, uint256 value, bytes data);\n event ConfirmTransaction(address indexed owner, uint256 indexed txIndex);\n event RevokeConfirmation(address indexed owner, uint256 indexed txIndex);\n event ExecuteTransaction(address indexed owner, uint256 indexed txIndex);\n\n modifier onlyOwner() {\n require(isOwner[msg.sender], \"Not an owner\");\n _;\n }\n\n modifier txExists(uint256 _txIndex) {\n require(_txIndex < transactions.length, \"Transaction does not exist\");\n _;\n }\n\n modifier notExecuted(uint256 _txIndex) {\n require(!transactions[_txIndex].executed, \"Transaction already executed\");\n _;\n }\n\n modifier notConfirmed(uint256 _txIndex) {\n require(!isConfirmed[_txIndex][msg.sender], \"Transaction already confirmed\");\n _;\n }\n\n constructor(address[] memory _owners, uint256 _numConfirmationsRequired) {\n require(_owners.length > 0, \"Owners required\");\n require(_numConfirmationsRequired > 0 && _numConfirmationsRequired <= _owners.length, \"Invalid number of required confirmations\");\n\n for (uint256 i = 0; i < _owners.length; i++) {\n address owner = _owners[i];\n require(owner != address(0), \"Invalid owner\");\n require(!isOwner[owner], \"Owner not unique\");\n\n isOwner[owner] = true;\n owners.push(owner);\n }\n\n numConfirmationsRequired = _numConfirmationsRequired;\n }\n\n receive() external payable {}\n\n function submitTransaction(address _to, uint256 _value, bytes calldata _data) external onlyOwner {\n uint256 txIndex = transactions.length;\n transactions.push(Transaction({\n to: _to,\n value: _value,\n data: _data,\n executed: false,\n numConfirmations: 0\n }));\n emit SubmitTransaction(msg.sender, txIndex, _to, _value, _data);\n }\n\n function confirmTransaction(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) notConfirmed(_txIndex) {\n Transaction storage transaction = transactions[_txIndex];\n transaction.numConfirmations += 1;\n isConfirmed[_txIndex][msg.sender] = true;\n emit ConfirmTransaction(msg.sender, _txIndex);\n }\n\n function executeTransaction(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) {\n Transaction storage transaction = transactions[_txIndex];\n require(transaction.numConfirmations >= numConfirmationsRequired, \"Cannot execute: insufficient confirmations\");\n\n transaction.executed = true;\n (bool success, ) = transaction.to.call{value: transaction.value}(transaction.data);\n require(success, \"Transaction failed\");\n\n emit ExecuteTransaction(msg.sender, _txIndex);\n }\n\n function revokeConfirmation(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) {\n require(isConfirmed[_txIndex][msg.sender], \"Transaction not confirmed\");\n Transaction storage transaction = transactions[_txIndex];\n transaction.numConfirmations -= 1;\n isConfirmed[_txIndex][msg.sender] = false;\n emit RevokeConfirmation(msg.sender, _txIndex);\n }\n\n function getTransactionCount() external view returns (uint256) {\n return transactions.length;\n }\n\n function getTransaction(uint256 _txIndex) external view returns (address to, uint256 value, bytes memory data, bool executed, uint256 numConfirmations) {\n Transaction storage transaction = transactions[_txIndex];\n return (transaction.to, transaction.value, transaction.data, transaction.executed, transaction.numConfirmations);\n }\n\n function getOwners() external view returns (address[] memory) {\n return owners;\n }\n}"}
{"task_id":"FormalEval/10","completion":"\n address[] public owners;\n mapping(address => bool) public isOwner;\n uint256 public numConfirmationsRequired;\n\n struct Transaction {\n address to;\n uint256 value;\n bytes data;\n bool executed;\n uint256 numConfirmations;\n }\n\n Transaction[] public transactions;\n mapping(uint256 => mapping(address => bool)) public isConfirmed;\n\n event SubmitTransaction(address indexed owner, uint256 indexed txIndex, address indexed to, uint256 value, bytes data);\n event ConfirmTransaction(address indexed owner, uint256 indexed txIndex);\n event RevokeConfirmation(address indexed owner, uint256 indexed txIndex);\n event ExecuteTransaction(address indexed owner, uint256 indexed txIndex);\n\n modifier onlyOwner() {\n require(isOwner[msg.sender], \"Not an owner\");\n _;\n }\n\n modifier txExists(uint256 _txIndex) {\n require(_txIndex < transactions.length, \"Transaction does not exist\");\n _;\n }\n\n modifier notExecuted(uint256 _txIndex) {\n require(!transactions[_txIndex].executed, \"Transaction already executed\");\n _;\n }\n\n modifier notConfirmed(uint256 _txIndex) {\n require(!isConfirmed[_txIndex][msg.sender], \"Transaction already confirmed\");\n _;\n }\n\n constructor(address[] memory _owners, uint256 _numConfirmationsRequired) {\n require(_owners.length > 0, \"Owners required\");\n require(_numConfirmationsRequired > 0 && _numConfirmationsRequired <= _owners.length, \"Invalid number of required confirmations\");\n\n for (uint256 i = 0; i < _owners.length; i++) {\n address owner = _owners[i];\n require(owner != address(0), \"Invalid owner\");\n require(!isOwner[owner], \"Owner not unique\");\n\n isOwner[owner] = true;\n owners.push(owner);\n }\n\n numConfirmationsRequired = _numConfirmationsRequired;\n }\n\n receive() external payable {}\n\n function submitTransaction(address _to, uint256 _value, bytes calldata _data) external onlyOwner {\n uint256 txIndex = transactions.length;\n transactions.push(Transaction({\n to: _to,\n value: _value,\n data: _data,\n executed: false,\n numConfirmations: 0\n }));\n emit SubmitTransaction(msg.sender, txIndex, _to, _value, _data);\n }\n\n function confirmTransaction(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) notConfirmed(_txIndex) {\n Transaction storage transaction = transactions[_txIndex];\n transaction.numConfirmations += 1;\n isConfirmed[_txIndex][msg.sender] = true;\n emit ConfirmTransaction(msg.sender, _txIndex);\n }\n\n function executeTransaction(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) {\n Transaction storage transaction = transactions[_txIndex];\n require(transaction.numConfirmations >= numConfirmationsRequired, \"Cannot execute: insufficient confirmations\");\n\n transaction.executed = true;\n (bool success, ) = transaction.to.call{value: transaction.value}(transaction.data);\n require(success, \"Transaction failed\");\n\n emit ExecuteTransaction(msg.sender, _txIndex);\n }\n\n function revokeConfirmation(uint256 _txIndex) external onlyOwner txExists(_txIndex) notExecuted(_txIndex) {\n require(isConfirmed[_txIndex][msg.sender], \"Transaction not confirmed\");\n Transaction storage transaction = transactions[_txIndex];\n transaction.numConfirmations -= 1;\n isConfirmed[_txIndex][msg.sender] = false;\n emit RevokeConfirmation(msg.sender, _txIndex);\n }\n\n function getTransactionCount() external view returns (uint256) {\n return transactions.length;\n }\n\n function getTransaction(uint256 _txIndex) external view returns (address to, uint256 value, bytes memory data, bool executed, uint256 numConfirmations) {\n Transaction storage transaction = transactions[_txIndex];\n return (transaction.to, transaction.value, transaction.data, transaction.executed, transaction.numConfirmations);\n }\n\n function getOwners() external view returns (address[] memory) {\n return owners;\n }\n}"}
{"task_id":"FormalEval/11","completion":"\n address private immutable _beneficiary;\n uint256 private immutable _start;\n uint256 private immutable _duration;\n uint256 private _released;\n bool private _locked;\n\n event TokensReleased(uint256 amount);\n\n modifier onlyBeneficiary() {\n require(msg.sender == _beneficiary, \"Not the beneficiary\");\n _;\n }\n\n modifier nonReentrant() {\n require(!_locked, \"Reentrancy guard\");\n _locked = true;\n _;\n _locked = false;\n }\n\n constructor(address beneficiary_, uint256 startTime_, uint256 duration_) {\n require(beneficiary_ != address(0), \"Beneficiary is zero address\");\n require(duration_ > 0, \"Duration must be greater than 0\");\n _beneficiary = beneficiary_;\n _start = startTime_;\n _duration = duration_;\n }\n\n receive() external payable {}\n\n function beneficiary() external view returns (address) {\n return _beneficiary;\n }\n\n function start() external view returns (uint256) {\n return _start;\n }\n\n function duration() external view returns (uint256) {\n return _duration;\n }\n\n function released() external view returns (uint256) {\n return _released;\n }\n\n function vestedAmount(uint256 timestamp) public view returns (uint256) {\n uint256 totalBalance = address(this).balance + _released;\n\n if (timestamp < _start) {\n return 0;\n } else if (timestamp >= _start + _duration) {\n return totalBalance;\n } else {\n return (totalBalance * (timestamp - _start)) / _duration;\n }\n }\n\n function releasable() public view returns (uint256) {\n return vestedAmount(block.timestamp) - _released;\n }\n\n function release() external onlyBeneficiary nonReentrant {\n uint256 amount = releasable();\n require(amount > 0, \"No tokens to release\");\n\n _released += amount;\n emit TokensReleased(amount);\n\n (bool success, ) = payable(_beneficiary).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n }\n}"}
{"task_id":"FormalEval/11","completion":"\n address private immutable _beneficiary;\n uint256 private immutable _start;\n uint256 private immutable _duration;\n uint256 private _released;\n bool private _locked;\n\n event TokensReleased(uint256 amount);\n\n modifier onlyBeneficiary() {\n require(msg.sender == _beneficiary, \"Not authorized\");\n _;\n }\n\n modifier nonReentrant() {\n require(!_locked, \"Reentrancy detected\");\n _locked = true;\n _;\n _locked = false;\n }\n\n constructor(address beneficiary_, uint256 startTime_, uint256 duration_) {\n require(beneficiary_ != address(0), \"Invalid beneficiary\");\n require(duration_ > 0, \"Duration must be > 0\");\n _beneficiary = beneficiary_;\n _start = startTime_;\n _duration = duration_;\n }\n\n receive() external payable {}\n\n function beneficiary() external view returns (address) {\n return _beneficiary;\n }\n\n function start() external view returns (uint256) {\n return _start;\n }\n\n function duration() external view returns (uint256) {\n return _duration;\n }\n\n function released() external view returns (uint256) {\n return _released;\n }\n\n function releasable() public view returns (uint256) {\n return vestedAmount(block.timestamp) - _released;\n }\n\n function release() external onlyBeneficiary nonReentrant {\n uint256 amount = releasable();\n require(amount > 0, \"Nothing to release\");\n\n _released += amount;\n (bool success, ) = payable(_beneficiary).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n\n emit TokensReleased(amount);\n }\n\n function vestedAmount(uint256 timestamp) public view returns (uint256) {\n uint256 totalBalance = address(this).balance + _released;\n\n if (timestamp < _start) {\n return 0;\n } else if (timestamp >= _start + _duration) {\n return totalBalance;\n } else {\n return (totalBalance * (timestamp - _start)) / _duration;\n }\n }\n}"}
{"task_id":"FormalEval/11","completion":"\n address private immutable _beneficiary;\n uint256 private immutable _start;\n uint256 private immutable _duration;\n uint256 private _released;\n\n event TokensReleased(uint256 amount);\n\n modifier onlyBeneficiary() {\n require(msg.sender == _beneficiary, \"Not the beneficiary\");\n _;\n }\n\n constructor(address beneficiary_, uint256 startTime_, uint256 duration_) {\n require(beneficiary_ != address(0), \"Beneficiary is zero address\");\n require(duration_ > 0, \"Duration must be greater than 0\");\n _beneficiary = beneficiary_;\n _start = startTime_;\n _duration = duration_;\n }\n\n receive() external payable {}\n\n function beneficiary() external view returns (address) {\n return _beneficiary;\n }\n\n function start() external view returns (uint256) {\n return _start;\n }\n\n function duration() external view returns (uint256) {\n return _duration;\n }\n\n function released() external view returns (uint256) {\n return _released;\n }\n\n function vestedAmount(uint256 timestamp) public view returns (uint256) {\n if (timestamp < _start) {\n return 0;\n } else if (timestamp >= _start + _duration) {\n return address(this).balance + _released;\n } else {\n return ((address(this).balance + _released) * (timestamp - _start)) / _duration;\n }\n }\n\n function releasable() public view returns (uint256) {\n return vestedAmount(block.timestamp) - _released;\n }\n\n function release() external onlyBeneficiary {\n uint256 amount = releasable();\n require(amount > 0, \"No tokens to release\");\n\n _released += amount;\n emit TokensReleased(amount);\n\n (bool success, ) = payable(_beneficiary).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n }\n}"}
{"task_id":"FormalEval/12","completion":" address public seller;\n uint256 public endAt;\n bool public ended;\n\n address public highestBidder;\n uint256 public highestBid;\n\n mapping(address => uint256) public pendingReturns;\n\n event BidPlaced(address indexed bidder, uint256 amount);\n event AuctionEnded(address indexed winner, uint256 amount);\n\n modifier onlyOwner() {\n require(msg.sender == seller, \"Not the seller\");\n _;\n }\n\n constructor(uint256 startingBid, uint256 auctionDuration) {\n seller = msg.sender;\n highestBid = startingBid;\n endAt = block.timestamp + auctionDuration;\n }\n\n /// @notice Place a bid in the auction\n function bid() external payable {\n require(block.timestamp < endAt, \"Auction expired\");\n require(msg.value > highestBid, \"Bid too low\");\n\n if (highestBidder != address(0)) {\n pendingReturns[highestBidder] += highestBid;\n }\n\n highestBidder = msg.sender;\n highestBid = msg.value;\n\n emit BidPlaced(msg.sender, msg.value);\n }\n\n /// @notice Withdraw overbid funds\n function withdraw() external returns (bool) {\n uint256 amount = pendingReturns[msg.sender];\n if (amount > 0) {\n pendingReturns[msg.sender] = 0;\n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n return true;\n }\n return false;\n }\n\n /// @notice End the auction and transfer funds to seller\n function end() external onlyOwner {\n require(block.timestamp >= endAt, \"Auction not yet ended\");\n require(!ended, \"Auction already ended\");\n\n ended = true;\n \n (bool success, ) = payable(seller).call{value: highestBid}(\"\");\n require(success, \"Transfer to seller failed\");\n\n emit AuctionEnded(highestBidder, highestBid);\n }\n\n function getSeller() external view returns (address) { return seller; }\n function getHighestBidder() external view returns (address) { return highestBidder; }\n function getHighestBid() external view returns (uint256) { return highestBid; }\n function getEnded() external view returns (bool) { return ended; }\n function getEndAt() external view returns (uint256) { return endAt; }\n}"}
{"task_id":"FormalEval/12","completion":" address public seller;\n uint256 public endAt;\n bool public ended;\n\n address public highestBidder;\n uint256 public highestBid;\n\n mapping(address => uint256) public pendingReturns;\n\n event BidPlaced(address indexed bidder, uint256 amount);\n event AuctionEnded(address indexed winner, uint256 amount);\n\n modifier onlyOwner() {\n require(msg.sender == seller, \"Not the seller\");\n _;\n }\n\n constructor(uint256 _startingBid, uint256 _auctionDuration) {\n seller = msg.sender;\n highestBid = _startingBid;\n endAt = block.timestamp + _auctionDuration;\n }\n\n function bid() external payable {\n require(block.timestamp < endAt, \"Auction expired\");\n require(msg.value > highestBid, \"Bid too low\");\n\n if (highestBidder != address(0)) {\n pendingReturns[highestBidder] += highestBid;\n }\n\n highestBidder = msg.sender;\n highestBid = msg.value;\n\n emit BidPlaced(msg.sender, msg.value);\n }\n\n function withdraw() external returns (bool) {\n uint256 amount = pendingReturns[msg.sender];\n if (amount > 0) {\n pendingReturns[msg.sender] = 0;\n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n }\n return true;\n }\n\n function end() external onlyOwner {\n require(block.timestamp >= endAt, \"Auction not yet ended\");\n require(!ended, \"Auction already ended\");\n\n ended = true;\n emit AuctionEnded(highestBidder, highestBid);\n\n (bool success, ) = payable(seller).call{value: highestBid}(\"\");\n require(success, \"Transfer to seller failed\");\n }\n\n function getSeller() external view returns (address) { return seller; }\n function getHighestBidder() external view returns (address) { return highestBidder; }\n function getHighestBid() external view returns (uint256) { return highestBid; }\n function getEnded() external view returns (bool) { return ended; }\n function getEndAt() external view returns (uint256) { return endAt; }\n}"}
{"task_id":"FormalEval/12","completion":" address public seller;\n uint256 public endAt;\n bool public ended;\n\n address public highestBidder;\n uint256 public highestBid;\n\n mapping(address => uint256) public pendingReturns;\n\n event BidPlaced(address indexed bidder, uint256 amount);\n event AuctionEnded(address indexed winner, uint256 amount);\n\n modifier onlySeller() {\n require(msg.sender == seller, \"Not the seller\");\n _;\n }\n\n constructor(uint256 _startingBid, uint256 _auctionDuration) {\n seller = msg.sender;\n highestBid = _startingBid;\n endAt = block.timestamp + _auctionDuration;\n }\n\n function bid() external payable {\n require(block.timestamp < endAt, \"Auction already ended\");\n require(msg.value > highestBid, \"Bid too low\");\n\n if (highestBidder != address(0)) {\n pendingReturns[highestBidder] += highestBid;\n }\n\n highestBidder = msg.sender;\n highestBid = msg.value;\n\n emit BidPlaced(msg.sender, msg.value);\n }\n\n function withdraw() external returns (bool) {\n uint256 amount = pendingReturns[msg.sender];\n if (amount > 0) {\n pendingReturns[msg.sender] = 0;\n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n }\n return true;\n }\n\n function end() external onlySeller {\n require(block.timestamp >= endAt, \"Auction not yet ended\");\n require(!ended, \"Auction already ended\");\n\n ended = true;\n emit AuctionEnded(highestBidder, highestBid);\n\n (bool success, ) = payable(seller).call{value: highestBid}(\"\");\n require(success, \"Transfer to seller failed\");\n }\n}"}
{"task_id":"FormalEval/13","completion":" address public owner;\n uint256 public rewardPool;\n bool private locked;\n\n struct StakeInfo {\n uint256 amount;\n uint256 lastUpdateTime;\n uint256 pendingRewards;\n }\n\n mapping(address => StakeInfo) public stakes;\n\n event Staked(address indexed user, uint256 amount);\n event Unstaked(address indexed user, uint256 amount);\n event RewardsClaimed(address indexed user, uint256 amount);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n function _calculateRewards(address _addr) internal view returns (uint256) {\n StakeInfo storage s = stakes[_addr];\n if (s.amount == 0) return 0;\n uint256 timeElapsed = block.timestamp - s.lastUpdateTime;\n return s.pendingRewards + (s.amount * timeElapsed);\n }\n\n function stake() external payable {\n require(msg.value > 0, \"Cannot stake 0\");\n \n _updateRewards(msg.sender);\n stakes[msg.sender].amount += msg.value;\n \n emit Staked(msg.sender, msg.value);\n }\n\n function unstake(uint256 amount) external nonReentrant {\n require(amount > 0, \"Amount must be > 0\");\n require(stakes[msg.sender].amount >= amount, \"Insufficient stake\");\n\n _updateRewards(msg.sender);\n stakes[msg.sender].amount -= amount;\n \n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n \n emit Unstaked(msg.sender, amount);\n }\n\n function claimRewards() external nonReentrant {\n _updateRewards(msg.sender);\n uint256 reward = stakes[msg.sender].pendingRewards;\n require(reward > 0, \"No rewards to claim\");\n require(rewardPool >= reward, \"Insufficient reward pool\");\n\n stakes[msg.sender].pendingRewards = 0;\n rewardPool -= reward;\n\n (bool success, ) = payable(msg.sender).call{value: reward}(\"\");\n require(success, \"Transfer failed\");\n\n emit RewardsClaimed(msg.sender, reward);\n }\n\n function _updateRewards(address _addr) internal {\n stakes[_addr].pendingRewards = _calculateRewards(_addr);\n stakes[_addr].lastUpdateTime = block.timestamp;\n }\n\n function fundRewards() external payable onlyOwner {\n rewardPool += msg.value;\n }\n\n function getStake(address _addr) external view returns (uint256) {\n return stakes[_addr].amount;\n }\n\n function getRewards(address _addr) external view returns (uint256) {\n return _calculateRewards(_addr);\n }\n}"}
{"task_id":"FormalEval/13","completion":" address public owner;\n uint256 public rewardPool;\n bool private locked;\n\n struct User {\n uint256 stakedAmount;\n uint256 lastUpdateTime;\n uint256 pendingRewards;\n }\n\n mapping(address => User) public users;\n\n event Staked(address indexed user, uint256 amount);\n event Unstaked(address indexed user, uint256 amount);\n event RewardsClaimed(address indexed user, uint256 amount);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n function _calculateRewards(address _addr) internal view returns (uint256) {\n User storage user = users[_addr];\n if (user.stakedAmount == 0) return 0;\n uint256 timeElapsed = block.timestamp - user.lastUpdateTime;\n return user.stakedAmount * timeElapsed;\n }\n\n function _updateRewards(address _addr) internal {\n users[_addr].pendingRewards += _calculateRewards(_addr);\n users[_addr].lastUpdateTime = block.timestamp;\n }\n\n function stake() external payable {\n require(msg.value > 0, \"Cannot stake 0\");\n _updateRewards(msg.sender);\n users[msg.sender].stakedAmount += msg.value;\n emit Staked(msg.sender, msg.value);\n }\n\n function unstake(uint256 amount) external nonReentrant {\n require(amount > 0, \"Amount must be > 0\");\n require(users[msg.sender].stakedAmount >= amount, \"Insufficient stake\");\n \n _updateRewards(msg.sender);\n users[msg.sender].stakedAmount -= amount;\n \n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n \n emit Unstaked(msg.sender, amount);\n }\n\n function claimRewards() external nonReentrant {\n _updateRewards(msg.sender);\n uint256 reward = users[msg.sender].pendingRewards;\n require(reward > 0, \"No rewards to claim\");\n require(rewardPool >= reward, \"Insufficient reward pool\");\n\n users[msg.sender].pendingRewards = 0;\n rewardPool -= reward;\n\n (bool success, ) = payable(msg.sender).call{value: reward}(\"\");\n require(success, \"Reward transfer failed\");\n\n emit RewardsClaimed(msg.sender, reward);\n }\n\n function fundRewards() external payable onlyOwner {\n rewardPool += msg.value;\n }\n\n function getStake(address _addr) external view returns (uint256) {\n return users[_addr].stakedAmount;\n }\n\n function getRewards(address _addr) external view returns (uint256) {\n return users[_addr].pendingRewards + _calculateRewards(_addr);\n }\n}"}
{"task_id":"FormalEval/13","completion":" address public owner;\n uint256 public rewardPool;\n bool private locked;\n\n struct StakeInfo {\n uint256 amount;\n uint256 lastUpdateTime;\n uint256 pendingRewards;\n }\n\n mapping(address => StakeInfo) public stakes;\n\n event Staked(address indexed user, uint256 amount);\n event Unstaked(address indexed user, uint256 amount);\n event RewardsClaimed(address indexed user, uint256 amount);\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Not the owner\");\n _;\n }\n\n modifier nonReentrant() {\n require(!locked, \"Reentrancy detected\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n function _calculateRewards(address _addr) internal view returns (uint256) {\n StakeInfo storage s = stakes[_addr];\n if (s.amount == 0) return 0;\n uint256 timeElapsed = block.timestamp - s.lastUpdateTime;\n return s.pendingRewards + (s.amount * timeElapsed);\n }\n\n function stake() external payable {\n require(msg.value > 0, \"Cannot stake 0\");\n \n _updateRewards(msg.sender);\n stakes[msg.sender].amount += msg.value;\n \n emit Staked(msg.sender, msg.value);\n }\n\n function unstake(uint256 amount) external nonReentrant {\n require(amount > 0, \"Amount must be > 0\");\n require(stakes[msg.sender].amount >= amount, \"Insufficient stake\");\n\n _updateRewards(msg.sender);\n stakes[msg.sender].amount -= amount;\n \n (bool success, ) = payable(msg.sender).call{value: amount}(\"\");\n require(success, \"Transfer failed\");\n \n emit Unstaked(msg.sender, amount);\n }\n\n function claimRewards() external nonReentrant {\n _updateRewards(msg.sender);\n uint256 reward = stakes[msg.sender].pendingRewards;\n require(reward > 0, \"No rewards to claim\");\n require(rewardPool >= reward, \"Insufficient reward pool\");\n\n stakes[msg.sender].pendingRewards = 0;\n rewardPool -= reward;\n\n (bool success, ) = payable(msg.sender).call{value: reward}(\"\");\n require(success, \"Reward transfer failed\");\n\n emit RewardsClaimed(msg.sender, reward);\n }\n\n function _updateRewards(address _addr) internal {\n stakes[_addr].pendingRewards = _calculateRewards(_addr);\n stakes[_addr].lastUpdateTime = block.timestamp;\n }\n\n function fundRewards() external payable onlyOwner {\n rewardPool += msg.value;\n }\n\n function getStake(address _addr) external view returns (uint256) {\n return stakes[_addr].amount;\n }\n\n function getRewards(address _addr) external view returns (uint256) {\n return _calculateRewards(_addr);\n }\n}"}
{"task_id":"FormalEval/14","completion":" address public immutable tokenA;\n address public immutable tokenB;\n\n uint256 public reserveA;\n uint256 public reserveB;\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n bool private locked;\n\n event LiquidityAdded(address indexed provider, uint256 amountA, uint256 amountB, uint256 shares);\n event LiquidityRemoved(address indexed provider, uint256 amountA, uint256 amountB, uint256 shares);\n event Swap(address indexed user, address tokenIn, uint256 amountIn, uint256 amountOut);\n\n modifier nonReentrant() {\n require(!locked, \"ReentrancyGuard: reentrant call\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor(address _tokenA, address _tokenB) {\n require(_tokenA != address(0) && _tokenB != address(0), \"Invalid token address\");\n require(_tokenA != _tokenB, \"Tokens must be different\");\n tokenA = _tokenA;\n tokenB = _tokenB;\n }\n\n function _sqrt(uint256 y) internal pure returns (uint256 z) {\n if (y > 3) {\n z = y;\n uint256 x = y / 2 + 1;\n while (x < z) {\n z = x;\n x = (y / x + x) / 2;\n }\n } else if (y != 0) {\n z = 1;\n }\n }\n\n function getReserves() external view returns (uint256, uint256) {\n return (reserveA, reserveB);\n }\n\n function addLiquidity(uint256 amountA, uint256 amountB) external nonReentrant returns (uint256 shares) {\n IERC20(tokenA).transferFrom(msg.sender, address(this), amountA);\n IERC20(tokenB).transferFrom(msg.sender, address(this), amountB);\n\n if (totalSupply == 0) {\n shares = _sqrt(amountA * amountB);\n } else {\n uint256 sharesA = (amountA * totalSupply) / reserveA;\n uint256 sharesB = (amountB * totalSupply) / reserveB;\n shares = sharesA < sharesB ? sharesA : sharesB;\n require(shares > 0, \"Insufficient liquidity minted\");\n }\n\n balanceOf[msg.sender] += shares;\n totalSupply += shares;\n reserveA += amountA;\n reserveB += amountB;\n\n emit LiquidityAdded(msg.sender, amountA, amountB, shares);\n }\n\n function removeLiquidity(uint256 shares) external nonReentrant returns (uint256 amountA, uint256 amountB) {\n require(shares <= balanceOf[msg.sender], \"Insufficient shares\");\n\n amountA = (shares * reserveA) / totalSupply;\n amountB = (shares * reserveB) / totalSupply;\n\n balanceOf[msg.sender] -= shares;\n totalSupply -= shares;\n reserveA -= amountA;\n reserveB -= amountB;\n\n IERC20(tokenA).transfer(msg.sender, amountA);\n IERC20(tokenB).transfer(msg.sender, amountB);\n\n emit LiquidityRemoved(msg.sender, amountA, amountB, shares);\n }\n\n function swap(address tokenIn, uint256 amountIn) external nonReentrant returns (uint256 amountOut) {\n require(tokenIn == tokenA || tokenIn == tokenB, \"Invalid token\");\n require(amountIn > 0, \"Amount must be > 0\");\n\n bool isA = tokenIn == tokenA;\n (uint256 resIn, uint256 resOut) = isA ? (reserveA, reserveB) : (reserveB, reserveA);\n address tokenOut = isA ? tokenB : tokenA;\n\n IERC20(tokenIn).transferFrom(msg.sender, address(this), amountIn);\n\n uint256 amountInWithFee = (amountIn * 997) / 1000;\n amountOut = (resOut * amountInWithFee) / (resIn + amountInWithFee);\n\n if (isA) {\n reserveA += amountIn;\n reserveB -= amountOut;\n } else {\n reserveB += amountIn;\n reserveA -= amountOut;\n }\n\n IERC20(tokenOut).transfer(msg.sender, amountOut);\n\n emit Swap(msg.sender, tokenIn, amountIn, amountOut);\n }\n}"}
{"task_id":"FormalEval/14","completion":" address public immutable tokenA;\n address public immutable tokenB;\n\n uint256 public reserveA;\n uint256 public reserveB;\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n bool private locked;\n\n event LiquidityAdded(address indexed provider, uint256 amountA, uint256 amountB, uint256 shares);\n event LiquidityRemoved(address indexed provider, uint256 amountA, uint256 amountB, uint256 shares);\n event Swap(address indexed user, address tokenIn, uint256 amountIn, uint256 amountOut);\n\n modifier nonReentrant() {\n require(!locked, \"ReentrancyGuard: reentrant call\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor(address _tokenA, address _tokenB) {\n require(_tokenA != address(0) && _tokenB != address(0), \"Invalid token addresses\");\n require(_tokenA != _tokenB, \"Tokens must be different\");\n tokenA = _tokenA;\n tokenB = _tokenB;\n }\n\n function _sqrt(uint256 y) internal pure returns (uint256 z) {\n if (y > 3) {\n z = y;\n uint256 x = y / 2 + 1;\n while (x < z) {\n z = x;\n x = (y / x + x) / 2;\n }\n } else if (y != 0) {\n z = 1;\n }\n }\n\n function addLiquidity(uint256 amountA, uint256 amountB) external nonReentrant returns (uint256 shares) {\n IERC20(tokenA).transferFrom(msg.sender, address(this), amountA);\n IERC20(tokenB).transferFrom(msg.sender, address(this), amountB);\n\n if (totalSupply == 0) {\n shares = _sqrt(amountA * amountB);\n } else {\n uint256 sharesA = (amountA * totalSupply) / reserveA;\n uint256 sharesB = (amountB * totalSupply) / reserveB;\n shares = sharesA < sharesB ? sharesA : sharesB;\n require(shares > 0, \"Insufficient liquidity minted\");\n }\n\n balanceOf[msg.sender] += shares;\n totalSupply += shares;\n reserveA += amountA;\n reserveB += amountB;\n\n emit LiquidityAdded(msg.sender, amountA, amountB, shares);\n }\n\n function removeLiquidity(uint256 shares) external nonReentrant returns (uint256 amountA, uint256 amountB) {\n require(shares <= balanceOf[msg.sender], \"Insufficient shares\");\n\n amountA = (shares * reserveA) / totalSupply;\n amountB = (shares * reserveB) / totalSupply;\n\n balanceOf[msg.sender] -= shares;\n totalSupply -= shares;\n reserveA -= amountA;\n reserveB -= amountB;\n\n IERC20(tokenA).transfer(msg.sender, amountA);\n IERC20(tokenB).transfer(msg.sender, amountB);\n\n emit LiquidityRemoved(msg.sender, amountA, amountB, shares);\n }\n\n function swap(address tokenIn, uint256 amountIn) external nonReentrant returns (uint256 amountOut) {\n require(tokenIn == tokenA || tokenIn == tokenB, \"Invalid token\");\n require(amountIn > 0, \"Invalid amount\");\n\n bool isTokenA = tokenIn == tokenA;\n (uint256 resIn, uint256 resOut) = isTokenA ? (reserveA, reserveB) : (reserveB, reserveA);\n address tokenOut = isTokenA ? tokenB : tokenA;\n\n IERC20(tokenIn).transferFrom(msg.sender, address(this), amountIn);\n\n uint256 amountInWithFee = (amountIn * 997) / 1000;\n amountOut = (resOut * amountInWithFee) / (resIn + amountInWithFee);\n\n if (isTokenA) {\n reserveA += amountIn;\n reserveB -= amountOut;\n } else {\n reserveB += amountIn;\n reserveA -= amountOut;\n }\n\n IERC20(tokenOut).transfer(msg.sender, amountOut);\n emit Swap(msg.sender, tokenIn, amountIn, amountOut);\n }\n\n function getReserves() external view returns (uint256, uint256) {\n return (reserveA, reserveB);\n }\n\n function totalShares() external view returns (uint256) {\n return totalSupply;\n }\n}"}
{"task_id":"FormalEval/14","completion":" address public immutable tokenA;\n address public immutable tokenB;\n\n uint256 public reserveA;\n uint256 public reserveB;\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n bool private locked;\n\n event LiquidityAdded(address indexed provider, uint256 amountA, uint256 amountB, uint256 shares);\n event LiquidityRemoved(address indexed provider, uint256 amountA, uint256 amountB, uint256 shares);\n event Swap(address indexed user, address tokenIn, uint256 amountIn, uint256 amountOut);\n\n modifier nonReentrant() {\n require(!locked, \"ReentrancyGuard: reentrant call\");\n locked = true;\n _;\n locked = false;\n }\n\n constructor(address _tokenA, address _tokenB) {\n require(_tokenA != address(0) && _tokenB != address(0), \"Invalid token addresses\");\n require(_tokenA != _tokenB, \"Tokens must be different\");\n tokenA = _tokenA;\n tokenB = _tokenB;\n }\n\n function _sqrt(uint256 y) internal pure returns (uint256 z) {\n if (y > 3) {\n z = y;\n uint256 x = y / 2 + 1;\n while (x < z) {\n z = x;\n x = (y / x + x) / 2;\n }\n } else if (y != 0) {\n z = 1;\n }\n }\n\n function getReserves() external view returns (uint256, uint256) {\n return (reserveA, reserveB);\n }\n\n function addLiquidity(uint256 amountA, uint256 amountB) external nonReentrant returns (uint256 shares) {\n IERC20(tokenA).transferFrom(msg.sender, address(this), amountA);\n IERC20(tokenB).transferFrom(msg.sender, address(this), amountB);\n\n if (totalSupply == 0) {\n shares = _sqrt(amountA * amountB);\n } else {\n uint256 sharesA = (amountA * totalSupply) / reserveA;\n uint256 sharesB = (amountB * totalSupply) / reserveB;\n shares = sharesA < sharesB ? sharesA : sharesB;\n require(shares > 0, \"Insufficient liquidity minted\");\n }\n\n balanceOf[msg.sender] += shares;\n totalSupply += shares;\n reserveA += amountA;\n reserveB += amountB;\n\n emit LiquidityAdded(msg.sender, amountA, amountB, shares);\n }\n\n function removeLiquidity(uint256 shares) external nonReentrant returns (uint256 amountA, uint256 amountB) {\n require(shares > 0 && balanceOf[msg.sender] >= shares, \"Invalid shares\");\n\n amountA = (shares * reserveA) / totalSupply;\n amountB = (shares * reserveB) / totalSupply;\n\n balanceOf[msg.sender] -= shares;\n totalSupply -= shares;\n reserveA -= amountA;\n reserveB -= amountB;\n\n IERC20(tokenA).transfer(msg.sender, amountA);\n IERC20(tokenB).transfer(msg.sender, amountB);\n\n emit LiquidityRemoved(msg.sender, amountA, amountB, shares);\n }\n\n function swap(address tokenIn, uint256 amountIn) external nonReentrant returns (uint256 amountOut) {\n require(tokenIn == tokenA || tokenIn == tokenB, \"Invalid token\");\n require(amountIn > 0, \"Invalid amount\");\n\n bool isA = tokenIn == tokenA;\n (uint256 resIn, uint256 resOut) = isA ? (reserveA, reserveB) : (reserveB, reserveA);\n address tokenOut = isA ? tokenB : tokenA;\n\n IERC20(tokenIn).transferFrom(msg.sender, address(this), amountIn);\n\n uint256 amountInWithFee = (amountIn * 997) / 1000;\n amountOut = (resOut * amountInWithFee) / (resIn + amountInWithFee);\n\n if (isA) {\n reserveA += amountIn;\n reserveB -= amountOut;\n } else {\n reserveB += amountIn;\n reserveA -= amountOut;\n }\n\n IERC20(tokenOut).transfer(msg.sender, amountOut);\n\n emit Swap(msg.sender, tokenIn, amountIn, amountOut);\n }\n}"}
|