Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x362A80d4c5Cf2A1c4C134cdE21836f6FC2ae81CE
Balance 0 ETH
Nonce 1
Code Size 4011 bytes
Indexed Transactions 1 (24,422,31024,422,310)
Gas Used (indexed) 98,231
External Etherscan · Sourcify

Contract Bytecode

4011 bytes
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063733bdef011610071578063733bdef01461019d578063b3c740e8146101c5578063b55fb44c146101f7578063c8b6cbf71461020a578063eb6c6fa914610258578063eceae7c31461026d57600080fd5b8063263c7249146100b95780632e17de78146100e65780633a98ef39146100fb57806352741cef146101265780635e7cda651461013b57806372f702f314610172575b600080fd5b6003546100ce90600160e01b900461ffff1681565b60405161ffff90911681526020015b60405180910390f35b6100f96100f4366004610d97565b610282565b005b60035461010e906001600160c01b031681565b6040516001600160c01b0390911681526020016100dd565b6003546100ce90600160f01b900461ffff1681565b610164610149366004610ceb565b6001600160a01b031660009081526002602052604090205490565b6040519081526020016100dd565b600154610185906001600160a01b031681565b6040516001600160a01b0390911681526020016100dd565b6101b06101ab366004610ceb565b610543565b604080519283526020830191909152016100dd565b6101d86101d3366004610daf565b610637565b604080516001600160c01b0390931683526020830191909152016100dd565b6100f9610205366004610d4e565b6106e7565b61021d610218366004610d05565b610981565b6040805194151585526001600160801b03909316602085015265ffffffffffff9091169183019190915261ffff1660608201526080016100dd565b6003546100ce90600160d01b900461ffff1681565b6003546100ce90600160c01b900461ffff1681565b600260005414156102da5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60026000818155338152602091909152604090205481106103365760405162461bcd60e51b81526020600482015260166024820152750a6e8c2d6caaca47440d2dcecc2d8d2c840d2dcc8caf60531b60448201526064016102d1565b33600090815260026020526040812080548390811061036557634e487b7160e01b600052603260045260246000fd5b6000918252602090912001805490915060ff16156103c55760405162461bcd60e51b815260206004820152601960248201527f5374616b6556523a20756e7374616b656420616c72656164790000000000000060448201526064016102d1565b805442906103e190600160b81b900461ffff1662015180610ec2565b82546103fc9190600160881b900465ffffffffffff16610e62565b65ffffffffffff1611156104525760405162461bcd60e51b815260206004820152601c60248201527f5374616b6556523a20756e7374616b696e6720746f6f206561726c790000000060448201526064016102d1565b805460009061047a9061010081046001600160801b031690600160b81b900461ffff16610637565b5060038054919250829160009061049b9084906001600160c01b0316610ef0565b82546001600160c01b0391821661010093840a9081029202191617909155835460ff1916600190811780865590546104eb93506001600160a01b03169133916001600160801b03919004166109dd565b60035460408051338152602081018690526001600160c01b03909216908201527fff46d10830539f082efd0aa8d2c40122e3b064a2e3f6b98ba814e0605759b943906060015b60405180910390a15050600160005550565b60008060005b6001600160a01b038416600090815260026020526040902054811015610631576001600160a01b03841660009081526002602052604081208054839081106105a157634e487b7160e01b600052603260045260246000fd5b6000918252602090912001805490915060ff16156105bf575061061f565b80546105d99061010090046001600160801b031685610e4a565b81549094506000906106049061010081046001600160801b031690600160b81b900461ffff16610637565b50905061061a6001600160c01b03821685610e4a565b935050505b8061062981610f44565b915050610549565b50915091565b60035460009081906103e89061016d90600160e01b900461ffff1661065c8688610ea3565b6106669190610ea3565b6106709190610e83565b61067a9190610e83565b6003549091506000906103e89069d3c21bcecceda100000090600160f01b900461ffff166106a88880610ea3565b6106b29190610ea3565b6106bc9190610e83565b6106c69190610e83565b9050806106d38387610e4a565b6106dd9190610e4a565b9250509250929050565b6002600054141561073a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102d1565b600260005560035461ffff600160c01b909104811690821610801590610771575060035461ffff600160d01b909104811690821611155b6107bd5760405162461bcd60e51b815260206004820152601960248201527f5374616b6556523a20696e76616c6964206c6f636b446179730000000000000060448201526064016102d1565b60006107d6836001600160801b03168361ffff16610637565b506003805491925082916000906107f79084906001600160c01b0316610e1f565b82546001600160c01b0391821661010093840a908102920219161790915533600081815260026020908152604080832081516080810183528481526001600160801b03808c1682860181815265ffffffffffff42811696850196875261ffff808f1660608701908152875460018181018a55988c5299909a209551959098018054925197519951909816600160b81b0261ffff60b81b1999909116600160881b029890981667ffffffffffffffff60881b199690931690990270ffffffffffffffffffffffffffffffff00199315159390931670ffffffffffffffffffffffffffffffffff19909916989098179190911792909216919091179290921790555461090d93506001600160a01b0316913090610a45565b600354604080513381526001600160801b03861660208201526001600160c01b038085169282019290925265ffffffffffff4216606082015261ffff85166080820152911660a08201527fa015aacd6499c35a0278d3ccf3954429037ec031f01760ca7ffaa98aa758a7789060c001610531565b6002602052816000526040600020818154811061099d57600080fd5b60009182526020909120015460ff8116925061010081046001600160801b03169150600160881b810465ffffffffffff1690600160b81b900461ffff1684565b6040516001600160a01b038316602482015260448101829052610a4090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610a83565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610a7d9085906323b872dd60e01b90608401610a09565b50505050565b6000610ad8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b559092919063ffffffff16565b805190915015610a405780806020019051810190610af69190610d2e565b610a405760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102d1565b6060610b648484600085610b6e565b90505b9392505050565b606082471015610bcf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102d1565b843b610c1d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d1565b600080866001600160a01b03168587604051610c399190610dd0565b60006040518083038185875af1925050503d8060008114610c76576040519150601f19603f3d011682016040523d82523d6000602084013e610c7b565b606091505b5091509150610c8b828286610c96565b979650505050505050565b60608315610ca5575081610b67565b825115610cb55782518084602001fd5b8160405162461bcd60e51b81526004016102d19190610dec565b80356001600160a01b0381168114610ce657600080fd5b919050565b600060208284031215610cfc578081fd5b610b6782610ccf565b60008060408385031215610d17578081fd5b610d2083610ccf565b946020939093013593505050565b600060208284031215610d3f578081fd5b81518015158114610b67578182fd5b60008060408385031215610d60578182fd5b82356001600160801b0381168114610d76578283fd5b9150602083013561ffff81168114610d8c578182fd5b809150509250929050565b600060208284031215610da8578081fd5b5035919050565b60008060408385031215610dc1578182fd5b50508035926020909101359150565b60008251610de2818460208701610f18565b9190910192915050565b6020815260008251806020840152610e0b816040850160208701610f18565b601f01601f19169190910160400192915050565b60006001600160c01b03828116848216808303821115610e4157610e41610f5f565b01949350505050565b60008219821115610e5d57610e5d610f5f565b500190565b600065ffffffffffff808316818516808303821115610e4157610e41610f5f565b600082610e9e57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610ebd57610ebd610f5f565b500290565b600065ffffffffffff80831681851681830481118215151615610ee757610ee7610f5f565b02949350505050565b60006001600160c01b0383811690831681811015610f1057610f10610f5f565b039392505050565b60005b83811015610f33578181015183820152602001610f1b565b83811115610a7d5750506000910152565b6000600019821415610f5857610f58610f5f565b5060010190565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220df55a394598bb930b3cb34700c852c0c235449427db713123d6019ac2134e3bf64736f6c63430008040033

Verified Source Code Full Match

Compiler: v0.8.4+commit.c7e474f2 EVM: istanbul Optimization: Yes (200 runs)
StakeVR.sol 118 lines
// SPDX-License-Identifier: MIT
pragma solidity =0.8.4;

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

contract StakeVR is ReentrancyGuard {
    using SafeERC20 for IERC20;

    uint32 constant HUNDRED_PERCENT = 1e3;

    struct Stake {
        bool unstaked;
        uint128 amount;
        uint48 lockTimestamp;
        uint16 lockDays;
    }

    IERC20 public stakingToken;
    mapping(address => Stake[]) public stakers;
    uint192 public totalShares;
    uint16 public minLockDays;
    uint16 public maxLockDays;
    uint16 public shareBonusPerYear;
    uint16 public shareBonusPer1MTokens;

    event EStake(
        address staker,
        uint128 amount,
        uint192 shares,
        uint48 lockTimestamp,
        uint16 lockDays,
        uint192 totalShares
    );

    event EUnstake(
        address staker,
        uint stakeIndex,
        uint192 totalShares
    );

    constructor(
        IERC20 _stakingToken,
        uint16 _minLockDays,
        uint16 _maxLockDays,
        uint16 _shareBonusPerYear,
        uint16 _shareBonusPer1MTokens
    ) {
        require(address(_stakingToken) != address(0));
        require(_minLockDays <= _maxLockDays, "StakeVR: minLockDays > maxLockDays");
        stakingToken = _stakingToken;
        minLockDays = _minLockDays;
        maxLockDays = _maxLockDays;
        shareBonusPerYear = _shareBonusPerYear;
        shareBonusPer1MTokens = _shareBonusPer1MTokens;
    }

    function stake(uint128 amount, uint16 lockDays) external nonReentrant {
        require(lockDays >= minLockDays && lockDays <= maxLockDays, "StakeVR: invalid lockDays");
        (uint192 shares,) = calculateShares(amount, lockDays);
        totalShares += shares;

        stakers[msg.sender].push(Stake(
            false,
            amount,
            uint48(block.timestamp),
            lockDays
        ));
        stakingToken.safeTransferFrom(msg.sender, address(this), amount);
        emit EStake(msg.sender, amount, shares, uint48(block.timestamp), lockDays, totalShares);
    }

    function unstake(uint stakeIndex) external nonReentrant {
        require(stakeIndex < stakers[msg.sender].length, "StakeVR: invalid index");
        Stake storage stakeRef = stakers[msg.sender][stakeIndex];
        require(!stakeRef.unstaked, "StakeVR: unstaked already");
        require(stakeRef.lockTimestamp + uint48(stakeRef.lockDays) * 86400 <= block.timestamp, "StakeVR: unstaking too early");

        (uint192 shares,) = calculateShares(stakeRef.amount, stakeRef.lockDays);
        totalShares -= shares;
        stakeRef.unstaked = true;
        stakingToken.safeTransfer(msg.sender, stakeRef.amount);
        emit EUnstake(msg.sender, stakeIndex, totalShares);
    }

    function calculateShares(
        uint amount, 
        uint lockDays
    ) public view returns (
        uint192 shares,
        uint longTermBonus
    ) {
        longTermBonus = amount * lockDays * shareBonusPerYear / 365 / HUNDRED_PERCENT;
        uint stakingMoreBonus = amount * amount * shareBonusPer1MTokens / 1e24 / HUNDRED_PERCENT;
        shares = uint192(amount + longTermBonus + stakingMoreBonus);
    }

    function getStakerInfo(
        address stakerAddress
    ) public view returns (
        uint256 totalStakeAmount,
        uint256 totalStakerShares
    ) {
        for (uint i = 0; i < stakers[stakerAddress].length; i++) {
            Stake storage stakeRef = stakers[stakerAddress][i];
            if (stakeRef.unstaked) continue;

            totalStakeAmount += stakeRef.amount;
            (uint192 shares,) = calculateShares(stakeRef.amount, stakeRef.lockDays);
            totalStakerShares += shares;
        }
    }

    function stakerStakeCount(address stakerAddress) public view returns (uint) {
        return stakers[stakerAddress].length;
    }
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.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));
        }
    }

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

Read Contract

calculateShares 0xb3c740e8 → uint192, uint256
getStakerInfo 0x733bdef0 → uint256, uint256
maxLockDays 0xeb6c6fa9 → uint16
minLockDays 0xeceae7c3 → uint16
shareBonusPer1MTokens 0x52741cef → uint16
shareBonusPerYear 0x263c7249 → uint16
stakerStakeCount 0x5e7cda65 → uint256
stakers 0xc8b6cbf7 → bool, uint128, uint48, uint16
stakingToken 0x72f702f3 → address
totalShares 0x3a98ef39 → uint192

Write Contract 2 functions

These functions modify contract state and require a wallet transaction to execute.

stake 0xb55fb44c
uint128 amount
uint16 lockDays
unstake 0x2e17de78
uint256 stakeIndex

Top Interactions

AddressTxnsSentReceived
0x1B4523EC...bC5C 1 1

Recent Transactions

CSV
|
Hash Method Block Age From/To Value Txn Fee Type
0x8cb89040...af422e 0xb55fb44c 24,422,310 IN 0x1B4523EC...bC5C 0 ETH EIP-1559