false
true
0

Contract Address Details

0x31f12b634Ebe9a0aA95145038364966d3d3f794b

Token
Janus Tower 28 (šŸ›28)
Creator
0xbd5c08–14460f at 0xde28fc–c7ddb0
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
157 Transactions
Transfers
0 Transfers
Gas Used
0
Last Balance Update
25915047
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
JnsTowerTokenR




Optimization enabled
true
Compiler version
v0.8.24+commit.e11b9ed9




Optimization runs
200
EVM Version
paris




Verified at
2025-07-22T15:49:10.002220Z

Constructor Arguments

0x0000000000000000000000001529db0ce047cec387eac38b179b93d3e1631b03000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000e4a616e757320546f7765722032380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006f09f8f9b32380000000000000000000000000000000000000000000000000000

Arg [0] (address) : 0x1529db0ce047cec387eac38b179b93d3e1631b03
Arg [1] (string) : Janus Tower 28
Arg [2] (string) : šŸ›28

              

contracts/JnsTowerTokenR.sol

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

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC165.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "./lib/FullMath.sol";
import "./lib/Constants.sol";

/// @title JNS Tower Reflection Token Contract
contract JnsTowerTokenR is ERC20, Ownable2Step, IERC165 {
    // --------------------------- STATE VARIABLES --------------------------- //

    address public BUY_BURN_ADDRESS;

    /// @notice Total tokens reflected to users.
    uint256 public totalReflections;

    /// @notice Total tokens burned to date.
    uint256 public totalBurned;

    /// @notice Are transcations to provided address exempt from taxes.
    mapping(address => bool) public whitelistTo;
    /// @notice Are transcations from provided address exempt from taxes.
    mapping(address => bool) public whitelistFrom;

    /// @notice Is address excluded from receiving reflections.
    mapping(address => bool) public isExcludedFromReflections;

    mapping(address => uint256) private _tOwned;
    mapping(address => uint256) private _rOwned;
    address[] private _excluded;

    uint256 private _tTotal = 1_000_000 ether;
    uint256 private _rTotal = (MAX_VALUE - (MAX_VALUE % _tTotal));

    // --------------------------- ERRORS --------------------------- //

    error ZeroAddress();
    error MaxSupply();
    error Prohibited();
    error ExcludedAddress();

    // --------------------------- EVENTS -------------------------- //

    event ReserveDistributed();

    // --------------------------- CONSTRUCTOR --------------------------- //

    constructor(address _owner, string memory _name, string memory _symbol) ERC20(_name, _symbol) Ownable(_owner) {
        _rOwned[_owner] = _rTotal;
        whitelistFrom[_owner] = true;
    }

    // --------------------------- PUBLIC FUNCTIONS --------------------------- //

    /// @notice Burns tokens from user's wallet.
    /// @param amount The amount of tokens to burn.
    function burn(uint256 amount) public {
        _rBurn(msg.sender, amount);
    }

    /// @notice Reflects tokens to all holders from user's wallet.
    /// @param amount The amount of tokens to reflect.
    function reflect(uint256 amount) public {
        address sender = msg.sender;
        if (isExcludedFromReflections[sender]) revert ExcludedAddress();
        uint256 rAmount = reflectionFromToken(amount);
        _balanceCheck(sender, rAmount, amount);
        _rOwned[sender] -= rAmount;
        _rTotal -= rAmount;
        totalReflections += amount;
    }

    // --------------------------- ADMINISTRATIVE FUNCTIONS --------------------------- //

    /// @notice Sets the Buy & Burn contract address.
    /// @param _address The address of the Buy & Burn contract.
    /// @dev Can only be called by the owner once.
    function setBuyBurn(address _address) external onlyOwner {
        if (BUY_BURN_ADDRESS != address(0)) revert Prohibited();
        if (_address == address(0)) revert ZeroAddress();
        BUY_BURN_ADDRESS = _address;
    }

    /// @notice Excludes the account from receiving reflections.
    /// @param account Address of the account to be excluded.
    function excludeAccountFromReflections(address account) public onlyOwner {
        if (isExcludedFromReflections[account]) revert ExcludedAddress();
        if (account == address(this)) revert Prohibited();
        if (_rOwned[account] > 0) {
            _tOwned[account] = tokenFromReflection(_rOwned[account]);
        }
        isExcludedFromReflections[account] = true;
        _excluded.push(account);
    }

    /// @notice Includes the account back to receiving reflections.
    /// @param account Address of the account to be included.
    function includeAccountToReflections(address account) public onlyOwner {
        if (!isExcludedFromReflections[account]) revert ExcludedAddress();
        uint256 difference = _rOwned[account] - (_getRate() * _tOwned[account]);
        for (uint256 i = 0; i < _excluded.length; i++) {
            if (_excluded[i] == account) {
                _excluded[i] = _excluded[_excluded.length - 1];
                _tOwned[account] = 0;
                _rOwned[account] -= difference;
                _rTotal -= difference;
                isExcludedFromReflections[account] = false;
                _excluded.pop();
                break;
            }
        }
    }

    /// @notice Sets the whitelist status for a specified address.
    /// @param _address The address which whitelist status will be modified.
    /// @param _to Will the transfer to the address be whitelisted.
    /// @param _from Will the transfer from the address be whitelisted.
    function setWhitelistStatus(address _address, bool _to, bool _from) external onlyOwner {
        whitelistTo[_address] = _to;
        whitelistFrom[_address] = _from;
    }

    // --------------------------- VIEW FUNCTIONS --------------------------- //

    function totalSupply() public view override returns (uint256) {
        return _tTotal;
    }

    function balanceOf(address account) public view override returns (uint256) {
        if (isExcludedFromReflections[account]) return _tOwned[account];
        return tokenFromReflection(_rOwned[account]);
    }

    function reflectionFromToken(uint256 tAmount) public view returns (uint256) {
        if (tAmount > _tTotal) revert MaxSupply();
        uint256 rAmount = tAmount * _getRate();
        return rAmount;
    }

    function tokenFromReflection(uint256 rAmount) public view returns (uint256) {
        if (rAmount > _rTotal) revert MaxSupply();
        return rAmount / _getRate();
    }

    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC20).interfaceId || interfaceId == type(IERC165).interfaceId;
    }

    // --------------------------- REFLECTIONS FUNCTIONS --------------------------- //

    function _rBurn(address account, uint256 tAmount) internal {
        uint256 rBurn = tAmount * _getRate();
        _balanceCheck(account, rBurn, tAmount);
        _rOwned[account] -= rBurn;
        if (isExcludedFromReflections[account]) _tOwned[account] -= tAmount;
        _rTotal -= rBurn;
        _tTotal -= tAmount;
        totalBurned += tAmount;
        emit Transfer(account, address(0), tAmount);
    }

    function _update(address from, address to, uint256 value) internal override {
        if (value > _tTotal) revert ERC20InsufficientBalance(from, tokenFromReflection(_rOwned[from]), value);
        if (whitelistFrom[from] || whitelistTo[to]) {
            uint256 rAmount = value * _getRate();
            _balanceCheck(from, rAmount, value);
            _rOwned[from] -= rAmount;
            if (isExcludedFromReflections[from]) _tOwned[from] -= value;
            _rOwned[to] += rAmount;
            if (isExcludedFromReflections[to]) _tOwned[to] += value;
            emit Transfer(from, to, value);
        } else {
            (
                uint256 rAmount,
                uint256 rTransferAmount,
                uint256 rFee,
                uint256 rReserve,
                uint256 tTransferAmount,
                uint256 tFee,
                uint256 tReserve
            ) = _getValues(value);
            _balanceCheck(from, rAmount, value);
            _rOwned[from] -= rAmount;
            if (isExcludedFromReflections[from]) _tOwned[from] -= value;
            _rOwned[to] += rTransferAmount;
            if (isExcludedFromReflections[to]) _tOwned[to] += tTransferAmount;
            _rOwned[BUY_BURN_ADDRESS] += rReserve;
            if (isExcludedFromReflections[BUY_BURN_ADDRESS]) _tOwned[BUY_BURN_ADDRESS] += tReserve;
            _reflectFee(rFee, tFee);

            emit Transfer(from, to, tTransferAmount);
        }
    }

    function _balanceCheck(address from, uint256 rAmount, uint256 value) internal view {
        uint256 fromBalance = _rOwned[from];
        if (fromBalance < rAmount) {
            revert ERC20InsufficientBalance(from, tokenFromReflection(fromBalance), value);
        }
    }

    function _reflectFee(uint256 rFee, uint256 tFee) private {
        _rTotal -= rFee;
        totalReflections += tFee;
    }

    function _getValues(uint256 tAmount)
        private
        view
        returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256)
    {
        (uint256 tTransferAmount, uint256 tFee, uint256 tReserve) = _getTValues(tAmount);
        uint256 currentRate = _getRate();
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 rReserve) =
            _getRValues(tAmount, tFee, tReserve, currentRate);
        return (rAmount, rTransferAmount, rFee, rReserve, tTransferAmount, tFee, tReserve);
    }

    function _getTValues(uint256 tAmount) private pure returns (uint256, uint256, uint256) {
        uint256 tFee = FullMath.mulDivRoundingUp(tAmount, REFLECTION_FEE_BPS, BPS_BASE);
        uint256 tReserve = FullMath.mulDivRoundingUp(tAmount, RESERVE_TAX_BPS, BPS_BASE);
        uint256 tTransferAmount = tAmount - tFee - tReserve;
        return (tTransferAmount, tFee, tReserve);
    }

    function _getRValues(uint256 tAmount, uint256 tFee, uint256 tReserve, uint256 currentRate)
        private
        pure
        returns (uint256, uint256, uint256, uint256)
    {
        uint256 rAmount = tAmount * currentRate;
        uint256 rFee = tFee * currentRate;
        uint256 rReserve = tReserve * currentRate;
        uint256 rTransferAmount = rAmount - rFee - rReserve;
        return (rAmount, rTransferAmount, rFee, rReserve);
    }

    function _getRate() private view returns (uint256) {
        (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
        return rSupply / tSupply;
    }

    function _getCurrentSupply() private view returns (uint256, uint256) {
        uint256 rSupply = _rTotal;
        uint256 tSupply = _tTotal;
        for (uint256 i = 0; i < _excluded.length; i++) {
            address account = _excluded[i];
            uint256 rValue = _rOwned[account];
            uint256 tValue = _tOwned[account];
            if (rValue > rSupply || tValue > tSupply) return (_rTotal, _tTotal);
            rSupply -= rValue;
            tSupply -= tValue;
        }
        if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal);
        return (rSupply, tSupply);
    }
}
        

@openzeppelin/contracts/access/Ownable.sol

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

@openzeppelin/contracts/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     *
     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}
          

@openzeppelin/contracts/interfaces/IERC1363.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data)
        external
        returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
          

@openzeppelin/contracts/interfaces/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";
          

@openzeppelin/contracts/interfaces/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";
          

@openzeppelin/contracts/interfaces/draft-IERC6093.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
          

@openzeppelin/contracts/token/ERC20/ERC20.sol

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

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}.
 *
 * 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 ERC-20
 * applications.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => 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 returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual 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 returns (uint8) {
        return 18;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual 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 `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` 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 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Skips emitting an {Approval} event indicating an allowance update. This is not
     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
     *
     * 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 `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` 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.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` 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.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     *
     * ```solidity
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

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

@openzeppelin/contracts/token/ERC20/IERC20.sol

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

@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
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);
}
          

@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 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 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(IERC1363 token, address from, address to, uint256 value, bytes memory data)
        internal
    {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}
          

@openzeppelin/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }

        (bool success,) = recipient.call{value: amount}("");
        if (!success) {
            revert Errors.FailedCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {Errors.FailedCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
     * of an unsuccessful call.
     */
    function verifyCallResultFromTarget(address target, bool success, bytes memory returndata)
        internal
        view
        returns (bytes memory)
    {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {Errors.FailedCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}
          

@openzeppelin/contracts/utils/Context.sol

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

@openzeppelin/contracts/utils/Errors.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}
          

@openzeppelin/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
          

@openzeppelin/contracts/utils/structs/EnumerableSet.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position is the index of the value in the `values` array plus 1.
        // Position 0 is used to mean a value is not in the set.
        mapping(bytes32 value => uint256) _positions;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._positions[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We cache the value's position to prevent multiple reads from the same storage slot
        uint256 position = set._positions[value];

        if (position != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 valueIndex = position - 1;
            uint256 lastIndex = set._values.length - 1;

            if (valueIndex != lastIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._positions[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        assembly ("memory-safe") {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly ("memory-safe") {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly ("memory-safe") {
            result := store
        }

        return result;
    }
}
          

contracts/JnsBuyBurn/JnsTowerBuyBurn.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./interfaces/IPulseXRouter02.sol";
import "./interfaces/IWPLS.sol";
import "./interfaces/IERC20Burnable.sol";
import "./lib/Constants.sol";

/// @title Janus Tower Buy&Burn Contract
contract JnsTowerBuyBurn is Ownable2Step {
    using EnumerableSet for EnumerableSet.AddressSet;
    using SafeERC20 for *;

    enum SwapTypes {
        DISABLED,
        V2
    }

    struct SwapTokenSettings {
        SwapTypes swapType;
        uint16 incentiveBps;
        uint32 interval;
        uint256 capPerSwap;
    }

    struct SingleSwapOptionsV3 {
        address tokenOut;
        uint24 fee;
    }

    // -------------------------- STATE VARIABLES -------------------------- //

    /// @notice Basis point incentive fee paid out for calling Buy & Burn.
    uint16 public buyBurnIncentiveFeeBps = 42;
    /// @notice Cooldown for Buy & Burns in seconds.
    uint32 public buyBurnInterval = 6 hours;
    /// @notice The maximum amount of šŸ› 27 that can be swapped per Buy & Burn.
    uint256 public capPerSwapBuyBurn = 100_000 ether;
    /// @notice Time of the last Buy & Burn in seconds.
    uint256 public lastBuyBurn;

    /// @notice Currently enabled tokens.
    EnumerableSet.AddressSet private _enabledTokens;
    /// @notice Swap settings per token.
    mapping(address => SwapTokenSettings) public swapSettings;
    /// @notice Times of last swap per token.
    mapping(address => uint256) public swapTimes;
    /// @notice Path of a swap for PulseX V2 protocol.
    mapping(address => address[]) public swapOptionsV2;

    // ------------------------------- EVENTS ------------------------------ //

    event SettingsUpdate();
    event TokenSwap();
    event BuyBurn();

    // ------------------------------- ERRORS ------------------------------ //

    error Prohibited();
    error ZeroAddress();
    error Cooldown();
    error InsufficientBalance();
    error IncorrectPathSettings();
    error TokenNotEnabled();
    error DuplicateSwapToken();
    error Unauthorized();

    // ------------------------------ MODIFIERS ---------------------------- //

    modifier onlyWhitelisted() {
        if (!WL_REGISTRY.isWhitelisted(msg.sender)) revert Unauthorized();
        _;
    }

    // ----------------------------- CONSTRUCTOR --------------------------- //

    constructor(address _owner) Ownable(_owner) {}

    // --------------------------- PUBLIC FUNCTIONS ------------------------ //

    receive() external payable {
        IWPLS(WPLS).deposit{value: msg.value}();
    }

    /// @notice Swaps whitelisted tokens.
    /// @param token Address of a token to swap.
    /// @param minAmountOut Minimum amount of tokens to receive from swap.
    /// @param deadline Deadline timestamp to perform the swap.
    function swapToken(address token, uint256 minAmountOut, uint256 deadline) external onlyWhitelisted {
        (uint256 amount, uint256 incentive, uint256 nextAvailable, SwapTypes swapType) = getSwapParams(token);
        if (block.timestamp < nextAvailable) revert Cooldown();
        if (amount == 0) revert InsufficientBalance();

        swapTimes[token] = block.timestamp;
        if (swapType == SwapTypes.V2) {
            _handleV2Swap(token, amount - incentive, minAmountOut, deadline);
        } else {
            revert Prohibited();
        }

        IERC20(token).safeTransfer(msg.sender, incentive);
        emit TokenSwap();
    }

    /// @notice Buys and burns šŸ› 28 tokens using šŸ› 27 balance.
    /// @param minAmountOut The minimum amount out for šŸ› 27 -> šŸ› 28 swap.
    /// @param deadline The deadline for the swaps.
    function buyAndBurn(uint256 minAmountOut, uint256 deadline) external onlyWhitelisted {
        (uint256 amount, uint256 incentive, uint256 nextAvailable) = getBuyBurnParams();
        if (block.timestamp < nextAvailable) revert Cooldown();
        if (amount == 0) revert InsufficientBalance();

        lastBuyBurn = block.timestamp;
        _swapT27ToT28(amount - incentive, minAmountOut, deadline);
        burnTokens();

        IERC20(TOWER_27).safeTransfer(msg.sender, incentive);
        emit BuyBurn();
    }

    /// @notice Burns all šŸ› 28 tokens available in the contract.
    function burnTokens() public {
        IERC20Burnable t28 = IERC20Burnable(TOWER_28);
        uint256 totalBalance = t28.balanceOf(address(this));
        if (totalBalance == 0) revert InsufficientBalance();
        t28.burn(totalBalance);
    }

    // ----------------------- ADMINISTRATIVE FUNCTIONS -------------------- //

    /// @notice Sets the incentive fee basis points (bps) for Buy & Burn calls.
    /// @param bps The incentive fee in basis points (30 - 500), (100 bps = 1%).
    function setBuyBurnIncentiveFee(uint16 bps) external onlyOwner {
        if (bps < 30 || bps > 500) revert Prohibited();
        buyBurnIncentiveFeeBps = bps;
        emit SettingsUpdate();
    }

    /// @notice Sets the Buy & Burn interval.
    /// @param limit The new interval in seconds.
    function setBuyBurnInterval(uint32 limit) external onlyOwner {
        if (limit == 0) revert Prohibited();
        buyBurnInterval = limit;
        emit SettingsUpdate();
    }

    /// @notice Sets the cap per swap for šŸ› 27 -> šŸ› 28 swaps during Buy & Burn calls.
    /// @param limit The new cap limit in WEI applied to šŸ› 27 balance.
    function setCapPerSwapBuyBurn(uint256 limit) external onlyOwner {
        capPerSwapBuyBurn = limit;
        emit SettingsUpdate();
    }

    /// @notice Adds a swap token that requires a PulseX V2 swap.
    /// @param token Address of the token to be enabled.
    /// @param path Array of addresses from input token to output token. (Supports Multihop)
    /// @param capPerSwap Maximum amount of tokens to be swapped in a single call.
    /// @param incentiveBps Basis points to be paid out as incentive to the caller (1% = 100 bps).
    /// @param interval Cooldown time in seconds.
    function addPulseXV2Token(
        address token,
        address[] memory path,
        uint256 capPerSwap,
        uint16 incentiveBps,
        uint32 interval
    ) external onlyOwner {
        if (token == address(0)) revert ZeroAddress();
        if (path.length < 2 || path[0] != token) revert IncorrectPathSettings();
        if (!_enabledTokens.add(token)) revert DuplicateSwapToken();
        swapOptionsV2[token] = path;
        swapSettings[token] = SwapTokenSettings(SwapTypes.V2, incentiveBps, interval, capPerSwap);
        emit SettingsUpdate();
    }

    /// @notice Removes a swap token from whitelisted tokens.
    /// @param token Address of the token to edit.
    /// @param capPerSwap Maximum amount of tokens to be distributed in a single call.
    /// @param incentiveBps Basis points to be paid out as incentive to the caller (1% = 100 bps).
    /// @param interval Cooldown time in seconds.
    function editTokenSettings(address token, uint256 capPerSwap, uint16 incentiveBps, uint32 interval)
        external
        onlyOwner
    {
        if (!_enabledTokens.contains(token)) revert TokenNotEnabled();
        SwapTokenSettings storage settings = swapSettings[token];
        settings.capPerSwap = capPerSwap;
        settings.incentiveBps = incentiveBps;
        settings.interval = interval;
        emit SettingsUpdate();
    }

    /// @notice Removes a swap token from whitelisted tokens.
    /// @param token Address of the token to be disabled.
    function disableToken(address token) external onlyOwner {
        if (!_enabledTokens.remove(token)) revert TokenNotEnabled();
        delete swapSettings[token];
        delete swapOptionsV2[token];
        emit SettingsUpdate();
    }

    // ---------------------------- VIEW FUNCTIONS ------------------------- //

    /// @notice Returns parameters for the next token swap.
    /// @param token Address of the token to be used in a swap.
    /// @return amount Total token amount used in the next swap.
    /// @return incentive Token amount paid out as incentive to the caller.
    /// @return nextAvailable Timestamp in seconds when next swap will be available.
    /// @return swapType Type of the swap to be performed.
    function getSwapParams(address token)
        public
        view
        returns (uint256 amount, uint256 incentive, uint256 nextAvailable, SwapTypes swapType)
    {
        SwapTokenSettings memory settings = swapSettings[token];
        if (settings.swapType == SwapTypes.DISABLED) revert TokenNotEnabled();
        uint256 balance = IERC20(token).balanceOf(address(this));
        amount = balance > settings.capPerSwap ? settings.capPerSwap : balance;
        nextAvailable = swapTimes[token] + settings.interval;
        incentive = _applyBps(amount, settings.incentiveBps);
        swapType = settings.swapType;
    }

    /// @notice Returns parameters for the next Buy & Burn.
    /// @return amount Total šŸ› 27 amount used in the next Buy & Burn.
    /// @return incentive šŸ› 27 amount paid out as incentive to the caller.
    /// @return nextAvailable Timestamp in seconds when next Buy & Burn will be available.
    function getBuyBurnParams() public view returns (uint256 amount, uint256 incentive, uint256 nextAvailable) {
        uint256 balance = IERC20(TOWER_27).balanceOf(address(this));
        amount = balance > capPerSwapBuyBurn ? capPerSwapBuyBurn : balance;
        nextAvailable = lastBuyBurn + buyBurnInterval;
        incentive = _applyBps(amount, buyBurnIncentiveFeeBps);
    }

    /// @notice Returns a list of all enabled swap tokens.
    function getEnabledTokens() external view returns (address[] memory) {
        return _enabledTokens.values();
    }

    /// @notice Returns a full PulseX path for a V2 swap token.
    function getPulseXV2Path(address token) external view returns (address[] memory) {
        return swapOptionsV2[token];
    }

    // -------------------------- INTERNAL FUNCTIONS ----------------------- //

    function _applyBps(uint256 amount, uint16 incentiveBps) internal pure returns (uint256) {
        return (amount * incentiveBps) / BPS_BASE;
    }

    function _swapT27ToT28(uint256 amountIn, uint256 minAmountOut, uint256 deadline) internal {
        IERC20(TOWER_27).safeIncreaseAllowance(PULSEX_V2_ROUTER, amountIn);
        address[] memory path = new address[](2);
        path[0] = TOWER_27;
        path[1] = TOWER_28;
        IPulseXRouter02(PULSEX_V2_ROUTER).swapExactTokensForTokensSupportingFeeOnTransferTokens(
            amountIn, minAmountOut, path, address(this), deadline
        );
    }

    function _handleV2Swap(address token, uint256 amountIn, uint256 minAmountOut, uint256 deadline) internal {
        IERC20(token).safeIncreaseAllowance(PULSEX_V2_ROUTER, amountIn);
        address[] memory path = swapOptionsV2[token];
        IPulseXRouter02(PULSEX_V2_ROUTER).swapExactTokensForTokensSupportingFeeOnTransferTokens(
            amountIn, minAmountOut, path, address(this), deadline
        );
    }
}
          

contracts/JnsBuyBurn/interfaces/IERC20Burnable.sol

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

import "@openzeppelin/contracts/interfaces/IERC20.sol";

interface IERC20Burnable is IERC20 {
    function burn(uint256 value) external;
}
          

contracts/JnsBuyBurn/interfaces/IPulseXRouter02.sol

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.2;

interface IPulseXRouter02 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
}
          

contracts/JnsBuyBurn/interfaces/IWPLS.sol

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.10;

import "@openzeppelin/contracts/interfaces/IERC20.sol";

/// @title Interface for WETH9
interface IWPLS is IERC20 {
    function deposit() external payable;
    function withdraw(uint256) external;
}
          

contracts/JnsBuyBurn/interfaces/IWhitelistRegistry.sol

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

interface IWhitelistRegistry {
    function isWhitelisted(address account) external view returns (bool);
    function setWhitelisted(address[] calldata accounts, bool _isWhitelisted) external;
}
          

contracts/JnsBuyBurn/lib/Constants.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

import "../interfaces/IWhitelistRegistry.sol";

// ===================== Contract Addresses ======================
address constant TOWER_27 = 0x969E3128DB078b179E9F3b3679710d2443cCDB72; // CHANGE
address constant TOWER_28 = 0x20Dc424c5fa468CbB1c702308F0cC9c14DA2825C; // CHANGE
address constant WPLS = 0xA1077a294dDE1B09bB078844df40758a5D0f9a27;

address constant PULSEX_V2_ROUTER = 0x165C3410fC91EF562C50559f7d2289fEbed552d9;

uint16 constant BPS_BASE = 100_00;

IWhitelistRegistry constant WL_REGISTRY = IWhitelistRegistry(0x8731d45ff9684d380302573cCFafd994Dfa7f7d3);
          

contracts/lib/Constants.sol

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

uint16 constant RESERVE_TAX_BPS = 1_50;
uint16 constant REFLECTION_FEE_BPS = 1_50;
uint16 constant BPS_BASE = 100_00;
uint256 constant MAX_VALUE = ~uint256(0);
          

contracts/lib/FullMath.sol

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

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(aƗbĆ·denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = a * b
            // Compute the product mod 2**256 and mod 2**256 - 1
            // then use the Chinese Remainder Theorem to reconstruct
            // the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2**256 + prod0
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(a, b, not(0))
                prod0 := mul(a, b)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division
            if (prod1 == 0) {
                require(denominator > 0);
                assembly {
                    result := div(prod0, denominator)
                }
                return result;
            }

            // Make sure the result is less than 2**256.
            // Also prevents denominator == 0
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly {
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator
            // Compute largest power of two divisor of denominator.
            // Always >= 1.
            uint256 twos = (0 - denominator) & denominator;
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly {
                prod0 := div(prod0, twos)
            }
            // Shift in bits from prod1 into prod0. For this we need
            // to flip `twos` such that it is 2**256 / twos.
            // If twos is zero, then it becomes one
            assembly {
                twos := add(div(sub(0, twos), twos), 1)
            }
            prod0 |= prod1 * twos;

            // Invert denominator mod 2**256
            // Now that denominator is an odd number, it has an inverse
            // modulo 2**256 such that denominator * inv = 1 mod 2**256.
            // Compute the inverse by starting with a seed that is correct
            // correct for four bits. That is, denominator * inv = 1 mod 2**4
            uint256 inv = (3 * denominator) ^ 2;
            // Now use Newton-Raphson iteration to improve the precision.
            // Thanks to Hensel's lifting lemma, this also works in modular
            // arithmetic, doubling the correct bits in each step.
            inv *= 2 - denominator * inv; // inverse mod 2**8
            inv *= 2 - denominator * inv; // inverse mod 2**16
            inv *= 2 - denominator * inv; // inverse mod 2**32
            inv *= 2 - denominator * inv; // inverse mod 2**64
            inv *= 2 - denominator * inv; // inverse mod 2**128
            inv *= 2 - denominator * inv; // inverse mod 2**256

            // Because the division is now exact we can divide by multiplying
            // with the modular inverse of denominator. This will give us the
            // correct result modulo 2**256. Since the precoditions guarantee
            // that the outcome is less than 2**256, this is the final result.
            // We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inv;
            return result;
        }
    }

    /// @notice Calculates ceil(aƗbĆ·denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            result = mulDiv(a, b, denominator);
            if (mulmod(a, b, denominator) > 0) {
                require(result < type(uint256).max);
                result++;
            }
        }
    }
}
          

Compiler Settings

{"viaIR":true,"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"paris"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_owner","internalType":"address"},{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"}]},{"type":"error","name":"ERC20InsufficientAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"allowance","internalType":"uint256"},{"type":"uint256","name":"needed","internalType":"uint256"}]},{"type":"error","name":"ERC20InsufficientBalance","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"needed","internalType":"uint256"}]},{"type":"error","name":"ERC20InvalidApprover","inputs":[{"type":"address","name":"approver","internalType":"address"}]},{"type":"error","name":"ERC20InvalidReceiver","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"error","name":"ERC20InvalidSender","inputs":[{"type":"address","name":"sender","internalType":"address"}]},{"type":"error","name":"ERC20InvalidSpender","inputs":[{"type":"address","name":"spender","internalType":"address"}]},{"type":"error","name":"ExcludedAddress","inputs":[]},{"type":"error","name":"MaxSupply","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"Prohibited","inputs":[]},{"type":"error","name":"ZeroAddress","inputs":[]},{"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":"OwnershipTransferStarted","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ReserveDistributed","inputs":[],"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":"address"}],"name":"BUY_BURN_ADDRESS","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"acceptOwnership","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":"value","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"excludeAccountFromReflections","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"includeAccountToReflections","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isExcludedFromReflections","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pendingOwner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"reflect","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"reflectionFromToken","inputs":[{"type":"uint256","name":"tAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBuyBurn","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setWhitelistStatus","inputs":[{"type":"address","name":"_address","internalType":"address"},{"type":"bool","name":"_to","internalType":"bool"},{"type":"bool","name":"_from","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenFromReflection","inputs":[{"type":"uint256","name":"rAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalBurned","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalReflections","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":"value","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":"value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"whitelistFrom","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"whitelistTo","inputs":[{"type":"address","name":"","internalType":"address"}]}]
              

Contract Creation Code

0x60406080815234620003e6576200197390813803806200001f81620003eb565b938439820190606083830312620003e65782516001600160a01b03939084811690819003620003e65760208281015190926001600160401b0391828111620003e657866200006f91830162000411565b9585820151838111620003e65762000088920162000411565b908551818111620002e6576003908154906001988983811c93168015620003db575b88841014620003c5578190601f938481116200036f575b5088908483116001146200030857600092620002fc575b505060001982851b1c191690891b1782555b8351928311620002e65760049384548981811c91168015620002db575b88821014620002c65790818386959493116200026c575b50879184116001146200020157600093620001f5575b505082881b92600019911b1c19161781555b8115620001de57509081600b9260018060a01b03199687600654166006558160055498891617600555855197167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a369d3c21bcecceda100000060105569085afffa6ff50bffffff199081601155600052600e82528360002055526000209060ff198254161790556114ef9081620004848239f35b6024906000855191631e4fbdf760e01b8352820152fd5b01519150388062000134565b9190899450601f1984169286600052886000209360005b8a8282106200025557505085116200023a575b50505050811b01815562000146565b01519060f884600019921b161c19169055388080806200022b565b8385015187558d9890960195938401930162000218565b909192935085600052876000208380870160051c8201928a8810620002bc575b918c918897969594930160051c01915b828110620002ac5750506200011e565b600081558796508c91016200029c565b925081926200028c565b602286634e487b7160e01b6000525260246000fd5b90607f169062000107565b634e487b7160e01b600052604160045260246000fd5b015190503880620000d8565b908b9350601f19831691866000528a6000209260005b8c8282106200035857505084116200033f575b505050811b018255620000ea565b015160001983871b60f8161c1916905538808062000331565b8385015186558f979095019493840193016200031e565b90915084600052886000208480850160051c8201928b8610620003bb575b918d91869594930160051c01915b828110620003ab575050620000c1565b600081558594508d91016200039b565b925081926200038d565b634e487b7160e01b600052602260045260246000fd5b92607f1692620000aa565b600080fd5b6040519190601f01601f191682016001600160401b03811183821017620002e657604052565b919080601f84011215620003e65782516001600160401b038111620002e65760209062000447601f8201601f19168301620003eb565b92818452828287010111620003e65760005b8181106200046f57508260009394955001015290565b85810183015184820184015282016200045956fe60806040908082526004918236101561001757600080fd5b600092833560e01c928363018763ed14610e245750826301ffc9a714610dcd578263053ab18214610d5657826306fdde0314610c7a578263095ea7b314610bcf5782631392c08614610baf57826316b627d114610b7157826318160ddd14610b5257826323b872dd14610a5c5782632d83811914610a3c578263313ce56714610a205782633394e5bb146108905783836342966c68146107b35750826343684b211461077557826363841a5f1461067057826370a0823114610643578263715018a6146105dc57826379ba50971461054f5782638da5cb5b1461052657826395d89b4114610405578263a9059cbb146103d4578263c6d13da71461035f57508163d137428314610336578163d89135cd14610317578163dd62ed3e146102ce578163e30c3978146102a5578163e5353a0e1461021a578163e6375d3e146101d8575063f2fde38b1461016857600080fd5b346101d55760203660031901126101d557610181610e89565b61018961134d565b600680546001600160a01b0319166001600160a01b039283169081179091556005549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b80fd5b9050346102165760203660031901126102165760209160ff9082906001600160a01b03610203610e89565b168152600c855220541690519015158152f35b5080fd5b90503461021657606036600319011261021657610235610e89565b6024359182151583036102a15760443591821515830361029d5761029a936102829161025f61134d565b60018060a01b03168652600a6020528286209060ff801983541691151516179055565b600b60205283209060ff801983541691151516179055565b80f35b8480fd5b8380fd5b90503461021657816003193601126102165760065490516001600160a01b039091168152602090f35b905034610216578060031936011261021657806020926102ec610e89565b6102f4610ea4565b6001600160a01b0391821683526001865283832091168252845220549051908152f35b9050346102165781600319360112610216576020906009549051908152f35b90503461021657816003193601126102165760075490516001600160a01b039091168152602090f35b909150346103d05760203660031901126103d05761037b610e89565b9061038461134d565b600754916001600160a01b03908184166103c057169283156103b35750506001600160a01b0319161760075580f35b5163d92e233d60e01b8152fd5b8451632b0039c760e21b81528390fd5b8280fd5b8382346102165780600319360112610216576020906103fe6103f4610e89565b602435903361105b565b5160018152f35b83823461021657816003193601126102165780519082845460018160011c906001831692831561051c575b6020938484108114610509578388529081156104ed5750600114610498575b505050829003601f01601f191682019267ffffffffffffffff8411838510176104855750829182610481925282610e40565b0390f35b634e487b7160e01b815260418552602490fd5b8787529192508591837f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b8385106104d9575050505083010185808061044f565b8054888601830152930192849082016104c3565b60ff1916878501525050151560051b840101905085808061044f565b634e487b7160e01b895260228a52602489fd5b91607f1691610430565b83823461021657816003193601126102165760055490516001600160a01b039091168152602090f35b9150346103d057826003193601126103d057600654916001600160a01b039133838516036105c55750506bffffffffffffffffffffffff60a01b8092166006556005549133908316176005553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b60249250519063118cdaa760e01b82523390820152fd5b83346101d557806003193601126101d5576105f561134d565b600680546001600160a01b031990811690915560058054918216905581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b83823461021657602036600319011261021657602090610669610664610e89565b610fb5565b9051908152f35b8382346102165760203660031901126102165761068b610e89565b9061069461134d565b6001600160a01b038216808452600c6020528184205460ff166107655730811461075557808452600e6020528184205480610739575b5050600c6020528220805460ff19166001179055600f549268010000000000000000841015610726575061070883600161029a949501600f55610f68565b90919060018060a01b038084549260031b9316831b921b1916179055565b634e487b7160e01b835260419052602482fd5b61074290610f50565b908452600d6020528184205584806106ca565b8151632b0039c760e21b81528590fd5b815163c87d620b60e01b81528590fd5b8382346102165760203660031901126102165760209160ff9082906001600160a01b036107a0610e89565b168152600b855220541690519015158152f35b92503461088c57602036600319011261088c5735906108246107e56107df6107d9611379565b90610f30565b84610eea565b6107f0848233610ff5565b338552600e602052828520610806828254610eba565b9055338552600c60205260ff8386205416610872575b601154610eba565b60115561083382601054610eba565b60105561084282600954610edd565b600955519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203392a380f35b600d602052828520610885858254610eba565b905561081c565b5050fd5b909150346103d0576020806003193601126102a1576108ad610e89565b916108b661134d565b60018060a01b0380931693848652600c91600c845260ff828820541615610a1257858752600e91600e855280882054936109126108f46107d9611379565b95898b5261090c600d97600d8a52858d205490610eea565b90610eba565b95895b600f80549081831015610a03578a918c61092e85610f68565b949054600395861b1c161461094857505050600101610915565b98909a999260009c9495969798929c19998a81019081116109f057906107088c8f61097561098195610f68565b9054911b1c1691610f68565b838d5284528b868120558352848b2061099b828254610eba565b90556109aa6011918254610eba565b90558952528620805460ff1916905583549081156109dd575001926109ce84610f68565b81939154921b1b191690555580f35b634e487b7160e01b875260319052602486fd5b634e487b7160e01b8f5260118a5260248ffd5b50505050505050505050505080f35b905163c87d620b60e01b8152fd5b8382346102165781600319360112610216576020905160128152f35b9083346101d55760203660031901126101d5575061066960209235610f50565b83346101d55760603660031901126101d557610a76610e89565b610a7e610ea4565b916044359360018060a01b038316808352600160205286832033845260205286832054916000198303610aba575b6020886103fe89898961105b565b868310610b22578115610b0b573315610af4575082526001602090815286832033845281529186902090859003905582906103fe87610aac565b8751634a1406b160e11b8152908101849052602490fd5b875163e602df0560e01b8152908101849052602490fd5b8751637dc7a0d960e11b8152339181019182526020820193909352604081018790528291506060010390fd5b0390fd5b8382346102165781600319360112610216576020906010549051908152f35b8382346102165760203660031901126102165760209160ff9082906001600160a01b03610b9c610e89565b168152600a855220541690519015158152f35b9083346101d55760203660031901126101d5575061066960209235610efd565b909150346103d057816003193601126103d057610bea610e89565b602435903315610c63576001600160a01b0316918215610c4c57508083602095338152600187528181208582528752205582519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925843392a35160018152f35b8351634a1406b160e11b8152908101859052602490fd5b835163e602df0560e01b8152808401869052602490fd5b8382346102165781600319360112610216578051908260035460018160011c9060018316928315610d4c575b6020938484108114610509578388529081156104ed5750600114610cf657505050829003601f01601f191682019267ffffffffffffffff8411838510176104855750829182610481925282610e40565b600387529192508591837fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b838510610d38575050505083010185808061044f565b805488860183015293019284908201610d22565b91607f1691610ca6565b9150346103d05760203660031901126103d057813591338452600c60205260ff8285205416610a12575090610dbc610dc792610d9183610efd565b90610d9d848333610ff5565b338652600e6020528520610db2828254610eba565b9055601154610eba565b601155600854610edd565b60085580f35b909150346103d05760203660031901126103d057359063ffffffff60e01b82168092036103d057602092506336372b0760e01b8214918215610e13575b50519015158152f35b6301ffc9a760e01b14915038610e0a565b8490346102165781600319360112610216576020906008548152f35b6020808252825181830181905290939260005b828110610e7557505060409293506000838284010152601f8019910116010190565b818101860151848201604001528501610e53565b600435906001600160a01b0382168203610e9f57565b600080fd5b602435906001600160a01b0382168203610e9f57565b91908203918211610ec757565b634e487b7160e01b600052601160045260246000fd5b91908201809211610ec757565b81810292918115918404141715610ec757565b6010548111610f1e57610f1b90610f156107d9611379565b90610eea565b90565b604051632cdb04a160e21b8152600490fd5b8115610f3a570490565b634e487b7160e01b600052601260045260246000fd5b6011548111610f1e57610f1b906107d96107d9611379565b600f54811015610f9f57600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8020190600090565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03166000908152600c602052604090205460ff16610fe757600e602052610f1b604060002054610f50565b600d60205260406000205490565b6001600160a01b0381166000908152600e60205260409020549091811061101b57505050565b611027610b4e91610f50565b60405163391434e360e21b81526001600160a01b039093166004840152602483015260448201929092529081906064820190565b916001600160a01b0380841692831561133457811693841561131b5760105483116112ff57916020917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef93600091868352600b85528660ff60408520541680156112e8575b1561117d5750506110e6836110df6110d96107d9611379565b82610eea565b8093610ff5565b858252600e8452604082206110fc828254610eba565b9055858252600c845260ff604083205416611163575b868252600e845261112860408320918254610edd565b9055858152600c835260ff604082205416611148575b50604051908152a3565b604090600d84522061115b828254610edd565b90553861113e565b600d845260408220611176848254610eba565b9055611112565b610dbc919261128b9461118f87611428565b946111ab61119c89611428565b936111b0856111ab8a8d610eba565b610eba565b996111bc6107d9611379565b80976111f6838c6111f08b6111e76111df6111d78987610eea565b988995610eea565b9e8f92610eea565b998a9184610eba565b96610ff5565b8652600e8d5261120b60408720918254610eba565b90558d8552600c8c5260ff6040862054166112cd575b508d8452600e8b5261123860408520918254610edd565b90558c8352600c8a5260ff6040842054166112b3575b81600754168352600e8a5261126860408420918254610edd565b9055600754168152600c885260ff604082205416611297575b5050601154610eba565b600855604051908152a3565b60406112aa91600d8a5220918254610edd565b90553880611281565b600d8a52604083206112c68a8254610edd565b905561124e565b600d8c526112e060408620918254610eba565b905538611221565b5050878352600a85528660ff6040852054166110c0565b905082600052600e602052610b4e611027604060002054610f50565b60405163ec442f0560e01b815260006004820152602490fd5b604051634b637e8f60e11b815260006004820152602490fd5b6005546001600160a01b0316330361136157565b60405163118cdaa760e01b8152336004820152602490fd5b6011549081601054928390600080600f54905b8183106113b3575050506113a08282610f30565b83106113ac5750509190565b9350919050565b909196946113c088610f68565b60018060a01b0391549060031b1c1682526020600e81526040600d81852054925283205491808211801561141f575b611412579161140361140992600194610eba565b97610eba565b9701919061138c565b5050505050915092509190565b508783116113ef565b90612710609661143784611450565b930961143f57565b90600019811015610e9f5760010190565b6000196096820960968202908180821091039080820391146114af5761271081811115610e9f5760967fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e91940990828211900360fc1b910360041c170290565b506127109150049056fea26469706673582212201d318e5b0604d9270a1de169b449b6bc65beec763b966674562389ad7da5ed5464736f6c634300081800330000000000000000000000001529db0ce047cec387eac38b179b93d3e1631b03000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000e4a616e757320546f7765722032380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006f09f8f9b32380000000000000000000000000000000000000000000000000000

Deployed ByteCode

0x60806040908082526004918236101561001757600080fd5b600092833560e01c928363018763ed14610e245750826301ffc9a714610dcd578263053ab18214610d5657826306fdde0314610c7a578263095ea7b314610bcf5782631392c08614610baf57826316b627d114610b7157826318160ddd14610b5257826323b872dd14610a5c5782632d83811914610a3c578263313ce56714610a205782633394e5bb146108905783836342966c68146107b35750826343684b211461077557826363841a5f1461067057826370a0823114610643578263715018a6146105dc57826379ba50971461054f5782638da5cb5b1461052657826395d89b4114610405578263a9059cbb146103d4578263c6d13da71461035f57508163d137428314610336578163d89135cd14610317578163dd62ed3e146102ce578163e30c3978146102a5578163e5353a0e1461021a578163e6375d3e146101d8575063f2fde38b1461016857600080fd5b346101d55760203660031901126101d557610181610e89565b61018961134d565b600680546001600160a01b0319166001600160a01b039283169081179091556005549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b80fd5b9050346102165760203660031901126102165760209160ff9082906001600160a01b03610203610e89565b168152600c855220541690519015158152f35b5080fd5b90503461021657606036600319011261021657610235610e89565b6024359182151583036102a15760443591821515830361029d5761029a936102829161025f61134d565b60018060a01b03168652600a6020528286209060ff801983541691151516179055565b600b60205283209060ff801983541691151516179055565b80f35b8480fd5b8380fd5b90503461021657816003193601126102165760065490516001600160a01b039091168152602090f35b905034610216578060031936011261021657806020926102ec610e89565b6102f4610ea4565b6001600160a01b0391821683526001865283832091168252845220549051908152f35b9050346102165781600319360112610216576020906009549051908152f35b90503461021657816003193601126102165760075490516001600160a01b039091168152602090f35b909150346103d05760203660031901126103d05761037b610e89565b9061038461134d565b600754916001600160a01b03908184166103c057169283156103b35750506001600160a01b0319161760075580f35b5163d92e233d60e01b8152fd5b8451632b0039c760e21b81528390fd5b8280fd5b8382346102165780600319360112610216576020906103fe6103f4610e89565b602435903361105b565b5160018152f35b83823461021657816003193601126102165780519082845460018160011c906001831692831561051c575b6020938484108114610509578388529081156104ed5750600114610498575b505050829003601f01601f191682019267ffffffffffffffff8411838510176104855750829182610481925282610e40565b0390f35b634e487b7160e01b815260418552602490fd5b8787529192508591837f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b8385106104d9575050505083010185808061044f565b8054888601830152930192849082016104c3565b60ff1916878501525050151560051b840101905085808061044f565b634e487b7160e01b895260228a52602489fd5b91607f1691610430565b83823461021657816003193601126102165760055490516001600160a01b039091168152602090f35b9150346103d057826003193601126103d057600654916001600160a01b039133838516036105c55750506bffffffffffffffffffffffff60a01b8092166006556005549133908316176005553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b60249250519063118cdaa760e01b82523390820152fd5b83346101d557806003193601126101d5576105f561134d565b600680546001600160a01b031990811690915560058054918216905581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b83823461021657602036600319011261021657602090610669610664610e89565b610fb5565b9051908152f35b8382346102165760203660031901126102165761068b610e89565b9061069461134d565b6001600160a01b038216808452600c6020528184205460ff166107655730811461075557808452600e6020528184205480610739575b5050600c6020528220805460ff19166001179055600f549268010000000000000000841015610726575061070883600161029a949501600f55610f68565b90919060018060a01b038084549260031b9316831b921b1916179055565b634e487b7160e01b835260419052602482fd5b61074290610f50565b908452600d6020528184205584806106ca565b8151632b0039c760e21b81528590fd5b815163c87d620b60e01b81528590fd5b8382346102165760203660031901126102165760209160ff9082906001600160a01b036107a0610e89565b168152600b855220541690519015158152f35b92503461088c57602036600319011261088c5735906108246107e56107df6107d9611379565b90610f30565b84610eea565b6107f0848233610ff5565b338552600e602052828520610806828254610eba565b9055338552600c60205260ff8386205416610872575b601154610eba565b60115561083382601054610eba565b60105561084282600954610edd565b600955519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203392a380f35b600d602052828520610885858254610eba565b905561081c565b5050fd5b909150346103d0576020806003193601126102a1576108ad610e89565b916108b661134d565b60018060a01b0380931693848652600c91600c845260ff828820541615610a1257858752600e91600e855280882054936109126108f46107d9611379565b95898b5261090c600d97600d8a52858d205490610eea565b90610eba565b95895b600f80549081831015610a03578a918c61092e85610f68565b949054600395861b1c161461094857505050600101610915565b98909a999260009c9495969798929c19998a81019081116109f057906107088c8f61097561098195610f68565b9054911b1c1691610f68565b838d5284528b868120558352848b2061099b828254610eba565b90556109aa6011918254610eba565b90558952528620805460ff1916905583549081156109dd575001926109ce84610f68565b81939154921b1b191690555580f35b634e487b7160e01b875260319052602486fd5b634e487b7160e01b8f5260118a5260248ffd5b50505050505050505050505080f35b905163c87d620b60e01b8152fd5b8382346102165781600319360112610216576020905160128152f35b9083346101d55760203660031901126101d5575061066960209235610f50565b83346101d55760603660031901126101d557610a76610e89565b610a7e610ea4565b916044359360018060a01b038316808352600160205286832033845260205286832054916000198303610aba575b6020886103fe89898961105b565b868310610b22578115610b0b573315610af4575082526001602090815286832033845281529186902090859003905582906103fe87610aac565b8751634a1406b160e11b8152908101849052602490fd5b875163e602df0560e01b8152908101849052602490fd5b8751637dc7a0d960e11b8152339181019182526020820193909352604081018790528291506060010390fd5b0390fd5b8382346102165781600319360112610216576020906010549051908152f35b8382346102165760203660031901126102165760209160ff9082906001600160a01b03610b9c610e89565b168152600a855220541690519015158152f35b9083346101d55760203660031901126101d5575061066960209235610efd565b909150346103d057816003193601126103d057610bea610e89565b602435903315610c63576001600160a01b0316918215610c4c57508083602095338152600187528181208582528752205582519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925843392a35160018152f35b8351634a1406b160e11b8152908101859052602490fd5b835163e602df0560e01b8152808401869052602490fd5b8382346102165781600319360112610216578051908260035460018160011c9060018316928315610d4c575b6020938484108114610509578388529081156104ed5750600114610cf657505050829003601f01601f191682019267ffffffffffffffff8411838510176104855750829182610481925282610e40565b600387529192508591837fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b838510610d38575050505083010185808061044f565b805488860183015293019284908201610d22565b91607f1691610ca6565b9150346103d05760203660031901126103d057813591338452600c60205260ff8285205416610a12575090610dbc610dc792610d9183610efd565b90610d9d848333610ff5565b338652600e6020528520610db2828254610eba565b9055601154610eba565b601155600854610edd565b60085580f35b909150346103d05760203660031901126103d057359063ffffffff60e01b82168092036103d057602092506336372b0760e01b8214918215610e13575b50519015158152f35b6301ffc9a760e01b14915038610e0a565b8490346102165781600319360112610216576020906008548152f35b6020808252825181830181905290939260005b828110610e7557505060409293506000838284010152601f8019910116010190565b818101860151848201604001528501610e53565b600435906001600160a01b0382168203610e9f57565b600080fd5b602435906001600160a01b0382168203610e9f57565b91908203918211610ec757565b634e487b7160e01b600052601160045260246000fd5b91908201809211610ec757565b81810292918115918404141715610ec757565b6010548111610f1e57610f1b90610f156107d9611379565b90610eea565b90565b604051632cdb04a160e21b8152600490fd5b8115610f3a570490565b634e487b7160e01b600052601260045260246000fd5b6011548111610f1e57610f1b906107d96107d9611379565b600f54811015610f9f57600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8020190600090565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03166000908152600c602052604090205460ff16610fe757600e602052610f1b604060002054610f50565b600d60205260406000205490565b6001600160a01b0381166000908152600e60205260409020549091811061101b57505050565b611027610b4e91610f50565b60405163391434e360e21b81526001600160a01b039093166004840152602483015260448201929092529081906064820190565b916001600160a01b0380841692831561133457811693841561131b5760105483116112ff57916020917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef93600091868352600b85528660ff60408520541680156112e8575b1561117d5750506110e6836110df6110d96107d9611379565b82610eea565b8093610ff5565b858252600e8452604082206110fc828254610eba565b9055858252600c845260ff604083205416611163575b868252600e845261112860408320918254610edd565b9055858152600c835260ff604082205416611148575b50604051908152a3565b604090600d84522061115b828254610edd565b90553861113e565b600d845260408220611176848254610eba565b9055611112565b610dbc919261128b9461118f87611428565b946111ab61119c89611428565b936111b0856111ab8a8d610eba565b610eba565b996111bc6107d9611379565b80976111f6838c6111f08b6111e76111df6111d78987610eea565b988995610eea565b9e8f92610eea565b998a9184610eba565b96610ff5565b8652600e8d5261120b60408720918254610eba565b90558d8552600c8c5260ff6040862054166112cd575b508d8452600e8b5261123860408520918254610edd565b90558c8352600c8a5260ff6040842054166112b3575b81600754168352600e8a5261126860408420918254610edd565b9055600754168152600c885260ff604082205416611297575b5050601154610eba565b600855604051908152a3565b60406112aa91600d8a5220918254610edd565b90553880611281565b600d8a52604083206112c68a8254610edd565b905561124e565b600d8c526112e060408620918254610eba565b905538611221565b5050878352600a85528660ff6040852054166110c0565b905082600052600e602052610b4e611027604060002054610f50565b60405163ec442f0560e01b815260006004820152602490fd5b604051634b637e8f60e11b815260006004820152602490fd5b6005546001600160a01b0316330361136157565b60405163118cdaa760e01b8152336004820152602490fd5b6011549081601054928390600080600f54905b8183106113b3575050506113a08282610f30565b83106113ac5750509190565b9350919050565b909196946113c088610f68565b60018060a01b0391549060031b1c1682526020600e81526040600d81852054925283205491808211801561141f575b611412579161140361140992600194610eba565b97610eba565b9701919061138c565b5050505050915092509190565b508783116113ef565b90612710609661143784611450565b930961143f57565b90600019811015610e9f5760010190565b6000196096820960968202908180821091039080820391146114af5761271081811115610e9f5760967fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e91940990828211900360fc1b910360041c170290565b506127109150049056fea26469706673582212201d318e5b0604d9270a1de169b449b6bc65beec763b966674562389ad7da5ed5464736f6c63430008180033