Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x39Fe7A7E7608d0F917382d205dF7EB3b2b653C6f
Balance 0 ETH
Nonce 1
Code Size 3682 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3682 bytes
0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063b88a802f116100a2578063ddbad8b811610071578063ddbad8b81461029a578063ee0ebe0c146102e9578063ee172546146102f2578063f2fde38b146102fb578063f826ed2e1461030e57600080fd5b8063b88a802f14610228578063c1dd608414610230578063c32d3ae214610254578063d82e39621461028757600080fd5b806372f702f3116100e957806372f702f3146101525780637b0472f014610191578063817b1cd2146101a45780638da5cb5b146101ad5780638da7ad23146101be57600080fd5b806316330d401461011b5780633ccfd60b146101375780634f49a78a14610141578063715018a61461014a575b600080fd5b61012460045481565b6040519081526020015b60405180910390f35b61013f610321565b005b61012460055481565b61013f6105b3565b6101797f0000000000000000000000005940fe0f3e6c192d605974066b463d05496fb00f81565b6040516001600160a01b03909116815260200161012e565b61013f61019f366004610ce5565b6105c5565b61012460025481565b6000546001600160a01b0316610179565b6101fe6101cc366004610d07565b600760205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161012e565b61013f61083b565b6002546003546005546040805193845260208401929092529082015260600161012e565b610267610262366004610d07565b6109e6565b60408051948552602085019390935291830152606082015260800161012e565b610124610295366004610d07565b610a84565b6102cc6102a8366004610d37565b60066020526000908152604090208054600182015460029092015490919060ff1683565b60408051938452602084019290925215159082015260600161012e565b61012460085481565b61012460035481565b61013f610309366004610d07565b610b73565b61013f61031c366004610d37565b610bb1565b610329610c3e565b336000908152600760205260409020600481015460ff166103825760405162461bcd60e51b815260206004820152600e60248201526d139bc81cdd185ad948199bdd5b9960921b60448201526064015b60405180910390fd5b8054600061038f33610a84565b60028085015460009081526006602090815260408083208151606081018352815480825260018084015495830195909552919095015460ff161515918501919091529087015493945090926103e49190610d66565b42101561041557612710600454856103fc9190610d7f565b6104069190610dac565b91506104128285610dce565b93505b84546002805491909103905560058054600019019055821561043a5760038054840190555b336000908152600760205260408120818155600181018290556002810182905560038101829055600401805460ff191690556104768486610d66565b9050801561052b5760405163a9059cbb60e01b8152336004820152602481018290527f0000000000000000000000005940fe0f3e6c192d605974066b463d05496fb00f6001600160a01b03169063a9059cbb906044016020604051808303816000875af11580156104eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050f9190610de1565b61052b5760405162461bcd60e51b815260040161037990610e03565b604080518681526020810185905233917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6910160405180910390a283156105a25760405184815233907f106f923f993c2149d49b4255ff723acafa1f2d94393f561d3eda32ae348f72419060200160405180910390a25b5050505050506105b160018055565b565b6105bb610c68565b6105b16000610c95565b6105cd610c3e565b600854821080156105ef575060008281526006602052604090206002015460ff165b61062d5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964207061636b61676560881b6044820152606401610379565b600081116106725760405162461bcd60e51b81526020600482015260126024820152710416d6f756e74206d757374206265203e20360741b6044820152606401610379565b3360009081526007602052604090206004015460ff16156106c75760405162461bcd60e51b815260206004820152600f60248201526e416c7265616479207374616b696e6760881b6044820152606401610379565b6040516323b872dd60e01b8152336004820152306024820152604481018290527f0000000000000000000000005940fe0f3e6c192d605974066b463d05496fb00f6001600160a01b0316906323b872dd906064016020604051808303816000875af115801561073a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075e9190610de1565b61077a5760405162461bcd60e51b815260040161037990610e03565b6040805160a08101825282815242602080830182815283850187815260608501938452600160808601818152336000818152600787528990209751885593518783015591516002808801919091559451600387015590516004909501805460ff19169515159590951790945582548601909255600580549093019092558251848152918201859052917f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee90910160405180910390a261083760018055565b5050565b610843610c3e565b336000908152600760205260409020600481015460ff166108975760405162461bcd60e51b815260206004820152600e60248201526d139bc81cdd185ad948199bdd5b9960921b6044820152606401610379565b60006108a233610a84565b9050600081116108e95760405162461bcd60e51b81526020600482015260126024820152714e6f2072657761726420746f20636c61696d60701b6044820152606401610379565b4260038381019190915580548201905560405163a9059cbb60e01b8152336004820152602481018290527f0000000000000000000000005940fe0f3e6c192d605974066b463d05496fb00f6001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098a9190610de1565b6109a65760405162461bcd60e51b815260040161037990610e03565b60405181815233907f106f923f993c2149d49b4255ff723acafa1f2d94393f561d3eda32ae348f72419060200160405180910390a250506105b160018055565b6001600160a01b0381166000908152600760209081526040808320815160a08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004015460ff1615156080820181905282918291829190610a5e57600080600080945094509450945050610a7d565b805160408201516020830151610a7389610a84565b9450945094509450505b9193509193565b6001600160a01b0381166000908152600760209081526040808320815160a08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004015460ff16151560808201819052610aea5750600092915050565b6040808201516000908152600660209081528282208351606080820186528254825260018301549382019390935260029091015460ff16151593810193909352830151610b379042610dce565b90506127106301e133808284602001518660000151020281610b5b57610b5b610d96565b0481610b6957610b69610d96565b0495945050505050565b610b7b610c68565b6001600160a01b038116610ba557604051631e4fbdf760e01b815260006004820152602401610379565b610bae81610c95565b50565b610bb9610c68565b610bb8811115610c035760405162461bcd60e51b81526020600482015260156024820152744665652063616e6e6f74206578636565642033302560581b6044820152606401610379565b60048190556040518181527f45108bbe17e2c6b15aef1a0c3b1668a1bc7f6d41aeb46a048100e839ba6fdac89060200160405180910390a150565b600260015403610c6157604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000546001600160a01b031633146105b15760405163118cdaa760e01b8152336004820152602401610379565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008060408385031215610cf857600080fd5b50508035926020909101359150565b600060208284031215610d1957600080fd5b81356001600160a01b0381168114610d3057600080fd5b9392505050565b600060208284031215610d4957600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610d7957610d79610d50565b92915050565b8082028115828204841417610d7957610d79610d50565b634e487b7160e01b600052601260045260246000fd5b600082610dc957634e487b7160e01b600052601260045260246000fd5b500490565b81810381811115610d7957610d79610d50565b600060208284031215610df357600080fd5b81518015158114610d3057600080fd5b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b60408201526060019056fea2646970667358221220cdf69a38b4ed02231d9093ca817712fbd8671b5144c70f81b079eadcda3d929764736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: paris Optimization: Yes (200 runs)
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @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 onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * 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;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

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

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
ARTEMISStaking.sol 214 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

contract ARTEMISStaking is Ownable, ReentrancyGuard {
    IERC20 public immutable stakingToken;

    uint256 public totalStaked;
    uint256 public totalRewardsDistributed;
    uint256 public earlyWithdrawalFee;
    uint256 public totalStakeholders;
    uint256 private constant BASIS_POINTS = 10000;

    struct StakingPackage {
        uint256 duration;
        uint256 apy;
        bool isActive;
    }

    struct UserStake {
        uint256 amount;
        uint256 startTime;
        uint256 packageId;
        uint256 lastRewardTime;
        bool exists;
    }

    mapping(uint256 => StakingPackage) public stakingPackage;
    mapping(address => UserStake) public userStakes;
    uint256 public packageCount;

    event Staked(address indexed user, uint256 amount, uint256 packageId);
    event Withdrawn(address indexed user, uint256 amount, uint256 fee);
    event RewardClaimed(address indexed user, uint256 reward);
    event PackageCreated(uint256 packageId, uint256 duration, uint256 apy);
    event PackageUpdated(uint256 packageId, uint256 apy);
    event EarlyWithdrawalFeeUpdated(uint256 newFee);

    constructor(address _stakingToken) Ownable(msg.sender) {
        stakingToken = IERC20(_stakingToken);
        earlyWithdrawalFee = 500;

        unchecked {
            _createPackage(30, 700);
            _createPackage(90, 2000);
            _createPackage(180, 3000);
        }
    }

    function setEarlyWithdrawalFee(uint256 _newFee) external onlyOwner {
        require(_newFee <= 3000, "Fee cannot exceed 30%");
        earlyWithdrawalFee = _newFee;
        emit EarlyWithdrawalFeeUpdated(_newFee);
    }

    function _createPackage(
        uint256 _durationInDays,
        uint256 _apyBasisPoints
    ) private {
        require(_durationInDays > 0 && _apyBasisPoints > 0, "Invalid params");

        stakingPackage[packageCount] = StakingPackage({
            duration: _durationInDays * 1 days,
            apy: _apyBasisPoints,
            isActive: true
        });

        emit PackageCreated(packageCount, _durationInDays, _apyBasisPoints);
        unchecked {
            packageCount++;
        }
    }

    function stake(uint256 _packageId, uint256 _amount) external nonReentrant {
        require(
            _packageId < packageCount && stakingPackage[_packageId].isActive,
            "Invalid package"
        );
        require(_amount > 0, "Amount must be > 0");
        require(!userStakes[msg.sender].exists, "Already staking");

        require(
            stakingToken.transferFrom(msg.sender, address(this), _amount),
            "Transfer failed"
        );

        userStakes[msg.sender] = UserStake({
            amount: _amount,
            startTime: block.timestamp,
            packageId: _packageId,
            lastRewardTime: block.timestamp,
            exists: true
        });

        unchecked {
            totalStaked += _amount;
            totalStakeholders++;
        }

        emit Staked(msg.sender, _amount, _packageId);
    }

    function calculateReward(address _staker) public view returns (uint256) {
        UserStake memory userStakeData = userStakes[_staker];
        if (!userStakeData.exists) return 0;

        StakingPackage memory stakingPkg = stakingPackage[
            userStakeData.packageId
        ];
        uint256 timeElapsed = block.timestamp - userStakeData.lastRewardTime;

        unchecked {
            return
                (userStakeData.amount * stakingPkg.apy * timeElapsed) /
                (365 days) /
                BASIS_POINTS;
        }
    }

    function withdraw() external nonReentrant {
        UserStake storage userStakePosition = userStakes[msg.sender];
        require(userStakePosition.exists, "No stake found");

        uint256 stakedAmount = userStakePosition.amount;
        uint256 rewardAmount = calculateReward(msg.sender);
        uint256 withdrawalFee = 0;

        StakingPackage memory package = stakingPackage[
            userStakePosition.packageId
        ];
        if (block.timestamp < userStakePosition.startTime + package.duration) {
            withdrawalFee = (stakedAmount * earlyWithdrawalFee) / BASIS_POINTS;
            stakedAmount -= withdrawalFee;
        }

        unchecked {
            totalStaked -= userStakePosition.amount;
            totalStakeholders--;
            if (rewardAmount > 0) {
                totalRewardsDistributed += rewardAmount;
            }
        }

        delete userStakes[msg.sender];

        uint256 totalWithdrawAmount = stakedAmount + rewardAmount;
        if (totalWithdrawAmount > 0) {
            require(
                stakingToken.transfer(msg.sender, totalWithdrawAmount),
                "Transfer failed"
            );
        }

        emit Withdrawn(msg.sender, stakedAmount, withdrawalFee);
        if (rewardAmount > 0) {
            emit RewardClaimed(msg.sender, rewardAmount);
        }
    }

    function claimReward() external nonReentrant {
        UserStake storage userStakePosition = userStakes[msg.sender];
        require(userStakePosition.exists, "No stake found");

        uint256 reward = calculateReward(msg.sender);
        require(reward > 0, "No reward to claim");

        userStakePosition.lastRewardTime = block.timestamp;

        unchecked {
            totalRewardsDistributed += reward;
        }

        require(stakingToken.transfer(msg.sender, reward), "Transfer failed");
        emit RewardClaimed(msg.sender, reward);
    }

    function getStakingStats()
        external
        view
        returns (
            uint256 totalStakedAmount,
            uint256 totalRewards,
            uint256 stakeholderCount
        )
    {
        return (totalStaked, totalRewardsDistributed, totalStakeholders);
    }

    function getUserStakeInfo(
        address _user
    )
        external
        view
        returns (
            uint256 amount,
            uint256 packageId,
            uint256 startTime,
            uint256 pendingReward
        )
    {
        UserStake memory userStakeData = userStakes[_user];
        if (!userStakeData.exists) return (0, 0, 0, 0);

        return (
            userStakeData.amount,
            userStakeData.packageId,
            userStakeData.startTime,
            calculateReward(_user)
        );
    }
}

Read Contract

calculateReward 0xd82e3962 → uint256
earlyWithdrawalFee 0x16330d40 → uint256
getStakingStats 0xc1dd6084 → uint256, uint256, uint256
getUserStakeInfo 0xc32d3ae2 → uint256, uint256, uint256, uint256
owner 0x8da5cb5b → address
packageCount 0xee0ebe0c → uint256
stakingPackage 0xddbad8b8 → uint256, uint256, bool
stakingToken 0x72f702f3 → address
totalRewardsDistributed 0xee172546 → uint256
totalStaked 0x817b1cd2 → uint256
totalStakeholders 0x4f49a78a → uint256
userStakes 0x8da7ad23 → uint256, uint256, uint256, uint256, bool

Write Contract 6 functions

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

claimReward 0xb88a802f
No parameters
renounceOwnership 0x715018a6
No parameters
setEarlyWithdrawalFee 0xf826ed2e
uint256 _newFee
stake 0x7b0472f0
uint256 _packageId
uint256 _amount
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters

Recent Transactions

No transactions found for this address