POL Price: $0.597262 (-2.18%)
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Latest 3 internal transactions

Parent Transaction Hash Block From To
520996402024-01-08 22:37:13340 days ago1704753433
0x9613d038...CF498A782
 Contract Creation0 POL
491079052023-10-24 20:39:17416 days ago1698179957
0x9613d038...CF498A782
 Contract Creation0 POL
446706162023-07-04 11:31:43529 days ago1688470303
0x9613d038...CF498A782
 Contract Creation0 POL
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC20StakingModuleFactory

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
File 1 of 12 : ERC20StakingModuleFactory.sol
/*
ERC20StakingModuleFactory

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
*/

pragma solidity 0.8.18;

import "./interfaces/IModuleFactory.sol";
import "./ERC20StakingModule.sol";

/**
 * @title ERC20 staking module factory
 *
 * @notice this factory contract handles deployment for the
 * ERC20StakingModule contract
 *
 * @dev it is called by the parent PoolFactory and is responsible
 * for parsing constructor arguments before creating a new contract
 */
contract ERC20StakingModuleFactory is IModuleFactory {
    /**
     * @inheritdoc IModuleFactory
     */
    function createModule(address, bytes calldata data)
        external
        override
        returns (address)
    {
        // validate
        require(data.length == 32, "smf1");

        // parse staking token
        address token;
        assembly {
            token := calldataload(100)
        }

        // create module
        ERC20StakingModule module =
            new ERC20StakingModule(token, address(this));
        module.transferOwnership(msg.sender);

        // output
        emit ModuleCreated(msg.sender, address(module));
        return address(module);
    }
}

File 2 of 12 : draft-IERC20Permit.sol
// 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);
}

File 3 of 12 : IERC20.sol
// 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);
}

File 4 of 12 : SafeERC20.sol
// 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");
        }
    }
}

File 5 of 12 : Address.sol
// 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);
        }
    }
}

File 6 of 12 : ERC20StakingModule.sol
/*
ERC20StakingModule

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
*/

pragma solidity 0.8.18;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "./interfaces/IStakingModule.sol";
import "./OwnerController.sol";
import "./TokenUtils.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, OwnerController {
    using SafeERC20 for IERC20;
    using TokenUtils for IERC20;

    // events
    event Approval(address indexed user, address indexed operator, bool value);

    // members
    IERC20 private immutable _token;
    address private immutable _factory;

    mapping(address => uint256) public shares;
    uint256 public totalShares;
    mapping(address => mapping(address => bool)) public approvals;

    /**
     * @param token_ the token that will be staked
     * @param factory_ address of module factory
     */
    constructor(address token_, address factory_) {
        require(token_ != address(0));
        _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 sender,
        uint256 amount,
        bytes calldata data
    ) external override onlyOwner returns (bytes32, uint256) {
        // validate
        require(amount > 0, "sm1");
        address account = _account(sender, data);

        // transfer
        uint256 minted = _token.receiveAmount(totalShares, sender, amount);

        // update user staking info
        shares[account] += minted;

        // add newly minted shares to global total
        totalShares += minted;

        bytes32 account_ = bytes32(uint256(uint160(account)));
        emit Staked(account_, sender, address(_token), amount, minted);

        return (account_, minted);
    }

    /**
     * @inheritdoc IStakingModule
     */
    function unstake(
        address sender,
        uint256 amount,
        bytes calldata data
    ) external override onlyOwner returns (bytes32, address, uint256) {
        // validate and get shares
        address account = _account(sender, data);
        uint256 burned = _shares(account, amount);

        // burn shares
        totalShares -= burned;
        shares[account] -= burned;

        // unstake
        _token.safeTransfer(sender, amount);

        bytes32 account_ = bytes32(uint256(uint160(account)));
        emit Unstaked(account_, sender, address(_token), amount, burned);

        return (account_, sender, burned);
    }

    /**
     * @inheritdoc IStakingModule
     */
    function claim(
        address sender,
        uint256 amount,
        bytes calldata data
    ) external override onlyOwner returns (bytes32, address, uint256) {
        address account = _account(sender, data);
        uint256 s = _shares(account, amount);
        bytes32 account_ = bytes32(uint256(uint160(account)));
        emit Claimed(account_, sender, address(_token), amount, s);
        return (account_, sender, s);
    }

    /**
     * @inheritdoc IStakingModule
     */
    function update(
        address sender,
        bytes calldata data
    ) external view override returns (bytes32) {
        return (bytes32(uint256(uint160(_account(sender, data)))));
    }

    /**
     * @inheritdoc IStakingModule
     */
    function clean(bytes calldata) external override {}

    /**
     * @notice set approval for operators to act on user position
     * @param operator address of operator
     * @param value boolean to grant or revoke approval
     */
    function approve(address operator, bool value) external {
        approvals[msg.sender][operator] = value;
        emit Approval(msg.sender, operator, value);
    }

    /**
     * @dev internal helper to get user balance
     * @param user address of interest
     */
    function _balance(address user) private view returns (uint256) {
        return _token.getAmount(totalShares, shares[user]);
    }

    /**
     * @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, "sm3");
        require(totalShares > 0, "sm4");

        // convert token amount to shares
        shares_ = _token.getShares(totalShares, amount);

        require(shares_ > 0, "sm5");
        require(shares[user] >= shares_, "sm6");
    }

    /**
     * @dev internal helper to get account and validate approval
     * @param sender address of sender
     * @param data either empty bytes or encoded account address
     */
    function _account(
        address sender,
        bytes calldata data
    ) private view returns (address) {
        require(data.length == 0 || data.length == 32, "sm7");

        if (data.length > 0) {
            address account;
            assembly {
                account := calldataload(132)
            }
            require(approvals[account][sender], "sm8");
            return account;
        } else {
            return sender;
        }
    }
}

File 7 of 12 : IEvents.sol
/*
IEvents

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
 */

pragma solidity 0.8.18;

/**
 * @title GYSR event system
 *
 * @notice common interface to define GYSR event system
 */
interface IEvents {
    // staking
    event Staked(
        bytes32 indexed account,
        address indexed user,
        address indexed token,
        uint256 amount,
        uint256 shares
    );
    event Unstaked(
        bytes32 indexed account,
        address indexed user,
        address indexed token,
        uint256 amount,
        uint256 shares
    );
    event Claimed(
        bytes32 indexed account,
        address indexed user,
        address indexed token,
        uint256 amount,
        uint256 shares
    );
    event Updated(bytes32 indexed account, address indexed user);

    // 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 RewardsExpired(
        address indexed token,
        uint256 amount,
        uint256 shares,
        uint256 timestamp
    );
    event RewardsWithdrawn(
        address indexed token,
        uint256 amount,
        uint256 shares,
        uint256 timestamp
    );
    event RewardsUpdated(bytes32 indexed account);

    // gysr
    event GysrSpent(address indexed user, uint256 amount);
    event GysrVested(address indexed user, uint256 amount);
    event GysrWithdrawn(uint256 amount);
    event Fee(address indexed receiver, address indexed token, uint256 amount);
}

File 8 of 12 : IModuleFactory.sol
/*
IModuleFactory

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
*/

pragma solidity 0.8.18;

/**
 * @title Module factory interface
 *
 * @notice this defines the common module factory interface used by the
 * main factory to create the staking and reward modules for a new Pool.
 */
interface IModuleFactory {
    // events
    event ModuleCreated(address indexed user, address module);

    /**
     * @notice create a new Pool module
     * @param config address for configuration contract
     * @param data binary encoded construction parameters
     * @return address of newly created module
     */
    function createModule(address config, bytes calldata data)
        external
        returns (address);
}

File 9 of 12 : IOwnerController.sol
/*
IOwnerController

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
*/

pragma solidity 0.8.18;

/**
 * @title Owner controller interface
 *
 * @notice this defines the interface for any contracts that use the
 * owner controller access pattern
 */
interface IOwnerController {
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() external view returns (address);

    /**
     * @dev Returns the address of the current controller.
     */
    function controller() external view returns (address);

    /**
     * @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) external;

    /**
     * @dev Transfers control of the contract to a new account (`newController`).
     * Can only be called by the owner.
     */
    function transferControl(address newController) external;
}

File 10 of 12 : IStakingModule.sol
/*
IStakingModule

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
*/

pragma solidity 0.8.18;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "./IEvents.sol";
import "./IOwnerController.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.
 */
interface IStakingModule is IOwnerController, IEvents {
    /**
     * @return array of staking tokens
     */
    function tokens() external view 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 returns (uint256[] memory);

    /**
     * @return address of module factory
     */
    function factory() external view returns (address);

    /**
     * @notice get total staked amount
     * @return totals for each staking token
     */
    function totals() external view returns (uint256[] memory);

    /**
     * @notice stake an amount of tokens for user
     * @param sender address of sender
     * @param amount number of tokens to stake
     * @param data additional data
     * @return bytes32 id of staking account
     * @return number of shares minted for stake
     */
    function stake(
        address sender,
        uint256 amount,
        bytes calldata data
    ) external returns (bytes32, uint256);

    /**
     * @notice unstake an amount of tokens for user
     * @param sender address of sender
     * @param amount number of tokens to unstake
     * @param data additional data
     * @return bytes32 id of staking account
     * @return address of reward receiver
     * @return number of shares burned for unstake
     */
    function unstake(
        address sender,
        uint256 amount,
        bytes calldata data
    ) external returns (bytes32, address, uint256);

    /**
     * @notice quote the share value for an amount of tokens without unstaking
     * @param sender address of sender
     * @param amount number of tokens to claim with
     * @param data additional data
     * @return bytes32 id of staking account
     * @return address of reward receiver
     * @return number of shares that the claim amount is worth
     */
    function claim(
        address sender,
        uint256 amount,
        bytes calldata data
    ) external returns (bytes32, address, uint256);

    /**
     * @notice method called by anyone to update accounting
     * @dev will only be called ad hoc and should not contain essential logic
     * @param sender address of user for update
     * @param data additional data
     * @return bytes32 id of staking account
     */
    function update(
        address sender,
        bytes calldata data
    ) external returns (bytes32);

    /**
     * @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
     * @param data additional data
     */
    function clean(bytes calldata data) external;
}

File 11 of 12 : OwnerController.sol
/*
OwnerController

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
*/

pragma solidity 0.8.18;

import "./interfaces/IOwnerController.sol";

/**
 * @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 is IOwnerController {
    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 override returns (address) {
        return _owner;
    }

    /**
     * @dev Returns the address of the current controller.
     */
    function controller() public view override returns (address) {
        return _controller;
    }

    /**
     * @dev Modifier that throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == msg.sender, "oc1");
        _;
    }

    /**
     * @dev Modifier that throws if called by any account other than the controller.
     */
    modifier onlyController() {
        require(_controller == msg.sender, "oc2");
        _;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    function requireOwner() internal view {
        require(_owner == msg.sender, "oc1");
    }

    /**
     * @dev Throws if called by any account other than the controller.
     */
    function requireController() internal view {
        require(_controller == msg.sender, "oc2");
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override {
        requireOwner();
        require(newOwner != address(0), "oc3");
        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 override {
        requireOwner();
        require(newController != address(0), "oc4");
        emit ControlTransferred(_controller, newController);
        _controller = newController;
    }
}

File 12 of 12 : TokenUtils.sol
/*
TokenUtils

https://github.com/gysr-io/core

SPDX-License-Identifier: MIT
*/

pragma solidity 0.8.18;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @title Token utilities
 *
 * @notice this library implements utility methods for token handling,
 * dynamic balance accounting, and fee processing
 */
library TokenUtils {
    using SafeERC20 for IERC20;

    event Fee(address indexed receiver, address indexed token, uint256 amount); // redefinition

    uint256 constant INITIAL_SHARES_PER_TOKEN = 1e6;
    uint256 constant FLOOR_SHARES_PER_TOKEN = 1e3;

    /**
     * @notice get token shares from amount
     * @param token erc20 token interface
     * @param total current total shares
     * @param amount balance of tokens
     */
    function getShares(
        IERC20 token,
        uint256 total,
        uint256 amount
    ) internal view returns (uint256) {
        if (total == 0) return 0;
        uint256 balance = token.balanceOf(address(this));
        if (total < balance * FLOOR_SHARES_PER_TOKEN)
            return amount * FLOOR_SHARES_PER_TOKEN;
        return (total * amount) / balance;
    }

    /**
     * @notice get token amount from shares
     * @param token erc20 token interface
     * @param total current total shares
     * @param shares balance of shares
     */
    function getAmount(
        IERC20 token,
        uint256 total,
        uint256 shares
    ) internal view returns (uint256) {
        if (total == 0) return 0;
        uint256 balance = token.balanceOf(address(this));
        if (total < balance * FLOOR_SHARES_PER_TOKEN)
            return shares / FLOOR_SHARES_PER_TOKEN;
        return (balance * shares) / total;
    }

    /**
     * @notice transfer tokens from sender into contract and convert to shares
     * for internal accounting
     * @param token erc20 token interface
     * @param total current total shares
     * @param sender token sender
     * @param amount number of tokens to be sent
     */
    function receiveAmount(
        IERC20 token,
        uint256 total,
        address sender,
        uint256 amount
    ) internal returns (uint256) {
        // note: we assume amount > 0 has already been validated

        //  transfer
        uint256 balance = token.balanceOf(address(this));
        token.safeTransferFrom(sender, address(this), amount);
        uint256 actual = token.balanceOf(address(this)) - balance;
        require(amount >= actual);

        // mint shares at current rate
        uint256 minted;
        if (total == 0) {
            minted = actual * INITIAL_SHARES_PER_TOKEN;
        } else if (total < balance * FLOOR_SHARES_PER_TOKEN) {
            minted = actual * FLOOR_SHARES_PER_TOKEN;
        } else {
            minted = (total * actual) / balance;
        }
        require(minted > 0);
        return minted;
    }

    /**
     * @notice transfer tokens from sender into contract, process protocol fee,
     * and convert to shares for internal accounting
     * @param token erc20 token interface
     * @param total current total shares
     * @param sender token sender
     * @param amount number of tokens to be sent
     * @param feeReceiver address to receive fee
     * @param feeRate portion of amount to take as fee in 18 decimals
     */
    function receiveWithFee(
        IERC20 token,
        uint256 total,
        address sender,
        uint256 amount,
        address feeReceiver,
        uint256 feeRate
    ) internal returns (uint256) {
        // note: we assume amount > 0 has already been validated

        // check initial token balance
        uint256 balance = token.balanceOf(address(this));

        // process fee
        uint256 fee;
        if (feeReceiver != address(0) && feeRate > 0 && feeRate < 1e18) {
            fee = (amount * feeRate) / 1e18;
            token.safeTransferFrom(sender, feeReceiver, fee);
            emit Fee(feeReceiver, address(token), fee);
        }

        // do transfer
        token.safeTransferFrom(sender, address(this), amount - fee);
        uint256 actual = token.balanceOf(address(this)) - balance;
        require(amount >= actual);

        // mint shares at current rate
        uint256 minted;
        if (total == 0) {
            minted = actual * INITIAL_SHARES_PER_TOKEN;
        } else if (total < balance * FLOOR_SHARES_PER_TOKEN) {
            minted = actual * FLOOR_SHARES_PER_TOKEN;
        } else {
            minted = (total * actual) / balance;
        }
        require(minted > 0);
        return minted;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"ModuleCreated","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"createModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50611f9b806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806320868d1814610030575b600080fd5b61004361003e36600461021e565b61006c565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6000602082146100e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100da9060208082526004908201527f736d663100000000000000000000000000000000000000000000000000000000604082015260600190565b60405180910390fd5b60006064359050600081306040516100fa90610211565b73ffffffffffffffffffffffffffffffffffffffff928316815291166020820152604001604051809103906000f08015801561013a573d6000803e3d6000fd5b506040517ff2fde38b00000000000000000000000000000000000000000000000000000000815233600482015290915073ffffffffffffffffffffffffffffffffffffffff82169063f2fde38b90602401600060405180830381600087803b1580156101a557600080fd5b505af11580156101b9573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff841681523392507ff708942ec477396a151a5285651961dcab8e8a82ea4f5b31a5236f92f6c92710915060200160405180910390a295945050505050565b611ca9806102bd83390190565b60008060006040848603121561023357600080fd5b833573ffffffffffffffffffffffffffffffffffffffff8116811461025757600080fd5b9250602084013567ffffffffffffffff8082111561027457600080fd5b818601915086601f83011261028857600080fd5b81358181111561029757600080fd5b8760208285010111156102a957600080fd5b602083019450809350505050925092509256fe60c06040523480156200001157600080fd5b5060405162001ca938038062001ca9833981016040819052620000349162000102565b60008054336001600160a01b0319918216811783556001805490921681179091556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3600080546040516001600160a01b0390911691907fa06677f7b64342b4bcbde423684dbdb5356acfe41ad0285b6ecbe6dc4bf427f2908290a36001600160a01b038216620000cd57600080fd5b6001600160a01b039182166080521660a0526200013a565b80516001600160a01b0381168114620000fd57600080fd5b919050565b600080604083850312156200011657600080fd5b6200012183620000e5565b91506200013160208401620000e5565b90509250929050565b60805160a051611b116200019860003960006102c301526000818161053b015281816105e4015281816107f0015281816108750152818161093501528181610acc01528181610b1c01528181610d8a01526110b20152611b116000f3fe608060405234801561001057600080fd5b506004361061011b5760003560e01c80638f0bc152116100b2578063c4113b8811610081578063ce7c2ac211610066578063ce7c2ac2146102e7578063f2fde38b14610307578063f77c47911461031a57600080fd5b8063c4113b88146102ae578063c45a0155146102c157600080fd5b80638f0bc152146102105780639d63848a14610253578063a32ce11e14610268578063c038a38e146102a657600080fd5b80633e12170f116100ee5780633e12170f146101845780636d16fa41146101ac5780636fd366b8146101bf5780638da5cb5b146101d157600080fd5b806302a688ed1461012057806327e235e3146101465780633a98ef39146101665780633d140d211461016f575b600080fd5b61013361012e366004611727565b610338565b6040519081526020015b60405180910390f35b61015961015436600461177a565b610365565b60405161013d9190611795565b61013360035481565b61018261017d3660046117ea565b6103b4565b005b610197610192366004611821565b61044b565b6040805192835260208301919091520161013d565b6101826101ba36600461177a565b610644565b6101826101cd36600461187b565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161013d565b61022361021e366004611821565b61073d565b6040805193845273ffffffffffffffffffffffffffffffffffffffff90921660208401529082015260600161013d565b61025b610851565b60405161013d91906118bd565b61029661027636600461190b565b600460209081526000928352604080842090915290825290205460ff1681565b604051901515815260200161013d565b6101596108e4565b6102236102bc366004611821565b6109d7565b7f00000000000000000000000000000000000000000000000000000000000000006101eb565b6101336102f536600461177a565b60026020526000908152604090205481565b61018261031536600461177a565b610b6c565b60015473ffffffffffffffffffffffffffffffffffffffff166101eb565b6000610345848484610c64565b73ffffffffffffffffffffffffffffffffffffffff1690505b9392505050565b6040805160018082528183019092526060916020808301908036833701905050905061039082610d58565b816000815181106103a3576103a361193e565b602002602001018181525050919050565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f1d3e246ebbc933bf65d3290db9f93d67ab91a12d2b19308a35806e04d1c174c5910160405180910390a35050565b60008054819073ffffffffffffffffffffffffffffffffffffffff1633146104ba5760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b6000851161050a5760405162461bcd60e51b815260206004820152600360248201527f736d31000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000610517878686610c64565b6003549091506000906105639073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016908a8a610db6565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604081208054929350839290919061059d90849061199c565b9250508190555080600360008282546105b6919061199c565b9091555050604080518881526020810183905273ffffffffffffffffffffffffffffffffffffffff848116927f0000000000000000000000000000000000000000000000000000000000000000821692918c169184917f020c82fffaa7f476edc4d209bc47371cb11635b2077978c27e7c39360146d2ed910160405180910390a49890975095505050505050565b61064c610f88565b73ffffffffffffffffffffffffffffffffffffffff81166106af5760405162461bcd60e51b815260206004820152600360248201527f6f6334000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b60015460405173ffffffffffffffffffffffffffffffffffffffff8084169216907fa06677f7b64342b4bcbde423684dbdb5356acfe41ad0285b6ecbe6dc4bf427f290600090a3600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600080548190819073ffffffffffffffffffffffffffffffffffffffff1633146107a95760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b60006107b6888787610c64565b905060006107c48289610ff1565b604080518a81526020810183905291925073ffffffffffffffffffffffffffffffffffffffff808516927f0000000000000000000000000000000000000000000000000000000000000000821692918d169184917f636cc28d1dc3c5f8610bbd1cabdf6585ab2ef79f4b9ae78e840c1b8fd5ac887a91015b60405180910390a49990975095505050505050565b604080516001808252818301909252606091602080830190803683370190505090507f0000000000000000000000000000000000000000000000000000000000000000816000815181106108a7576108a761193e565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505090565b60408051600180825281830190925260609160208083019080368337019050506040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015610991573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b591906119af565b816000815181106109c8576109c861193e565b60200260200101818152505090565b600080548190819073ffffffffffffffffffffffffffffffffffffffff163314610a435760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000610a50888787610c64565b90506000610a5e8289610ff1565b90508060036000828254610a7291906119c8565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604081208054839290610aac9084906119c8565b90915550610af3905073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168a8a6111a0565b604080518981526020810183905273ffffffffffffffffffffffffffffffffffffffff808516927f0000000000000000000000000000000000000000000000000000000000000000821692918d169184917f31d5ceefd9ae9f1d896ec09a203f74a59524f36c970d3ede03478bb30c550a21910161083c565b610b74610f88565b73ffffffffffffffffffffffffffffffffffffffff8116610bd75760405162461bcd60e51b815260206004820152600360248201527f6f6333000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000811580610c735750602082145b610cbf5760405162461bcd60e51b815260206004820152600360248201527f736d37000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b8115610d515760843573ffffffffffffffffffffffffffffffffffffffff81811660009081526004602090815260408083209389168352929052205460ff16610d4a5760405162461bcd60e51b815260206004820152600360248201527f736d38000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b905061035e565b508261035e565b60035473ffffffffffffffffffffffffffffffffffffffff8083166000908152600260205260408120549092610db0927f00000000000000000000000000000000000000000000000000000000000000001691611279565b92915050565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8716906370a0823190602401602060405180830381865afa158015610e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4991906119af565b9050610e6d73ffffffffffffffffffffffffffffffffffffffff8716853086611363565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090829073ffffffffffffffffffffffffffffffffffffffff8916906370a0823190602401602060405180830381865afa158015610edc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0091906119af565b610f0a91906119c8565b905080841015610f1957600080fd5b600086600003610f3757610f30620f4240836119db565b9050610f6e565b610f436103e8846119db565b871015610f5657610f306103e8836119db565b82610f6183896119db565b610f6b91906119f2565b90505b60008111610f7b57600080fd5b925050505b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610fef5760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b565b60008082116110425760405162461bcd60e51b815260206004820152600360248201527f736d33000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000600354116110945760405162461bcd60e51b815260206004820152600360248201527f736d34000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6003546110d99073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690846113c7565b90506000811161112b5760405162461bcd60e51b815260206004820152600360248201527f736d35000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040902054811115610db05760405162461bcd60e51b815260206004820152600360248201527f736d36000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526112749084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611496565b505050565b60008260000361128b5750600061035e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa1580156112f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131c91906119af565b905061132a6103e8826119db565b8410156113455761133d6103e8846119f2565b91505061035e565b8361135084836119db565b61135a91906119f2565b95945050505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526113c19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016111f2565b50505050565b6000826000036113d95750600061035e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa158015611446573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146a91906119af565b90506114786103e8826119db565b84101561148b5761133d6103e8846119db565b8061135084866119db565b60006114f8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166115889092919063ffffffff16565b80519091501561127457808060200190518101906115169190611a2d565b6112745760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104b1565b6060610f808484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516115bc9190611a6e565b60006040518083038185875af1925050503d80600081146115f9576040519150601f19603f3d011682016040523d82523d6000602084013e6115fe565b606091505b5091509150610f7b878383876060831561168657825160000361167f5773ffffffffffffffffffffffffffffffffffffffff85163b61167f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104b1565b5081610f80565b610f80838381511561169b5781518083602001fd5b8060405162461bcd60e51b81526004016104b19190611a8a565b803573ffffffffffffffffffffffffffffffffffffffff811681146116d957600080fd5b919050565b60008083601f8401126116f057600080fd5b50813567ffffffffffffffff81111561170857600080fd5b60208301915083602082850101111561172057600080fd5b9250929050565b60008060006040848603121561173c57600080fd5b611745846116b5565b9250602084013567ffffffffffffffff81111561176157600080fd5b61176d868287016116de565b9497909650939450505050565b60006020828403121561178c57600080fd5b61035e826116b5565b6020808252825182820181905260009190848201906040850190845b818110156117cd578351835292840192918401916001016117b1565b50909695505050505050565b80151581146117e757600080fd5b50565b600080604083850312156117fd57600080fd5b611806836116b5565b91506020830135611816816117d9565b809150509250929050565b6000806000806060858703121561183757600080fd5b611840856116b5565b935060208501359250604085013567ffffffffffffffff81111561186357600080fd5b61186f878288016116de565b95989497509550505050565b6000806020838503121561188e57600080fd5b823567ffffffffffffffff8111156118a557600080fd5b6118b1858286016116de565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b818110156117cd57835173ffffffffffffffffffffffffffffffffffffffff16835292840192918401916001016118d9565b6000806040838503121561191e57600080fd5b611927836116b5565b9150611935602084016116b5565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610db057610db061196d565b6000602082840312156119c157600080fd5b5051919050565b81810381811115610db057610db061196d565b8082028115828204841417610db057610db061196d565b600082611a28577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215611a3f57600080fd5b815161035e816117d9565b60005b83811015611a65578181015183820152602001611a4d565b50506000910152565b60008251611a80818460208701611a4a565b9190910192915050565b6020815260008251806020840152611aa9816040850160208701611a4a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220705b8fbd1ad8bab3b56965d9184f18f799f5b3703da78c006d8f686bcd16f6fe64736f6c63430008120033a26469706673582212206dcb06dc82724847b4d3133263601188f6aacefe906534f48d4de4fdd78d5aa164736f6c63430008120033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806320868d1814610030575b600080fd5b61004361003e36600461021e565b61006c565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6000602082146100e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100da9060208082526004908201527f736d663100000000000000000000000000000000000000000000000000000000604082015260600190565b60405180910390fd5b60006064359050600081306040516100fa90610211565b73ffffffffffffffffffffffffffffffffffffffff928316815291166020820152604001604051809103906000f08015801561013a573d6000803e3d6000fd5b506040517ff2fde38b00000000000000000000000000000000000000000000000000000000815233600482015290915073ffffffffffffffffffffffffffffffffffffffff82169063f2fde38b90602401600060405180830381600087803b1580156101a557600080fd5b505af11580156101b9573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff841681523392507ff708942ec477396a151a5285651961dcab8e8a82ea4f5b31a5236f92f6c92710915060200160405180910390a295945050505050565b611ca9806102bd83390190565b60008060006040848603121561023357600080fd5b833573ffffffffffffffffffffffffffffffffffffffff8116811461025757600080fd5b9250602084013567ffffffffffffffff8082111561027457600080fd5b818601915086601f83011261028857600080fd5b81358181111561029757600080fd5b8760208285010111156102a957600080fd5b602083019450809350505050925092509256fe60c06040523480156200001157600080fd5b5060405162001ca938038062001ca9833981016040819052620000349162000102565b60008054336001600160a01b0319918216811783556001805490921681179091556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3600080546040516001600160a01b0390911691907fa06677f7b64342b4bcbde423684dbdb5356acfe41ad0285b6ecbe6dc4bf427f2908290a36001600160a01b038216620000cd57600080fd5b6001600160a01b039182166080521660a0526200013a565b80516001600160a01b0381168114620000fd57600080fd5b919050565b600080604083850312156200011657600080fd5b6200012183620000e5565b91506200013160208401620000e5565b90509250929050565b60805160a051611b116200019860003960006102c301526000818161053b015281816105e4015281816107f0015281816108750152818161093501528181610acc01528181610b1c01528181610d8a01526110b20152611b116000f3fe608060405234801561001057600080fd5b506004361061011b5760003560e01c80638f0bc152116100b2578063c4113b8811610081578063ce7c2ac211610066578063ce7c2ac2146102e7578063f2fde38b14610307578063f77c47911461031a57600080fd5b8063c4113b88146102ae578063c45a0155146102c157600080fd5b80638f0bc152146102105780639d63848a14610253578063a32ce11e14610268578063c038a38e146102a657600080fd5b80633e12170f116100ee5780633e12170f146101845780636d16fa41146101ac5780636fd366b8146101bf5780638da5cb5b146101d157600080fd5b806302a688ed1461012057806327e235e3146101465780633a98ef39146101665780633d140d211461016f575b600080fd5b61013361012e366004611727565b610338565b6040519081526020015b60405180910390f35b61015961015436600461177a565b610365565b60405161013d9190611795565b61013360035481565b61018261017d3660046117ea565b6103b4565b005b610197610192366004611821565b61044b565b6040805192835260208301919091520161013d565b6101826101ba36600461177a565b610644565b6101826101cd36600461187b565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161013d565b61022361021e366004611821565b61073d565b6040805193845273ffffffffffffffffffffffffffffffffffffffff90921660208401529082015260600161013d565b61025b610851565b60405161013d91906118bd565b61029661027636600461190b565b600460209081526000928352604080842090915290825290205460ff1681565b604051901515815260200161013d565b6101596108e4565b6102236102bc366004611821565b6109d7565b7f00000000000000000000000000000000000000000000000000000000000000006101eb565b6101336102f536600461177a565b60026020526000908152604090205481565b61018261031536600461177a565b610b6c565b60015473ffffffffffffffffffffffffffffffffffffffff166101eb565b6000610345848484610c64565b73ffffffffffffffffffffffffffffffffffffffff1690505b9392505050565b6040805160018082528183019092526060916020808301908036833701905050905061039082610d58565b816000815181106103a3576103a361193e565b602002602001018181525050919050565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f1d3e246ebbc933bf65d3290db9f93d67ab91a12d2b19308a35806e04d1c174c5910160405180910390a35050565b60008054819073ffffffffffffffffffffffffffffffffffffffff1633146104ba5760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b6000851161050a5760405162461bcd60e51b815260206004820152600360248201527f736d31000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000610517878686610c64565b6003549091506000906105639073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016908a8a610db6565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604081208054929350839290919061059d90849061199c565b9250508190555080600360008282546105b6919061199c565b9091555050604080518881526020810183905273ffffffffffffffffffffffffffffffffffffffff848116927f0000000000000000000000000000000000000000000000000000000000000000821692918c169184917f020c82fffaa7f476edc4d209bc47371cb11635b2077978c27e7c39360146d2ed910160405180910390a49890975095505050505050565b61064c610f88565b73ffffffffffffffffffffffffffffffffffffffff81166106af5760405162461bcd60e51b815260206004820152600360248201527f6f6334000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b60015460405173ffffffffffffffffffffffffffffffffffffffff8084169216907fa06677f7b64342b4bcbde423684dbdb5356acfe41ad0285b6ecbe6dc4bf427f290600090a3600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600080548190819073ffffffffffffffffffffffffffffffffffffffff1633146107a95760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b60006107b6888787610c64565b905060006107c48289610ff1565b604080518a81526020810183905291925073ffffffffffffffffffffffffffffffffffffffff808516927f0000000000000000000000000000000000000000000000000000000000000000821692918d169184917f636cc28d1dc3c5f8610bbd1cabdf6585ab2ef79f4b9ae78e840c1b8fd5ac887a91015b60405180910390a49990975095505050505050565b604080516001808252818301909252606091602080830190803683370190505090507f0000000000000000000000000000000000000000000000000000000000000000816000815181106108a7576108a761193e565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505090565b60408051600180825281830190925260609160208083019080368337019050506040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015610991573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b591906119af565b816000815181106109c8576109c861193e565b60200260200101818152505090565b600080548190819073ffffffffffffffffffffffffffffffffffffffff163314610a435760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000610a50888787610c64565b90506000610a5e8289610ff1565b90508060036000828254610a7291906119c8565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604081208054839290610aac9084906119c8565b90915550610af3905073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168a8a6111a0565b604080518981526020810183905273ffffffffffffffffffffffffffffffffffffffff808516927f0000000000000000000000000000000000000000000000000000000000000000821692918d169184917f31d5ceefd9ae9f1d896ec09a203f74a59524f36c970d3ede03478bb30c550a21910161083c565b610b74610f88565b73ffffffffffffffffffffffffffffffffffffffff8116610bd75760405162461bcd60e51b815260206004820152600360248201527f6f6333000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000811580610c735750602082145b610cbf5760405162461bcd60e51b815260206004820152600360248201527f736d37000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b8115610d515760843573ffffffffffffffffffffffffffffffffffffffff81811660009081526004602090815260408083209389168352929052205460ff16610d4a5760405162461bcd60e51b815260206004820152600360248201527f736d38000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b905061035e565b508261035e565b60035473ffffffffffffffffffffffffffffffffffffffff8083166000908152600260205260408120549092610db0927f00000000000000000000000000000000000000000000000000000000000000001691611279565b92915050565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8716906370a0823190602401602060405180830381865afa158015610e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4991906119af565b9050610e6d73ffffffffffffffffffffffffffffffffffffffff8716853086611363565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090829073ffffffffffffffffffffffffffffffffffffffff8916906370a0823190602401602060405180830381865afa158015610edc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0091906119af565b610f0a91906119c8565b905080841015610f1957600080fd5b600086600003610f3757610f30620f4240836119db565b9050610f6e565b610f436103e8846119db565b871015610f5657610f306103e8836119db565b82610f6183896119db565b610f6b91906119f2565b90505b60008111610f7b57600080fd5b925050505b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610fef5760405162461bcd60e51b815260206004820152600360248201527f6f6331000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b565b60008082116110425760405162461bcd60e51b815260206004820152600360248201527f736d33000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6000600354116110945760405162461bcd60e51b815260206004820152600360248201527f736d34000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b6003546110d99073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690846113c7565b90506000811161112b5760405162461bcd60e51b815260206004820152600360248201527f736d35000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040902054811115610db05760405162461bcd60e51b815260206004820152600360248201527f736d36000000000000000000000000000000000000000000000000000000000060448201526064016104b1565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526112749084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611496565b505050565b60008260000361128b5750600061035e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa1580156112f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131c91906119af565b905061132a6103e8826119db565b8410156113455761133d6103e8846119f2565b91505061035e565b8361135084836119db565b61135a91906119f2565b95945050505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526113c19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016111f2565b50505050565b6000826000036113d95750600061035e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa158015611446573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146a91906119af565b90506114786103e8826119db565b84101561148b5761133d6103e8846119db565b8061135084866119db565b60006114f8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166115889092919063ffffffff16565b80519091501561127457808060200190518101906115169190611a2d565b6112745760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104b1565b6060610f808484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516115bc9190611a6e565b60006040518083038185875af1925050503d80600081146115f9576040519150601f19603f3d011682016040523d82523d6000602084013e6115fe565b606091505b5091509150610f7b878383876060831561168657825160000361167f5773ffffffffffffffffffffffffffffffffffffffff85163b61167f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104b1565b5081610f80565b610f80838381511561169b5781518083602001fd5b8060405162461bcd60e51b81526004016104b19190611a8a565b803573ffffffffffffffffffffffffffffffffffffffff811681146116d957600080fd5b919050565b60008083601f8401126116f057600080fd5b50813567ffffffffffffffff81111561170857600080fd5b60208301915083602082850101111561172057600080fd5b9250929050565b60008060006040848603121561173c57600080fd5b611745846116b5565b9250602084013567ffffffffffffffff81111561176157600080fd5b61176d868287016116de565b9497909650939450505050565b60006020828403121561178c57600080fd5b61035e826116b5565b6020808252825182820181905260009190848201906040850190845b818110156117cd578351835292840192918401916001016117b1565b50909695505050505050565b80151581146117e757600080fd5b50565b600080604083850312156117fd57600080fd5b611806836116b5565b91506020830135611816816117d9565b809150509250929050565b6000806000806060858703121561183757600080fd5b611840856116b5565b935060208501359250604085013567ffffffffffffffff81111561186357600080fd5b61186f878288016116de565b95989497509550505050565b6000806020838503121561188e57600080fd5b823567ffffffffffffffff8111156118a557600080fd5b6118b1858286016116de565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b818110156117cd57835173ffffffffffffffffffffffffffffffffffffffff16835292840192918401916001016118d9565b6000806040838503121561191e57600080fd5b611927836116b5565b9150611935602084016116b5565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610db057610db061196d565b6000602082840312156119c157600080fd5b5051919050565b81810381811115610db057610db061196d565b8082028115828204841417610db057610db061196d565b600082611a28577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215611a3f57600080fd5b815161035e816117d9565b60005b83811015611a65578181015183820152602001611a4d565b50506000910152565b60008251611a80818460208701611a4a565b9190910192915050565b6020815260008251806020840152611aa9816040850160208701611a4a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220705b8fbd1ad8bab3b56965d9184f18f799f5b3703da78c006d8f686bcd16f6fe64736f6c63430008120033a26469706673582212206dcb06dc82724847b4d3133263601188f6aacefe906534f48d4de4fdd78d5aa164736f6c63430008120033

Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.