Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/ArcMasterChef.sol": {
"content": "/**\r
*Submitted for verification at Etherscan.io on 2021-11-26\r
*/\r
\r
// File @openzeppelin/contracts/math/SafeMath.sol@v3.4.2\r
// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.6.0 <0.8.0;\r
\r
/**\r
* @dev Wrappers over Solidity's arithmetic operations with added overflow\r
* checks.\r
*\r
* Arithmetic operations in Solidity wrap on overflow. This can easily result\r
* in bugs, because programmers usually assume that an overflow raises an\r
* error, which is the standard behavior in high level programming languages.\r
* `SafeMath` restores this intuition by reverting the transaction when an\r
* operation overflows.\r
*\r
* Using this library instead of the unchecked operations eliminates an entire\r
* class of bugs, so it's recommended to use it always.\r
*/\r
library SafeMath {\r
/**\r
* @dev Returns the addition of two unsigned integers, with an overflow flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryAdd(uint256 a, uint256 b)\r
internal\r
pure\r
returns (bool, uint256)\r
{\r
uint256 c = a + b;\r
if (c < a) return (false, 0);\r
return (true, c);\r
}\r
\r
/**\r
* @dev Returns the substraction of two unsigned integers, with an overflow flag.\r
*\r
* _Available since v3.4._\r
*/\r
function trySub(uint256 a, uint256 b)\r
internal\r
pure\r
returns (bool, uint256)\r
{\r
if (b > a) return (false, 0);\r
return (true, a - b);\r
}\r
\r
/**\r
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryMul(uint256 a, uint256 b)\r
internal\r
pure\r
returns (bool, uint256)\r
{\r
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r
// benefit is lost if 'b' is also tested.\r
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r
if (a == 0) return (true, 0);\r
uint256 c = a * b;\r
if (c / a != b) return (false, 0);\r
return (true, c);\r
}\r
\r
/**\r
* @dev Returns the division of two unsigned integers, with a division by zero flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryDiv(uint256 a, uint256 b)\r
internal\r
pure\r
returns (bool, uint256)\r
{\r
if (b == 0) return (false, 0);\r
return (true, a / b);\r
}\r
\r
/**\r
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryMod(uint256 a, uint256 b)\r
internal\r
pure\r
returns (bool, uint256)\r
{\r
if (b == 0) return (false, 0);\r
return (true, a % b);\r
}\r
\r
/**\r
* @dev Returns the addition of two unsigned integers, reverting on\r
* overflow.\r
*\r
* Counterpart to Solidity's `+` operator.\r
*\r
* Requirements:\r
*\r
* - Addition cannot overflow.\r
*/\r
function add(uint256 a, uint256 b) internal pure returns (uint256) {\r
uint256 c = a + b;\r
require(c >= a, "SafeMath: addition overflow");\r
return c;\r
}\r
\r
/**\r
* @dev Returns the subtraction of two unsigned integers, reverting on\r
* overflow (when the result is negative).\r
*\r
* Counterpart to Solidity's `-` operator.\r
*\r
* Requirements:\r
*\r
* - Subtraction cannot overflow.\r
*/\r
function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r
require(b <= a, "SafeMath: subtraction overflow");\r
return a - b;\r
}\r
\r
/**\r
* @dev Returns the multiplication of two unsigned integers, reverting on\r
* overflow.\r
*\r
* Counterpart to Solidity's `*` operator.\r
*\r
* Requirements:\r
*\r
* - Multiplication cannot overflow.\r
*/\r
function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r
if (a == 0) return 0;\r
uint256 c = a * b;\r
require(c / a == b, "SafeMath: multiplication overflow");\r
return c;\r
}\r
\r
/**\r
* @dev Returns the integer division of two unsigned integers, reverting on\r
* division by zero. The result is rounded towards zero.\r
*\r
* Counterpart to Solidity's `/` operator. Note: this function uses a\r
* `revert` opcode (which leaves remaining gas untouched) while Solidity\r
* uses an invalid opcode to revert (consuming all remaining gas).\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function div(uint256 a, uint256 b) internal pure returns (uint256) {\r
require(b > 0, "SafeMath: division by zero");\r
return a / b;\r
}\r
\r
/**\r
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r
* reverting when dividing by zero.\r
*\r
* Counterpart to Solidity's `%` operator. This function uses a `revert`\r
* opcode (which leaves remaining gas untouched) while Solidity uses an\r
* invalid opcode to revert (consuming all remaining gas).\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r
require(b > 0, "SafeMath: modulo by zero");\r
return a % b;\r
}\r
\r
/**\r
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r
* overflow (when the result is negative).\r
*\r
* CAUTION: This function is deprecated because it requires allocating memory for the error\r
* message unnecessarily. For custom revert reasons use {trySub}.\r
*\r
* Counterpart to Solidity's `-` operator.\r
*\r
* Requirements:\r
*\r
* - Subtraction cannot overflow.\r
*/\r
function sub(\r
uint256 a,\r
uint256 b,\r
string memory errorMessage\r
) internal pure returns (uint256) {\r
require(b <= a, errorMessage);\r
return a - b;\r
}\r
\r
/**\r
* @dev Returns the integer division of two unsigned integers, reverting with custom message on\r
* division by zero. The result is rounded towards zero.\r
*\r
* CAUTION: This function is deprecated because it requires allocating memory for the error\r
* message unnecessarily. For custom revert reasons use {tryDiv}.\r
*\r
* Counterpart to Solidity's `/` operator. Note: this function uses a\r
* `revert` opcode (which leaves remaining gas untouched) while Solidity\r
* uses an invalid opcode to revert (consuming all remaining gas).\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function div(\r
uint256 a,\r
uint256 b,\r
string memory errorMessage\r
) internal pure returns (uint256) {\r
require(b > 0, errorMessage);\r
return a / b;\r
}\r
\r
/**\r
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r
* reverting with custom message when dividing by zero.\r
*\r
* CAUTION: This function is deprecated because it requires allocating memory for the error\r
* message unnecessarily. For custom revert reasons use {tryMod}.\r
*\r
* Counterpart to Solidity's `%` operator. This function uses a `revert`\r
* opcode (which leaves remaining gas untouched) while Solidity uses an\r
* invalid opcode to revert (consuming all remaining gas).\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function mod(\r
uint256 a,\r
uint256 b,\r
string memory errorMessage\r
) internal pure returns (uint256) {\r
require(b > 0, errorMessage);\r
return a % b;\r
}\r
}\r
\r
// File @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol@v3.4.2\r
\r
pragma solidity >=0.6.2 <0.8.0;\r
\r
/**\r
* @dev Collection of functions related to the address type\r
*/\r
library AddressUpgradeable {\r
/**\r
* @dev Returns true if `account` is a contract.\r
*\r
* [IMPORTANT]\r
* ====\r
* It is unsafe to assume that an address for which this function returns\r
* false is an externally-owned account (EOA) and not a contract.\r
*\r
* Among others, `isContract` will return false for the following\r
* types of addresses:\r
*\r
* - an externally-owned account\r
* - a contract in construction\r
* - an address where a contract will be created\r
* - an address where a contract lived, but was destroyed\r
* ====\r
*/\r
function isContract(address account) internal view returns (bool) {\r
// This method relies on extcodesize, which returns 0 for contracts in\r
// construction, since the code is only stored at the end of the\r
// constructor execution.\r
\r
uint256 size;\r
// solhint-disable-next-line no-inline-assembly\r
assembly {\r
size := extcodesize(account)\r
}\r
return size > 0;\r
}\r
\r
/**\r
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r
* `recipient`, forwarding all available gas and reverting on errors.\r
*\r
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r
* of certain opcodes, possibly making contracts go over the 2300 gas limit\r
* imposed by `transfer`, making them unable to receive funds via\r
* `transfer`. {sendValue} removes this limitation.\r
*\r
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r
*\r
* IMPORTANT: because control is transferred to `recipient`, care must be\r
* taken to not create reentrancy vulnerabilities. Consider using\r
* {ReentrancyGuard} or the\r
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r
*/\r
function sendValue(address payable recipient, uint256 amount) internal {\r
require(\r
address(this).balance >= amount,\r
"Address: insufficient balance"\r
);\r
\r
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value\r
(bool success, ) = recipient.call{value: amount}("");\r
require(\r
success,\r
"Address: unable to send value, recipient may have reverted"\r
);\r
}\r
\r
/**\r
* @dev Performs a Solidity function call using a low level `call`. A\r
* plain`call` is an unsafe replacement for a function call: use this\r
* function instead.\r
*\r
* If `target` reverts with a revert reason, it is bubbled up by this\r
* function (like regular Solidity function calls).\r
*\r
* Returns the raw returned data. To convert to the expected return value,\r
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r
*\r
* Requirements:\r
*\r
* - `target` must be a contract.\r
* - calling `target` with `data` must not revert.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCall(address target, bytes memory data)\r
internal\r
returns (bytes memory)\r
{\r
return functionCall(target, data, "Address: low-level call failed");\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r
* `errorMessage` as a fallback revert reason when `target` reverts.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCall(\r
address target,\r
bytes memory data,\r
string memory errorMessage\r
) internal returns (bytes memory) {\r
return functionCallWithValue(target, data, 0, errorMessage);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r
* but also transferring `value` wei to `target`.\r
*\r
* Requirements:\r
*\r
* - the calling contract must have an ETH balance of at least `value`.\r
* - the called Solidity function must be `payable`.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCallWithValue(\r
address target,\r
bytes memory data,\r
uint256 value\r
) internal returns (bytes memory) {\r
return\r
functionCallWithValue(\r
target,\r
data,\r
value,\r
"Address: low-level call with value failed"\r
);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r
* with `errorMessage` as a fallback revert reason when `target` reverts.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCallWithValue(\r
address target,\r
bytes memory data,\r
uint256 value,\r
string memory errorMessage\r
) internal returns (bytes memory) {\r
require(\r
address(this).balance >= value,\r
"Address: insufficient balance for call"\r
);\r
require(isContract(target), "Address: call to non-contract");\r
\r
// solhint-disable-next-line avoid-low-level-calls\r
(bool success, bytes memory returndata) = target.call{value: value}(\r
data\r
);\r
return _verifyCallResult(success, returndata, errorMessage);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r
* but performing a static call.\r
*\r
* _Available since v3.3._\r
*/\r
function functionStaticCall(address target, bytes memory data)\r
internal\r
view\r
returns (bytes memory)\r
{\r
return\r
functionStaticCall(\r
target,\r
data,\r
"Address: low-level static call failed"\r
);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r
* but performing a static call.\r
*\r
* _Available since v3.3._\r
*/\r
function functionStaticCall(\r
address target,\r
bytes memory data,\r
string memory errorMessage\r
) internal view returns (bytes memory) {\r
require(isContract(target), "Address: static call to non-contract");\r
\r
// solhint-disable-next-line avoid-low-level-calls\r
(bool success, bytes memory returndata) = target.staticcall(data);\r
return _verifyCallResult(success, returndata, errorMessage);\r
}\r
\r
function _verifyCallResult(\r
bool success,\r
bytes memory returndata,\r
string memory errorMessage\r
) private pure returns (bytes memory) {\r
if (success) {\r
return returndata;\r
} else {\r
// Look for revert reason and bubble it up if present\r
if (returndata.length > 0) {\r
// The easiest way to bubble the revert reason is using memory via assembly\r
\r
// solhint-disable-next-line no-inline-assembly\r
assembly {\r
let returndata_size := mload(returndata)\r
revert(add(32, returndata), returndata_size)\r
}\r
} else {\r
revert(errorMessage);\r
}\r
}\r
}\r
}\r
\r
// File @openzeppelin/contracts-upgradeable/proxy/Initializable.sol@v3.4.2\r
\r
// solhint-disable-next-line compiler-version\r
pragma solidity >=0.4.24 <0.8.0;\r
\r
/**\r
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\r
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\r
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\r
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\r
*\r
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\r
* possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.\r
*\r
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\r
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\r
*/\r
abstract contract Initializable {\r
/**\r
* @dev Indicates that the contract has been initialized.\r
*/\r
bool private _initialized;\r
\r
/**\r
* @dev Indicates that the contract is in the process of being initialized.\r
*/\r
bool private _initializing;\r
\r
/**\r
* @dev Modifier to protect an initializer function from being invoked twice.\r
*/\r
modifier initializer() {\r
require(\r
_initializing || _isConstructor() || !_initialized,\r
"Initializable: contract is already initialized"\r
);\r
\r
bool isTopLevelCall = !_initializing;\r
if (isTopLevelCall) {\r
_initializing = true;\r
_initialized = true;\r
}\r
\r
_;\r
\r
if (isTopLevelCall) {\r
_initializing = false;\r
}\r
}\r
\r
/// @dev Returns true if and only if the function is running in the constructor\r
function _isConstructor() private view returns (bool) {\r
return !AddressUpgradeable.isContract(address(this));\r
}\r
}\r
\r
// File @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol@v3.4.2\r
\r
pragma solidity >=0.6.0 <0.8.0;\r
\r
/*\r
* @dev Provides information about the current execution context, including the\r
* sender of the transaction and its data. While these are generally available\r
* via msg.sender and msg.data, they should not be accessed in such a direct\r
* manner, since when dealing with GSN meta-transactions the account sending and\r
* paying for execution may not be the actual sender (as far as an application\r
* is concerned).\r
*\r
* This contract is only required for intermediate, library-like contracts.\r
*/\r
abstract contract ContextUpgradeable is Initializable {\r
function __Context_init() internal initializer {\r
__Context_init_unchained();\r
}\r
\r
function __Context_init_unchained() internal initializer {}\r
\r
function _msgSender() internal view virtual returns (address payable) {\r
return msg.sender;\r
}\r
\r
function _msgData() internal view virtual returns (bytes memory) {\r
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\r
return msg.data;\r
}\r
\r
uint256[50] private __gap;\r
}\r
\r
// File @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol@v3.4.2\r
\r
pragma solidity >=0.6.0 <0.8.0;\r
\r
/**\r
* @dev Contract module which provides a basic access control mechanism, where\r
* there is an account (an owner) that can be granted exclusive access to\r
* specific functions.\r
*\r
* By default, the owner account will be the one that deploys the contract. This\r
* can later be changed with {transferOwnership}.\r
*\r
* This module is used through inheritance. It will make available the modifier\r
* `onlyOwner`, which can be applied to your functions to restrict their use to\r
* the owner.\r
*/\r
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\r
address private _owner;\r
\r
event OwnershipTransferred(\r
address indexed previousOwner,\r
address indexed newOwner\r
);\r
\r
/**\r
* @dev Initializes the contract setting the deployer as the initial owner.\r
*/\r
function __Ownable_init() internal initializer {\r
__Context_init_unchained();\r
__Ownable_init_unchained();\r
}\r
\r
function __Ownable_init_unchained() internal initializer {\r
address msgSender = _msgSender();\r
_owner = msgSender;\r
emit OwnershipTransferred(address(0), msgSender);\r
}\r
\r
/**\r
* @dev Returns the address of the current owner.\r
*/\r
function owner() public view virtual returns (address) {\r
return _owner;\r
}\r
\r
/**\r
* @dev Throws if called by any account other than the owner.\r
*/\r
modifier onlyOwner() {\r
require(owner() == _msgSender(), "Ownable: caller is not the owner");\r
_;\r
}\r
\r
/**\r
* @dev Leaves the contract without owner. It will not be possible to call\r
* `onlyOwner` functions anymore. Can only be called by the current owner.\r
*\r
* NOTE: Renouncing ownership will leave the contract without an owner,\r
* thereby removing any functionality that is only available to the owner.\r
*/\r
function renounceOwnership() public virtual onlyOwner {\r
emit OwnershipTransferred(_owner, address(0));\r
_owner = address(0);\r
}\r
\r
/**\r
* @dev Transfers ownership of the contract to a new account (`newOwner`).\r
* Can only be called by the current owner.\r
*/\r
function transferOwnership(address newOwner) public virtual onlyOwner {\r
require(\r
newOwner != address(0),\r
"Ownable: new owner is the zero address"\r
);\r
emit OwnershipTransferred(_owner, newOwner);\r
_owner = newOwner;\r
}\r
\r
uint256[49] private __gap;\r
}\r
\r
// File @openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol@v3.4.2\r
\r
pragma solidity >=0.6.0 <0.8.0;\r
\r
/**\r
* @dev Contract module that helps prevent reentrant calls to a function.\r
*\r
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\r
* available, which can be applied to functions to make sure there are no nested\r
* (reentrant) calls to them.\r
*\r
* Note that because there is a single `nonReentrant` guard, functions marked as\r
* `nonReentrant` may not call one another. This can be worked around by making\r
* those functions `private`, and then adding `external` `nonReentrant` entry\r
* points to them.\r
*\r
* TIP: If you would like to learn more about reentrancy and alternative ways\r
* to protect against it, check out our blog post\r
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\r
*/\r
abstract contract ReentrancyGuardUpgradeable is Initializable {\r
// Booleans are more expensive than uint256 or any type that takes up a full\r
// word because each write operation emits an extra SLOAD to first read the\r
// slot's contents, replace the bits taken up by the boolean, and then write\r
// back. This is the compiler's defense against contract upgrades and\r
// pointer aliasing, and it cannot be disabled.\r
\r
// The values being non-zero value makes deployment a bit more expensive,\r
// but in exchange the refund on every call to nonReentrant will be lower in\r
// amount. Since refunds are capped to a percentage of the total\r
// transaction's gas, it is best to keep them low in cases like this one, to\r
// increase the likelihood of the full refund coming into effect.\r
uint256 private constant _NOT_ENTERED = 1;\r
uint256 private constant _ENTERED = 2;\r
\r
uint256 private _status;\r
\r
function __ReentrancyGuard_init() internal initializer {\r
__ReentrancyGuard_init_unchained();\r
}\r
\r
function __ReentrancyGuard_init_unchained() internal initializer {\r
_status = _NOT_ENTERED;\r
}\r
\r
/**\r
* @dev Prevents a contract from calling itself, directly or indirectly.\r
* Calling a `nonReentrant` function from another `nonReentrant`\r
* function is not supported. It is possible to prevent this from happening\r
* by making the `nonReentrant` function external, and make it call a\r
* `private` function that does the actual work.\r
*/\r
modifier nonReentrant() {\r
// On the first call to nonReentrant, _notEntered will be true\r
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");\r
\r
// Any calls to nonReentrant after this point will fail\r
_status = _ENTERED;\r
\r
_;\r
\r
// By storing the original value once again, a refund is triggered (see\r
// https://eips.ethereum.org/EIPS/eip-2200)\r
_status = _NOT_ENTERED;\r
}\r
uint256[49] private __gap;\r
}\r
\r
// File @openzeppelin/contracts/token/ERC20/IERC20.sol@v3.4.2\r
\r
pragma solidity >=0.6.0 <0.8.0;\r
\r
/**\r
* @dev Interface of the ERC20 standard as defined in the EIP.\r
*/\r
interface IERC20 {\r
/**\r
* @dev Returns the amount of tokens in existence.\r
*/\r
function totalSupply() external view returns (uint256);\r
\r
/**\r
* @dev Returns the amount of tokens owned by `account`.\r
*/\r
function balanceOf(address account) external view returns (uint256);\r
\r
/**\r
* @dev Moves `amount` tokens from the caller's account to `recipient`.\r
*\r
* Returns a boolean value indicating whether the operation succeeded.\r
*\r
* Emits a {Transfer} event.\r
*/\r
function transfer(address recipient, uint256 amount)\r
external\r
returns (bool);\r
\r
/**\r
* @dev Returns the remaining number of tokens that `spender` will be\r
* allowed to spend on behalf of `owner` through {transferFrom}. This is\r
* zero by default.\r
*\r
* This value changes when {approve} or {transferFrom} are called.\r
*/\r
function allowance(address owner, address spender)\r
external\r
view\r
returns (uint256);\r
\r
/**\r
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\r
*\r
* Returns a boolean value indicating whether the operation succeeded.\r
*\r
* IMPORTANT: Beware that changing an allowance with this method brings the risk\r
* that someone may use both the old and the new allowance by unfortunate\r
* transaction ordering. One possible solution to mitigate this race\r
* condition is to first reduce the spender's allowance to 0 and set the\r
* desired value afterwards:\r
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r
*\r
* Emits an {Approval} event.\r
*/\r
function approve(address spender, uint256 amount) external returns (bool);\r
\r
/**\r
* @dev Moves `amount` tokens from `sender` to `recipient` using the\r
* allowance mechanism. `amount` is then deducted from the caller's\r
* allowance.\r
*\r
* Returns a boolean value indicating whether the operation succeeded.\r
*\r
* Emits a {Transfer} event.\r
*/\r
function transferFrom(\r
address sender,\r
address recipient,\r
uint256 amount\r
) external returns (bool);\r
\r
/**\r
* @dev Emitted when `value` tokens are moved from one account (`from`) to\r
* another (`to`).\r
*\r
* Note that `value` may be zero.\r
*/\r
event Transfer(address indexed from, address indexed to, uint256 value);\r
\r
/**\r
* @dev Emitted when the allowance of a `spender` for an `owner` is set by\r
* a call to {approve}. `value` is the new allowance.\r
*/\r
event Approval(\r
address indexed owner,\r
address indexed spender,\r
uint256 value\r
);\r
}\r
\r
// File @openzeppelin/contracts/utils/Address.sol@v3.4.2\r
\r
pragma solidity >=0.6.2 <0.8.0;\r
\r
/**\r
* @dev Collection of functions related to the address type\r
*/\r
library Address {\r
/**\r
* @dev Returns true if `account` is a contract.\r
*\r
* [IMPORTANT]\r
* ====\r
* It is unsafe to assume that an address for which this function returns\r
* false is an externally-owned account (EOA) and not a contract.\r
*\r
* Among others, `isContract` will return false for the following\r
* types of addresses:\r
*\r
* - an externally-owned account\r
* - a contract in construction\r
* - an address where a contract will be created\r
* - an address where a contract lived, but was destroyed\r
* ====\r
*/\r
function isContract(address account) internal view returns (bool) {\r
// This method relies on extcodesize, which returns 0 for contracts in\r
// construction, since the code is only stored at the end of the\r
// constructor execution.\r
\r
uint256 size;\r
// solhint-disable-next-line no-inline-assembly\r
assembly {\r
size := extcodesize(account)\r
}\r
return size > 0;\r
}\r
\r
/**\r
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r
* `recipient`, forwarding all available gas and reverting on errors.\r
*\r
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r
* of certain opcodes, possibly making contracts go over the 2300 gas limit\r
* imposed by `transfer`, making them unable to receive funds via\r
* `transfer`. {sendValue} removes this limitation.\r
*\r
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r
*\r
* IMPORTANT: because control is transferred to `recipient`, care must be\r
* taken to not create reentrancy vulnerabilities. Consider using\r
* {ReentrancyGuard} or the\r
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r
*/\r
function sendValue(address payable recipient, uint256 amount) internal {\r
require(\r
address(this).balance >= amount,\r
"Address: insufficient balance"\r
);\r
\r
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value\r
(bool success, ) = recipient.call{value: amount}("");\r
require(\r
success,\r
"Address: unable to send value, recipient may have reverted"\r
);\r
}\r
\r
/**\r
* @dev Performs a Solidity function call using a low level `call`. A\r
* plain`call` is an unsafe replacement for a function call: use this\r
* function instead.\r
*\r
* If `target` reverts with a revert reason, it is bubbled up by this\r
* function (like regular Solidity function calls).\r
*\r
* Returns the raw returned data. To convert to the expected return value,\r
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r
*\r
* Requirements:\r
*\r
* - `target` must be a contract.\r
* - calling `target` with `data` must not revert.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCall(address target, bytes memory data)\r
internal\r
returns (bytes memory)\r
{\r
return functionCall(target, data, "Address: low-level call failed");\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r
* `errorMessage` as a fallback revert reason when `target` reverts.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCall(\r
address target,\r
bytes memory data,\r
string memory errorMessage\r
) internal returns (bytes memory) {\r
return functionCallWithValue(target, data, 0, errorMessage);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r
* but also transferring `value` wei to `target`.\r
*\r
* Requirements:\r
*\r
* - the calling contract must have an ETH balance of at least `value`.\r
* - the called Solidity function must be `payable`.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCallWithValue(\r
address target,\r
bytes memory data,\r
uint256 value\r
) internal returns (bytes memory) {\r
return\r
functionCallWithValue(\r
target,\r
data,\r
value,\r
"Address: low-level call with value failed"\r
);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r
* with `errorMessage` as a fallback revert reason when `target` reverts.\r
*\r
* _Available since v3.1._\r
*/\r
function functionCallWithValue(\r
address target,\r
bytes memory data,\r
uint256 value,\r
string memory errorMessage\r
) internal returns (bytes memory) {\r
require(\r
address(this).balance >= value,\r
"Address: insufficient balance for call"\r
);\r
require(isContract(target), "Address: call to non-contract");\r
\r
// solhint-disable-next-line avoid-low-level-calls\r
(bool success, bytes memory returndata) = target.call{value: value}(\r
data\r
);\r
return _verifyCallResult(success, returndata, errorMessage);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r
* but performing a static call.\r
*\r
* _Available since v3.3._\r
*/\r
function functionStaticCall(address target, bytes memory data)\r
internal\r
view\r
returns (bytes memory)\r
{\r
return\r
functionStaticCall(\r
target,\r
data,\r
"Address: low-level static call failed"\r
);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r
* but performing a static call.\r
*\r
* _Available since v3.3._\r
*/\r
function functionStaticCall(\r
address target,\r
bytes memory data,\r
string memory errorMessage\r
) internal view returns (bytes memory) {\r
require(isContract(target), "Address: static call to non-contract");\r
\r
// solhint-disable-next-line avoid-low-level-calls\r
(bool success, bytes memory returndata) = target.staticcall(data);\r
return _verifyCallResult(success, returndata, errorMessage);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r
* but performing a delegate call.\r
*\r
* _Available since v3.4._\r
*/\r
function functionDelegateCall(address target, bytes memory data)\r
internal\r
returns (bytes memory)\r
{\r
return\r
functionDelegateCall(\r
target,\r
data,\r
"Address: low-level delegate call failed"\r
);\r
}\r
\r
/**\r
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r
* but performing a delegate call.\r
*\r
* _Available since v3.4._\r
*/\r
function functionDelegateCall(\r
address target,\r
bytes memory data,\r
string memory errorMessage\r
) internal returns (bytes memory) {\r
require(isContract(target), "Address: delegate call to non-contract");\r
\r
// solhint-disable-next-line avoid-low-level-calls\r
(bool success, bytes memory returndata) = target.delegatecall(data);\r
return _verifyCallResult(success, returndata, errorMessage);\r
}\r
\r
function _verifyCallResult(\r
bool success,\r
bytes memory returndata,\r
string memory errorMessage\r
) private pure returns (bytes memory) {\r
if (success) {\r
return returndata;\r
} else {\r
// Look for revert reason and bubble it up if present\r
if (returndata.length > 0) {\r
// The easiest way to bubble the revert reason is using memory via assembly\r
\r
// solhint-disable-next-line no-inline-assembly\r
assembly {\r
let returndata_size := mload(returndata)\r
revert(add(32, returndata), returndata_size)\r
}\r
} else {\r
revert(errorMessage);\r
}\r
}\r
}\r
}\r
\r
// File @openzeppelin/contracts/token/ERC20/SafeERC20.sol@v3.4.2\r
\r
pragma solidity >=0.6.0 <0.8.0;\r
\r
/**\r
* @title SafeERC20\r
* @dev Wrappers around ERC20 operations that throw on failure (when the token\r
* contract returns false). Tokens that return no value (and instead revert or\r
* throw on failure) are also supported, non-reverting calls are assumed to be\r
* successful.\r
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\r
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\r
*/\r
library SafeERC20 {\r
using SafeMath for uint256;\r
using Address for address;\r
\r
function safeTransfer(\r
IERC20 token,\r
address to,\r
uint256 value\r
) internal {\r
_callOptionalReturn(\r
token,\r
abi.encodeWithSelector(token.transfer.selector, to, value)\r
);\r
}\r
\r
function safeTransferFrom(\r
IERC20 token,\r
address from,\r
address to,\r
uint256 value\r
) internal {\r
_callOptionalReturn(\r
token,\r
abi.encodeWithSelector(token.transferFrom.selector, from, to, value)\r
);\r
}\r
\r
/**\r
* @dev Deprecated. This function has issues similar to the ones found in\r
* {IERC20-approve}, and its usage is discouraged.\r
*\r
* Whenever possible, use {safeIncreaseAllowance} and\r
* {safeDecreaseAllowance} instead.\r
*/\r
function safeApprove(\r
IERC20 token,\r
address spender,\r
uint256 value\r
) internal {\r
// safeApprove should only be called when setting an initial allowance,\r
// or when resetting it to zero. To increase and decrease it, use\r
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\r
// solhint-disable-next-line max-line-length\r
require(\r
(value == 0) || (token.allowance(address(this), spender) == 0),\r
"SafeERC20: approve from non-zero to non-zero allowance"\r
);\r
_callOptionalReturn(\r
token,\r
abi.encodeWithSelector(token.approve.selector, spender, value)\r
);\r
}\r
\r
function safeIncreaseAllowance(\r
IERC20 token,\r
address spender,\r
uint256 value\r
) internal {\r
uint256 newAllowance = token.allowance(address(this), spender).add(\r
value\r
);\r
_callOptionalReturn(\r
token,\r
abi.encodeWithSelector(\r
token.approve.selector,\r
spender,\r
newAllowance\r
)\r
);\r
}\r
\r
function safeDecreaseAllowance(\r
IERC20 token,\r
address spender,\r
uint256 value\r
) internal {\r
uint256 newAllowance = token.allowance(address(this), spender).sub(\r
value,\r
"SafeERC20: decreased allowance below zero"\r
);\r
_callOptionalReturn(\r
token,\r
abi.encodeWithSelector(\r
token.approve.selector,\r
spender,\r
newAllowance\r
)\r
);\r
}\r
\r
/**\r
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\r
* on the return value: the return value is optional (but if data is returned, it must not be false).\r
* @param token The token targeted by the call.\r
* @param data The call data (encoded using abi.encode or one of its variants).\r
*/\r
function _callOptionalReturn(IERC20 token, bytes memory data) private {\r
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\r
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\r
// the target address contains contract code and also asserts for success in the low-level call.\r
\r
bytes memory returndata = address(token).functionCall(\r
data,\r
"SafeERC20: low-level call failed"\r
);\r
if (returndata.length > 0) {\r
// Return data is optional\r
// solhint-disable-next-line max-line-length\r
require(\r
abi.decode(returndata, (bool)),\r
"SafeERC20: ERC20 operation did not succeed"\r
);\r
}\r
}\r
}\r
\r
// File contracts/ArcMasterChef.sol\r
\r
//** Arc MasterChef Contract */\r
//** Version 2.2.0 */\r
\r
pragma solidity 0.6.12;\r
pragma experimental ABIEncoderV2;\r
\r
contract ArcMasterChef is OwnableUpgradeable, ReentrancyGuardUpgradeable {\r
using SafeMath for uint256;\r
using SafeERC20 for IERC20;\r
// Info of each user.\r
struct UserInfo {\r
uint256 amount; // How many LP tokens the user has provided.\r
uint256 rewardDebt; // Reward debt. See explanation below.\r
uint256 rewardLockedUp; // Reward locked up.\r
uint256 nextHarvestUntil; // When can the user harvest again.\r
//\r
// We do some fancy math here. Basically, any point in time, the amount of Arcs\r
// entitled to a user but is pending to be distributed is:\r
//\r
// pending reward = (user.amount * pool.accArcPerShare) - user.rewardDebt\r
//\r
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:\r
// 1. The pool's `accArcPerShare` (and `lastRewardBlock`) gets updated.\r
// 2. User receives the pending reward sent to his/her address.\r
// 3. User's `amount` gets updated.\r
// 4. User's `rewardDebt` gets updated.\r
}\r
// Info of each pool.\r
struct PoolInfo {\r
IERC20 lpToken; // Address of LP token contract.\r
uint256 allocPoint; // How many allocation points assigned to this pool. Arcs to distribute per block.\r
uint256 lastRewardBlock; // Last block number that Arcs distribution occurs.\r
uint256 accArcPerShare; // Accumulated Arcs per share, times 1e12. See below.\r
uint16 depositFeeBP; // Deposit fee in basis points\r
uint256 harvestInterval; // Harvest interval in seconds\r
}\r
// The Arc TOKEN!\r
IERC20 public arc;\r
\r
// Deposit Fee address\r
address public feeAddress;\r
// Reward tokens holder address\r
address public rewardHolder;\r
// Arcs tokens created per block. 0.5 Arc per block. 10% to arc charity ( address )\r
uint256 public arcPerBlock;\r
// Bonus muliplier for early arc makers.\r
uint256 public constant BONUS_MULTIPLIER = 1;\r
// Max harvest interval: 14 days.\r
uint256 public constant MAXIMUM_HARVEST_INTERVAL = 10 days;\r
// Info of each pool.\r
PoolInfo[] public poolInfo;\r
// Info of each user that stakes LP tokens.\r
mapping(uint256 => mapping(address => UserInfo)) public userInfo;\r
// Total allocation points. Must be the sum of all allocation points in all pools.\r
uint256 public totalAllocPoint;\r
// The block number when Arcs mining starts.\r
uint256 public startBlock;\r
// Total locked up rewards\r
uint256 public totalLockedUpRewards;\r
// LP token status\r
mapping(address => bool) public exists;\r
\r
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);\r
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);\r
event Compound(address indexed user, uint256 indexed pid, uint256 amount);\r
event EmergencyWithdraw(\r
address indexed user,\r
uint256 indexed pid,\r
uint256 amount\r
);\r
event EmissionRateUpdated(\r
address indexed caller,\r
uint256 previousAmount,\r
uint256 newAmount\r
);\r
event RewardLockedUp(\r
address indexed user,\r
uint256 indexed pid,\r
uint256 amountLockedUp\r
);\r
\r
function initialize(\r
address _arc,\r
address _feeAddress,\r
address _rewardHolder,\r
uint256 _startBlock,\r
uint256 _arcPerBlock\r
) public initializer {\r
arc = IERC20(_arc);\r
rewardHolder = _rewardHolder;\r
startBlock = _startBlock;\r
arcPerBlock = _arcPerBlock;\r
\r
feeAddress = _feeAddress;\r
totalAllocPoint = 0;\r
__Ownable_init();\r
__ReentrancyGuard_init();\r
}\r
\r
function poolLength() external view returns (uint256) {\r
return poolInfo.length;\r
}\r
\r
// Add a new lp to the pool. Can only be called by the owner.\r
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.\r
function add(\r
uint256 _allocPoint,\r
IERC20 _lpToken,\r
uint16 _depositFeeBP,\r
uint256 _harvestInterval,\r
bool _withUpdate\r
) public onlyOwner {\r
require(!exists[address(_lpToken)], "add: token exists");\r
exists[address(_lpToken)] = true;\r
\r
require(_depositFeeBP <= 500, "add: invalid deposit fee basis points");\r
require(\r
_harvestInterval <= MAXIMUM_HARVEST_INTERVAL,\r
"add: invalid harvest interval"\r
);\r
if (_withUpdate) {\r
massUpdatePools();\r
}\r
uint256 lastRewardBlock = block.number > startBlock\r
? block.number\r
: startBlock;\r
totalAllocPoint = totalAllocPoint.add(_allocPoint);\r
poolInfo.push(\r
PoolInfo({\r
lpToken: _lpToken,\r
allocPoint: _allocPoint,\r
lastRewardBlock: lastRewardBlock,\r
accArcPerShare: 0,\r
depositFeeBP: _depositFeeBP,\r
harvestInterval: _harvestInterval\r
})\r
);\r
}\r
\r
// Update the given pool's Arcs allocation point and deposit fee. Can only be called by the owner.\r
function set(\r
uint256 _pid,\r
uint256 _allocPoint,\r
uint16 _depositFeeBP,\r
uint256 _harvestInterval,\r
bool _withUpdate\r
) public onlyOwner {\r
require(_depositFeeBP <= 500, "set: invalid deposit fee basis points");\r
require(\r
_harvestInterval <= MAXIMUM_HARVEST_INTERVAL,\r
"set: invalid harvest interval"\r
);\r
if (_withUpdate) {\r
massUpdatePools();\r
}\r
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(\r
_allocPoint\r
);\r
poolInfo[_pid].allocPoint = _allocPoint;\r
poolInfo[_pid].depositFeeBP = _depositFeeBP;\r
poolInfo[_pid].harvestInterval = _harvestInterval;\r
}\r
\r
// Return reward multiplier over the given _from to _to block.\r
function getMultiplier(uint256 _from, uint256 _to)\r
public\r
pure\r
returns (uint256)\r
{\r
return _to.sub(_from).mul(BONUS_MULTIPLIER);\r
}\r
\r
// View function to see pending Arcs on frontend.\r
function pendingArc(uint256 _pid, address _user)\r
external\r
view\r
returns (uint256)\r
{\r
PoolInfo storage pool = poolInfo[_pid];\r
UserInfo storage user = userInfo[_pid][_user];\r
uint256 accArcPerShare = pool.accArcPerShare;\r
uint256 lpSupply = pool.lpToken.balanceOf(address(this));\r
if (block.number > pool.lastRewardBlock && lpSupply != 0) {\r
uint256 multiplier = getMultiplier(\r
pool.lastRewardBlock,\r
block.number\r
);\r
uint256 arcReward = multiplier\r
.mul(arcPerBlock)\r
.mul(pool.allocPoint)\r
.div(totalAllocPoint);\r
accArcPerShare = accArcPerShare.add(\r
arcReward.mul(1e12).div(lpSupply)\r
);\r
}\r
uint256 pending = user.amount.mul(accArcPerShare).div(1e12).sub(\r
user.rewardDebt\r
);\r
return pending.add(user.rewardLockedUp);\r
}\r
\r
// View function to see if user can harvest Arcs.\r
function canHarvest(uint256 _pid, address _user)\r
public\r
view\r
returns (bool)\r
{\r
UserInfo storage user = userInfo[_pid][_user];\r
return block.timestamp >= user.nextHarvestUntil;\r
}\r
\r
// Update reward variables for all pools. Be careful of gas spending!\r
function massUpdatePools() public {\r
uint256 length = poolInfo.length;\r
for (uint256 pid = 0; pid < length; ++pid) {\r
updatePool(pid);\r
}\r
}\r
\r
// Update reward variables of the given pool to be up-to-date.\r
function updatePool(uint256 _pid) public {\r
PoolInfo storage pool = poolInfo[_pid];\r
if (block.number <= pool.lastRewardBlock) {\r
return;\r
}\r
uint256 lpSupply = pool.lpToken.balanceOf(address(this));\r
if (lpSupply == 0 || pool.allocPoint == 0) {\r
pool.lastRewardBlock = block.number;\r
return;\r
}\r
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);\r
uint256 arcReward = multiplier\r
.mul(arcPerBlock)\r
.mul(pool.allocPoint)\r
.div(totalAllocPoint);\r
\r
pool.accArcPerShare = pool.accArcPerShare.add(\r
arcReward.mul(1e12).div(lpSupply)\r
);\r
pool.lastRewardBlock = block.number;\r
}\r
\r
// Deposit LP tokens to MasterChef for Arcs allocation.\r
function deposit(uint256 _pid, uint256 _amount) public nonReentrant {\r
PoolInfo storage pool = poolInfo[_pid];\r
UserInfo storage user = userInfo[_pid][msg.sender];\r
updatePool(_pid);\r
\r
payOrLockupPendingArc(_pid);\r
if (_amount > 0) {\r
uint256 beforeBalance = pool.lpToken.balanceOf(address(this));\r
pool.lpToken.safeTransferFrom(\r
address(msg.sender),\r
address(this),\r
_amount\r
);\r
_amount = pool.lpToken.balanceOf(address(this)).sub(beforeBalance);\r
if (pool.depositFeeBP > 0) {\r
uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000);\r
pool.lpToken.safeTransfer(feeAddress, depositFee);\r
user.amount = user.amount.add(_amount).sub(depositFee);\r
} else {\r
user.amount = user.amount.add(_amount);\r
}\r
}\r
user.rewardDebt = user.amount.mul(pool.accArcPerShare).div(1e12);\r
emit Deposit(msg.sender, _pid, _amount);\r
}\r
\r
// Withdraw LP tokens from MasterChef.\r
function withdraw(uint256 _pid, uint256 _amount) public nonReentrant {\r
PoolInfo storage pool = poolInfo[_pid];\r
UserInfo storage user = userInfo[_pid][msg.sender];\r
require(user.amount >= _amount, "withdraw: not good");\r
updatePool(_pid);\r
payOrLockupPendingArc(_pid);\r
if (_amount > 0) {\r
user.amount = user.amount.sub(_amount);\r
pool.lpToken.safeTransfer(address(msg.sender), _amount);\r
}\r
user.rewardDebt = user.amount.mul(pool.accArcPerShare).div(1e12);\r
emit Withdraw(msg.sender, _pid, _amount);\r
}\r
\r
// Compound tokens to Arc pool.\r
function compound(uint256 _pid) public nonReentrant {\r
PoolInfo storage pool = poolInfo[_pid];\r
UserInfo storage user = userInfo[_pid][msg.sender];\r
require(\r
address(pool.lpToken) == address(arc),\r
"compound: not able to compound"\r
);\r
updatePool(_pid);\r
uint256 pending = user.amount.mul(pool.accArcPerShare).div(1e12).sub(\r
user.rewardDebt\r
);\r
safeArcTransferFrom(rewardHolder, address(this), pending);\r
user.amount = user.amount.add(pending);\r
user.rewardDebt = user.amount.mul(pool.accArcPerShare).div(1e12);\r
emit Compound(msg.sender, _pid, pending);\r
}\r
\r
// Withdraw without caring about rewards. EMERGENCY ONLY.\r
function emergencyWithdraw(uint256 _pid) public nonReentrant {\r
PoolInfo storage pool = poolInfo[_pid];\r
UserInfo storage user = userInfo[_pid][msg.sender];\r
uint256 amount = user.amount;\r
user.amount = 0;\r
user.rewardDebt = 0;\r
user.rewardLockedUp = 0;\r
user.nextHarvestUntil = 0;\r
pool.lpToken.safeTransfer(address(msg.sender), amount);\r
emit EmergencyWithdraw(msg.sender, _pid, amount);\r
}\r
\r
// Pay or lockup pending Arcs.\r
function payOrLockupPendingArc(uint256 _pid) internal {\r
PoolInfo storage pool = poolInfo[_pid];\r
UserInfo storage user = userInfo[_pid][msg.sender];\r
if (user.nextHarvestUntil == 0) {\r
user.nextHarvestUntil = block.timestamp.add(pool.harvestInterval);\r
}\r
uint256 pending = user.amount.mul(pool.accArcPerShare).div(1e12).sub(\r
user.rewardDebt\r
);\r
if (canHarvest(_pid, msg.sender)) {\r
if (pending > 0 || user.rewardLockedUp > 0) {\r
uint256 totalRewards = pending.add(user.rewardLockedUp);\r
// reset lockup\r
totalLockedUpRewards = totalLockedUpRewards.sub(\r
user.rewardLockedUp\r
);\r
user.rewardLockedUp = 0;\r
user.nextHarvestUntil = block.timestamp.add(\r
pool.harvestInterval\r
);\r
// send rewards\r
safeArcTransferFrom(rewardHolder, msg.sender, totalRewards);\r
}\r
} else if (pending > 0) {\r
user.rewardLockedUp = user.rewardLockedUp.add(pending);\r
totalLockedUpRewards = totalLockedUpRewards.add(pending);\r
emit RewardLockedUp(msg.sender, _pid, pending);\r
}\r
}\r
\r
// Safe Arc transfer function, just in case if rounding error causes pool to not have enough arcs.\r
function safeArcTransferFrom(\r
address _from,\r
address _to,\r
uint256 _amount\r
) internal {\r
uint256 arcBal = arc.balanceOf(rewardHolder);\r
if (_amount > arcBal) {\r
revert("Not enough balance");\r
} else {\r
arc.transferFrom(_from, _to, _amount);\r
}\r
}\r
\r
function setFeeAddress(address _feeAddress) public {\r
require(msg.sender == feeAddress, "setFeeAddress: FORBIDDEN");\r
require(_feeAddress != address(0), "setFeeAddress: ZERO");\r
feeAddress = _feeAddress;\r
}\r
\r
function setRewardHolder(address _rewardHolder) public {\r
require(msg.sender == rewardHolder, "setRewardHolder: FORBIDDEN");\r
require(_rewardHolder != address(0), "setRewardHolder: ZERO");\r
rewardHolder = _rewardHolder;\r
}\r
\r
// Pancake has to add hidden dummy pools in order to alter the emission, here we make it simple and transparent to all.\r
function updateEmissionRate(uint256 _arcPerBlock) public onlyOwner {\r
massUpdatePools();\r
emit EmissionRateUpdated(msg.sender, arcPerBlock, _arcPerBlock);\r
arcPerBlock = _arcPerBlock;\r
}\r
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-10-24 13:06:47
Comments
Log in to comment.
No comments yet.