Contract Overview
Balance:
0 CLV
CLV Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x13cf3f0932349ea78c80a0113e0b674a727717a13e3ed4aab6ad187c6acf069a | 0x610bb561 | 2711671 | 12 days 13 hrs ago | 0xd134a7d9485c1aac0cbf82718cf6d6e3fd130945 | IN | Create: ERC20StakingModuleInfo | 0 CLV | 0.00699321 |
[ Download CSV Export ]
Contract Name:
ERC20StakingModuleInfo
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
/* ERC20StakingModule https://github.com/FanbaseEU/Staking_Ethereum_SmartContracts SPDX-License-Identifier: MIT */ pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./interfaces/IStakingModule.sol"; /** * @title ERC20 staking module * * @notice this staking module allows users to deposit an amount of ERC20 token * in exchange for shares credited to their address. When the user * unstakes, these shares will be burned and a reward will be distributed. */ contract ERC20StakingModule is IStakingModule { using SafeERC20 for IERC20; // constant uint256 public constant INITIAL_SHARES_PER_TOKEN = 10**6; // members IERC20 private immutable _token; address private immutable _factory; mapping(address => uint256) public shares; uint256 public totalShares; /** * @param token_ the token that will be rewarded */ constructor(address token_, address factory_) { _token = IERC20(token_); _factory = factory_; } /** * @inheritdoc IStakingModule */ function tokens() external view override returns (address[] memory tokens_) { tokens_ = new address[](1); tokens_[0] = address(_token); } /** * @inheritdoc IStakingModule */ function balances(address user) external view override returns (uint256[] memory balances_) { balances_ = new uint256[](1); balances_[0] = _balance(user); } /** * @inheritdoc IStakingModule */ function factory() external view override returns (address) { return _factory; } /** * @inheritdoc IStakingModule */ function totals() external view override returns (uint256[] memory totals_) { totals_ = new uint256[](1); totals_[0] = _token.balanceOf(address(this)); } /** * @inheritdoc IStakingModule */ function stake( address user, uint256 amount, bytes calldata ) external override onlyOwner returns (address, uint256) { // validate require(amount > 0, "Staking amount must greater than 0"); // transfer uint256 total = _token.balanceOf(address(this)); _token.safeTransferFrom(user, address(this), amount); uint256 actual = _token.balanceOf(address(this)) - total; // mint staking shares at current rate uint256 minted = (totalShares > 0) ? (totalShares * actual) / total : actual * INITIAL_SHARES_PER_TOKEN; require(minted > 0, "User share must greater than 0"); // update user staking info shares[user] += minted; // add newly minted shares to global total totalShares += minted; emit Staked(user, address(_token), amount, minted); return (user, minted); } /** * @inheritdoc IStakingModule */ function unstake( address user, uint256 amount, bytes calldata ) external override onlyOwner returns (address, uint256) { // validate and get shares uint256 burned = _shares(user, amount); // burn shares totalShares -= burned; shares[user] -= burned; // unstake _token.safeTransfer(user, amount); emit Unstaked(user, address(_token), amount, burned); return (user, burned); } /** * @inheritdoc IStakingModule */ function claim( address user, uint256 amount, bytes calldata ) external override onlyOwner returns (address, uint256) { uint256 s = _shares(user, amount); emit Claimed(user, address(_token), amount, s); return (user, s); } /** * @inheritdoc IStakingModule */ function update(address) external override {} /** * @inheritdoc IStakingModule */ function clean() external override {} /** * @dev internal helper to get user balance * @param user address of interest */ function _balance(address user) private view returns (uint256) { if (totalShares == 0) { return 0; } return (_token.balanceOf(address(this)) * shares[user]) / totalShares; } /** * @dev internal helper to validate and convert user stake amount to shares * @param user address of user * @param amount number of tokens to consider * @return shares_ equivalent number of shares */ function _shares(address user, uint256 amount) private view returns (uint256 shares_) { // validate require(amount > 0, "Unstaking amount must greater than 0"); require(totalShares > 0, "Insufficient shares in this pool"); // convert token amount to shares shares_ = (totalShares * amount) / _token.balanceOf(address(this)); require(shares_ > 0, "Shares must greater than 0"); require(shares[user] >= shares_, "User shares exceeds total shares"); } }
/* ERC20StakingModuleInfo https://github.com/FanbaseEU/Staking_Ethereum_SmartContracts SPDX-License-Identifier: MIT */ pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "../interfaces/IStakingModule.sol"; import "../ERC20StakingModule.sol"; /** * @title ERC20 staking module info library * * @notice this library provides read-only convenience functions to query * additional information about the ERC20StakingModule contract. */ library ERC20StakingModuleInfo { /** * @notice convenience function to get token metadata in a single call * @param module address of staking module * @return address * @return name * @return symbol * @return decimals */ function token(address module) public view returns ( address, string memory, string memory, uint8 ) { IStakingModule m = IStakingModule(module); IERC20Metadata tkn = IERC20Metadata(m.tokens()[0]); return (address(tkn), tkn.name(), tkn.symbol(), tkn.decimals()); } /** * @notice quote the share value for an amount of tokens * @param module address of staking module * @param addr account address of interest * @param amount number of tokens. if zero, return entire share balance * @return number of shares */ function shares( address module, address addr, uint256 amount ) public view returns (uint256) { ERC20StakingModule m = ERC20StakingModule(module); // return all user shares if (amount == 0) { return m.shares(addr); } uint256 totalShares = m.totalShares(); require(totalShares > 0, "smi1"); // convert token amount to shares IERC20Metadata tkn = IERC20Metadata(m.tokens()[0]); uint256 s = (totalShares * amount) / tkn.balanceOf(module); require(s > 0, "smi2"); require(m.shares(addr) >= s, "smi3"); return s; } /** * @notice get shares per token * @param module address of staking module * @return current shares per token */ function sharesPerToken(address module) public view returns (uint256) { ERC20StakingModule m = ERC20StakingModule(module); uint256 totalShares = m.totalShares(); if (totalShares == 0) { return 1e24; } IERC20Metadata tkn = IERC20Metadata(m.tokens()[0]); return (totalShares * 1e18) / tkn.balanceOf(module); } }
/* IEvents https://github.com/FanbaseEU/Staking_Ethereum_SmartContracts SPDX-License-Identifier: MIT */ pragma solidity 0.8.4; /** * @title GYSR event system * * @notice common interface to define GYSR event system */ interface IEvents { // staking event Staked( address indexed user, address indexed token, uint256 amount, uint256 shares ); event Unstaked( address indexed user, address indexed token, uint256 amount, uint256 shares ); event Claimed( address indexed user, address indexed token, uint256 amount, uint256 shares ); // rewards event RewardsDistributed( address indexed user, address indexed token, uint256 amount, uint256 shares ); event RewardsFunded( address indexed token, uint256 amount, uint256 shares, uint256 timestamp ); event RewardsUnlocked(address indexed token, uint256 shares); event RewardsExpired( address indexed token, uint256 amount, uint256 shares, uint256 timestamp ); // gysr event GysrSpent(address indexed user, uint256 amount); event GysrVested(address indexed user, uint256 amount); event GysrWithdrawn(uint256 amount); }
/* IStakingModule https://github.com/FanbaseEU/Staking_Ethereum_SmartContracts SPDX-License-Identifier: MIT */ pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IEvents.sol"; import "../OwnerController.sol"; /** * @title Staking module interface * * @notice this contract defines the common interface that any staking module * must implement to be compatible with the modular Pool architecture. */ abstract contract IStakingModule is OwnerController, IEvents { // constants uint256 public constant DECIMALS = 18; /** * @return array of staking tokens */ function tokens() external view virtual returns (address[] memory); /** * @notice get balance of user * @param user address of user * @return balances of each staking token */ function balances(address user) external view virtual returns (uint256[] memory); /** * @return address of module factory */ function factory() external view virtual returns (address); /** * @notice get total staked amount * @return totals for each staking token */ function totals() external view virtual returns (uint256[] memory); /** * @notice stake an amount of tokens for user * @param user address of user * @param amount number of tokens to stake * @param data additional data * @return address of staking account * @return number of shares minted for stake */ function stake( address user, uint256 amount, bytes calldata data ) external virtual returns (address, uint256); /** * @notice unstake an amount of tokens for user * @param user address of user * @param amount number of tokens to unstake * @param data additional data * @return address of staking account * @return number of shares burned for unstake */ function unstake( address user, uint256 amount, bytes calldata data ) external virtual returns (address, uint256); /** * @notice quote the share value for an amount of tokens without unstaking * @param user address of user * @param amount number of tokens to claim with * @param data additional data * @return address of staking account * @return number of shares that the claim amount is worth */ function claim( address user, uint256 amount, bytes calldata data ) external virtual returns (address, uint256); /** * @notice method called by anyone to update accounting * @param user address of user for update * @dev will only be called ad hoc and should not contain essential logic */ function update(address user) external virtual; /** * @notice method called by owner to clean up and perform additional accounting * @dev will only be called ad hoc and should not contain any essential logic */ function clean() external virtual; }
/* OwnerController https://github.com/FanbaseEU/Staking_Ethereum_SmartContracts SPDX-License-Identifier: MIT */ pragma solidity 0.8.4; /** * @title Owner controller * * @notice this base contract implements an owner-controller access model. * * @dev the contract is an adapted version of the OpenZeppelin Ownable contract. * It allows the owner to designate an additional account as the controller to * perform restricted operations. * * Other changes include supporting role verification with a require method * in addition to the modifier option, and removing some unneeded functionality. * * Original contract here: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol */ contract OwnerController { address private _owner; address private _controller; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); event ControlTransferred( address indexed previousController, address indexed newController ); constructor() { _owner = msg.sender; _controller = msg.sender; emit OwnershipTransferred(address(0), _owner); emit ControlTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Returns the address of the current controller. */ function controller() public view returns (address) { return _controller; } /** * @dev Modifier that throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == msg.sender, "Only owner can perform this action"); _; } /** * @dev Modifier that throws if called by any account other than the controller. */ modifier onlyController() { require(_controller == msg.sender, "Only controller can perform this action"); _; } /** * @dev Throws if called by any account other than the owner. */ function requireOwner() internal view { require(_owner == msg.sender, "Only owner can perform this action"); } /** * @dev Throws if called by any account other than the controller. */ function requireController() internal view { require(_controller == msg.sender, "Only controller can perform this action"); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). This can * include renouncing ownership by transferring to the zero address. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual { requireOwner(); require(newOwner != address(0), "New owner address can't be zero"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } /** * @dev Transfers control of the contract to a new account (`newController`). * Can only be called by the owner. */ function transferControl(address newController) public virtual { requireOwner(); require(newController != address(0), "New controller address can't be zero"); emit ControlTransferred(_controller, newController); _controller = newController; } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"module","type":"address"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"shares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"sharesPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610bb561003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361061004b5760003560e01c806336fe2c99146100505780635ab2c676146100765780636d46a1db14610089575b600080fd5b61006361005e366004610873565b6100ac565b6040519081526020015b60405180910390f35b610063610084366004610857565b610467565b61009c610097366004610857565b61063e565b60405161006d9493929190610a5c565b600083826101355760405163673e156160e11b81526001600160a01b03858116600483015282169063ce7c2ac29060240160206040518083038186803b1580156100f557600080fd5b505afa158015610109573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012d91906109f7565b915050610460565b6000816001600160a01b0316633a98ef396040518163ffffffff1660e01b815260040160206040518083038186803b15801561017057600080fd5b505afa158015610184573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a891906109f7565b9050600081116102055760405162461bcd60e51b81526004016101fc9060208082526004908201527f736d693100000000000000000000000000000000000000000000000000000000604082015260600190565b60405180910390fd5b6000826001600160a01b0316639d63848a6040518163ffffffff1660e01b815260040160006040518083038186803b15801561024057600080fd5b505afa158015610254573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261027c91908101906108b3565b60008151811061029c57634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516370a0823160e01b81526001600160a01b0389811660048301529192506000918316906370a082319060240160206040518083038186803b1580156102ee57600080fd5b505afa158015610302573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061032691906109f7565b6103308785610af6565b61033a9190610ad6565b90506000811161038e5760405162461bcd60e51b81526004016101fc9060208082526004908201527f736d693200000000000000000000000000000000000000000000000000000000604082015260600190565b60405163673e156160e11b81526001600160a01b03888116600483015282919086169063ce7c2ac29060240160206040518083038186803b1580156103d257600080fd5b505afa1580156103e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040a91906109f7565b101561045a5760405162461bcd60e51b81526004016101fc9060208082526004908201527f736d693300000000000000000000000000000000000000000000000000000000604082015260600190565b93505050505b9392505050565b6000808290506000816001600160a01b0316633a98ef396040518163ffffffff1660e01b815260040160206040518083038186803b1580156104a857600080fd5b505afa1580156104bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e091906109f7565b9050806104fa575069d3c21bcecceda10000009392505050565b6000826001600160a01b0316639d63848a6040518163ffffffff1660e01b815260040160006040518083038186803b15801561053557600080fd5b505afa158015610549573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261057191908101906108b3565b60008151811061059157634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516370a0823160e01b81526001600160a01b038781166004830152919250908216906370a082319060240160206040518083038186803b1580156105e157600080fd5b505afa1580156105f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061991906109f7565b61062b83670de0b6b3a7640000610af6565b6106359190610ad6565b95945050505050565b60006060806000808590506000816001600160a01b0316639d63848a6040518163ffffffff1660e01b815260040160006040518083038186803b15801561068457600080fd5b505afa158015610698573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106c091908101906108b3565b6000815181106106e057634e487b7160e01b600052603260045260246000fd5b6020026020010151905080816001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561072457600080fd5b505afa158015610738573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107609190810190610967565b826001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561079957600080fd5b505afa1580156107ad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107d59190810190610967565b836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561080e57600080fd5b505afa158015610822573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108469190610a0f565b955095509550955050509193509193565b600060208284031215610868578081fd5b813561046081610b67565b600080600060608486031215610887578182fd5b833561089281610b67565b925060208401356108a281610b67565b929592945050506040919091013590565b600060208083850312156108c5578182fd5b825167ffffffffffffffff808211156108dc578384fd5b818501915085601f8301126108ef578384fd5b81518181111561090157610901610b51565b8060051b9150610912848301610aa5565b8181528481019084860184860187018a101561092c578788fd5b8795505b8386101561095a578051945061094585610b67565b84835260019590950194918601918601610930565b5098975050505050505050565b600060208284031215610978578081fd5b815167ffffffffffffffff8082111561098f578283fd5b818401915084601f8301126109a2578283fd5b8151818111156109b4576109b4610b51565b6109c7601f8201601f1916602001610aa5565b91508082528560208285010111156109dd578384fd5b6109ee816020840160208601610b21565b50949350505050565b600060208284031215610a08578081fd5b5051919050565b600060208284031215610a20578081fd5b815160ff81168114610460578182fd5b60008151808452610a48816020860160208601610b21565b601f01601f19169290920160200192915050565b6001600160a01b0385168152608060208201526000610a7e6080830186610a30565b8281036040840152610a908186610a30565b91505060ff8316606083015295945050505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715610ace57610ace610b51565b604052919050565b600082610af157634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610b1c57634e487b7160e01b81526011600452602481fd5b500290565b60005b83811015610b3c578181015183820152602001610b24565b83811115610b4b576000848401525b50505050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610b7c57600080fd5b5056fea264697066735822122074abe08d07d369c3366e073ed2b7a4a2502a00bbee24827735c3824fece1e11064736f6c63430008040033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.