false
true
0

Contract Address Details

0xfbC13Eb54962b1aD66AE00d5965B37DF2aCA388b

Contract Name
CommissionTree
Creator
0x6f5e8b–11d74b at 0xcde85f–4cc295
Balance
0 tPLS
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
25393873
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
CommissionTree




Optimization enabled
false
Compiler version
v0.8.20+commit.a1b79de6




EVM Version




Verified at
2026-09-14T19:05:41.470894Z

Constructor Arguments

00000000000000000000000060bfae5c67f32ecdcea707843bc809cd64ec0060000000000000000000000000489577615c4f0e269c7bf0b270961c810a86526e0000000000000000000000006b208cdc0598e3327ba2f31aeed4ce4a93c3c9650000000000000000000000002843da5f8bb6be9206cbea39fc7f8e4ae6d047e7

Arg [0] (address) : 0x60bfae5c67f32ecdcea707843bc809cd64ec0060
Arg [1] (address) : 0x489577615c4f0e269c7bf0b270961c810a86526e
Arg [2] (address) : 0x6b208cdc0598e3327ba2f31aeed4ce4a93c3c965
Arg [3] (address) : 0x2843da5f8bb6be9206cbea39fc7f8e4ae6d047e7

              

contracts/core/CommissionTree.sol

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

import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import {IBBACoin} from "../interfaces/IBBACoin.sol";

/// @title CommissionTree
/// @notice The affiliate engine for the Blockbids ecosystem. Holds the upline
///         graph and pays sponsors three levels deep on two separate streams:
///
///         Stream A - auctions: the web2 engine hands over the 8.5% slice of
///         gross auction revenue in BID, and it is split 10/5/2 (in 17ths) up
///         the winner's chain.
///
///         Stream B - staking: YieldVault reports each stake and freshly
///         minted BBA goes up the chain at 10% / 5% / 2% of the staked amount.
///
///         Any level with no sponsor falls through to the company rotator,
///         so no commission is ever stranded.
/// @dev Needs MINTER_ROLE on BBACoin for Stream B, and the engine must approve
///      this contract for the BID budget before calling Stream A.
contract CommissionTree is AccessControl, ReentrancyGuard {
    using SafeERC20 for IERC20;

    // --- Roles ---

    bytes32 public constant VAULT_ROLE = keccak256("VAULT_ROLE"); // YieldVault
    bytes32 public constant ENGINE_ROLE = keccak256("ENGINE_ROLE"); // web2 relayer

    // --- Tokens ---

    IERC20 public bidToken;   // paid out on auctions, pulled from the engine
    IBBACoin public bbaToken; // minted on stakes

    // --- Rotator ---

    // Two company wallets taking turns as the sponsor for orphan signups, and
    // as the catch-all for any commission level with no upline.
    address[2] public companyWallets;
    uint8 public rotatorIndex;

    // --- Affiliate tree ---

    // Permanent once set. A sponsor must already be registered before anyone
    // can name them, and nobody can be registered twice, so the graph is
    // append-only and cycles are impossible by construction.
    mapping(address => address) public sponsor;
    mapping(address => bool) public isRegistered;

    // --- Payout constants ---

    // Hardcoded depth. Bounded traversal is the whole point: an MLM tree can be
    // thousands deep, and an unbounded walk would eventually run out of gas and
    // brick every auction settlement.
    uint8 private constant MAX_LEVELS = 3;

    // Auction split in 17ths (10 + 5 + 2), which is exactly the 58.82 / 29.41 /
    // 11.77 spread with no denominator games.
    uint256 private constant AUCTION_L1_PARTS = 10;
    uint256 private constant AUCTION_L2_PARTS = 5;
    uint256 private constant AUCTION_TOTAL_PARTS = 17;

    // Staking mint rates, straight percentages of the staked amount.
    uint256 private constant STAKING_L1_PCT = 10;
    uint256 private constant STAKING_L2_PCT = 5;
    uint256 private constant STAKING_L3_PCT = 2;
    uint256 private constant PCT_DENOMINATOR = 100;

    // --- Events ---

    event UserRegistered(address indexed user, address indexed sponsor, bool viaRotator);
    event RotatorAdvanced(uint8 newIndex);
    event AuctionCommissionPaid(
        address indexed winner,
        address indexed recipient,
        uint8 level,
        uint256 amount,
        bool viaRotator
    );
    event StakingCommissionMinted(
        address indexed staker,
        address indexed recipient,
        uint8 level,
        uint256 amount,
        bool viaRotator
    );
    event CompanyWalletUpdated(uint8 indexed index, address indexed previous, address indexed current);
    event BidTokenUpdated(address indexed previous, address indexed current);
    event BbaTokenUpdated(address indexed previous, address indexed current);
    event ERC20Rescued(address indexed token, address indexed to, uint256 amount);

    constructor(
        address _bidToken,
        address _bbaToken,
        address _companyWalletA,
        address _companyWalletB
    ) {
        require(_bidToken != address(0), "Tree: bid is zero");
        require(_bbaToken != address(0), "Tree: bba is zero");
        require(_companyWalletA != address(0), "Tree: wallet A is zero");
        require(_companyWalletB != address(0), "Tree: wallet B is zero");

        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);

        bidToken = IERC20(_bidToken);
        bbaToken = IBBACoin(_bbaToken);

        companyWallets[0] = _companyWalletA;
        companyWallets[1] = _companyWalletB;

        // The company wallets seed the tree. Without this nobody could name one
        // as their upline, since registerUser only accepts registered sponsors.
        isRegistered[_companyWalletA] = true;
        isRegistered[_companyWalletB] = true;
    }

    // ============================================================
    //                  REGISTRATION & ROTATOR
    // ============================================================

    /// @notice Bind `user` to `upline`, or to the next company wallet if the
    ///         upline is unusable.
    /// @dev ENGINE_ROLE only. The signature takes `user` rather than using
    ///      msg.sender, so leaving it open would let anyone front-run a signup
    ///      with registerUser(victim, attacker) and permanently own that
    ///      wallet's commissions - the binding can never be undone.
    function registerUser(address user, address upline) external onlyRole(ENGINE_ROLE) {
        require(user != address(0), "Tree: user is zero");
        require(!isRegistered[user], "Tree: already registered");

        // A referrer only counts if they are in the tree and are not the user
        // themselves; anything else (zero, unknown, self) is an orphan.
        bool validUpline = upline != address(0) && upline != user && isRegistered[upline];

        address assigned;
        if (validUpline) {
            assigned = upline;
        } else {
            assigned = companyWallets[rotatorIndex];
            rotatorIndex = (rotatorIndex + 1) % 2;
            emit RotatorAdvanced(rotatorIndex);
        }

        sponsor[user] = assigned;
        isRegistered[user] = true;

        emit UserRegistered(user, assigned, !validUpline);
    }

    // ============================================================
    //          STREAM A - AUCTION COMMISSIONS (BID)
    // ============================================================

    /// @notice Pay the winner's upline out of `totalCommissionBudget` BID.
    /// @param winner                the bidder whose chain gets paid
    /// @param totalCommissionBudget the exact 8.5% slice of gross auction
    ///                              revenue, already computed off-chain
    /// @dev The caller must approve this contract for the budget first. Pulling
    ///      before paying means we can only ever hand out BID we actually hold.
    function distributeAuctionCommissions(address winner, uint256 totalCommissionBudget)
        external
        onlyRole(ENGINE_ROLE)
        nonReentrant
    {
        require(winner != address(0), "Tree: winner is zero");
        require(totalCommissionBudget > 0, "Tree: budget is zero");

        bidToken.safeTransferFrom(msg.sender, address(this), totalCommissionBudget);

        uint256[MAX_LEVELS] memory shares;
        shares[0] = (totalCommissionBudget * AUCTION_L1_PARTS) / AUCTION_TOTAL_PARTS;
        shares[1] = (totalCommissionBudget * AUCTION_L2_PARTS) / AUCTION_TOTAL_PARTS;
        // Remainder rather than *2/17, so the three shares always re-add to the
        // budget exactly and integer truncation can never leave dust stuck here.
        shares[2] = totalCommissionBudget - shares[0] - shares[1];

        address fallbackWallet = companyWallets[rotatorIndex];
        address current = sponsor[winner];

        for (uint8 i = 0; i < MAX_LEVELS; i++) {
            bool viaRotator = current == address(0);
            address recipient = viaRotator ? fallbackWallet : current;

            if (shares[i] > 0) {
                bidToken.safeTransfer(recipient, shares[i]);
                emit AuctionCommissionPaid(winner, recipient, i + 1, shares[i], viaRotator);
            }

            // Once the chain runs out every remaining level is an orphan too.
            if (!viaRotator) {
                current = sponsor[current];
            }
        }
    }

    // ============================================================
    //          STREAM B - STAKING COMMISSIONS (BBA)
    // ============================================================

    /// @notice Mint sponsor commissions on a fresh stake.
    /// @dev VAULT_ROLE only. Nothing is pulled in - this is new BBA supply
    ///      minted on top of the stake, 17% of it in total.
    function distributeStakingCommissions(address staker, uint256 stakedAmount)
        external
        onlyRole(VAULT_ROLE)
        nonReentrant
    {
        require(staker != address(0), "Tree: staker is zero");
        require(stakedAmount > 0, "Tree: amount is zero");

        uint256[MAX_LEVELS] memory shares;
        shares[0] = (stakedAmount * STAKING_L1_PCT) / PCT_DENOMINATOR;
        shares[1] = (stakedAmount * STAKING_L2_PCT) / PCT_DENOMINATOR;
        shares[2] = (stakedAmount * STAKING_L3_PCT) / PCT_DENOMINATOR;

        address fallbackWallet = companyWallets[rotatorIndex];
        address current = sponsor[staker];

        for (uint8 i = 0; i < MAX_LEVELS; i++) {
            bool viaRotator = current == address(0);
            address recipient = viaRotator ? fallbackWallet : current;

            if (shares[i] > 0) {
                bbaToken.mint(recipient, shares[i]);
                emit StakingCommissionMinted(staker, recipient, i + 1, shares[i], viaRotator);
            }

            if (!viaRotator) {
                current = sponsor[current];
            }
        }
    }

    // ============================================================
    //                          ADMIN
    // ============================================================

    /// @notice Swap one of the two rotator wallets.
    function setCompanyWallet(uint8 index, address wallet)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        require(index < 2, "Tree: bad index");
        require(wallet != address(0), "Tree: wallet is zero");

        emit CompanyWalletUpdated(index, companyWallets[index], wallet);
        companyWallets[index] = wallet;

        // Keep it namable as an upline, same as the ones set at construction.
        isRegistered[wallet] = true;
    }

    function setBidToken(address _bidToken) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(_bidToken != address(0), "Tree: bid is zero");
        emit BidTokenUpdated(address(bidToken), _bidToken);
        bidToken = IERC20(_bidToken);
    }

    function setBbaToken(address _bbaToken) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(_bbaToken != address(0), "Tree: bba is zero");
        emit BbaTokenUpdated(address(bbaToken), _bbaToken);
        bbaToken = IBBACoin(_bbaToken);
    }

    /// @notice Recover tokens sent here by mistake.
    /// @dev No surplus guard needed the way YieldVault has one - this contract
    ///      never holds a balance between transactions, since every BID it
    ///      pulls is paid straight back out in the same call.
    function rescueERC20(address token, address to, uint256 amount)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        require(to != address(0), "Tree: to is zero");
        IERC20(token).safeTransfer(to, amount);
        emit ERC20Rescued(token, to, amount);
    }
}
        

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

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

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
          

@openzeppelin/contracts/interfaces/IERC1363.sol

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

pragma solidity >=0.6.2;

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/IERC20.sol

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

pragma solidity >=0.4.16;

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

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

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

pragma solidity >=0.4.16;

/**
 * @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/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/ReentrancyGuard.sol

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

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 *
 * IMPORTANT: Deprecated. This storage-based reentrancy guard will be removed and replaced
 * by the {ReentrancyGuardTransient} variant in v6.0.
 *
 * @custom:stateless
 */
abstract contract ReentrancyGuard {
    using StorageSlot for bytes32;

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant REENTRANCY_GUARD_STORAGE =
        0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

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

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

    constructor() {
        _reentrancyGuardStorageSlot().getUint256Slot().value = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    /**
     * @dev A `view` only version of {nonReentrant}. Use to block view functions
     * from being called, preventing reading from inconsistent contract state.
     *
     * CAUTION: This is a "view" modifier and does not change the reentrancy
     * status. Use it only on view functions. For payable or non-payable functions,
     * use the standard {nonReentrant} modifier instead.
     */
    modifier nonReentrantView() {
        _nonReentrantBeforeView();
        _;
    }

    function _nonReentrantBeforeView() private view {
        if (_reentrancyGuardEntered()) {
            revert ReentrancyGuardReentrantCall();
        }
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        _nonReentrantBeforeView();

        // Any calls to nonReentrant after this point will fail
        _reentrancyGuardStorageSlot().getUint256Slot().value = ENTERED;
    }

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _reentrancyGuardStorageSlot().getUint256Slot().value == ENTERED;
    }

    function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) {
        return REENTRANCY_GUARD_STORAGE;
    }
}
          

@openzeppelin/contracts/access/AccessControl.sol

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

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /// @inheritdoc ERC165
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}
          

@openzeppelin/contracts/utils/StorageSlot.sol

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

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC-1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct Int256Slot {
        int256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Int256Slot` with member `value` located at `slot`.
     */
    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns a `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }
}
          

@openzeppelin/contracts/access/IAccessControl.sol

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

pragma solidity >=0.8.4;

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted to signal this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}
          

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

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

pragma solidity >=0.4.16;

/**
 * @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/interfaces/IERC165.sol

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

pragma solidity >=0.4.16;

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

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

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

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.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 {
        if (!_safeTransfer(token, to, value, true)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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 {
        if (!_safeTransferFrom(token, from, to, value, true)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _safeTransfer(token, to, value, false);
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _safeTransferFrom(token, from, to, value, false);
    }

    /**
     * @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 {
        if (!_safeApprove(token, spender, value, false)) {
            if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
            if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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 relies 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 relies 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}.
     * Oppositely, 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 `token.transfer(to, value)` call, 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 to The recipient of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
        bytes4 selector = IERC20.transfer.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(to, shr(96, not(0))))
            mstore(0x24, value)
            success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
        }
    }

    /**
     * @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, 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 from The sender of the tokens
     * @param to The recipient of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value,
        bool bubble
    ) private returns (bool success) {
        bytes4 selector = IERC20.transferFrom.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(from, shr(96, not(0))))
            mstore(0x24, and(to, shr(96, not(0))))
            mstore(0x44, value)
            success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
            mstore(0x60, 0)
        }
    }

    /**
     * @dev Imitates a Solidity `token.approve(spender, value)` call, 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 spender The spender of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
        bytes4 selector = IERC20.approve.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(spender, shr(96, not(0))))
            mstore(0x24, value)
            success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
        }
    }
}
          

contracts/interfaces/IBBACoin.sol

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

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

/// @title IBBACoin
/// @notice Minimal interface the rest of the ecosystem needs against BBACoin:
///         BidToken mints BBA rewards, QuarterlyBurner reads supply and burns
///         it out of the treasury.
interface IBBACoin is IERC20 {
    function mint(address to, uint256 amount) external;
    function burnSupply(uint256 amount) external;
}
          

Compiler Settings

{"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":"_bidToken","internalType":"address"},{"type":"address","name":"_bbaToken","internalType":"address"},{"type":"address","name":"_companyWalletA","internalType":"address"},{"type":"address","name":"_companyWalletB","internalType":"address"}]},{"type":"error","name":"AccessControlBadConfirmation","inputs":[]},{"type":"error","name":"AccessControlUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bytes32","name":"neededRole","internalType":"bytes32"}]},{"type":"error","name":"ReentrancyGuardReentrantCall","inputs":[]},{"type":"error","name":"SafeERC20FailedOperation","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"event","name":"AuctionCommissionPaid","inputs":[{"type":"address","name":"winner","internalType":"address","indexed":true},{"type":"address","name":"recipient","internalType":"address","indexed":true},{"type":"uint8","name":"level","internalType":"uint8","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"bool","name":"viaRotator","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"BbaTokenUpdated","inputs":[{"type":"address","name":"previous","internalType":"address","indexed":true},{"type":"address","name":"current","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"BidTokenUpdated","inputs":[{"type":"address","name":"previous","internalType":"address","indexed":true},{"type":"address","name":"current","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"CompanyWalletUpdated","inputs":[{"type":"uint8","name":"index","internalType":"uint8","indexed":true},{"type":"address","name":"previous","internalType":"address","indexed":true},{"type":"address","name":"current","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ERC20Rescued","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RotatorAdvanced","inputs":[{"type":"uint8","name":"newIndex","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"StakingCommissionMinted","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"address","name":"recipient","internalType":"address","indexed":true},{"type":"uint8","name":"level","internalType":"uint8","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"bool","name":"viaRotator","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"UserRegistered","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"sponsor","internalType":"address","indexed":true},{"type":"bool","name":"viaRotator","internalType":"bool","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"ENGINE_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"VAULT_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IBBACoin"}],"name":"bbaToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"bidToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"companyWallets","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"distributeAuctionCommissions","inputs":[{"type":"address","name":"winner","internalType":"address"},{"type":"uint256","name":"totalCommissionBudget","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"distributeStakingCommissions","inputs":[{"type":"address","name":"staker","internalType":"address"},{"type":"uint256","name":"stakedAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isRegistered","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"registerUser","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"upline","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"callerConfirmation","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rescueERC20","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"rotatorIndex","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBbaToken","inputs":[{"type":"address","name":"_bbaToken","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBidToken","inputs":[{"type":"address","name":"_bidToken","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCompanyWallet","inputs":[{"type":"uint8","name":"index","internalType":"uint8"},{"type":"address","name":"wallet","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"sponsor","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b50604051620018fb380380620018fb8339810160408190526200003491620002fa565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00556001600160a01b038416620000a85760405162461bcd60e51b8152602060048201526011602482015270547265653a20626964206973207a65726f60781b60448201526064015b60405180910390fd5b6001600160a01b038316620000f45760405162461bcd60e51b8152602060048201526011602482015270547265653a20626261206973207a65726f60781b60448201526064016200009f565b6001600160a01b0382166200014c5760405162461bcd60e51b815260206004820152601660248201527f547265653a2077616c6c65742041206973207a65726f0000000000000000000060448201526064016200009f565b6001600160a01b038116620001a45760405162461bcd60e51b815260206004820152601660248201527f547265653a2077616c6c65742042206973207a65726f0000000000000000000060448201526064016200009f565b620001b16000336200022e565b50600180546001600160a01b03199081166001600160a01b039687161782556002805482169587169590951790945560038054938616938516841790556004805492909516919093168117909355600090815260076020526040808220805460ff1990811685179091559382529020805490921617905562000357565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16620002d3576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556200028a3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620002d7565b5060005b92915050565b80516001600160a01b0381168114620002f557600080fd5b919050565b600080600080608085870312156200031157600080fd5b6200031c85620002dd565b93506200032c60208601620002dd565b92506200033c60408601620002dd565b91506200034c60608601620002dd565b905092959194509250565b61159480620003676000396000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c806398c4f1ac116100b8578063c3c5a5471161007c578063c3c5a54714610303578063d547741f14610326578063dfafd4fd14610339578063e1d353781461034c578063ebc8a2621461035f578063fbe93b781461037257600080fd5b806398c4f1ac1461029b578063a217fddf146102c2578063a22a5bc2146102ca578063a6683c65146102dd578063b2118a8d146102f057600080fd5b806336568abe1161010a57806336568abe146101ef578063501ee12614610202578063766c4f37146102155780637f06572214610256578063885fc6561461027557806391d148541461028857600080fd5b806301ffc9a7146101475780630354adb21461016f5780631084b34314610184578063248a9ca3146101b95780632f2ff15d146101dc575b600080fd5b61015a610155366004611323565b610385565b60405190151581526020015b60405180910390f35b61018261017d366004611370565b6103bc565b005b6101ab7f5d0c23b505d97686a7eb149c2db3c9cdda71d0f1778515d411985ce042bf17a181565b604051908152602001610166565b6101ab6101c73660046113a3565b60009081526020819052604090206001015490565b6101826101ea3660046113bc565b610608565b6101826101fd3660046113bc565b610633565b6101826102103660046113df565b61066b565b61023e6102233660046113df565b6006602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610166565b6005546102639060ff1681565b60405160ff9091168152602001610166565b61023e6102833660046113a3565b61071d565b61015a6102963660046113bc565b61073d565b6101ab7f31e0210044b4f6757ce6aa31f9c6e8d4896d24a755014887391a926c5224d95981565b6101ab600081565b6101826102d83660046113fa565b610766565b6101826102eb3660046113df565b610a3b565b6101826102fe366004611424565b610aed565b61015a6103113660046113df565b60076020526000908152604090205460ff1681565b6101826103343660046113bc565b610ba8565b60015461023e906001600160a01b031681565b61018261035a366004611460565b610bcd565b61018261036d3660046113fa565b610d19565b60025461023e906001600160a01b031681565b60006001600160e01b03198216637965db0b60e01b14806103b657506301ffc9a760e01b6001600160e01b03198316145b92915050565b7f5d0c23b505d97686a7eb149c2db3c9cdda71d0f1778515d411985ce042bf17a16103e681611009565b6001600160a01b0383166104365760405162461bcd60e51b8152602060048201526012602482015271547265653a2075736572206973207a65726f60701b60448201526064015b60405180910390fd5b6001600160a01b03831660009081526007602052604090205460ff161561049f5760405162461bcd60e51b815260206004820152601860248201527f547265653a20616c726561647920726567697374657265640000000000000000604482015260640161042d565b60006001600160a01b038316158015906104cb5750836001600160a01b0316836001600160a01b031614155b80156104ef57506001600160a01b03831660009081526007602052604090205460ff165b90506000811561050057508261058d565b60055460039060ff166002811061051957610519611484565b01546005546001600160a01b03909116915060029061053c9060ff1660016114b0565b61054691906114df565b6005805460ff191660ff9290921691821790556040519081527f259c73084332d8083b66457d31983714d2636d8b52fe38baea84ae9d9d1dc1c29060200160405180910390a15b6001600160a01b03858116600081815260066020908152604080832080546001600160a01b03191695871695861790556007825291829020805460ff191660011790559051851581527f859d113797d39f050d937c356ae6c65cef56740d5748fdbe2766c43aab2f5438910160405180910390a35050505050565b60008281526020819052604090206001015461062381611009565b61062d8383611016565b50505050565b6001600160a01b038116331461065c5760405163334bd91960e11b815260040160405180910390fd5b61066682826110a8565b505050565b600061067681611009565b6001600160a01b0382166106c05760405162461bcd60e51b8152602060048201526011602482015270547265653a20626964206973207a65726f60781b604482015260640161042d565b6001546040516001600160a01b038085169216907f3d95ddbd62e70d2b2604c43cb7a4f582291d1d790e813f0ea997adc4a13d3ca990600090a350600180546001600160a01b0319166001600160a01b0392909216919091179055565b6003816002811061072d57600080fd5b01546001600160a01b0316905081565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b7f5d0c23b505d97686a7eb149c2db3c9cdda71d0f1778515d411985ce042bf17a161079081611009565b610798611113565b6001600160a01b0383166107e55760405162461bcd60e51b8152602060048201526014602482015273547265653a2077696e6e6572206973207a65726f60601b604482015260640161042d565b6000821161082c5760405162461bcd60e51b8152602060048201526014602482015273547265653a20627564676574206973207a65726f60601b604482015260640161042d565b600154610844906001600160a01b0316333085611141565b61084c611305565b6011610859600a85611501565b6108639190611518565b81526011610872600585611501565b61087c9190611518565b60208201819052815161088f908561152c565b610899919061152c565b604082015260055460009060039060ff16600281106108ba576108ba611484565b01546001600160a01b0386811660009081526006602052604081205492821693509116905b600360ff82161015610a0e576001600160a01b038216156000816109035783610905565b845b90506000868460ff166003811061091e5761091e611484565b602002015111156109d55761095a81878560ff166003811061094257610942611484565b60200201516001546001600160a01b03169190611177565b6001600160a01b03808216908a167f688f1806314286caaa3336d48b31420f00e968df993d2ba83204f3feea127e566109948660016114b0565b898760ff16600381106109a9576109a9611484565b602090810291909101516040805160ff9094168452918301528615159082015260600160405180910390a35b816109f9576001600160a01b03938416600090815260066020526040902054909316925b50508080610a069061153f565b9150506108df565b5050505061066660017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b6000610a4681611009565b6001600160a01b038216610a905760405162461bcd60e51b8152602060048201526011602482015270547265653a20626261206973207a65726f60781b604482015260640161042d565b6002546040516001600160a01b038085169216907fbf98f1ee7301f79fde742c95d928a6cee1cb5b1145b8b630ae0013c7fe508ac490600090a350600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000610af881611009565b6001600160a01b038316610b415760405162461bcd60e51b815260206004820152601060248201526f547265653a20746f206973207a65726f60801b604482015260640161042d565b610b556001600160a01b0385168484611177565b826001600160a01b0316846001600160a01b03167f8bbfbb5d7fcacf6fc74005cdede0635561638507f576c95f7f294c22141be2e584604051610b9a91815260200190565b60405180910390a350505050565b600082815260208190526040902060010154610bc381611009565b61062d83836110a8565b6000610bd881611009565b60028360ff1610610c1d5760405162461bcd60e51b815260206004820152600f60248201526e0a8e4caca7440c4c2c840d2dcc8caf608b1b604482015260640161042d565b6001600160a01b038216610c6a5760405162461bcd60e51b8152602060048201526014602482015273547265653a2077616c6c6574206973207a65726f60601b604482015260640161042d565b816001600160a01b031660038460ff1660028110610c8a57610c8a611484565b01546040516001600160a01b039091169060ff8616907ffd33f1bd1c87d1ad4558680942fc16aa42979dc0f5d21f18eef2c1f6a72ab05e90600090a48160038460ff1660028110610cdd57610cdd611484565b0180546001600160a01b0319166001600160a01b03928316179055919091166000908152600760205260409020805460ff191660011790555050565b7f31e0210044b4f6757ce6aa31f9c6e8d4896d24a755014887391a926c5224d959610d4381611009565b610d4b611113565b6001600160a01b038316610d985760405162461bcd60e51b8152602060048201526014602482015273547265653a207374616b6572206973207a65726f60601b604482015260640161042d565b60008211610ddf5760405162461bcd60e51b8152602060048201526014602482015273547265653a20616d6f756e74206973207a65726f60601b604482015260640161042d565b610de7611305565b6064610df4600a85611501565b610dfe9190611518565b81526064610e0d600585611501565b610e179190611518565b60208201526064610e29600285611501565b610e339190611518565b604082015260055460009060039060ff1660028110610e5457610e54611484565b01546001600160a01b0386811660009081526006602052604081205492821693509116905b600360ff82161015610a0e576001600160a01b03821615600081610e9d5783610e9f565b845b90506000868460ff1660038110610eb857610eb8611484565b60200201511115610fd0576002546001600160a01b03166340c10f19828860ff871660038110610eea57610eea611484565b60200201516040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015610f3557600080fd5b505af1158015610f49573d6000803e3d6000fd5b50505050806001600160a01b0316896001600160a01b03167f7e715ac9816d76d2dc049a75f68a60f3a537fad818151d5b1d94c9812eed9a5a856001610f8f91906114b0565b898760ff1660038110610fa457610fa4611484565b602090810291909101516040805160ff9094168452918301528615159082015260600160405180910390a35b81610ff4576001600160a01b03938416600090815260066020526040902054909316925b505080806110019061153f565b915050610e79565b61101381336111ac565b50565b6000611022838361073d565b6110a0576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556110583390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016103b6565b5060006103b6565b60006110b4838361073d565b156110a0576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016103b6565b61111b6111e9565b60027f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b61114f84848484600161122d565b61062d57604051635274afe760e01b81526001600160a01b038516600482015260240161042d565b611184838383600161129f565b61066657604051635274afe760e01b81526001600160a01b038416600482015260240161042d565b6111b6828261073d565b6111e55760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161042d565b5050565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005460020361122b57604051633ee5aeb560e01b815260040160405180910390fd5b565b6040516323b872dd60e01b60008181526001600160a01b038781166004528616602452604485905291602083606481808c5af19250600160005114831661128d578383151615611280573d6000823e3d81fd5b6000883b113d1516831692505b60405250600060605295945050505050565b60405163a9059cbb60e01b60008181526001600160a01b038616600452602485905291602083604481808b5af1925060016000511483166112f95783831516156112ec573d6000823e3d81fd5b6000873b113d1516831692505b60405250949350505050565b60405180606001604052806003906020820280368337509192915050565b60006020828403121561133557600080fd5b81356001600160e01b03198116811461134d57600080fd5b9392505050565b80356001600160a01b038116811461136b57600080fd5b919050565b6000806040838503121561138357600080fd5b61138c83611354565b915061139a60208401611354565b90509250929050565b6000602082840312156113b557600080fd5b5035919050565b600080604083850312156113cf57600080fd5b8235915061139a60208401611354565b6000602082840312156113f157600080fd5b61134d82611354565b6000806040838503121561140d57600080fd5b61141683611354565b946020939093013593505050565b60008060006060848603121561143957600080fd5b61144284611354565b925061145060208501611354565b9150604084013590509250925092565b6000806040838503121561147357600080fd5b823560ff8116811461138c57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60ff81811683821601908111156103b6576103b661149a565b634e487b7160e01b600052601260045260246000fd5b600060ff8316806114f2576114f26114c9565b8060ff84160691505092915050565b80820281158282048414176103b6576103b661149a565b600082611527576115276114c9565b500490565b818103818111156103b6576103b661149a565b600060ff821660ff81036115555761155561149a565b6001019291505056fea2646970667358221220a60d124d845d4171163a58541b725edbcfc774c3392a5a2bc78c13797d2662c164736f6c6343000814003300000000000000000000000060bfae5c67f32ecdcea707843bc809cd64ec0060000000000000000000000000489577615c4f0e269c7bf0b270961c810a86526e0000000000000000000000006b208cdc0598e3327ba2f31aeed4ce4a93c3c9650000000000000000000000002843da5f8bb6be9206cbea39fc7f8e4ae6d047e7

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101425760003560e01c806398c4f1ac116100b8578063c3c5a5471161007c578063c3c5a54714610303578063d547741f14610326578063dfafd4fd14610339578063e1d353781461034c578063ebc8a2621461035f578063fbe93b781461037257600080fd5b806398c4f1ac1461029b578063a217fddf146102c2578063a22a5bc2146102ca578063a6683c65146102dd578063b2118a8d146102f057600080fd5b806336568abe1161010a57806336568abe146101ef578063501ee12614610202578063766c4f37146102155780637f06572214610256578063885fc6561461027557806391d148541461028857600080fd5b806301ffc9a7146101475780630354adb21461016f5780631084b34314610184578063248a9ca3146101b95780632f2ff15d146101dc575b600080fd5b61015a610155366004611323565b610385565b60405190151581526020015b60405180910390f35b61018261017d366004611370565b6103bc565b005b6101ab7f5d0c23b505d97686a7eb149c2db3c9cdda71d0f1778515d411985ce042bf17a181565b604051908152602001610166565b6101ab6101c73660046113a3565b60009081526020819052604090206001015490565b6101826101ea3660046113bc565b610608565b6101826101fd3660046113bc565b610633565b6101826102103660046113df565b61066b565b61023e6102233660046113df565b6006602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610166565b6005546102639060ff1681565b60405160ff9091168152602001610166565b61023e6102833660046113a3565b61071d565b61015a6102963660046113bc565b61073d565b6101ab7f31e0210044b4f6757ce6aa31f9c6e8d4896d24a755014887391a926c5224d95981565b6101ab600081565b6101826102d83660046113fa565b610766565b6101826102eb3660046113df565b610a3b565b6101826102fe366004611424565b610aed565b61015a6103113660046113df565b60076020526000908152604090205460ff1681565b6101826103343660046113bc565b610ba8565b60015461023e906001600160a01b031681565b61018261035a366004611460565b610bcd565b61018261036d3660046113fa565b610d19565b60025461023e906001600160a01b031681565b60006001600160e01b03198216637965db0b60e01b14806103b657506301ffc9a760e01b6001600160e01b03198316145b92915050565b7f5d0c23b505d97686a7eb149c2db3c9cdda71d0f1778515d411985ce042bf17a16103e681611009565b6001600160a01b0383166104365760405162461bcd60e51b8152602060048201526012602482015271547265653a2075736572206973207a65726f60701b60448201526064015b60405180910390fd5b6001600160a01b03831660009081526007602052604090205460ff161561049f5760405162461bcd60e51b815260206004820152601860248201527f547265653a20616c726561647920726567697374657265640000000000000000604482015260640161042d565b60006001600160a01b038316158015906104cb5750836001600160a01b0316836001600160a01b031614155b80156104ef57506001600160a01b03831660009081526007602052604090205460ff165b90506000811561050057508261058d565b60055460039060ff166002811061051957610519611484565b01546005546001600160a01b03909116915060029061053c9060ff1660016114b0565b61054691906114df565b6005805460ff191660ff9290921691821790556040519081527f259c73084332d8083b66457d31983714d2636d8b52fe38baea84ae9d9d1dc1c29060200160405180910390a15b6001600160a01b03858116600081815260066020908152604080832080546001600160a01b03191695871695861790556007825291829020805460ff191660011790559051851581527f859d113797d39f050d937c356ae6c65cef56740d5748fdbe2766c43aab2f5438910160405180910390a35050505050565b60008281526020819052604090206001015461062381611009565b61062d8383611016565b50505050565b6001600160a01b038116331461065c5760405163334bd91960e11b815260040160405180910390fd5b61066682826110a8565b505050565b600061067681611009565b6001600160a01b0382166106c05760405162461bcd60e51b8152602060048201526011602482015270547265653a20626964206973207a65726f60781b604482015260640161042d565b6001546040516001600160a01b038085169216907f3d95ddbd62e70d2b2604c43cb7a4f582291d1d790e813f0ea997adc4a13d3ca990600090a350600180546001600160a01b0319166001600160a01b0392909216919091179055565b6003816002811061072d57600080fd5b01546001600160a01b0316905081565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b7f5d0c23b505d97686a7eb149c2db3c9cdda71d0f1778515d411985ce042bf17a161079081611009565b610798611113565b6001600160a01b0383166107e55760405162461bcd60e51b8152602060048201526014602482015273547265653a2077696e6e6572206973207a65726f60601b604482015260640161042d565b6000821161082c5760405162461bcd60e51b8152602060048201526014602482015273547265653a20627564676574206973207a65726f60601b604482015260640161042d565b600154610844906001600160a01b0316333085611141565b61084c611305565b6011610859600a85611501565b6108639190611518565b81526011610872600585611501565b61087c9190611518565b60208201819052815161088f908561152c565b610899919061152c565b604082015260055460009060039060ff16600281106108ba576108ba611484565b01546001600160a01b0386811660009081526006602052604081205492821693509116905b600360ff82161015610a0e576001600160a01b038216156000816109035783610905565b845b90506000868460ff166003811061091e5761091e611484565b602002015111156109d55761095a81878560ff166003811061094257610942611484565b60200201516001546001600160a01b03169190611177565b6001600160a01b03808216908a167f688f1806314286caaa3336d48b31420f00e968df993d2ba83204f3feea127e566109948660016114b0565b898760ff16600381106109a9576109a9611484565b602090810291909101516040805160ff9094168452918301528615159082015260600160405180910390a35b816109f9576001600160a01b03938416600090815260066020526040902054909316925b50508080610a069061153f565b9150506108df565b5050505061066660017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b6000610a4681611009565b6001600160a01b038216610a905760405162461bcd60e51b8152602060048201526011602482015270547265653a20626261206973207a65726f60781b604482015260640161042d565b6002546040516001600160a01b038085169216907fbf98f1ee7301f79fde742c95d928a6cee1cb5b1145b8b630ae0013c7fe508ac490600090a350600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000610af881611009565b6001600160a01b038316610b415760405162461bcd60e51b815260206004820152601060248201526f547265653a20746f206973207a65726f60801b604482015260640161042d565b610b556001600160a01b0385168484611177565b826001600160a01b0316846001600160a01b03167f8bbfbb5d7fcacf6fc74005cdede0635561638507f576c95f7f294c22141be2e584604051610b9a91815260200190565b60405180910390a350505050565b600082815260208190526040902060010154610bc381611009565b61062d83836110a8565b6000610bd881611009565b60028360ff1610610c1d5760405162461bcd60e51b815260206004820152600f60248201526e0a8e4caca7440c4c2c840d2dcc8caf608b1b604482015260640161042d565b6001600160a01b038216610c6a5760405162461bcd60e51b8152602060048201526014602482015273547265653a2077616c6c6574206973207a65726f60601b604482015260640161042d565b816001600160a01b031660038460ff1660028110610c8a57610c8a611484565b01546040516001600160a01b039091169060ff8616907ffd33f1bd1c87d1ad4558680942fc16aa42979dc0f5d21f18eef2c1f6a72ab05e90600090a48160038460ff1660028110610cdd57610cdd611484565b0180546001600160a01b0319166001600160a01b03928316179055919091166000908152600760205260409020805460ff191660011790555050565b7f31e0210044b4f6757ce6aa31f9c6e8d4896d24a755014887391a926c5224d959610d4381611009565b610d4b611113565b6001600160a01b038316610d985760405162461bcd60e51b8152602060048201526014602482015273547265653a207374616b6572206973207a65726f60601b604482015260640161042d565b60008211610ddf5760405162461bcd60e51b8152602060048201526014602482015273547265653a20616d6f756e74206973207a65726f60601b604482015260640161042d565b610de7611305565b6064610df4600a85611501565b610dfe9190611518565b81526064610e0d600585611501565b610e179190611518565b60208201526064610e29600285611501565b610e339190611518565b604082015260055460009060039060ff1660028110610e5457610e54611484565b01546001600160a01b0386811660009081526006602052604081205492821693509116905b600360ff82161015610a0e576001600160a01b03821615600081610e9d5783610e9f565b845b90506000868460ff1660038110610eb857610eb8611484565b60200201511115610fd0576002546001600160a01b03166340c10f19828860ff871660038110610eea57610eea611484565b60200201516040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015610f3557600080fd5b505af1158015610f49573d6000803e3d6000fd5b50505050806001600160a01b0316896001600160a01b03167f7e715ac9816d76d2dc049a75f68a60f3a537fad818151d5b1d94c9812eed9a5a856001610f8f91906114b0565b898760ff1660038110610fa457610fa4611484565b602090810291909101516040805160ff9094168452918301528615159082015260600160405180910390a35b81610ff4576001600160a01b03938416600090815260066020526040902054909316925b505080806110019061153f565b915050610e79565b61101381336111ac565b50565b6000611022838361073d565b6110a0576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556110583390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016103b6565b5060006103b6565b60006110b4838361073d565b156110a0576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016103b6565b61111b6111e9565b60027f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b61114f84848484600161122d565b61062d57604051635274afe760e01b81526001600160a01b038516600482015260240161042d565b611184838383600161129f565b61066657604051635274afe760e01b81526001600160a01b038416600482015260240161042d565b6111b6828261073d565b6111e55760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161042d565b5050565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005460020361122b57604051633ee5aeb560e01b815260040160405180910390fd5b565b6040516323b872dd60e01b60008181526001600160a01b038781166004528616602452604485905291602083606481808c5af19250600160005114831661128d578383151615611280573d6000823e3d81fd5b6000883b113d1516831692505b60405250600060605295945050505050565b60405163a9059cbb60e01b60008181526001600160a01b038616600452602485905291602083604481808b5af1925060016000511483166112f95783831516156112ec573d6000823e3d81fd5b6000873b113d1516831692505b60405250949350505050565b60405180606001604052806003906020820280368337509192915050565b60006020828403121561133557600080fd5b81356001600160e01b03198116811461134d57600080fd5b9392505050565b80356001600160a01b038116811461136b57600080fd5b919050565b6000806040838503121561138357600080fd5b61138c83611354565b915061139a60208401611354565b90509250929050565b6000602082840312156113b557600080fd5b5035919050565b600080604083850312156113cf57600080fd5b8235915061139a60208401611354565b6000602082840312156113f157600080fd5b61134d82611354565b6000806040838503121561140d57600080fd5b61141683611354565b946020939093013593505050565b60008060006060848603121561143957600080fd5b61144284611354565b925061145060208501611354565b9150604084013590509250925092565b6000806040838503121561147357600080fd5b823560ff8116811461138c57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60ff81811683821601908111156103b6576103b661149a565b634e487b7160e01b600052601260045260246000fd5b600060ff8316806114f2576114f26114c9565b8060ff84160691505092915050565b80820281158282048414176103b6576103b661149a565b600082611527576115276114c9565b500490565b818103818111156103b6576103b661149a565b600060ff821660ff81036115555761155561149a565b6001019291505056fea2646970667358221220a60d124d845d4171163a58541b725edbcfc774c3392a5a2bc78c13797d2662c164736f6c63430008140033