- We're indexing this chain right now. Some of the counts may be inaccurate.

Contract Address Details

0xB9efC3dDE7F8acb8F6b3eF8975F027db5C6C48A0

Token
Test (TEST)
Creator
0x86f5e4–664cd8 at 0x8c6426–9e1540
Balance
0 CANTO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
1 Transfers
Gas Used
Fetching gas used...
Last Balance Update
9598551
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
SimpleToken




Optimization enabled
true
Compiler version
v0.8.1+commit.df193b15




Optimization runs
200
EVM Version
istanbul




Verified at
2024-06-08T22:46:55.923718Z

src/examples/tokens/SimpleToken.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {CsrRewardsERC20} from "../../contracts/CsrRewardsERC20.sol";

contract SimpleToken is ERC20, CsrRewardsERC20 {
    constructor(string memory _name, string memory _symbol, bool _usingFee, uint16 _feeBasisPoints, uint256 _supply)
        ERC20(_name, _symbol)
        CsrRewardsERC20(_usingFee, _feeBasisPoints)
    {
        _mint(msg.sender, _supply);
    }

    function _afterTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, CsrRewardsERC20) {
        super._afterTokenTransfer(from, to, amount);
    }
}
        

/src/contracts/TurnstileRegister.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {TurnstileInterface} from "./TurnstileInterface.sol";

contract TurnstileRegister {
    uint256 public csrID;

    TurnstileInterface public constant TURNSTILE = TurnstileInterface(0xEcf044C5B4b867CFda001101c617eCd347095B44);

    constructor() {
        csrID = TURNSTILE.register(address(this));
    }
}
          

/src/contracts/TurnstileInterface.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface TurnstileInterface {
    function register(address _recipient) external returns (uint256 tokenId);
    function assign(uint256 _tokenId) external;
    function balances(uint256 _tokenId) external view returns (uint256 feesEarned);
    function withdraw(uint256 _tokenId, address payable _recipient, uint256 _amount) external returns (uint256 amount);
}
          

/src/contracts/CsrRewardsERC20.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {TurnstileRegister} from "./TurnstileRegister.sol";

/**
 * @title CSR Reward Accumulating Token
 * Distributes all CSR earned to reward eligible holders
 * Logic is borrowed and modified from Synthetix StakingRewards.sol
 */
abstract contract CsrRewardsERC20 is ERC20, ReentrancyGuard, TurnstileRegister {
    bool public immutable usingWithdrawCallFee;
    uint16 public immutable withdrawCallFeeBasisPoints;

    uint256 public rewardPerEligibleToken;
    mapping(address => uint256) public userRewardPerTokenPaid;
    mapping(address => uint256) public rewardsEarned;

    uint256 private _totalRewardEligibleSupply;
    mapping(address => uint256) private _rewardEligibleBalances;
    mapping(address => bool) private _rewardEligibleAddress;

    uint16 internal constant _BPS = 10000;

    event RewardsDelivered(uint256 amount);
    event RewardsClaimed(address indexed account, uint256 amount);

    constructor(
        bool _usingWithdrawCallFee, 
        uint16 _withdrawCallFeeBasisPoints
    ) TurnstileRegister() {
        usingWithdrawCallFee = _usingWithdrawCallFee;
        withdrawCallFeeBasisPoints = _withdrawCallFeeBasisPoints;
    }

    receive() external payable {
        require(
            msg.sender == address(TURNSTILE), "CsrRewardsERC20: Only turnstile transfers will be processed for rewards"
        );
        // _registerRewardDelivery(msg.value);
    }

    /// VIEW FUNCTIONS

    function totalRewardEligibleSupply() external view returns (uint256) {
        return _totalRewardEligibleSupply;
    }

    function rewardEligibleBalanceOf(address account) external view returns (uint256) {
        return _rewardEligibleBalances[account];
    }

    function earned(address account) public view returns (uint256) {
        return rewardsEarned[account]
            + (_rewardEligibleBalances[account] * (rewardPerEligibleToken - userRewardPerTokenPaid[account]) / 1e18);
    }

    function turnstileBalance() public view returns (uint256) {
        return TURNSTILE.balances(csrID);
    }

    function _withdrawFeeAmount(uint256 amountBeingClaimed) internal view returns (uint256) {
        return amountBeingClaimed * withdrawCallFeeBasisPoints / _BPS;
    }

    function currentWithdrawFeeAmount() external view returns (uint256) {
        return _withdrawFeeAmount(turnstileBalance());
    }

    /// INTERNAL FUNCTIONS

    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual override {
        /// @dev First time transfer to address with code size 0 will register as reward eligible
        /// Contract addresses will have code size 0 before and during deploy
        /// Any method that sends this token to that address will make the contract reward eligible
        /// NB Self-minting in constructor makes this contract reward eligible
        if (_rewardEligibleAddress[to]) {
            _increaseRewardEligibleBalance(to, amount);
        } else {
            if (to.code.length == 0) {
                _increaseRewardEligibleBalance(to, amount);
                _rewardEligibleAddress[to] = true;
            }
        }

        if (_rewardEligibleAddress[from]) {
            _updateReward(from);
            _totalRewardEligibleSupply -= amount;
            _rewardEligibleBalances[from] -= amount;
        }
    }

    function _transferCANTO(address to, uint256 amount) internal {
        (bool success,) = payable(to).call{value: amount}("");
        require(success, "CsrRewardsERC20: Unable to send value, recipient may have reverted");
    }

    function _updateReward(address account) internal {
        rewardsEarned[account] = earned(account);
        userRewardPerTokenPaid[account] = rewardPerEligibleToken;
    }

    function _registerRewardDelivery(uint256 rewardAmount) internal {
        rewardPerEligibleToken += rewardAmount * 1e18 / _totalRewardEligibleSupply;

        emit RewardsDelivered(rewardAmount);
    }

    function _increaseRewardEligibleBalance(address to, uint256 amount) private {
        _updateReward(to);
        _totalRewardEligibleSupply += amount;
        _rewardEligibleBalances[to] += amount;
    }

    /// EXTERNAL MUTABLE FUNCTIONS

    /// @notice Token holder function for claiming CSR rewards
    function getReward() external virtual nonReentrant {
        _updateReward(msg.sender);
        uint256 reward = rewardsEarned[msg.sender];
        if (reward > 0) {
            rewardsEarned[msg.sender] = 0;
            _transferCANTO(msg.sender, reward);

            emit RewardsClaimed(msg.sender, reward);
        }
    }

    /// @notice Public function for collecting and distributing contract accumulated CSR
    function withdrawFromTurnstile() external virtual nonReentrant {
        uint256 amountToClaim = turnstileBalance();
        require(amountToClaim > 0, "CsrRewardsERC20: No CSR to claim");

        TURNSTILE.withdraw(csrID, payable(address(this)), amountToClaim);

        if (usingWithdrawCallFee) {
            uint256 feeAmount = _withdrawFeeAmount(amountToClaim);
            _registerRewardDelivery(amountToClaim - feeAmount);
            _transferCANTO(msg.sender, feeAmount);
        } else {
            _registerRewardDelivery(amountToClaim);
        }
    }
}
          

/lib/openzeppelin-contracts/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

/lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
          

/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}
          

/lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
          

/lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // 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;
    }
}
          

Compiler Settings

{"remappings":[":@openzeppelin/=lib/openzeppelin-contracts/",":ds-test/=lib/forge-std/lib/ds-test/src/",":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",":forge-std/=lib/forge-std/src/",":openzeppelin-contracts/=lib/openzeppelin-contracts/",":openzeppelin/=lib/openzeppelin-contracts/contracts/"],"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"istanbul","compilationTarget":{"src/examples/tokens/SimpleToken.sol":"SimpleToken"}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"},{"type":"bool","name":"_usingFee","internalType":"bool"},{"type":"uint16","name":"_feeBasisPoints","internalType":"uint16"},{"type":"uint256","name":"_supply","internalType":"uint256"}]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsClaimed","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsDelivered","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract TurnstileInterface"}],"name":"TURNSTILE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"csrID","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentWithdrawFeeAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"decreaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"subtractedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"earned","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getReward","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"increaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"addedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardEligibleBalanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerEligibleToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardsEarned","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalRewardEligibleSupply","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"turnstileBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userRewardPerTokenPaid","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"usingWithdrawCallFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"withdrawCallFeeBasisPoints","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawFromTurnstile","inputs":[]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

0x60c06040523480156200001157600080fd5b5060405162001c0538038062001c05833981016040819052620000349162000573565b828286868160039080519060200190620000509291906200041a565b508051620000669060049060208401906200041a565b5050600160055550604051632210724360e11b815273ecf044c5b4b867cfda001101c617ecd347095b4490634420e48690620000a790309060040162000631565b602060405180830381600087803b158015620000c257600080fd5b505af1158015620000d7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000fd919062000618565b60065590151560f81b60805260f01b6001600160f01b03191660a05262000125338262000130565b505050505062000766565b6001600160a01b038216620001625760405162461bcd60e51b8152600401620001599062000645565b60405180910390fd5b6200017060008383620001f2565b806002600082825462000184919062000685565b90915550506001600160a01b038216600081815260208190526040808220805485019055517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90620001d89085906200067c565b60405180910390a3620001ee60008383620001f7565b5050565b505050565b620001f28383836200020f60201b620009ee1760201c565b6001600160a01b0382166000908152600c602052604090205460ff161562000243576200023d8282620002fd565b62000283565b6001600160a01b0382163b62000283576200025f8282620002fd565b6001600160a01b0382166000908152600c60205260409020805460ff191660011790555b6001600160a01b0383166000908152600c602052604090205460ff1615620001f257620002b08362000354565b80600a6000828254620002c49190620006e3565b90915550506001600160a01b0383166000908152600b602052604081208054839290620002f3908490620006e3565b9091555050505050565b620003088262000354565b80600a60008282546200031c919062000685565b90915550506001600160a01b0382166000908152600b6020526040812080548392906200034b90849062000685565b90915550505050565b6200035f816200038d565b6001600160a01b03909116600090815260096020908152604080832093909355600754600890915291902055565b6001600160a01b038116600090815260086020526040812054600754670de0b6b3a764000091620003be91620006e3565b6001600160a01b0384166000908152600b6020526040902054620003e39190620006c1565b620003ef9190620006a0565b6001600160a01b03831660009081526009602052604090205462000414919062000685565b92915050565b8280546200042890620006fd565b90600052602060002090601f0160209004810192826200044c576000855562000497565b82601f106200046757805160ff191683800117855562000497565b8280016001018555821562000497579182015b82811115620004975782518255916020019190600101906200047a565b50620004a5929150620004a9565b5090565b5b80821115620004a55760008155600101620004aa565b600082601f830112620004d1578081fd5b81516001600160401b0380821115620004ee57620004ee62000750565b604051601f8301601f19908116603f0116810190828211818310171562000519576200051962000750565b8160405283815260209250868385880101111562000535578485fd5b8491505b8382101562000558578582018301518183018401529082019062000539565b838211156200056957848385830101525b9695505050505050565b600080600080600060a086880312156200058b578081fd5b85516001600160401b0380821115620005a2578283fd5b620005b089838a01620004c0565b96506020880151915080821115620005c6578283fd5b50620005d588828901620004c0565b94505060408601518015158114620005eb578182fd5b606087015190935061ffff8116811462000603578182fd5b80925050608086015190509295509295909350565b6000602082840312156200062a578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b600082198211156200069b576200069b6200073a565b500190565b600082620006bc57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615620006de57620006de6200073a565b500290565b600082821015620006f857620006f86200073a565b500390565b6002810460018216806200071257607f821691505b602082108114156200073457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b60805160f81c60a05160f01c611465620007a0600039600081816106f80152610b030152600081816105db015261082a01526114656000f3fe6080604052600436106101695760003560e01c806341f0f4d8116100d15780638bfea4391161008a578063a457c2d711610064578063a457c2d714610419578063a9059cbb14610439578063b1953b6f14610459578063dd62ed3e1461046e576101ac565b80638bfea439146103cf57806395d89b41146103ef578063a04af4bb14610404576101ac565b806341f0f4d81461033057806370a08231146103455780637bd5cbde14610365578063855314281461037a57806389a6acc01461038f5780638b876347146103af576101ac565b80631d888021116101235780631d88802114610282578063201dcfb31461029757806323b872dd146102b9578063313ce567146102d957806339509351146102fb5780633d18b9121461031b576101ac565b80628cc262146101b1578063023b4f5f146101e757806306fdde03146101fc578063095ea7b31461021e5780630ddeeada1461024b57806318160ddd1461026d576101ac565b366101ac573373ecf044c5b4b867cfda001101c617ecd347095b44146101aa5760405162461bcd60e51b81526004016101a19061111c565b60405180910390fd5b005b600080fd5b3480156101bd57600080fd5b506101d16101cc366004610ed6565b61048e565b6040516101de919061133a565b60405180910390f35b3480156101f357600080fd5b506101aa610515565b34801561020857600080fd5b50610211610642565b6040516101de9190610fc7565b34801561022a57600080fd5b5061023e610239366004610f64565b6106d4565b6040516101de9190610fa8565b34801561025757600080fd5b506102606106f6565b6040516101de919061132b565b34801561027957600080fd5b506101d161071a565b34801561028e57600080fd5b506101d1610720565b3480156102a357600080fd5b506102ac610726565b6040516101de9190610fb3565b3480156102c557600080fd5b5061023e6102d4366004610f29565b61073e565b3480156102e557600080fd5b506102ee61076c565b6040516101de9190611362565b34801561030757600080fd5b5061023e610316366004610f64565b610771565b34801561032757600080fd5b506101aa61079d565b34801561033c57600080fd5b5061023e610828565b34801561035157600080fd5b506101d1610360366004610ed6565b61084c565b34801561037157600080fd5b506101d1610867565b34801561038657600080fd5b506101d16108f7565b34801561039b57600080fd5b506101d16103aa366004610ed6565b610909565b3480156103bb57600080fd5b506101d16103ca366004610ed6565b610924565b3480156103db57600080fd5b506101d16103ea366004610ed6565b610936565b3480156103fb57600080fd5b50610211610948565b34801561041057600080fd5b506101d1610957565b34801561042557600080fd5b5061023e610434366004610f64565b61095d565b34801561044557600080fd5b5061023e610454366004610f64565b6109a5565b34801561046557600080fd5b506101d16109bd565b34801561047a57600080fd5b506101d1610489366004610ef7565b6109c3565b6001600160a01b038116600090815260086020526040812054600754670de0b6b3a7640000916104bd916113c7565b6001600160a01b0384166000908152600b60205260409020546104e091906113a8565b6104ea9190611388565b6001600160a01b03831660009081526009602052604090205461050d9190611370565b90505b919050565b61051d610acf565b6000610527610867565b9050600081116105495760405162461bcd60e51b81526004016101a190611189565b600654604051631cc6d2f960e31b815273ecf044c5b4b867cfda001101c617ecd347095b449163e63697c891610586919030908690600401611343565b602060405180830381600087803b1580156105a057600080fd5b505af11580156105b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d89190610f8d565b507f00000000000000000000000000000000000000000000000000000000000000001561062e57600061060a82610af9565b905061061e61061982846113c7565b610b36565b6106283382610ba6565b50610637565b61063781610b36565b50610640610c22565b565b606060038054610651906113de565b80601f016020809104026020016040519081016040528092919081815260200182805461067d906113de565b80156106ca5780601f1061069f576101008083540402835291602001916106ca565b820191906000526020600020905b8154815290600101906020018083116106ad57829003601f168201915b5050505050905090565b6000806106df610c29565b90506106ec818585610c2d565b5060019392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60025490565b60065481565b73ecf044c5b4b867cfda001101c617ecd347095b4481565b600080610749610c29565b9050610756858285610ce1565b610761858585610d2b565b506001949350505050565b601290565b60008061077c610c29565b90506106ec81858561078e85896109c3565b6107989190611370565b610c2d565b6107a5610acf565b6107ae33610e2c565b33600090815260096020526040902054801561063757336000818152600960205260408120556107de9082610ba6565b336001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe82604051610817919061133a565b60405180910390a250610640610c22565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001600160a01b031660009081526020819052604090205490565b600654604051634903b0d160e01b815260009173ecf044c5b4b867cfda001101c617ecd347095b4491634903b0d1916108a29160040161133a565b60206040518083038186803b1580156108ba57600080fd5b505afa1580156108ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f29190610f8d565b905090565b60006108f2610904610867565b610af9565b6001600160a01b03166000908152600b602052604090205490565b60086020526000908152604090205481565b60096020526000908152604090205481565b606060048054610651906113de565b600a5490565b600080610968610c29565b9050600061097682866109c3565b9050838110156109985760405162461bcd60e51b81526004016101a1906112e6565b6107618286868403610c2d565b6000806109b0610c29565b90506106ec818585610d2b565b60075481565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0382166000908152600c602052604090205460ff1615610a1e57610a198282610e63565b610a5b565b6001600160a01b0382163b610a5b57610a378282610e63565b6001600160a01b0382166000908152600c60205260409020805460ff191660011790555b6001600160a01b0383166000908152600c602052604090205460ff1615610aca57610a8583610e2c565b80600a6000828254610a9791906113c7565b90915550506001600160a01b0383166000908152600b602052604081208054839290610ac49084906113c7565b90915550505b505050565b60026005541415610af25760405162461bcd60e51b81526004016101a1906112af565b6002600555565b6000612710610b2c7f000000000000000000000000000000000000000000000000000000000000000061ffff16846113a8565b61050d9190611388565b600a54610b4b82670de0b6b3a76400006113a8565b610b559190611388565b60076000828254610b669190611370565b90915550506040517f3c67104483541e0784de45745293680ec52e10daeb4b03c61846b1002298a38f90610b9b90839061133a565b60405180910390a150565b6000826001600160a01b031682604051610bbf90610fa5565b60006040518083038185875af1925050503d8060008114610bfc576040519150601f19603f3d011682016040523d82523d6000602084013e610c01565b606091505b5050905080610aca5760405162461bcd60e51b81526004016101a1906111be565b6001600555565b3390565b6001600160a01b038316610c535760405162461bcd60e51b81526004016101a19061126b565b6001600160a01b038216610c795760405162461bcd60e51b81526004016101a19061105d565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610cd490859061133a565b60405180910390a3505050565b6000610ced84846109c3565b90506000198114610d255781811015610d185760405162461bcd60e51b81526004016101a19061109f565b610d258484848403610c2d565b50505050565b6001600160a01b038316610d515760405162461bcd60e51b81526004016101a190611226565b6001600160a01b038216610d775760405162461bcd60e51b81526004016101a19061101a565b610d82838383610aca565b6001600160a01b03831660009081526020819052604090205481811015610dbb5760405162461bcd60e51b81526004016101a1906110d6565b6001600160a01b0380851660008181526020819052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610e1990869061133a565b60405180910390a3610d25848484610eb4565b610e358161048e565b6001600160a01b03909116600090815260096020908152604080832093909355600754600890915291902055565b610e6c82610e2c565b80600a6000828254610e7e9190611370565b90915550506001600160a01b0382166000908152600b602052604081208054839290610eab908490611370565b90915550505050565b610aca8383836109ee565b80356001600160a01b038116811461051057600080fd5b600060208284031215610ee7578081fd5b610ef082610ebf565b9392505050565b60008060408385031215610f09578081fd5b610f1283610ebf565b9150610f2060208401610ebf565b90509250929050565b600080600060608486031215610f3d578081fd5b610f4684610ebf565b9250610f5460208501610ebf565b9150604084013590509250925092565b60008060408385031215610f76578182fd5b610f7f83610ebf565b946020939093013593505050565b600060208284031215610f9e578081fd5b5051919050565b90565b901515815260200190565b6001600160a01b0391909116815260200190565b6000602080835283518082850152825b81811015610ff357858101830151858201604001528201610fd7565b818111156110045783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601d908201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604082015260600190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b60208082526047908201527f4373725265776172647345524332303a204f6e6c79207475726e7374696c652060408201527f7472616e73666572732077696c6c2062652070726f63657373656420666f72206060820152667265776172647360c81b608082015260a00190565b6020808252818101527f4373725265776172647345524332303a204e6f2043535220746f20636c61696d604082015260600190565b60208082526042908201527f4373725265776172647345524332303a20556e61626c6520746f2073656e642060408201527f76616c75652c20726563697069656e74206d6179206861766520726576657274606082015261195960f21b608082015260a00190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b61ffff91909116815260200190565b90815260200190565b9283526001600160a01b03919091166020830152604082015260600190565b60ff91909116815260200190565b6000821982111561138357611383611419565b500190565b6000826113a357634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156113c2576113c2611419565b500290565b6000828210156113d9576113d9611419565b500390565b6002810460018216806113f257607f821691505b6020821081141561141357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea26469706673582212207a23011ac1b177f75e0c039f35bf3a41eabde365a08ace130bcc98fb2904878a64736f6c6343000801003300000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000004546573740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045445535400000000000000000000000000000000000000000000000000000000

Deployed ByteCode

0x