false
false
0
The new Blockscout UI is now open source! Learn how to deploy it here

Contract Address Details

0xE9C87A63D3E24f1cEC55f488C2856Ca4A78A8e9A

Contract Name
AdminFacet
Creator
0x086878–42b1b8 at 0xe679d5–6a96c4
Balance
0 ETH
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
1178742
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
AdminFacet




Optimization enabled
true
Compiler version
v0.8.28+commit.7893614a




Optimization runs
50
EVM Version
paris




Verified at
2024-11-06T21:33:31.083923Z

Constructor Arguments

0x0000000000000000000000005dfd63a79a1179a7f5451143b9fe40a853fb3bf1

Arg [0] (address) : 0x5dfd63a79a1179a7f5451143b9fe40a853fb3bf1

              

contracts/AdminFacet.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";
import "contracts/lib/PoolBalanceLib.sol";
import "contracts/interfaces/IAuthorizer.sol";
import "contracts/interfaces/IVC.sol";
import "contracts/interfaces/IFacet.sol";
import "contracts/VaultStorage.sol";
import "./Diamond.sol";
import "openzeppelin/utils/math/SafeCast.sol";
/**
 * @dev a Facet for administrative and deployment logic.
 *
 * Diamond.yul does not contrain functions for modifying the routing table.
 * this facet is special because it deploys Diamond.yul and bootstraps such functions.
 * the flow of bootstrapping is:
 *                   AdminFacet.deploy()
 *       --create--> Diamond.yul constructor
 * --delegatecall--> AdminFacet.fallback()
 * --delegatecall--> AdminFacet.initializeFacet()
 */

contract AdminFacet is VaultStorage, IFacet {
    event AuthorizerChanged(IAuthorizer indexed authorizer);
    event TreasuryChanged(address indexed addr);

    address immutable deployer;
    IAuthorizer immutable initialAuth;
    address immutable thisImplementation;

    constructor(IAuthorizer auth_) {
        deployer = msg.sender;
        initialAuth = auth_;
        thisImplementation = address(this);
    }

    /**
     * @dev deploy any bytecode given. used to deploy Diamond.yul
     *
     */
    function deploy() external returns (address) {
        require(msg.sender == deployer);
        address deployed = address(new Diamond());
        require(deployed != address(0));
        //try BLAST.configureGovernor(deployed) {} catch (bytes memory) {}
        return deployed;
    }

    /**
     * to be called by Diamond.yul constructor.
     *
     * delegatecalls this.initializeFacet()
     */
    fallback() external {
        require(address(this) != address(thisImplementation));
        bytes memory data = abi.encodeWithSelector(IFacet.initializeFacet.selector);
        address this_ = thisImplementation;
        assembly ("memory-safe") {
            let success := delegatecall(gas(), this_, add(data, 32), mload(data), 0, 0)
            if iszero(success) { revert(0, 0) }
        }
    }

    /**
     * initializeFacet() is called only once by IVault.admin_addFacet().
     * but in this case, it will be
     */
    function initializeFacet() external {
        if (StorageSlot.getAddressSlot(SSLOT_HYPERCORE_AUTHORIZER).value == address(0)) {
            StorageSlot.getAddressSlot(SSLOT_HYPERCORE_AUTHORIZER).value = address(initialAuth);
            emit AuthorizerChanged(initialAuth);
        }
        _setFunction(AdminFacet.admin_setFunctions.selector, thisImplementation);
        _setFunction(AdminFacet.admin_addFacet.selector, thisImplementation);
        _setFunction(AdminFacet.admin_setAuthorizer.selector, thisImplementation);
        _setFunction(AdminFacet.admin_pause.selector, thisImplementation);
        _setFunction(AdminFacet.admin_pausePool.selector, thisImplementation);
        _setFunction(AdminFacet.admin_setTreasury.selector, thisImplementation);
    }

    function admin_setFunctions(address implementation, bytes4[] calldata sigs) external authenticate {
        for (uint256 i = 0; i < sigs.length; i++) {
            _setFunction(sigs[i], implementation);
        }
    }

    function admin_pause(bool t) external authenticate {
        StorageSlot.getUint256Slot(SSLOT_PAUSABLE_PAUSED).value = t ? 1 : 0;
    }

    function admin_pausePool(address pool, bool t) external authenticate {
        _pausedPools()[pool] = t;
    }

    /**
     * @dev delegatecalls the implementation's initializeFacet()
     */
    function admin_addFacet(IFacet implementation) external authenticate {
        bytes memory data = abi.encodeWithSelector(IFacet.initializeFacet.selector);
        assembly ("memory-safe") {
            let success := delegatecall(gas(), implementation, add(data, 32), mload(data), 0, 0)
            if iszero(success) { revert(0, 0) }
        }
    }

    function admin_setAuthorizer(IAuthorizer auth_) external authenticate {
        StorageSlot.getAddressSlot(SSLOT_HYPERCORE_AUTHORIZER).value = address(auth_);
        emit AuthorizerChanged(auth_);
    }

    function admin_setTreasury(address treasury) external authenticate {
        StorageSlot.getAddressSlot(SSLOT_HYPERCORE_TREASURY).value = address(treasury);
        emit TreasuryChanged(treasury);
    }
}
        

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

lib/openzeppelin-contracts/contracts/token/ERC1155/extensions/ERC1155Supply.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol)

pragma solidity ^0.8.0;

import "../ERC1155.sol";

/**
 * @dev Extension of ERC1155 that adds tracking of total supply per id.
 *
 * Useful for scenarios where Fungible and Non-fungible tokens have to be
 * clearly identified. Note: While a totalSupply of 1 might mean the
 * corresponding is an NFT, there is no guarantees that no other token with the
 * same id are not going to be minted.
 */
abstract contract ERC1155Supply is ERC1155 {
    mapping(uint256 => uint256) private _totalSupply;

    /**
     * @dev Total amount of tokens in with a given id.
     */
    function totalSupply(uint256 id) public view virtual returns (uint256) {
        return _totalSupply[id];
    }

    /**
     * @dev Indicates whether any token exist with a given id, or not.
     */
    function exists(uint256 id) public view virtual returns (bool) {
        return ERC1155Supply.totalSupply(id) > 0;
    }

    /**
     * @dev See {ERC1155-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        if (from == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                _totalSupply[ids[i]] += amounts[i];
            }
        }

        if (to == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                uint256 id = ids[i];
                uint256 amount = amounts[i];
                uint256 supply = _totalSupply[id];
                require(supply >= amount, "ERC1155: burn amount exceeds totalSupply");
                unchecked {
                    _totalSupply[id] = supply - amount;
                }
            }
        }
    }
}
          

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

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

pragma solidity ^0.8.0;

/**
 * @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 ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 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) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

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

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

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

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            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) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            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) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}
          

lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 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);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
          

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
          

contracts/interfaces/IBribe.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";
import "./IGauge.sol";
import "./IPool.sol";

interface IBribe is IPool {
    /**
     * @dev This method is called when someone vote/harvest from/to a @param gauge,
     * and when this IBribe happens to be attached to the gauge.
     *
     * Attachment can happen without IBribe's permission. Implementations must verify that @param gauge is correct.
     *
     * Returns balance deltas; their net differences are credited as bribe.
     * deltaExternal must be zero or negative; Vault will take specified amounts from the contract's balance
     *
     * @param  gauge  the gauge to bribe for.
     * @param  elapsed  elapsed time after last call; can be used to save gas.
     * @return bribeTokens list of tokens to bribe
     * @return deltaGauge same order as bribeTokens, the desired change of gauge balance
     * @return deltaPool same order as bribeTokens, the desired change of pool balance
     * @return deltaExternal same order as bribeTokens, the vault will pull this amount out from the bribe contract with transferFrom()
     */
    function velocore__bribe(IGauge gauge, uint256 elapsed)
        external
        returns (
            Token[] memory bribeTokens,
            int128[] memory deltaGauge,
            int128[] memory deltaPool,
            int128[] memory deltaExternal
        );

    function bribeTokens(IGauge gauge) external view returns (Token[] memory);
    function bribeRates(IGauge gauge) external view returns (uint256[] memory);
}
          

lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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);
}
          

lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol

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

pragma solidity ^0.8.0;

/**
 * @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 of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @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._indexes[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 read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 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 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

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

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

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

            // Delete the index for the deleted slot
            delete set._indexes[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._indexes[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;

        /// @solidity memory-safe-assembly
        assembly {
            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;

        /// @solidity memory-safe-assembly
        assembly {
            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;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}
          

contracts/lib/PoolBalanceLib.sol

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

import "openzeppelin/utils/math/SafeCast.sol";

// a pool's balances are stored as two uint128;
// the only difference between them is that new emissions are credited into the gauge balance.
// the pool can use them in any way they want.

type PoolBalance is bytes32;

library PoolBalanceLib {
    using PoolBalanceLib for PoolBalance;
    using SafeCast for uint256;
    using SafeCast for int256;

    function gaugeHalf(PoolBalance self) internal pure returns (uint256) {
        return uint128(bytes16(PoolBalance.unwrap(self)));
    }

    function poolHalf(PoolBalance self) internal pure returns (uint256) {
        return uint128(uint256(PoolBalance.unwrap(self)));
    }

    function pack(uint256 a, uint256 b) internal pure returns (PoolBalance) {
        uint128 a_ = uint128(a);
        uint128 b_ = uint128(b);
        require(b == b_ && a == a_, "overflow");
        return PoolBalance.wrap(bytes32(bytes16(a_)) | bytes32(uint256(b_)));
    }

    function credit(PoolBalance self, int256 dGauge, int256 dPool) internal pure returns (PoolBalance) {
        return pack(
            (int256(uint256(self.gaugeHalf())) + dGauge).toUint256(),
            (int256(uint256(self.poolHalf())) + dPool).toUint256()
        );
    }

    function credit(PoolBalance self, int256 dPool) internal pure returns (PoolBalance) {
        return pack(self.gaugeHalf(), (int256(uint256(self.poolHalf())) + dPool).toUint256());
    }
}
          

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

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

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC1155).interfaceId ||
            interfaceId == type(IERC1155MetadataURI).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: address zero is not a valid owner");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] memory accounts,
        uint256[] memory ids
    ) public view virtual override returns (uint256[] memory) {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(address from, uint256 id, uint256 amount) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `ids` and `amounts` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}
          

contracts/interfaces/IPool.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";

interface IPool {
    function poolParams() external view returns (bytes memory);
}
          

lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}
          

contracts/interfaces/IFacet.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

interface IFacet {
    function initializeFacet() external;
}
          

lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}
          

lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}
          

lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol

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

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}
          

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @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.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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 silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}
          

contracts/interfaces/IVC.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";

interface IVC is IERC20 {
    function dispense() external returns (uint256);
    function emissionRate() external view returns (uint256);
}
          

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

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

pragma solidity ^0.8.0;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
          

contracts/interfaces/IAuthorizer.sol

// SPDX-License-Identifier: UNLICENSED
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;

interface IAuthorizer {
    /**
     * @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`.
     */
    function canPerform(bytes32 actionId, address account, address where) external view returns (bool);
}
          

lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol

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

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
          

contracts/interfaces/IConverter.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";

interface IConverter {
    /**
     * @dev This method is called by Vault.execute().
     * Vault will transfer any positively specified amounts directly to the IConverter before calling velocore__convert.
     *
     * Instead of returning balance delta numbers, IConverter is expected to directly transfer outputs back to vault.
     * Vault will measure the difference, and credit the user.
     */
    function velocore__convert(address user, Token[] calldata tokens, int128[] memory amounts, bytes calldata data)
        external;
}
          

lib/openzeppelin-contracts/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol

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

pragma solidity ^0.8.0;

import "../IERC1155.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURI is IERC1155 {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}
          

contracts/Diamond.sol

// This is the code Vault address will actually hold.

// a Diamond proxy with two ingrained functions
// implementation addresses will be stored on the last 2^32 slots. in other words, bitwise_not(msg.sig).
// the value will be either:
// 1. implementation address --> normal function
// 2. bitwise_not(implementation address) --> view function, implemented with the ingrained function 2

// on creation, it delegatecalls back to the caller.
// the caller is expected to initialize the storage.

// ingrained function 1: 'read' (0x72656164)
// a cheap way to read storage slots
// other contracts are expected to directly read predefined storage slots using this mechanism.
// expected calldata:
//    0x72656164 | bytes32 | bytes32 | bytes32 ... (no length header)
//    the query is interpreted as a series of storage slots.
// returns:
//    bytes32 | bytes32 | bytes32 | ....
//    returns storage values without header

// ingraned function 2: 'view' (0x76696577)
// delegatecall any contract; revert if the call didn't, and vice versa.
// used to calculate the result of a state-modifying function, without actually modifying the state.
// expected calldata: 0x76696577 | destination address padded to 32 bytes | calldata to be forwarded

contract Diamond {
    constructor() {
        assembly {
            let success := delegatecall(gas(), caller(), 0, 0, 0, 0)
            if iszero(success) { revert(0, 0) }
        }
    }

    fallback() external payable {
        assembly {
            if calldatasize() {
                let selector := shr(0xe0, calldataload(0x00))
                if eq(selector, 0x72656164) {
                    // 'read'
                    for { let i := 4 } lt(i, calldatasize()) { i := add(i, 0x20) } { mstore(i, sload(calldataload(i))) }
                    return(4, sub(calldatasize(), 4))
                }
                if eq(selector, 0x76696577) {
                    // view
                    calldatacopy(0, 36, sub(calldatasize(), 36))
                    let success := delegatecall(gas(), calldataload(4), 0, sub(calldatasize(), 36), 0, 0)
                    returndatacopy(0, 0, returndatasize())
                    if success { revert(0, returndatasize()) }
                    return(0, returndatasize())
                }
                let implementation := sload(not(selector))
                if implementation {
                    if lt(implementation, 0x10000000000000000000000000000000000000000) {
                        // registered as a function
                        calldatacopy(0, 0, calldatasize())
                        let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                        returndatacopy(0, 0, returndatasize())
                        switch result
                        case 0 { revert(0, returndatasize()) }
                        default { return(0, returndatasize()) }
                    }
                    // registered as a view function
                    mstore(0, 0x7669657700000000000000000000000000000000000000000000000000000000)
                    mstore(4, not(implementation))
                    calldatacopy(36, 0, calldatasize())
                    let success := delegatecall(gas(), address(), 0, add(calldatasize(), 36), 0, 0)
                    returndatacopy(0, 0, returndatasize())
                    if success { revert(0, returndatasize()) }
                    return(0, returndatasize())
                }
                revert(0, 0)
            }
        }
    }
}
          

contracts/interfaces/IGauge.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";
import "contracts/interfaces/IPool.sol";

/**
 * Gauges are just pools.
 * instead of velocore__execute, they interact with velocore__gauge.
 * (un)staking is done by putting/extracting staking token (usually LP token) from/into the pool with velocore__gauge.
 * harvesting is done by setting the staking amount to zero.
 */
interface IGauge is IPool {
    /**
     * @dev This method is called by Vault.execute().
     * the parameters and return values are the same as velocore__execute.
     * The only difference is that the vault will call velocore__emission before calling velocore__gauge.
     */
    function velocore__gauge(
        address user,
        Token[] calldata tokens,
        int128[] memory amounts,
        bytes calldata data
    ) external returns (int128[] memory deltaGauge, int128[] memory deltaPool);

    /**
     * @dev This method is called by Vault.execute() before calling velocore__emission or changing votes.
     *
     * The vault will credit emitted VC into the gauge balance.
     * IGauge is expected to update its internal ledger.
     * @param newEmissions newly emitted VCs since last emission
     */
    function velocore__emission(uint256 newEmissions) external;

    function stakeableTokens() external view returns (Token[] memory);

    function stakedTokens(
        address user
    ) external view returns (uint256[] memory);

    function stakedTokens() external view returns (uint256[] memory);

    function emissionShare(address user) external view returns (uint256);

    function naturalBribes() external view returns (Token[] memory);
}
          

contracts/interfaces/ISwap.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";
import "./IPool.sol";

interface ISwap is IPool {
    /**
     * @param user the user that requested swap
     * @param tokens sorted, unique list of tokens that user asked to swap
     * @param amounts same order as tokens, requested change of token balance, positive when pool receives, negative when pool gives. type(int128).max for unknown values, for which the pool should decide.
     * @param data auxillary data for pool-specific uses.
     * @return deltaGauge same order as tokens, the desired change of gauge balance
     * @return deltaPool same order as bribeTokens, the desired change of pool balance
     */
    function velocore__execute(address user, Token[] calldata tokens, int128[] memory amounts, bytes calldata data)
        external
        returns (int128[] memory, int128[] memory);
    function swapType() external view returns (string memory);
    function listedTokens() external view returns (Token[] memory);
    function lpTokens() external view returns (Token[] memory);
    function underlyingTokens(Token lp) external view returns (Token[] memory);
    //function spotPrice(Token token, Token base) external view returns (uint256);
}
          

lib/openzeppelin-contracts/contracts/utils/structs/BitMaps.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/BitMaps.sol)
pragma solidity ^0.8.0;

/**
 * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential.
 * Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor].
 */
library BitMaps {
    struct BitMap {
        mapping(uint256 => uint256) _data;
    }

    /**
     * @dev Returns whether the bit at `index` is set.
     */
    function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
        uint256 bucket = index >> 8;
        uint256 mask = 1 << (index & 0xff);
        return bitmap._data[bucket] & mask != 0;
    }

    /**
     * @dev Sets the bit at `index` to the boolean `value`.
     */
    function setTo(BitMap storage bitmap, uint256 index, bool value) internal {
        if (value) {
            set(bitmap, index);
        } else {
            unset(bitmap, index);
        }
    }

    /**
     * @dev Sets the bit at `index`.
     */
    function set(BitMap storage bitmap, uint256 index) internal {
        uint256 bucket = index >> 8;
        uint256 mask = 1 << (index & 0xff);
        bitmap._data[bucket] |= mask;
    }

    /**
     * @dev Unsets the bit at `index`.
     */
    function unset(BitMap storage bitmap, uint256 index) internal {
        uint256 bucket = index >> 8;
        uint256 mask = 1 << (index & 0xff);
        bitmap._data[bucket] &= ~mask;
    }
}
          

contracts/lib/Token.sol

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

import "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import "openzeppelin/token/ERC1155/IERC1155.sol";
import "openzeppelin/token/ERC1155/extensions/ERC1155Supply.sol";
import "openzeppelin/token/ERC20/extensions/IERC20Metadata.sol";
import "openzeppelin/token/ERC721/extensions/IERC721Metadata.sol";

// a library for abstracting tokens
// provides a common interface for ERC20, ERC1155, and ERC721 tokens.

bytes32 constant TOKEN_MASK = 0x000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
bytes32 constant ID_MASK = 0x00FFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000;

uint256 constant ID_SHIFT = 160;
bytes32 constant TOKENSPEC_MASK = 0xFF00000000000000000000000000000000000000000000000000000000000000;

string constant NATIVE_TOKEN_SYMBOL = "ETH";

type Token is bytes32;

type TokenSpecType is bytes32;

using {TokenSpec_equals as ==} for TokenSpecType global;
using {Token_equals as ==} for Token global;
using {Token_lt as <} for Token global;
using {Token_lte as <=} for Token global;
using {Token_ne as !=} for Token global;

Token constant NATIVE_TOKEN =
    Token.wrap(bytes32(0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE) & TOKEN_MASK);

function TokenSpec_equals(TokenSpecType a, TokenSpecType b) pure returns (bool) {
    return TokenSpecType.unwrap(a) == TokenSpecType.unwrap(b);
}

function Token_equals(Token a, Token b) pure returns (bool) {
    return Token.unwrap(a) == Token.unwrap(b);
}

function Token_ne(Token a, Token b) pure returns (bool) {
    return Token.unwrap(a) != Token.unwrap(b);
}

function Token_lt(Token a, Token b) pure returns (bool) {
    return Token.unwrap(a) < Token.unwrap(b);
}

function Token_lte(Token a, Token b) pure returns (bool) {
    return Token.unwrap(a) <= Token.unwrap(b);
}

library TokenSpec {
    TokenSpecType constant ERC20 =
        TokenSpecType.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);

    TokenSpecType constant ERC721 =
        TokenSpecType.wrap(0x0100000000000000000000000000000000000000000000000000000000000000);

    TokenSpecType constant ERC1155 =
        TokenSpecType.wrap(0x0200000000000000000000000000000000000000000000000000000000000000);
}

function toToken(IERC20 tok) pure returns (Token) {
    return Token.wrap(bytes32(uint256(uint160(address(tok)))));
}

function toToken(TokenSpecType spec_, uint88 id_, address addr_) pure returns (Token) {
    return Token.wrap(
        TokenSpecType.unwrap(spec_) | bytes32((bytes32(uint256(id_)) << ID_SHIFT) & ID_MASK)
            | bytes32(uint256(uint160(addr_)))
    );
}

library TokenLib {
    using TokenLib for Token;
    using TokenLib for bytes32;
    using SafeERC20 for IERC20;
    using SafeERC20 for IERC20Metadata;

    function wrap(bytes32 data) internal pure returns (Token) {
        return Token.wrap(data);
    }

    function unwrap(Token tok) internal pure returns (bytes32) {
        return Token.unwrap(tok);
    }

    function addr(Token tok) internal pure returns (address) {
        return address(uint160(uint256(tok.unwrap() & TOKEN_MASK)));
    }

    function id(Token tok) internal pure returns (uint256) {
        return uint256((tok.unwrap() & ID_MASK) >> ID_SHIFT);
    }

    function spec(Token tok) internal pure returns (TokenSpecType) {
        return TokenSpecType.wrap(tok.unwrap() & TOKENSPEC_MASK);
    }

    function toIERC20(Token tok) internal pure returns (IERC20Metadata) {
        return IERC20Metadata(tok.addr());
    }

    function toIERC1155(Token tok) internal pure returns (IERC1155) {
        return IERC1155(tok.addr());
    }

    function toIERC721(Token tok) internal pure returns (IERC721Metadata) {
        return IERC721Metadata(tok.addr());
    }

    function balanceOf(Token tok, address user) internal view returns (uint256) {
        if (tok == NATIVE_TOKEN) {
            return user.balance;
        } else if (tok.spec() == TokenSpec.ERC20) {
            require(tok.id() == 0);
            return tok.toIERC20().balanceOf(user); // ERC721 balanceOf() has the same signature
        } else if (tok.spec() == TokenSpec.ERC1155) {
            return tok.toIERC1155().balanceOf(user, tok.id());
        } else if (tok.spec() == TokenSpec.ERC721) {
            return tok.toIERC721().ownerOf(tok.id()) == user ? 1 : 0;
        }

        revert("invalid token");
    }

    function totalSupply(Token tok) internal view returns (uint256) {
        require(tok != NATIVE_TOKEN);
        if (tok.spec() == TokenSpec.ERC20) {
            require(tok.id() == 0);
            return tok.toIERC20().totalSupply(); // ERC721 balanceOf() has the same signature
        } else if (tok.spec() == TokenSpec.ERC1155) {
            return ERC1155Supply(tok.addr()).totalSupply(tok.id());
        } else if (tok.spec() == TokenSpec.ERC721) {
            return 1;
        }

        revert("invalid token");
    }

    function symbol(Token tok) internal view returns (string memory) {
        if (tok == NATIVE_TOKEN) {
            return NATIVE_TOKEN_SYMBOL;
        } else if (tok.spec() == TokenSpec.ERC20) {
            require(tok.id() == 0);
            return tok.toIERC20().symbol(); // ERC721 balanceOf() has the same signature
        } else if (tok.spec() == TokenSpec.ERC1155) {
            return "";
        } else if (tok.spec() == TokenSpec.ERC721) {
            return tok.toIERC721().symbol();
        }
    }

    function decimals(Token tok) internal view returns (uint8) {
        if (tok == NATIVE_TOKEN) {
            return 18;
        } else if (tok.spec() == TokenSpec.ERC20) {
            require(tok.id() == 0);
            return IERC20Metadata(tok.addr()).decimals();
        }
        return 0;
    }

    function transferFrom(Token tok, address from, address to, uint256 amount) internal {
        if (tok == NATIVE_TOKEN) {
            require(from == address(this), "native token transferFrom is not supported");
            assembly {
                let success := call(gas(), to, amount, 0, 0, 0, 0)
                if iszero(success) { revert(0, 0) }
            }
        } else if (tok.spec() == TokenSpec.ERC20) {
            require(tok.id() == 0);
            if (from == address(this)) {
                tok.toIERC20().safeTransfer(to, amount);
            } else {
                tok.toIERC20().safeTransferFrom(from, to, amount);
            }
        } else if (tok.spec() == TokenSpec.ERC721) {
            require(amount == 1, "invalid amount");
            tok.toIERC721().safeTransferFrom(from, to, tok.id());
        } else if (tok.spec() == TokenSpec.ERC1155) {
            tok.toIERC1155().safeTransferFrom(from, to, tok.id(), amount, "");
        } else {
            revert("invalid token");
        }
    }

    function meteredTransferFrom(Token tok, address from, address to, uint256 amount) internal returns (uint256) {
        uint256 balBefore = tok.balanceOf(to);
        tok.transferFrom(from, to, amount);
        return tok.balanceOf(to) - balBefore;
    }

    function safeTransferFrom(Token tok, address from, address to, uint256 amount) internal {
        require(tok.meteredTransferFrom(from, to, amount) >= amount);
    }

    function toScaledBalance(Token tok, uint256 amount) internal view returns (uint256) {
        return amount;
    }

    function fromScaledBalance(Token tok, uint256 amount) internal view returns (uint256) {
        return amount;
    }

    function toScaledBalance(Token tok, int128 amount) internal view returns (int128) {
        return amount;
    }

    function fromScaledBalance(Token tok, int128 amount) internal view returns (int128) {
        return amount;
    }
}
          

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

contracts/interfaces/IVault.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/interfaces/IAuthorizer.sol";
import "contracts/interfaces/IFacet.sol";
import "contracts/interfaces/IGauge.sol";
import "contracts/interfaces/IConverter.sol";
import "contracts/interfaces/IBribe.sol";
import "contracts/interfaces/ISwap.sol";
import "contracts/lib/Token.sol";

bytes32 constant SSLOT_HYPERCORE_TREASURY = bytes32(
    uint256(keccak256("hypercore.treasury")) - 1
);
bytes32 constant SSLOT_HYPERCORE_AUTHORIZER = bytes32(
    uint256(keccak256("hypercore.authorizer")) - 1
);
bytes32 constant SSLOT_HYPERCORE_ROUTINGTABLE = bytes32(
    uint256(keccak256("hypercore.routingTable")) - 1
);
bytes32 constant SSLOT_HYPERCORE_POOLBALANCES = bytes32(
    uint256(keccak256("hypercore.poolBalances")) - 1
);
bytes32 constant SSLOT_HYPERCORE_REBASEORACLES = bytes32(
    uint256(keccak256("hypercore.rebaseOracles")) - 1
);
bytes32 constant SSLOT_HYPERCORE_LASTBALANCES = bytes32(
    uint256(keccak256("hypercore.lastBalances")) - 1
);
bytes32 constant SSLOT_HYPERCORE_USERBALANCES = bytes32(
    uint256(keccak256("hypercore.userBalances")) - 1
);
bytes32 constant SSLOT_HYPERCORE_EMISSIONINFORMATION = bytes32(
    uint256(keccak256("hypercore.emissionInformation")) - 1
);
bytes32 constant SSLOT_REENTRACNYGUARD_LOCKED = bytes32(
    uint256(keccak256("ReentrancyGuard.locked")) - 1
);
bytes32 constant SSLOT_PAUSABLE_PAUSED = bytes32(
    uint256(keccak256("Pausable.paused")) - 1
);

bytes32 constant SSLOT_PAUSED_POOLS = bytes32(
    uint256(keccak256("hypercore.pausedPools")) - 1
);

struct VelocoreOperation {
    bytes32 poolId;
    bytes32[] tokenInformations;
    bytes data;
}

struct route {
    address from;
    address to;
    bool stable;
}

interface IVault {
    struct Facet {
        address facetAddress;
        bytes4[] functionSelectors;
    }

    enum FacetCutAction {
        Add,
        Replace,
        Remove
    }
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
    event Swap(
        ISwap indexed pool,
        address indexed user,
        Token[] tokenRef,
        int128[] delta
    );
    event Gauge(
        IGauge indexed pool,
        address indexed user,
        Token[] tokenRef,
        int128[] delta
    );
    event Convert(
        IConverter indexed pool,
        address indexed user,
        Token[] tokenRef,
        int128[] delta
    );
    event Vote(IGauge indexed pool, address indexed user, int256 voteDelta);
    event UserBalance(
        address indexed to,
        address indexed from,
        Token[] tokenRef,
        int128[] delta
    );
    event BribeAttached(IGauge indexed gauge, IBribe indexed bribe);
    event BribeKilled(IGauge indexed gauge, IBribe indexed bribe);
    event GaugeKilled(IGauge indexed gauge, bool killed);

    function notifyInitialSupply(Token, uint128, uint128) external;

    function attachBribe(IGauge gauge, IBribe bribe) external;

    function killBribe(IGauge gauge, IBribe bribe) external;

    function killGauge(IGauge gauge, bool t) external;

    function ballotToken() external returns (Token);

    function emissionToken() external returns (Token);

    function execute(
        Token[] calldata tokenRef,
        int128[] memory deposit,
        VelocoreOperation[] calldata ops
    ) external payable;

    function facets() external view returns (Facet[] memory facets_);

    function facetFunctionSelectors(
        address _facet
    ) external view returns (bytes4[] memory facetFunctionSelectors_);

    function facetAddresses()
        external
        view
        returns (address[] memory facetAddresses_);

    function facetAddress(
        bytes4 _functionSelector
    ) external view returns (address facetAddress_);

    function query(
        address user,
        Token[] calldata tokenRef,
        int128[] memory deposit,
        VelocoreOperation[] calldata ops
    ) external returns (int128[] memory);

    function admin_setFunctions(
        address implementation,
        bytes4[] calldata sigs
    ) external;

    function admin_addFacet(IFacet implementation) external;

    function admin_setAuthorizer(IAuthorizer auth_) external;

    function admin_pause(bool t) external;

    function admin_setTreasury(address treasury) external;

    function emissionStarted() external view returns (bool);

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        route[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapTokensForExactTokens(
        uint256 amountOut,
        uint256 amountInMax,
        route[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactETHForTokens(
        uint256 amountOutMin,
        route[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function swapTokensForExactETH(
        uint256 amountOut,
        uint256 amountInMax,
        route[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactTokensForETH(
        uint256 amountIn,
        uint256 amountOutMin,
        route[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapETHForExactTokens(
        uint256 amountOut,
        route[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function getAmountsOut(
        uint256 amountIn,
        route[] calldata path
    ) external returns (uint256[] memory amounts);

    function getAmountsIn(
        uint256 amountOut,
        route[] calldata path
    ) external returns (uint256[] memory amounts);

    function execute1(
        address pool,
        uint8 method,
        address t1,
        uint8 m1,
        int128 a1,
        bytes memory data
    ) external payable returns (int128[] memory);

    function query1(
        address pool,
        uint8 method,
        address t1,
        uint8 m1,
        int128 a1,
        bytes memory data
    ) external returns (int128[] memory);

    function execute2(
        address pool,
        uint8 method,
        address t1,
        uint8 m1,
        int128 a1,
        address t2,
        uint8 m2,
        int128 a2,
        bytes memory data
    ) external payable returns (int128[] memory);

    function query2(
        address pool,
        uint8 method,
        address t1,
        uint8 m1,
        int128 a1,
        address t2,
        uint8 m2,
        int128 a2,
        bytes memory data
    ) external returns (int128[] memory);

    function execute3(
        address pool,
        uint8 method,
        address t1,
        uint8 m1,
        int128 a1,
        address t2,
        uint8 m2,
        int128 a2,
        address t3,
        uint8 m3,
        int128 a3,
        bytes memory data
    ) external payable returns (int128[] memory);

    function query3(
        address pool,
        uint8 method,
        address t1,
        uint8 m1,
        int128 a1,
        address t2,
        uint8 m2,
        int128 a2,
        address t3,
        uint8 m3,
        int128 a3,
        bytes memory data
    ) external returns (int128[] memory);

    function getPair(address t0, address t1) external view returns (address);

    function allPairs(uint256 i) external view returns (address);

    function allPairsLength() external view returns (uint256);

    function getPoolBalance(address, Token) external view returns (uint256);

    function getGaugeBalance(address, Token) external view returns (uint256);

    function claimGasses(address[] memory, address) external;

    function removeLiquidityETH(
        address token,
        bool stable,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountToken, uint256 amountETH);

    function quoteRemoveLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 liquidity
    ) external returns (uint256 amountA, uint256 amountB);

    function addLiquidityETH(
        address tokenA,
        bool stable,
        uint256 amountADesired,
        uint256 amountAMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external payable returns (uint256 amountA, uint256 amountETH, uint256 liquidity);
    function addLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) external payable returns (uint256 amountA, uint256 amountB, uint256 liquidity);
    function quoteAddLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 amountADesired,
        uint256 amountBDesired
    ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountA, uint256 amountB);
    function deposit(address pool, uint256 amount) external;
    function withdraw(address pool, uint256 amount) external;
}
          

contracts/VaultStorage.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import "contracts/lib/Token.sol";
import "contracts/interfaces/IVault.sol";
import "contracts/interfaces/IGauge.sol";
import "contracts/lib/PoolBalanceLib.sol";
import "contracts/interfaces/IGauge.sol";
import "contracts/interfaces/IBribe.sol";
import "contracts/interfaces/IAuthorizer.sol";
import "openzeppelin/utils/structs/BitMaps.sol";
import "openzeppelin/utils/StorageSlot.sol";
import "openzeppelin/utils/structs/EnumerableSet.sol";

// A base contract inherited by every facet.

// Vault stores everything on named slots, in order to:
// - prevent storage collision
// - make information access cheaper. (see Diamond.yul)
// The downside of doing that is that storage access becomes exteremely verbose;
// We define large singleton structs to mitigate that.

struct EmissionInformation {
    // a singleton struct for emission-related global data
    // accessed as `_e()`
    uint128 perVote; // (number of VC tokens ever emitted, per vote) * 1e9; monotonically increasing.
    uint128 totalVotes; // the current sum of votes on all pool
    mapping(IGauge => GaugeInformation) gauges; // per-guage informations
    uint32 timestamp1;
}

struct GaugeInformation {
    // we use `lastBribeUpdate == 1` as a special value indicating a killed gauge
    // note that this is updated with bribe calculation, not emission calculation, unlike perVoteAtLastEmissionUpdate
    uint32 lastBribeUpdate;
    uint112 perVoteAtLastEmissionUpdate;
    //
    // total vote on this gauge
    uint112 totalVotes;
    //
    mapping(address => uint256) userVotes;
    //
    // bribes are contracts; we call them to extort bribes on demand
    EnumerableSet.AddressSet bribes;
    //
    // for storing extorted bribes.
    // we track (accumulated reward / vote), per bribe contract, per token
    // we separately track rewards from different bribes, to contain bad-behaving bribe contracts
    mapping(IBribe => mapping(Token => Rewards)) rewards;
}

// tracks the distribution of a single token
struct Rewards {
    // accumulated rewards per vote * 1e9
    uint256 current;
    // `accumulated rewards per vote * 1e9` at the moment of last claim of the user
    mapping(address => uint256) snapshots;
    uint256 balance;
    bool old;
}

struct RoutingTable {
    EnumerableSet.Bytes32Set sigs;
    mapping(address => EnumerableSet.Bytes32Set) sigsByImplementation;
}

contract VaultStorage {
    using EnumerableSet for EnumerableSet.Bytes32Set;

    event Swap(ISwap indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
    event Gauge(IGauge indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
    event Convert(IConverter indexed pool, address indexed user, Token[] tokenRef, int128[] delta);
    event Vote(IGauge indexed pool, address indexed user, int256 voteDelta);
    event UserBalance(address indexed to, address indexed from, Token[] tokenRef, int128[] delta);
    event BribeAttached(IGauge indexed gauge, IBribe indexed bribe);
    event BribeKilled(IGauge indexed gauge, IBribe indexed bribe);
    event GaugeKilled(IGauge indexed gauge, bool killed);

    enum FacetCutAction {
        Add,
        Replace,
        Remove
    }
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);

    function _getImplementation(bytes4 sig) internal view returns (address impl, bool readonly) {
        assembly ("memory-safe") {
            impl := sload(not(shr(0xe0, sig)))
            if iszero(lt(impl, 0x10000000000000000000000000000000000000000)) {
                readonly := 1
                impl := not(impl)
            }
        }
    }

    function _setFunction(bytes4 sig, address implementation) internal {
        (address oldImplementation,) = _getImplementation(sig);
        FacetCut[] memory a = new FacetCut[](1);
        a[0].facetAddress = implementation;
        a[0].action = FacetCutAction.Add;
        a[0].functionSelectors = new bytes4[](1);
        a[0].functionSelectors[0] = sig;
        if (oldImplementation != address(0)) {
            a[0].action = FacetCutAction.Replace;
        }
        if (implementation == address(0)) a[0].action = FacetCutAction.Remove;
        emit DiamondCut(a, implementation, "");
        assembly ("memory-safe") {
            sstore(not(shr(0xe0, sig)), implementation)
        }

        if (oldImplementation != address(0)) {
            _routingTable().sigsByImplementation[oldImplementation].remove(sig);
        }

        if (implementation == address(0)) {
            _routingTable().sigs.remove(sig);
        } else {
            _routingTable().sigs.add(sig);
            _routingTable().sigsByImplementation[implementation].add(sig);
        }
    }

    // viewer implementations are stored as `not(implementation)`. please refer to Diamond.yul for more information
    function _setViewer(bytes4 sig, address implementation) internal {
        (address oldImplementation,) = _getImplementation(sig);
        FacetCut[] memory a = new FacetCut[](1);
        a[0].facetAddress = implementation;
        a[0].action = FacetCutAction.Add;
        a[0].functionSelectors = new bytes4[](1);
        a[0].functionSelectors[0] = sig;
        if (oldImplementation != address(0)) {
            a[0].action = FacetCutAction.Replace;
        }
        if (implementation == address(0)) a[0].action = FacetCutAction.Remove;
        emit DiamondCut(a, implementation, "");
        assembly ("memory-safe") {
            sstore(not(shr(0xe0, sig)), not(implementation))
        }
        if (oldImplementation != address(0)) {
            _routingTable().sigsByImplementation[oldImplementation].remove(sig);
        }

        if (implementation == address(0)) {
            _routingTable().sigs.remove(sig);
        } else {
            _routingTable().sigs.add(sig);
            _routingTable().sigsByImplementation[implementation].add(sig);
        }
    }

    function _routingTable() internal pure returns (RoutingTable storage ret) {
        bytes32 slot = SSLOT_HYPERCORE_ROUTINGTABLE;
        assembly ("memory-safe") {
            ret.slot := slot
        }
    }

    // each pool has two accounts of balance: gauge balance and pool balance; both are uint128.
    // they are stored in a wrapped bytes32, PoolBalance
    // the only difference between them is that new emissions are credited into the gauge balance.
    // the pool can use them in any way they want.
    function _poolBalances() internal pure returns (mapping(IPool => mapping(Token => PoolBalance)) storage ret) {
        bytes32 slot = SSLOT_HYPERCORE_POOLBALANCES;
        assembly ("memory-safe") {
            ret.slot := slot
        }
    }

    function _e() internal pure returns (EmissionInformation storage ret) {
        bytes32 slot = SSLOT_HYPERCORE_EMISSIONINFORMATION;
        assembly ("memory-safe") {
            ret.slot := slot
        }
    }

    // users can also store tokens directly in the vault; their balances are tracked separately.
    function _userBalances() internal pure returns (mapping(address => mapping(Token => uint256)) storage ret) {
        bytes32 slot = SSLOT_HYPERCORE_USERBALANCES;
        assembly ("memory-safe") {
            ret.slot := slot
        }
    }

    function _pausedPools() internal pure returns (mapping(address => bool) storage ret) {
        bytes32 slot = SSLOT_PAUSED_POOLS;
        assembly ("memory-safe") {
            ret.slot := slot
        }
    }

    modifier nonReentrant() {
        require(StorageSlot.getUint256Slot(SSLOT_REENTRACNYGUARD_LOCKED).value < 2, "REENTRANCY");
        StorageSlot.getUint256Slot(SSLOT_REENTRACNYGUARD_LOCKED).value = 2;
        _;
        StorageSlot.getUint256Slot(SSLOT_REENTRACNYGUARD_LOCKED).value = 1;
    }

    modifier whenNotPaused() {
        require(StorageSlot.getUint256Slot(SSLOT_PAUSABLE_PAUSED).value == 0, "PAUSED");
        _;
    }

    // this contract delegates access control to another contract, IAuthenticator.
    // this design was inspired by Balancer.
    // actionId is a function of method signature and contract address
    modifier authenticate() {
        authenticateCaller();
        _;
    }

    function authenticateCaller() internal {
        bytes32 actionId = keccak256(abi.encodePacked(bytes32(uint256(uint160(address(this)))), msg.sig));
        require(
            IAuthorizer(StorageSlot.getAddressSlot(SSLOT_HYPERCORE_AUTHORIZER).value).canPerform(
                actionId, msg.sender, address(this)
            ),
            "unauthorized"
        );
    }
}
          

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

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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
          

Compiler Settings

{"viaIR":true,"remappings":["@prb/test/=lib/prb-math/lib/prb-test/src/","ds-test/=lib/solmate/lib/ds-test/src/","forge-std/=lib/forge-std/src/","openzeppelin/=lib/openzeppelin-contracts/contracts/","@openzeppelin/=lib/openzeppelin-contracts/","openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@prb/math/=lib/prb-math/","prb-test/=lib/prb-math/lib/prb-test/src/","solmate/=lib/solmate/src/","lzapp/=lib/solidity-examples/contracts/","algebra-core/=lib/Algebra/src/core/contracts/","algebra-plugin/=lib/Algebra/src/plugin/contracts/","algebra-periphery/=lib/Algebra/src/periphery/contracts/","algebra-farming/=lib/Algebra/src/farming/contracts/","@cryptoalgebra/integral-base-plugin/=lib/Algebra/src/plugin/","@cryptoalgebra/integral-core/=lib/Algebra/src/core/","@cryptoalgebra/integral-periphery/=lib/Algebra/src/periphery/","Algebra/=lib/Algebra/src/","erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/","prb-math/=lib/prb-math/src/"],"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"]}},"optimizer":{"runs":50,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"libraries":{},"evmVersion":"paris"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"auth_","internalType":"contract IAuthorizer"}]},{"type":"event","name":"AuthorizerChanged","inputs":[{"type":"address","name":"authorizer","internalType":"contract IAuthorizer","indexed":true}],"anonymous":false},{"type":"event","name":"BribeAttached","inputs":[{"type":"address","name":"gauge","internalType":"contract IGauge","indexed":true},{"type":"address","name":"bribe","internalType":"contract IBribe","indexed":true}],"anonymous":false},{"type":"event","name":"BribeKilled","inputs":[{"type":"address","name":"gauge","internalType":"contract IGauge","indexed":true},{"type":"address","name":"bribe","internalType":"contract IBribe","indexed":true}],"anonymous":false},{"type":"event","name":"Convert","inputs":[{"type":"address","name":"pool","internalType":"contract IConverter","indexed":true},{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"bytes32[]","name":"tokenRef","internalType":"Token[]","indexed":false},{"type":"int128[]","name":"delta","internalType":"int128[]","indexed":false}],"anonymous":false},{"type":"event","name":"DiamondCut","inputs":[{"type":"tuple[]","name":"_diamondCut","internalType":"struct VaultStorage.FacetCut[]","indexed":false,"components":[{"type":"address","name":"facetAddress","internalType":"address"},{"type":"uint8","name":"action","internalType":"enum VaultStorage.FacetCutAction"},{"type":"bytes4[]","name":"functionSelectors","internalType":"bytes4[]"}]},{"type":"address","name":"_init","internalType":"address","indexed":false},{"type":"bytes","name":"_calldata","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"Gauge","inputs":[{"type":"address","name":"pool","internalType":"contract IGauge","indexed":true},{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"bytes32[]","name":"tokenRef","internalType":"Token[]","indexed":false},{"type":"int128[]","name":"delta","internalType":"int128[]","indexed":false}],"anonymous":false},{"type":"event","name":"GaugeKilled","inputs":[{"type":"address","name":"gauge","internalType":"contract IGauge","indexed":true},{"type":"bool","name":"killed","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"Swap","inputs":[{"type":"address","name":"pool","internalType":"contract ISwap","indexed":true},{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"bytes32[]","name":"tokenRef","internalType":"Token[]","indexed":false},{"type":"int128[]","name":"delta","internalType":"int128[]","indexed":false}],"anonymous":false},{"type":"event","name":"TreasuryChanged","inputs":[{"type":"address","name":"addr","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"UserBalance","inputs":[{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"bytes32[]","name":"tokenRef","internalType":"Token[]","indexed":false},{"type":"int128[]","name":"delta","internalType":"int128[]","indexed":false}],"anonymous":false},{"type":"event","name":"Vote","inputs":[{"type":"address","name":"pool","internalType":"contract IGauge","indexed":true},{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"int256","name":"voteDelta","internalType":"int256","indexed":false}],"anonymous":false},{"type":"fallback","stateMutability":"nonpayable"},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"admin_addFacet","inputs":[{"type":"address","name":"implementation","internalType":"contract IFacet"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"admin_pause","inputs":[{"type":"bool","name":"t","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"admin_pausePool","inputs":[{"type":"address","name":"pool","internalType":"address"},{"type":"bool","name":"t","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"admin_setAuthorizer","inputs":[{"type":"address","name":"auth_","internalType":"contract IAuthorizer"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"admin_setFunctions","inputs":[{"type":"address","name":"implementation","internalType":"address"},{"type":"bytes4[]","name":"sigs","internalType":"bytes4[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"admin_setTreasury","inputs":[{"type":"address","name":"treasury","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"deploy","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initializeFacet","inputs":[]}]
              

Contract Creation Code

0x60e03461008a57601f611d4038819003918201601f19168301916001600160401b0383118484101761008f5780849260209460405283398101031261008a57516001600160a01b038116810361008a573360805260a0523060c052604051611c9a90816100a68239608051816112ad015260a05181611169015260c051818181601501526101110152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe60806040526004361015610079575b34610074577f0000000000000000000000000000000000000000000000000000000000000000306001600160a01b038216146100745760008091604051602081019063fe88866560e01b82526004815261006960248261180b565b51915af41561007457005b600080fd5b60003560e01c80631c7330821461175d5780632b76dc4c146116e8578063356fd835146113a157806352d9492714611344578063775c300c1461129a5780639c3e816614611248578063ca17c397146111c25763fe8886650361000e573461007457600036600319011261007457600080516020611c2583398151915280546001600160a01b03161561115b575b5063356fd83519547f0000000000000000000000000000000000000000000000000000000000000000600160a01b821015611153575b60409081519061014d838361180b565b60018252601f1983019060005b828110611129575061016b8361192d565b516001600160a01b0382169081905294600060206101888661192d565b5101528451610197868261180b565b6001815283366020830137856101ac8661192d565b51015263356fd83560e01b6101cc866101c48761192d565b51015161192d565b526001600160a01b038116151580611114575b861594856110ff575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b82821061106d5750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a18263356fd8351955611031575b508215610fe05761027463356fd83560e01b600080516020611c45833981519152611968565b505b639c3e81661954600160a01b811015610fda575b838551610297878261180b565b6001815260005b858110610fab5750876102b08261192d565b5152600060206102bf8361192d565b51015286516102ce888261180b565b6001815285366020830137876102e38361192d565b510152634e1f40b360e11b6102fb886101c48461192d565b526001600160a01b03831615159182610f96575b610f81575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610eef5750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a182639c3e81661955610eb3575b508215610e62576103a0634e1f40b360e11b600080516020611c45833981519152611968565b505b631c7330821954600160a01b811015610e5c575b8385516103c3878261180b565b6001815260005b858110610e2d5750876103dc8261192d565b5152600060206103eb8361192d565b51015286516103fa888261180b565b60018152853660208301378761040f8361192d565b510152630e39984160e11b610427886101c48461192d565b526001600160a01b03831615159182610e18575b610e03575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610d715750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a182631c7330821955610d35575b508215610ce4576104cc630e39984160e11b600080516020611c45833981519152611968565b505b6352d949271954600160a01b811015610cde575b8385516104ef878261180b565b6001815260005b858110610caf5750876105088261192d565b5152600060206105178361192d565b5101528651610526888261180b565b60018152853660208301378761053b8361192d565b5101526352d9492760e01b610553886101c48461192d565b526001600160a01b03831615159182610c9a575b610c85575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610bf35750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a1826352d949271955610bb7575b508215610b66576105f86352d9492760e01b600080516020611c45833981519152611968565b505b632b76dc4c1954600160a01b811015610b60575b83855161061b878261180b565b6001815260005b858110610b315750876106348261192d565b5152600060206106438361192d565b5101528651610652888261180b565b6001815285366020830137876106678361192d565b510152630addb71360e21b61067f886101c48461192d565b526001600160a01b03831615159182610b1c575b610b07575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610a755750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a182632b76dc4c1955610a39575b5082156109e857610724630addb71360e21b600080516020611c45833981519152611968565b505b63ca17c397195491600160a01b8310156109e0575b845184929161074a878361180b565b6001825260005b8181106109ad5750876107638361192d565b5152600060206107728461192d565b510152865190610782888361180b565b60018252366020830137866107968361192d565b51015263ca17c39760e01b6107ae876101c48461192d565b526001600160a01b03841615159283610998575b610983575b855190606082016060835281518091526080830190602060808260051b8601019301916000905b8282106108dc5750505050906020600080516020611c05833981519152928982840152600083820391828b860152520190a163ca17c39719556108a0575b50156108565750610854905063ca17c39760e01b600080516020611c45833981519152611968565b005b6108549161087963ca17c39760e01b600080516020611c45833981519152611a68565b506000908152600080516020611be58339815191526020522063ca17c39760e01b90611a68565b6001600160a01b03166000908152600080516020611be58339815191526020528290206108d59063ca17c39760e01b90611968565b503861082c565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d578360608f60209460809486839901520151958201528451809452019201906000905b80821061094a575050506020806001929601920192019092916107ee565b82516001600160e01b03191684526020938401939092019160019091019061092c565b634e487b7160e01b600052602160045260246000fd5b600260206109908361192d565b5101526107c7565b600160206109a58461192d565b5101526107c2565b6020919293945087516109bf816117f0565b60008152600083820152606089820152828286010152019085939291610751565b91199161073b565b610a07630addb71360e21b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610a3384600020630addb71360e21b90611a68565b50610726565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610a6e90630addb71360e21b90611968565b50386106fe565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610ae4575050506020806001929601920192019092916106bf565b82516001600160e01b031916845260209384019390920191600190910190610ac6565b60026020610b148361192d565b510152610698565b60016020610b298461192d565b510152610693565b60209192508751610b41816117f0565b6000815260008382015260608982015282828501015201908591610622565b1961060e565b610b856352d9492760e01b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610bb1846000206352d9492760e01b90611a68565b506105fa565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610bec906352d9492760e01b90611968565b50386105d2565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610c6257505050602080600192960192019201909291610593565b82516001600160e01b031916845260209384019390920191600190910190610c44565b60026020610c928361192d565b51015261056c565b60016020610ca78461192d565b510152610567565b60209192508751610cbf816117f0565b60008152600083820152606089820152828285010152019085916104f6565b196104e2565b610d03630e39984160e11b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610d2f84600020630e39984160e11b90611a68565b506104ce565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610d6a90630e39984160e11b90611968565b50386104a6565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610de057505050602080600192960192019201909291610467565b82516001600160e01b031916845260209384019390920191600190910190610dc2565b60026020610e108361192d565b510152610440565b60016020610e258461192d565b51015261043b565b60209192508751610e3d816117f0565b60008152600083820152606089820152828285010152019085916103ca565b196103b6565b610e81634e1f40b360e11b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610ead84600020634e1f40b360e11b90611a68565b506103a2565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610ee890634e1f40b360e11b90611968565b503861037a565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610f5e5750505060208060019296019201920190929161033b565b82516001600160e01b031916845260209384019390920191600190910190610f40565b60026020610f8e8361192d565b510152610314565b60016020610fa38461192d565b51015261030f565b60209192508751610fbb816117f0565b600081526000838201526060898201528282850101520190859161029e565b1961028a565b610fff63356fd83560e01b600080516020611c45833981519152611a68565b5084600052600080516020611be583398151915260205261102b8460002063356fd83560e01b90611a68565b50610276565b6001600160a01b03166000908152600080516020611be58339815191526020528490206110669063356fd83560e01b90611968565b503861024e565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b8082106110dc5750505060208060019296019201920190929161020f565b82516001600160e01b0319168452602093840193909201916001909101906110be565b6002602061110c8361192d565b5101526101e8565b600160206111218761192d565b5101526101df565b6020908551611137816117f0565b600081526000838201526060878201528282870101520161015a565b90199061013d565b80546001600160a01b0319167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169081179091557f94b979b6831a51293e2641426f97747feed46f17779fed9cd18d1ecefcfe92ef600080a238610107565b34610074576020366003190112610074576111db6117da565b6111e361182c565b7f8f688873691912f8fe135293a1e4047b82cd30dddf57571cb75b40a636c8f5d680546001600160a01b0319166001600160a01b039290921691821790557fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f608600080a2005b34610074576020366003190112610074576004356001600160a01b0381168103610074576000809161127861182c565b60405163fe88866560e01b60208201908152600482529061006960248261180b565b34610074576000366003190112610074577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610074576040516101228082018281106001600160401b0382111761132e578291611ac3833903906000f08015611322576001600160a01b0316801561007457602090604051908152f35b6040513d6000823e3d90fd5b634e487b7160e01b600052604160045260246000fd5b346100745760203660031901126100745760043580151581036100745761136961182c565b156113985760ff60015b167fabc3a851eef7cc061af44295e96ff7ea964e5bfdace1a0d992cfec9f50839bdd55005b60ff6000611373565b34610074576040366003190112610074576113ba6117da565b602435906001600160401b0382116100745736602383011215610074578160040135916001600160401b038311610074573660248460051b8301011161007457829061140461182c565b60209260406001600160a01b03821660005b8581101561085457600060248260051b8701013563ffffffff60e01b8116908181036116e45760e01c19805490600160a01b8210156116dc575b86519061145d888361180b565b60018252845b8c81106116b45750866114758361192d565b51528460206114838461192d565b5101528751611492898261180b565b600181528c366020830137886114a78461192d565b510152836114b8896101c48561192d565b526001600160a01b0383161515918261169f575b871561168a575b959493929190899089518a8a60608301606084528b5180915260808401602060808360051b8701019d01918b5b8181106115ce575050505082918960019c60209384600080516020611c058339815191529701528481038093860152520190a1556115a0575b508585611562575061155a9150600080516020611c45833981519152611968565b505b01611416565b61159a9261157e83600080516020611c45833981519152611a68565b50868152600080516020611be583398151915260205220611a68565b5061155c565b848060a01b03168252600080516020611be58339815191526020526115c781878420611968565b508a611539565b935093509395509395969798999a607f19868203018452845160018060a01b03815116825260208101516003811015611676578f839260609260208396015201519282015260206080835192836060820152019201908c905b80821061165357505050602080600192960194019101928c918f9694938f949d9c9b9a9998969d611500565b82516001600160e01b031916845260209384019390920191600190910190611627565b634e487b7160e01b8d52602160045260248dfd5b600260206116978361192d565b5101526114d3565b600160206116ac8361192d565b5101526114cc565b60209089516116c2816117f0565b878152878382015260608b82015282828601015201611463565b901990611450565b8280fd5b34610074576040366003190112610074576117016117da565b602435908115158092036100745761171761182c565b60018060a01b03166000527f1391d08c4b94bb5ee939c8df9f834abd360a89f43ca1e029966eee3f2187784f60205260406000209060ff80198354169116179055600080f35b34610074576020366003190112610074576004356001600160a01b038116908190036100745761178b61182c565b600080516020611c2583398151915280546001600160a01b0319166001600160a01b0383161790557f94b979b6831a51293e2641426f97747feed46f17779fed9cd18d1ecefcfe92ef600080a2005b600435906001600160a01b038216820361007457565b606081019081106001600160401b0382111761132e57604052565b90601f801991011681019081106001600160401b0382111761132e57604052565b604051602081019030825263ffffffff60e01b6000351660408201526024815261185760448261180b565b519020600080516020611c25833981519152546040516326f8aa2160e21b81526004810192909252336024830152306044830152602090829060649082906001600160a01b03165afa908115611322576000916118eb575b50156118b757565b60405162461bcd60e51b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5e995960a21b6044820152606490fd5b6020813d602011611925575b816119046020938361180b565b81010312611921575190811515820361191e5750386118af565b80fd5b5080fd5b3d91506118f7565b80511561193a5760200190565b634e487b7160e01b600052603260045260246000fd5b805482101561193a5760005260206000200190600090565b9060018201918160005282602052604060002054801515600014611a5f576000198101818111611a49578254600019810191908211611a49578082036119fb575b505050805480156119e55760001901906119c38282611950565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b611a32611a0b611a1b9386611950565b90549060031b1c92839286611950565b819391549060031b91821b91600019901b19161790565b9055600052836020526040600020553880806119a9565b634e487b7160e01b600052601160045260246000fd5b50505050600090565b6001810190826000528160205260406000205415600014611aba578054600160401b81101561132e57611aa5611a1b826001879401855584611950565b90555491600052602052604060002055600190565b50505060009056fe6080604052346022576000808080335af41560225760405160fa90816100288239f35b600080fdfe608060405236600a57005b60003560e01c6372656164811460a65763766965778114608657195480602f57600080fd5b600160a01b8110606b57637669657760e01b600052196004523660006024376000806024360181305af43d6000803e6066573d6000f35b3d6000fd5b60008091368280378136915af43d6000803e156066573d6000f35b60008036602319018060248337816004355af43d6000803e6066573d6000f35b60045b36811060b85736600319016004f35b803554815260200160a956fea2646970667358221220512627942425c8edbcef98b81cbc276e61d390569ebbbe4d02fada0666bd202664736f6c634300081c0033643b8a6b3ed8752748bc6461fd4a02b0c30db5660ff05b0028ccebefb6b5f2638faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6730ebf818546cf436ba3e823ca878b84c3d55a00f566d51f4b07ec1ab90533db4e643b8a6b3ed8752748bc6461fd4a02b0c30db5660ff05b0028ccebefb6b5f261a2646970667358221220cc106ff5007fef0bdca75db072c5706d529c5e36ab51a42047d4dc86499244eb64736f6c634300081c00330000000000000000000000005dfd63a79a1179a7f5451143b9fe40a853fb3bf1

Deployed ByteCode

0x60806040526004361015610079575b34610074577f000000000000000000000000e9c87a63d3e24f1cec55f488c2856ca4a78a8e9a306001600160a01b038216146100745760008091604051602081019063fe88866560e01b82526004815261006960248261180b565b51915af41561007457005b600080fd5b60003560e01c80631c7330821461175d5780632b76dc4c146116e8578063356fd835146113a157806352d9492714611344578063775c300c1461129a5780639c3e816614611248578063ca17c397146111c25763fe8886650361000e573461007457600036600319011261007457600080516020611c2583398151915280546001600160a01b03161561115b575b5063356fd83519547f000000000000000000000000e9c87a63d3e24f1cec55f488c2856ca4a78a8e9a600160a01b821015611153575b60409081519061014d838361180b565b60018252601f1983019060005b828110611129575061016b8361192d565b516001600160a01b0382169081905294600060206101888661192d565b5101528451610197868261180b565b6001815283366020830137856101ac8661192d565b51015263356fd83560e01b6101cc866101c48761192d565b51015161192d565b526001600160a01b038116151580611114575b861594856110ff575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b82821061106d5750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a18263356fd8351955611031575b508215610fe05761027463356fd83560e01b600080516020611c45833981519152611968565b505b639c3e81661954600160a01b811015610fda575b838551610297878261180b565b6001815260005b858110610fab5750876102b08261192d565b5152600060206102bf8361192d565b51015286516102ce888261180b565b6001815285366020830137876102e38361192d565b510152634e1f40b360e11b6102fb886101c48461192d565b526001600160a01b03831615159182610f96575b610f81575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610eef5750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a182639c3e81661955610eb3575b508215610e62576103a0634e1f40b360e11b600080516020611c45833981519152611968565b505b631c7330821954600160a01b811015610e5c575b8385516103c3878261180b565b6001815260005b858110610e2d5750876103dc8261192d565b5152600060206103eb8361192d565b51015286516103fa888261180b565b60018152853660208301378761040f8361192d565b510152630e39984160e11b610427886101c48461192d565b526001600160a01b03831615159182610e18575b610e03575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610d715750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a182631c7330821955610d35575b508215610ce4576104cc630e39984160e11b600080516020611c45833981519152611968565b505b6352d949271954600160a01b811015610cde575b8385516104ef878261180b565b6001815260005b858110610caf5750876105088261192d565b5152600060206105178361192d565b5101528651610526888261180b565b60018152853660208301378761053b8361192d565b5101526352d9492760e01b610553886101c48461192d565b526001600160a01b03831615159182610c9a575b610c85575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610bf35750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a1826352d949271955610bb7575b508215610b66576105f86352d9492760e01b600080516020611c45833981519152611968565b505b632b76dc4c1954600160a01b811015610b60575b83855161061b878261180b565b6001815260005b858110610b315750876106348261192d565b5152600060206106438361192d565b5101528651610652888261180b565b6001815285366020830137876106678361192d565b510152630addb71360e21b61067f886101c48461192d565b526001600160a01b03831615159182610b1c575b610b07575b865190606082016060835281518091526080830190602060808260051b8601019301916000905b828210610a755750505050906020600080516020611c05833981519152928a82840152600083820391828c860152520190a182632b76dc4c1955610a39575b5082156109e857610724630addb71360e21b600080516020611c45833981519152611968565b505b63ca17c397195491600160a01b8310156109e0575b845184929161074a878361180b565b6001825260005b8181106109ad5750876107638361192d565b5152600060206107728461192d565b510152865190610782888361180b565b60018252366020830137866107968361192d565b51015263ca17c39760e01b6107ae876101c48461192d565b526001600160a01b03841615159283610998575b610983575b855190606082016060835281518091526080830190602060808260051b8601019301916000905b8282106108dc5750505050906020600080516020611c05833981519152928982840152600083820391828b860152520190a163ca17c39719556108a0575b50156108565750610854905063ca17c39760e01b600080516020611c45833981519152611968565b005b6108549161087963ca17c39760e01b600080516020611c45833981519152611a68565b506000908152600080516020611be58339815191526020522063ca17c39760e01b90611a68565b6001600160a01b03166000908152600080516020611be58339815191526020528290206108d59063ca17c39760e01b90611968565b503861082c565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d578360608f60209460809486839901520151958201528451809452019201906000905b80821061094a575050506020806001929601920192019092916107ee565b82516001600160e01b03191684526020938401939092019160019091019061092c565b634e487b7160e01b600052602160045260246000fd5b600260206109908361192d565b5101526107c7565b600160206109a58461192d565b5101526107c2565b6020919293945087516109bf816117f0565b60008152600083820152606089820152828286010152019085939291610751565b91199161073b565b610a07630addb71360e21b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610a3384600020630addb71360e21b90611a68565b50610726565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610a6e90630addb71360e21b90611968565b50386106fe565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610ae4575050506020806001929601920192019092916106bf565b82516001600160e01b031916845260209384019390920191600190910190610ac6565b60026020610b148361192d565b510152610698565b60016020610b298461192d565b510152610693565b60209192508751610b41816117f0565b6000815260008382015260608982015282828501015201908591610622565b1961060e565b610b856352d9492760e01b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610bb1846000206352d9492760e01b90611a68565b506105fa565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610bec906352d9492760e01b90611968565b50386105d2565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610c6257505050602080600192960192019201909291610593565b82516001600160e01b031916845260209384019390920191600190910190610c44565b60026020610c928361192d565b51015261056c565b60016020610ca78461192d565b510152610567565b60209192508751610cbf816117f0565b60008152600083820152606089820152828285010152019085916104f6565b196104e2565b610d03630e39984160e11b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610d2f84600020630e39984160e11b90611a68565b506104ce565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610d6a90630e39984160e11b90611968565b50386104a6565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610de057505050602080600192960192019201909291610467565b82516001600160e01b031916845260209384019390920191600190910190610dc2565b60026020610e108361192d565b510152610440565b60016020610e258461192d565b51015261043b565b60209192508751610e3d816117f0565b60008152600083820152606089820152828285010152019085916103ca565b196103b6565b610e81634e1f40b360e11b600080516020611c45833981519152611a68565b5084600052600080516020611be5833981519152602052610ead84600020634e1f40b360e11b90611a68565b506103a2565b6001600160a01b03166000908152600080516020611be5833981519152602052849020610ee890634e1f40b360e11b90611968565b503861037a565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b808210610f5e5750505060208060019296019201920190929161033b565b82516001600160e01b031916845260209384019390920191600190910190610f40565b60026020610f8e8361192d565b510152610314565b60016020610fa38461192d565b51015261030f565b60209192508751610fbb816117f0565b600081526000838201526060898201528282850101520190859161029e565b1961028a565b610fff63356fd83560e01b600080516020611c45833981519152611a68565b5084600052600080516020611be583398151915260205261102b8460002063356fd83560e01b90611a68565b50610276565b6001600160a01b03166000908152600080516020611be58339815191526020528490206110669063356fd83560e01b90611968565b503861024e565b90919293607f198682030182528451606082019060018060a01b0381511683526020810151600381101561096d57838f94856020946080948660609401520151958201528451809452019201906000905b8082106110dc5750505060208060019296019201920190929161020f565b82516001600160e01b0319168452602093840193909201916001909101906110be565b6002602061110c8361192d565b5101526101e8565b600160206111218761192d565b5101526101df565b6020908551611137816117f0565b600081526000838201526060878201528282870101520161015a565b90199061013d565b80546001600160a01b0319167f0000000000000000000000005dfd63a79a1179a7f5451143b9fe40a853fb3bf16001600160a01b03169081179091557f94b979b6831a51293e2641426f97747feed46f17779fed9cd18d1ecefcfe92ef600080a238610107565b34610074576020366003190112610074576111db6117da565b6111e361182c565b7f8f688873691912f8fe135293a1e4047b82cd30dddf57571cb75b40a636c8f5d680546001600160a01b0319166001600160a01b039290921691821790557fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f608600080a2005b34610074576020366003190112610074576004356001600160a01b0381168103610074576000809161127861182c565b60405163fe88866560e01b60208201908152600482529061006960248261180b565b34610074576000366003190112610074577f000000000000000000000000086878caccc00930cfe701a7ca26d3094e42b1b86001600160a01b03163303610074576040516101228082018281106001600160401b0382111761132e578291611ac3833903906000f08015611322576001600160a01b0316801561007457602090604051908152f35b6040513d6000823e3d90fd5b634e487b7160e01b600052604160045260246000fd5b346100745760203660031901126100745760043580151581036100745761136961182c565b156113985760ff60015b167fabc3a851eef7cc061af44295e96ff7ea964e5bfdace1a0d992cfec9f50839bdd55005b60ff6000611373565b34610074576040366003190112610074576113ba6117da565b602435906001600160401b0382116100745736602383011215610074578160040135916001600160401b038311610074573660248460051b8301011161007457829061140461182c565b60209260406001600160a01b03821660005b8581101561085457600060248260051b8701013563ffffffff60e01b8116908181036116e45760e01c19805490600160a01b8210156116dc575b86519061145d888361180b565b60018252845b8c81106116b45750866114758361192d565b51528460206114838461192d565b5101528751611492898261180b565b600181528c366020830137886114a78461192d565b510152836114b8896101c48561192d565b526001600160a01b0383161515918261169f575b871561168a575b959493929190899089518a8a60608301606084528b5180915260808401602060808360051b8701019d01918b5b8181106115ce575050505082918960019c60209384600080516020611c058339815191529701528481038093860152520190a1556115a0575b508585611562575061155a9150600080516020611c45833981519152611968565b505b01611416565b61159a9261157e83600080516020611c45833981519152611a68565b50868152600080516020611be583398151915260205220611a68565b5061155c565b848060a01b03168252600080516020611be58339815191526020526115c781878420611968565b508a611539565b935093509395509395969798999a607f19868203018452845160018060a01b03815116825260208101516003811015611676578f839260609260208396015201519282015260206080835192836060820152019201908c905b80821061165357505050602080600192960194019101928c918f9694938f949d9c9b9a9998969d611500565b82516001600160e01b031916845260209384019390920191600190910190611627565b634e487b7160e01b8d52602160045260248dfd5b600260206116978361192d565b5101526114d3565b600160206116ac8361192d565b5101526114cc565b60209089516116c2816117f0565b878152878382015260608b82015282828601015201611463565b901990611450565b8280fd5b34610074576040366003190112610074576117016117da565b602435908115158092036100745761171761182c565b60018060a01b03166000527f1391d08c4b94bb5ee939c8df9f834abd360a89f43ca1e029966eee3f2187784f60205260406000209060ff80198354169116179055600080f35b34610074576020366003190112610074576004356001600160a01b038116908190036100745761178b61182c565b600080516020611c2583398151915280546001600160a01b0319166001600160a01b0383161790557f94b979b6831a51293e2641426f97747feed46f17779fed9cd18d1ecefcfe92ef600080a2005b600435906001600160a01b038216820361007457565b606081019081106001600160401b0382111761132e57604052565b90601f801991011681019081106001600160401b0382111761132e57604052565b604051602081019030825263ffffffff60e01b6000351660408201526024815261185760448261180b565b519020600080516020611c25833981519152546040516326f8aa2160e21b81526004810192909252336024830152306044830152602090829060649082906001600160a01b03165afa908115611322576000916118eb575b50156118b757565b60405162461bcd60e51b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5e995960a21b6044820152606490fd5b6020813d602011611925575b816119046020938361180b565b81010312611921575190811515820361191e5750386118af565b80fd5b5080fd5b3d91506118f7565b80511561193a5760200190565b634e487b7160e01b600052603260045260246000fd5b805482101561193a5760005260206000200190600090565b9060018201918160005282602052604060002054801515600014611a5f576000198101818111611a49578254600019810191908211611a49578082036119fb575b505050805480156119e55760001901906119c38282611950565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b611a32611a0b611a1b9386611950565b90549060031b1c92839286611950565b819391549060031b91821b91600019901b19161790565b9055600052836020526040600020553880806119a9565b634e487b7160e01b600052601160045260246000fd5b50505050600090565b6001810190826000528160205260406000205415600014611aba578054600160401b81101561132e57611aa5611a1b826001879401855584611950565b90555491600052602052604060002055600190565b50505060009056fe6080604052346022576000808080335af41560225760405160fa90816100288239f35b600080fdfe608060405236600a57005b60003560e01c6372656164811460a65763766965778114608657195480602f57600080fd5b600160a01b8110606b57637669657760e01b600052196004523660006024376000806024360181305af43d6000803e6066573d6000f35b3d6000fd5b60008091368280378136915af43d6000803e156066573d6000f35b60008036602319018060248337816004355af43d6000803e6066573d6000f35b60045b36811060b85736600319016004f35b803554815260200160a956fea2646970667358221220512627942425c8edbcef98b81cbc276e61d390569ebbbe4d02fada0666bd202664736f6c634300081c0033643b8a6b3ed8752748bc6461fd4a02b0c30db5660ff05b0028ccebefb6b5f2638faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6730ebf818546cf436ba3e823ca878b84c3d55a00f566d51f4b07ec1ab90533db4e643b8a6b3ed8752748bc6461fd4a02b0c30db5660ff05b0028ccebefb6b5f261a2646970667358221220cc106ff5007fef0bdca75db072c5706d529c5e36ab51a42047d4dc86499244eb64736f6c634300081c0033