ETH Price: $3,386.86 (+1.24%)

Contract

0xec857E00E7E50273724Cb027f852f871B1FeF50E
 

Overview

ETH Balance

0.23485 ETH

Eth Value

$795.40 (@ $3,386.86/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Distribute Payou...187943072023-12-15 21:52:11378 days ago1702677131IN
0xec857E00...1B1FeF50E
0 ETH0.0103159571.77313005
Distribute Payou...187942942023-12-15 21:49:35378 days ago1702676975IN
0xec857E00...1B1FeF50E
0 ETH0.0135431984.20815519
Pay175251642023-06-21 2:48:35556 days ago1687315715IN
0xec857E00...1B1FeF50E
0.001 ETH0.00356413.18019794
Pay175173952023-06-20 0:37:47557 days ago1687221467IN
0xec857E00...1B1FeF50E
0.0001 ETH0.0037584613.05421896
Pay175033822023-06-18 1:24:59559 days ago1687051499IN
0xec857E00...1B1FeF50E
0.01 ETH0.0044704513.88170413

Latest 7 internal transactions

Advanced mode:
Parent Transaction Hash Block
From
To
187943072023-12-15 21:52:11378 days ago1702677131
0xec857E00...1B1FeF50E
0.08125 ETH
187942942023-12-15 21:49:35378 days ago1702676975
0xec857E00...1B1FeF50E
3.25 ETH
178495972023-08-05 15:15:23511 days ago1691248523
0xec857E00...1B1FeF50E
0.025 ETH
176607172023-07-10 3:52:35537 days ago1688961155
0xec857E00...1B1FeF50E
0.01 ETH
176607162023-07-10 3:52:23537 days ago1688961143
0xec857E00...1B1FeF50E
0.01 ETH
176607142023-07-10 3:51:59537 days ago1688961119
0xec857E00...1B1FeF50E
0.01 ETH
175659782023-06-26 20:30:47550 days ago1687811447
0xec857E00...1B1FeF50E
3.5 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
JBETHPaymentTerminal

Compiler Version
v0.8.16+commit.07a7930e

Optimization Enabled:
Yes with 400 runs

Other Settings:
default evmVersion
File 1 of 62 : JBETHPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/Address.sol';
import './abstract/JBPayoutRedemptionPaymentTerminal.sol';
import './libraries/JBSplitsGroups.sol';

/**
  @notice
  Manages all inflows and outflows of ETH funds into the protocol ecosystem.

  @dev
  Inherits from -
  JBPayoutRedemptionPaymentTerminal: Generic terminal managing all inflows and outflows of funds into the protocol ecosystem.
*/
contract JBETHPaymentTerminal is JBPayoutRedemptionPaymentTerminal {
  //*********************************************************************//
  // -------------------------- internal views ------------------------- //
  //*********************************************************************//

  /** 
    @notice
    Checks the balance of tokens in this contract.

    @return The contract's balance, as a fixed point number with the same amount of decimals as this terminal.
  */
  function _balance() internal view override returns (uint256) {
    return address(this).balance;
  }

  //*********************************************************************//
  // -------------------------- constructor ---------------------------- //
  //*********************************************************************//

  /**
    @param _baseWeightCurrency The currency to base token issuance on.
    @param _operatorStore A contract storing operator assignments.
    @param _projects A contract which mints ERC-721's that represent project ownership and transfers.
    @param _directory A contract storing directories of terminals and controllers for each project.
    @param _splitsStore A contract that stores splits for each project.
    @param _prices A contract that exposes price feeds.
    @param _store A contract that stores the terminal's data.
    @param _owner The address that will own this contract.
  */
  constructor(
    uint256 _baseWeightCurrency,
    IJBOperatorStore _operatorStore,
    IJBProjects _projects,
    IJBDirectory _directory,
    IJBSplitsStore _splitsStore,
    IJBPrices _prices,
    IJBSingleTokenPaymentTerminalStore _store,
    address _owner
  )
    JBPayoutRedemptionPaymentTerminal(
      JBTokens.ETH,
      18, // 18 decimals.
      JBCurrencies.ETH,
      _baseWeightCurrency,
      JBSplitsGroups.ETH_PAYOUT,
      _operatorStore,
      _projects,
      _directory,
      _splitsStore,
      _prices,
      _store,
      _owner
    )
  // solhint-disable-next-line no-empty-blocks
  {

  }

  //*********************************************************************//
  // ---------------------- internal transactions ---------------------- //
  //*********************************************************************//

  /** 
    @notice
    Transfers tokens.

    @param _from The address from which the transfer should originate.
    @param _to The address to which the transfer should go.
    @param _amount The amount of the transfer, as a fixed point number with the same number of decimals as this terminal.
  */
  function _transferFrom(
    address _from,
    address payable _to,
    uint256 _amount
  ) internal override {
    _from; // Prevents unused var compiler and natspec complaints.

    Address.sendValue(_to, _amount);
  }
}

File 2 of 62 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 62 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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);
}

File 4 of 62 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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
     * ====
     *
     * [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://diligence.consensys.net/posts/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.5.11/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);
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

File 6 of 62 : 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;
    }
}

File 7 of 62 : 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);
}

File 8 of 62 : PRBMath.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;

import "prb-math/contracts/PRBMath.sol";

File 9 of 62 : JBOperatable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../interfaces/IJBOperatable.sol';

/** 
  @notice
  Modifiers to allow access to functions based on the message sender's operator status.

  @dev
  Adheres to -
  IJBOperatable: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.
*/
abstract contract JBOperatable is IJBOperatable {
  //*********************************************************************//
  // --------------------------- custom errors -------------------------- //
  //*********************************************************************//
  error UNAUTHORIZED();

  //*********************************************************************//
  // ---------------------------- modifiers ---------------------------- //
  //*********************************************************************//

  /** 
    @notice
    Only allows the speficied account or an operator of the account to proceed. 

    @param _account The account to check for.
    @param _domain The domain namespace to look for an operator within. 
    @param _permissionIndex The index of the permission to check for. 
  */
  modifier requirePermission(
    address _account,
    uint256 _domain,
    uint256 _permissionIndex
  ) {
    _requirePermission(_account, _domain, _permissionIndex);
    _;
  }

  /** 
    @notice
    Only allows the speficied account, an operator of the account to proceed, or a truthy override flag. 

    @param _account The account to check for.
    @param _domain The domain namespace to look for an operator within. 
    @param _permissionIndex The index of the permission to check for. 
    @param _override A condition to force allowance for.
  */
  modifier requirePermissionAllowingOverride(
    address _account,
    uint256 _domain,
    uint256 _permissionIndex,
    bool _override
  ) {
    _requirePermissionAllowingOverride(_account, _domain, _permissionIndex, _override);
    _;
  }

  //*********************************************************************//
  // ---------------- public immutable stored properties --------------- //
  //*********************************************************************//

  /** 
    @notice 
    A contract storing operator assignments.
  */
  IJBOperatorStore public override operatorStore;

  //*********************************************************************//
  // -------------------------- internal views ------------------------- //
  //*********************************************************************//

  /** 
    @notice
    Require the message sender is either the account or has the specified permission.

    @param _account The account to allow.
    @param _domain The domain namespace within which the permission index will be checked.
    @param _permissionIndex The permission index that an operator must have within the specified domain to be allowed.
  */
  function _requirePermission(
    address _account,
    uint256 _domain,
    uint256 _permissionIndex
  ) internal view {
    if (
      msg.sender != _account &&
      !operatorStore.hasPermission(msg.sender, _account, _domain, _permissionIndex) &&
      !operatorStore.hasPermission(msg.sender, _account, 0, _permissionIndex)
    ) revert UNAUTHORIZED();
  }

  /** 
    @notice
    Require the message sender is either the account, has the specified permission, or the override condition is true.

    @param _account The account to allow.
    @param _domain The domain namespace within which the permission index will be checked.
    @param _domain The permission index that an operator must have within the specified domain to be allowed.
    @param _override The override condition to allow.
  */
  function _requirePermissionAllowingOverride(
    address _account,
    uint256 _domain,
    uint256 _permissionIndex,
    bool _override
  ) internal view {
    if (
      !_override &&
      msg.sender != _account &&
      !operatorStore.hasPermission(msg.sender, _account, _domain, _permissionIndex) &&
      !operatorStore.hasPermission(msg.sender, _account, 0, _permissionIndex)
    ) revert UNAUTHORIZED();
  }
}

File 10 of 62 : JBPayoutRedemptionPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@paulrberg/contracts/math/PRBMath.sol';
import './../interfaces/IJBController.sol';
import './../interfaces/IJBPayoutRedemptionPaymentTerminal.sol';
import './../libraries/JBConstants.sol';
import './../libraries/JBCurrencies.sol';
import './../libraries/JBFixedPointNumber.sol';
import './../libraries/JBFundingCycleMetadataResolver.sol';
import './../libraries/JBOperations.sol';
import './../libraries/JBTokens.sol';
import './../structs/JBPayDelegateAllocation.sol';
import './../structs/JBTokenAmount.sol';
import './JBOperatable.sol';
import './JBSingleTokenPaymentTerminal.sol';

/**
  @notice
  Generic terminal managing all inflows and outflows of funds into the protocol ecosystem.

  @dev
  A project can transfer its funds, along with the power to reconfigure and mint/burn their tokens, from this contract to another allowed terminal of the same token type contract at any time.

  @dev
  Adheres to -
  IJBPayoutRedemptionPaymentTerminal: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.

  @dev
  Inherits from -
  JBSingleTokenPaymentTerminal: Generic terminal managing all inflows of funds into the protocol ecosystem for one token.
  JBOperatable: Includes convenience functionality for checking a message sender's permissions before executing certain transactions.
  Ownable: Includes convenience functionality for checking a message sender's permissions before executing certain transactions.
*/
abstract contract JBPayoutRedemptionPaymentTerminal is
  JBSingleTokenPaymentTerminal,
  JBOperatable,
  Ownable,
  IJBPayoutRedemptionPaymentTerminal
{
  // A library that parses the packed funding cycle metadata into a friendlier format.
  using JBFundingCycleMetadataResolver for JBFundingCycle;

  //*********************************************************************//
  // --------------------------- custom errors ------------------------- //
  //*********************************************************************//
  error FEE_TOO_HIGH();
  error INADEQUATE_DISTRIBUTION_AMOUNT();
  error INADEQUATE_RECLAIM_AMOUNT();
  error INADEQUATE_TOKEN_COUNT();
  error NO_MSG_VALUE_ALLOWED();
  error PAY_TO_ZERO_ADDRESS();
  error PROJECT_TERMINAL_MISMATCH();
  error REDEEM_TO_ZERO_ADDRESS();
  error TERMINAL_IN_SPLIT_ZERO_ADDRESS();
  error TERMINAL_TOKENS_INCOMPATIBLE();

  //*********************************************************************//
  // ---------------------------- modifiers ---------------------------- //
  //*********************************************************************//

  /** 
    @notice 
    A modifier that verifies this terminal is a terminal of provided project ID.
  */
  modifier isTerminalOf(uint256 _projectId) {
    if (!directory.isTerminalOf(_projectId, this)) revert PROJECT_TERMINAL_MISMATCH();
    _;
  }

  //*********************************************************************//
  // --------------------- internal stored constants ------------------- //
  //*********************************************************************//

  /**
    @notice
    Maximum fee that can be set for a funding cycle configuration.

    @dev
    Out of MAX_FEE (100_000_000 / 1_000_000_000).
  */
  uint256 internal constant _FEE_CAP = 100_000_000;

  /**
    @notice
    The fee beneficiary project ID is 1, as it should be the first project launched during the deployment process.
  */
  uint256 internal constant _FEE_BENEFICIARY_PROJECT_ID = 1;

  //*********************************************************************//
  // --------------------- internal stored properties ------------------ //
  //*********************************************************************//

  /**
    @notice
    Fees that are being held to be processed later.

    _projectId The ID of the project for which fees are being held.
  */
  mapping(uint256 => JBFee[]) internal _heldFeesOf;

  //*********************************************************************//
  // ---------------- public immutable stored properties --------------- //
  //*********************************************************************//

  /**
    @notice
    Mints ERC-721's that represent project ownership and transfers.
  */
  IJBProjects public immutable override projects;

  /**
    @notice
    The directory of terminals and controllers for projects.
  */
  IJBDirectory public immutable override directory;

  /**
    @notice
    The contract that stores splits for each project.
  */
  IJBSplitsStore public immutable override splitsStore;

  /**
    @notice
    The contract that exposes price feeds.
  */
  IJBPrices public immutable override prices;

  /**
    @notice
    The contract that stores and manages the terminal's data.
  */
  IJBSingleTokenPaymentTerminalStore public immutable override store;

  /**
    @notice
    The currency to base token issuance on.

    @dev
    If this differs from `currency`, there must be a price feed available to convert `currency` to `baseWeightCurrency`.
  */
  uint256 public immutable override baseWeightCurrency;

  /**
    @notice
    The group that payout splits coming from this terminal are identified by.
  */
  uint256 public immutable override payoutSplitsGroup;

  //*********************************************************************//
  // --------------------- public stored properties -------------------- //
  //*********************************************************************//

  /**
    @notice
    The platform fee percent.

    @dev
    Out of MAX_FEE (50_000_000 / 1_000_000_000)
  */
  uint256 public override fee = 50_000_000; // 5%

  /**
    @notice
    The data source that returns a discount to apply to a project's fee.
  */
  IJBFeeGauge public override feeGauge;

  /**
    @notice
    Addresses that can be paid towards from this terminal without incurring a fee.

    @dev
    Only addresses that are considered to be contained within the ecosystem can be feeless. Funds sent outside the ecosystem may incur fees despite being stored as feeless.

    _address The address that can be paid toward.
  */
  mapping(address => bool) public override isFeelessAddress;

  //*********************************************************************//
  // ------------------------- external views -------------------------- //
  //*********************************************************************//

  /**
    @notice
    Gets the current overflowed amount in this terminal for a specified project, in terms of ETH.

    @dev
    The current overflow is represented as a fixed point number with 18 decimals.

    @param _projectId The ID of the project to get overflow for.

    @return The current amount of ETH overflow that project has in this terminal, as a fixed point number with 18 decimals.
  */
  function currentEthOverflowOf(
    uint256 _projectId
  ) external view virtual override returns (uint256) {
    // Get this terminal's current overflow.
    uint256 _overflow = store.currentOverflowOf(this, _projectId);

    // Adjust the decimals of the fixed point number if needed to have 18 decimals.
    uint256 _adjustedOverflow = (decimals == 18)
      ? _overflow
      : JBFixedPointNumber.adjustDecimals(_overflow, decimals, 18);

    // Return the amount converted to ETH.
    return
      (currency == JBCurrencies.ETH)
        ? _adjustedOverflow
        : PRBMath.mulDiv(
          _adjustedOverflow,
          10 ** decimals,
          prices.priceFor(currency, JBCurrencies.ETH, decimals)
        );
  }

  /**
    @notice
    The fees that are currently being held to be processed later for each project.

    @param _projectId The ID of the project for which fees are being held.

    @return An array of fees that are being held.
  */
  function heldFeesOf(uint256 _projectId) external view override returns (JBFee[] memory) {
    return _heldFeesOf[_projectId];
  }

  //*********************************************************************//
  // -------------------------- public views --------------------------- //
  //*********************************************************************//

  /**
    @notice
    Indicates if this contract adheres to the specified interface.

    @dev 
    See {IERC165-supportsInterface}.

    @param _interfaceId The ID of the interface to check for adherance to.
  */
  function supportsInterface(
    bytes4 _interfaceId
  ) public view virtual override(JBSingleTokenPaymentTerminal, IERC165) returns (bool) {
    return
      _interfaceId == type(IJBPayoutRedemptionPaymentTerminal).interfaceId ||
      _interfaceId == type(IJBPayoutTerminal).interfaceId ||
      _interfaceId == type(IJBAllowanceTerminal).interfaceId ||
      _interfaceId == type(IJBRedemptionTerminal).interfaceId ||
      _interfaceId == type(IJBOperatable).interfaceId ||
      super.supportsInterface(_interfaceId);
  }

  //*********************************************************************//
  // -------------------------- internal views ------------------------- //
  //*********************************************************************//

  /** 
    @notice
    Checks the balance of tokens in this contract.

    @return The contract's balance.
  */
  function _balance() internal view virtual returns (uint256);

  //*********************************************************************//
  // -------------------------- constructor ---------------------------- //
  //*********************************************************************//

  /**
    @param _token The token that this terminal manages.
    @param _decimals The number of decimals the token fixed point amounts are expected to have.
    @param _currency The currency that this terminal's token adheres to for price feeds.
    @param _baseWeightCurrency The currency to base token issuance on.
    @param _payoutSplitsGroup The group that denotes payout splits from this terminal in the splits store.
    @param _operatorStore A contract storing operator assignments.
    @param _projects A contract which mints ERC-721's that represent project ownership and transfers.
    @param _directory A contract storing directories of terminals and controllers for each project.
    @param _splitsStore A contract that stores splits for each project.
    @param _prices A contract that exposes price feeds.
    @param _store A contract that stores the terminal's data.
    @param _owner The address that will own this contract.
  */
  constructor(
    // payable constructor save the gas used to check msg.value==0
    address _token,
    uint256 _decimals,
    uint256 _currency,
    uint256 _baseWeightCurrency,
    uint256 _payoutSplitsGroup,
    IJBOperatorStore _operatorStore,
    IJBProjects _projects,
    IJBDirectory _directory,
    IJBSplitsStore _splitsStore,
    IJBPrices _prices,
    IJBSingleTokenPaymentTerminalStore _store,
    address _owner
  ) payable JBSingleTokenPaymentTerminal(_token, _decimals, _currency) {
    operatorStore = _operatorStore; // JBOperatable

    baseWeightCurrency = _baseWeightCurrency;
    payoutSplitsGroup = _payoutSplitsGroup;
    projects = _projects;
    directory = _directory;
    splitsStore = _splitsStore;
    prices = _prices;
    store = _store;

    transferOwnership(_owner);
  }

  //*********************************************************************//
  // ---------------------- external transactions ---------------------- //
  //*********************************************************************//

  /**
    @notice
    Contribute tokens to a project.

    @param _projectId The ID of the project being paid.
    @param _amount The amount of terminal tokens being received, as a fixed point number with the same amount of decimals as this terminal. If this terminal's token is ETH, this is ignored and msg.value is used in its place.
    @param _token The token being paid. This terminal ignores this property since it only manages one token. 
    @param _beneficiary The address to mint tokens for and pass along to the funding cycle's data source and delegate.
    @param _minReturnedTokens The minimum number of project tokens expected in return, as a fixed point number with the same amount of decimals as this terminal.
    @param _preferClaimedTokens A flag indicating whether the request prefers to mint project tokens into the beneficiaries wallet rather than leaving them unclaimed. This is only possible if the project has an attached token contract. Leaving them unclaimed saves gas.
    @param _memo A memo to pass along to the emitted event, and passed along the the funding cycle's data source and delegate.  A data source can alter the memo before emitting in the event and forwarding to the delegate.
    @param _metadata Bytes to send along to the data source, delegate, and emitted event, if provided.

    @return The number of tokens minted for the beneficiary, as a fixed point number with 18 decimals.
  */
  function pay(
    uint256 _projectId,
    uint256 _amount,
    address _token,
    address _beneficiary,
    uint256 _minReturnedTokens,
    bool _preferClaimedTokens,
    string calldata _memo,
    bytes calldata _metadata
  ) external payable virtual override isTerminalOf(_projectId) returns (uint256) {
    _token; // Prevents unused var compiler and natspec complaints.

    // ETH shouldn't be sent if this terminal's token isn't ETH.
    if (token != JBTokens.ETH) {
      if (msg.value > 0) revert NO_MSG_VALUE_ALLOWED();

      // Get a reference to the balance before receiving tokens.
      uint256 _balanceBefore = _balance();

      // Transfer tokens to this terminal from the msg sender.
      _transferFrom(msg.sender, payable(address(this)), _amount);

      // The amount should reflect the change in balance.
      _amount = _balance() - _balanceBefore;
    }
    // If this terminal's token is ETH, override _amount with msg.value.
    else _amount = msg.value;

    return
      _pay(
        _amount,
        msg.sender,
        _projectId,
        _beneficiary,
        _minReturnedTokens,
        _preferClaimedTokens,
        _memo,
        _metadata
      );
  }

  /**
    @notice
    Holders can redeem their tokens to claim the project's overflowed tokens, or to trigger rules determined by the project's current funding cycle's data source.

    @dev
    Only a token holder or a designated operator can redeem its tokens.

    @param _holder The account to redeem tokens for.
    @param _projectId The ID of the project to which the tokens being redeemed belong.
    @param _tokenCount The number of project tokens to redeem, as a fixed point number with 18 decimals.
    @param _token The token being reclaimed. This terminal ignores this property since it only manages one token. 
    @param _minReturnedTokens The minimum amount of terminal tokens expected in return, as a fixed point number with the same amount of decimals as the terminal.
    @param _beneficiary The address to send the terminal tokens to.
    @param _memo A memo to pass along to the emitted event.
    @param _metadata Bytes to send along to the data source, delegate, and emitted event, if provided.

    @return reclaimAmount The amount of terminal tokens that the project tokens were redeemed for, as a fixed point number with 18 decimals.
  */
  function redeemTokensOf(
    address _holder,
    uint256 _projectId,
    uint256 _tokenCount,
    address _token,
    uint256 _minReturnedTokens,
    address payable _beneficiary,
    string memory _memo,
    bytes memory _metadata
  )
    external
    virtual
    override
    requirePermission(_holder, _projectId, JBOperations.REDEEM)
    returns (uint256 reclaimAmount)
  {
    _token; // Prevents unused var compiler and natspec complaints.

    return
      _redeemTokensOf(
        _holder,
        _projectId,
        _tokenCount,
        _minReturnedTokens,
        _beneficiary,
        _memo,
        _metadata
      );
  }

  /**
    @notice
    Distributes payouts for a project with the distribution limit of its current funding cycle.

    @dev
    Payouts are sent to the preprogrammed splits. Any leftover is sent to the project's owner.

    @dev
    Anyone can distribute payouts on a project's behalf. The project can preconfigure a wildcard split that is used to send funds to msg.sender. This can be used to incentivize calling this function.

    @dev
    All funds distributed outside of this contract or any feeless terminals incure the protocol fee.

    @param _projectId The ID of the project having its payouts distributed.
    @param _amount The amount of terminal tokens to distribute, as a fixed point number with same number of decimals as this terminal.
    @param _currency The expected currency of the amount being distributed. Must match the project's current funding cycle's distribution limit currency.
    @param _token The token being distributed. This terminal ignores this property since it only manages one token. 
    @param _minReturnedTokens The minimum number of terminal tokens that the `_amount` should be valued at in terms of this terminal's currency, as a fixed point number with the same number of decimals as this terminal.
    @param _memo A memo to pass along to the emitted event.

    @return netLeftoverDistributionAmount The amount that was sent to the project owner, as a fixed point number with the same amount of decimals as this terminal.
  */
  function distributePayoutsOf(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency,
    address _token,
    uint256 _minReturnedTokens,
    string calldata _memo
  ) external virtual override returns (uint256 netLeftoverDistributionAmount) {
    _token; // Prevents unused var compiler and natspec complaints.

    return _distributePayoutsOf(_projectId, _amount, _currency, _minReturnedTokens, _memo);
  }

  /**
    @notice
    Allows a project to send funds from its overflow up to the preconfigured allowance.

    @dev
    Only a project's owner or a designated operator can use its allowance.

    @dev
    Incurs the protocol fee.

    @param _projectId The ID of the project to use the allowance of.
    @param _amount The amount of terminal tokens to use from this project's current allowance, as a fixed point number with the same amount of decimals as this terminal.
    @param _currency The expected currency of the amount being distributed. Must match the project's current funding cycle's overflow allowance currency.
    @param _token The token being distributed. This terminal ignores this property since it only manages one token. 
    @param _minReturnedTokens The minimum number of tokens that the `_amount` should be valued at in terms of this terminal's currency, as a fixed point number with 18 decimals.
    @param _beneficiary The address to send the funds to.
    @param _memo A memo to pass along to the emitted event.

    @return netDistributedAmount The amount of tokens that was distributed to the beneficiary, as a fixed point number with the same amount of decimals as the terminal.
  */
  function useAllowanceOf(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency,
    address _token,
    uint256 _minReturnedTokens,
    address payable _beneficiary,
    string memory _memo
  )
    external
    virtual
    override
    requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.USE_ALLOWANCE)
    returns (uint256 netDistributedAmount)
  {
    _token; // Prevents unused var compiler and natspec complaints.

    return _useAllowanceOf(_projectId, _amount, _currency, _minReturnedTokens, _beneficiary, _memo);
  }

  /**
    @notice
    Allows a project owner to migrate its funds and operations to a new terminal that accepts the same token type.

    @dev
    Only a project's owner or a designated operator can migrate it.

    @param _projectId The ID of the project being migrated.
    @param _to The terminal contract that will gain the project's funds.

    @return balance The amount of funds that were migrated, as a fixed point number with the same amount of decimals as this terminal.
  */
  function migrate(
    uint256 _projectId,
    IJBPaymentTerminal _to
  )
    external
    virtual
    override
    requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.MIGRATE_TERMINAL)
    returns (uint256 balance)
  {
    // The terminal being migrated to must accept the same token as this terminal.
    if (!_to.acceptsToken(token, _projectId)) revert TERMINAL_TOKENS_INCOMPATIBLE();

    // Record the migration in the store.
    balance = store.recordMigration(_projectId);

    // Transfer the balance if needed.
    if (balance > 0) {
      // Trigger any inherited pre-transfer logic.
      _beforeTransferTo(address(_to), balance);

      // If this terminal's token is ETH, send it in msg.value.
      uint256 _payableValue = token == JBTokens.ETH ? balance : 0;

      // Withdraw the balance to transfer to the new terminal;
      _to.addToBalanceOf{value: _payableValue}(_projectId, balance, token, '', bytes(''));
    }

    emit Migrate(_projectId, _to, balance, msg.sender);
  }

  /**
    @notice
    Receives funds belonging to the specified project.

    @param _projectId The ID of the project to which the funds received belong.
    @param _amount The amount of tokens to add, as a fixed point number with the same number of decimals as this terminal. If this is an ETH terminal, this is ignored and msg.value is used instead.
    @param _token The token being paid. This terminal ignores this property since it only manages one currency. 
    @param _memo A memo to pass along to the emitted event.
    @param _metadata Extra data to pass along to the emitted event.
  */
  function addToBalanceOf(
    uint256 _projectId,
    uint256 _amount,
    address _token,
    string calldata _memo,
    bytes calldata _metadata
  ) external payable virtual override isTerminalOf(_projectId) {
    _token; // Prevents unused var compiler and natspec complaints.

    // If this terminal's token isn't ETH, make sure no msg.value was sent, then transfer the tokens in from msg.sender.
    if (token != JBTokens.ETH) {
      // Amount must be greater than 0.
      if (msg.value > 0) revert NO_MSG_VALUE_ALLOWED();

      // Get a reference to the balance before receiving tokens.
      uint256 _balanceBefore = _balance();

      // Transfer tokens to this terminal from the msg sender.
      _transferFrom(msg.sender, payable(address(this)), _amount);

      // The amount should reflect the change in balance.
      _amount = _balance() - _balanceBefore;
    }
    // If the terminal's token is ETH, override `_amount` with msg.value.
    else _amount = msg.value;

    // Add to balance while only refunding held fees if the funds aren't originating from a feeless terminal.
    _addToBalanceOf(_projectId, _amount, !isFeelessAddress[msg.sender], _memo, _metadata);
  }

  /**
    @notice
    Process any fees that are being held for the project.

    @dev
    Only a project owner, an operator, or the contract's owner can process held fees.

    @param _projectId The ID of the project whos held fees should be processed.
  */
  function processFees(
    uint256 _projectId
  )
    external
    virtual
    override
    requirePermissionAllowingOverride(
      projects.ownerOf(_projectId),
      _projectId,
      JBOperations.PROCESS_FEES,
      msg.sender == owner()
    )
  {
    // Get a reference to the project's held fees.
    JBFee[] memory _heldFees = _heldFeesOf[_projectId];

    // Delete the held fees.
    delete _heldFeesOf[_projectId];

    // Push array length in stack
    uint256 _heldFeeLength = _heldFees.length;

    // Process each fee.
    for (uint256 _i; _i < _heldFeeLength; ) {
      // Get the fee amount.
      uint256 _amount = _feeAmount(
        _heldFees[_i].amount,
        _heldFees[_i].fee,
        _heldFees[_i].feeDiscount
      );

      // Process the fee.
      _processFee(_amount, _heldFees[_i].beneficiary);

      emit ProcessFee(_projectId, _amount, true, _heldFees[_i].beneficiary, msg.sender);

      unchecked {
        ++_i;
      }
    }
  }

  /**
    @notice
    Allows the fee to be updated.

    @dev
    Only the owner of this contract can change the fee.

    @param _fee The new fee, out of MAX_FEE.
  */
  function setFee(uint256 _fee) external virtual override onlyOwner {
    // The provided fee must be within the max.
    if (_fee > _FEE_CAP) revert FEE_TOO_HIGH();

    // Store the new fee.
    fee = _fee;

    emit SetFee(_fee, msg.sender);
  }

  /**
    @notice
    Allows the fee gauge to be updated.

    @dev
    Only the owner of this contract can change the fee gauge.

    @param _feeGauge The new fee gauge.
  */
  function setFeeGauge(IJBFeeGauge _feeGauge) external virtual override onlyOwner {
    // Store the new fee gauge.
    feeGauge = _feeGauge;

    emit SetFeeGauge(_feeGauge, msg.sender);
  }

  /**
    @notice
    Sets whether projects operating on this terminal can pay towards the specified address without incurring a fee.

    @dev
    Only the owner of this contract can set addresses as feeless.

    @param _address The address that can be paid towards while still bypassing fees.
    @param _flag A flag indicating whether the terminal should be feeless or not.
  */
  function setFeelessAddress(address _address, bool _flag) external virtual override onlyOwner {
    // Set the flag value.
    isFeelessAddress[_address] = _flag;

    emit SetFeelessAddress(_address, _flag, msg.sender);
  }

  //*********************************************************************//
  // ---------------------- internal transactions ---------------------- //
  //*********************************************************************//

  /** 
    @notice
    Transfers tokens.

    @param _from The address from which the transfer should originate.
    @param _to The address to which the transfer should go.
    @param _amount The amount of the transfer, as a fixed point number with the same number of decimals as this terminal.
  */
  function _transferFrom(address _from, address payable _to, uint256 _amount) internal virtual {
    _from; // Prevents unused var compiler and natspec complaints.
    _to; // Prevents unused var compiler and natspec complaints.
    _amount; // Prevents unused var compiler and natspec complaints.
  }

  /** 
    @notice
    Logic to be triggered before transferring tokens from this terminal.

    @param _to The address to which the transfer is going.
    @param _amount The amount of the transfer, as a fixed point number with the same number of decimals as this terminal.
  */
  function _beforeTransferTo(address _to, uint256 _amount) internal virtual {
    _to; // Prevents unused var compiler and natspec complaints.
    _amount; // Prevents unused var compiler and natspec complaints.
  }

  /**
    @notice
    Holders can redeem their tokens to claim the project's overflowed tokens, or to trigger rules determined by the project's current funding cycle's data source.

    @dev
    Only a token holder or a designated operator can redeem its tokens.

    @param _holder The account to redeem tokens for.
    @param _projectId The ID of the project to which the tokens being redeemed belong.
    @param _tokenCount The number of project tokens to redeem, as a fixed point number with 18 decimals.
    @param _minReturnedTokens The minimum amount of terminal tokens expected in return, as a fixed point number with the same amount of decimals as the terminal.
    @param _beneficiary The address to send the terminal tokens to.
    @param _memo A memo to pass along to the emitted event.
    @param _metadata Bytes to send along to the data source, delegate, and emitted event, if provided.

    @return reclaimAmount The amount of terminal tokens that the project tokens were redeemed for, as a fixed point number with 18 decimals.
  */
  function _redeemTokensOf(
    address _holder,
    uint256 _projectId,
    uint256 _tokenCount,
    uint256 _minReturnedTokens,
    address payable _beneficiary,
    string memory _memo,
    bytes memory _metadata
  ) internal returns (uint256 reclaimAmount) {
    // Can't send reclaimed funds to the zero address.
    if (_beneficiary == address(0)) revert REDEEM_TO_ZERO_ADDRESS();

    // Define variables that will be needed outside the scoped section below.
    // Keep a reference to the funding cycle during which the redemption is being made.
    JBFundingCycle memory _fundingCycle;

    // Scoped section prevents stack too deep. `_delegateAllocations` only used within scope.
    {
      JBRedemptionDelegateAllocation[] memory _delegateAllocations;

      // Record the redemption.
      (_fundingCycle, reclaimAmount, _delegateAllocations, _memo) = store.recordRedemptionFor(
        _holder,
        _projectId,
        _tokenCount,
        _memo,
        _metadata
      );

      // The amount being reclaimed must be at least as much as was expected.
      if (reclaimAmount < _minReturnedTokens) revert INADEQUATE_RECLAIM_AMOUNT();

      // Burn the project tokens.
      if (_tokenCount > 0)
        IJBController(directory.controllerOf(_projectId)).burnTokensOf(
          _holder,
          _projectId,
          _tokenCount,
          '',
          false
        );

      // If delegate allocations were specified by the data source, fulfill them.
      if (_delegateAllocations.length != 0) {
        // Keep a reference to the token amount being forwarded to the delegate.
        JBTokenAmount memory _forwardedAmount = JBTokenAmount(token, 0, decimals, currency);

        JBDidRedeemData memory _data = JBDidRedeemData(
          _holder,
          _projectId,
          _fundingCycle.configuration,
          _tokenCount,
          JBTokenAmount(token, reclaimAmount, decimals, currency),
          _forwardedAmount,
          _beneficiary,
          _memo,
          _metadata
        );

        uint256 _numDelegates = _delegateAllocations.length;

        for (uint256 _i; _i < _numDelegates; ) {
          // Get a reference to the delegate being iterated on.
          JBRedemptionDelegateAllocation memory _delegateAllocation = _delegateAllocations[_i];

          // Trigger any inherited pre-transfer logic.
          _beforeTransferTo(address(_delegateAllocation.delegate), _delegateAllocation.amount);

          // Keep track of the msg.value to use in the delegate call
          uint256 _payableValue;

          // If this terminal's token is ETH, send it in msg.value.
          if (token == JBTokens.ETH) _payableValue = _delegateAllocation.amount;

          // Pass the correct token forwardedAmount to the delegate
          _data.forwardedAmount.value = _delegateAllocation.amount;

          _delegateAllocation.delegate.didRedeem{value: _payableValue}(_data);

          emit DelegateDidRedeem(
            _delegateAllocation.delegate,
            _data,
            _delegateAllocation.amount,
            msg.sender
          );
          unchecked {
            ++_i;
          }
        }
      }
    }

    // Send the reclaimed funds to the beneficiary.
    if (reclaimAmount > 0) _transferFrom(address(this), _beneficiary, reclaimAmount);

    emit RedeemTokens(
      _fundingCycle.configuration,
      _fundingCycle.number,
      _projectId,
      _holder,
      _beneficiary,
      _tokenCount,
      reclaimAmount,
      _memo,
      _metadata,
      msg.sender
    );
  }

  /**
    @notice
    Distributes payouts for a project with the distribution limit of its current funding cycle.

    @dev
    Payouts are sent to the preprogrammed splits. Any leftover is sent to the project's owner.

    @dev
    Anyone can distribute payouts on a project's behalf. The project can preconfigure a wildcard split that is used to send funds to msg.sender. This can be used to incentivize calling this function.

    @dev
    All funds distributed outside of this contract or any feeless terminals incure the protocol fee.

    @param _projectId The ID of the project having its payouts distributed.
    @param _amount The amount of terminal tokens to distribute, as a fixed point number with same number of decimals as this terminal.
    @param _currency The expected currency of the amount being distributed. Must match the project's current funding cycle's distribution limit currency.
    @param _minReturnedTokens The minimum number of terminal tokens that the `_amount` should be valued at in terms of this terminal's currency, as a fixed point number with the same number of decimals as this terminal.
    @param _memo A memo to pass along to the emitted event.

    @return netLeftoverDistributionAmount The amount that was sent to the project owner, as a fixed point number with the same amount of decimals as this terminal.
  */
  function _distributePayoutsOf(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency,
    uint256 _minReturnedTokens,
    string calldata _memo
  ) internal returns (uint256 netLeftoverDistributionAmount) {
    // Record the distribution.
    (JBFundingCycle memory _fundingCycle, uint256 _distributedAmount) = store.recordDistributionFor(
      _projectId,
      _amount,
      _currency
    );

    // The amount being distributed must be at least as much as was expected.
    if (_distributedAmount < _minReturnedTokens) revert INADEQUATE_DISTRIBUTION_AMOUNT();

    // Get a reference to the project owner, which will receive tokens from paying the platform fee
    // and receive any extra distributable funds not allocated to payout splits.
    address payable _projectOwner = payable(projects.ownerOf(_projectId));

    // Define variables that will be needed outside the scoped section below.
    // Keep a reference to the fee amount that was paid.
    uint256 _fee;

    // Scoped section prevents stack too deep. `_feeDiscount`, `_feeEligibleDistributionAmount`, and `_leftoverDistributionAmount` only used within scope.
    {
      // Get the amount of discount that should be applied to any fees taken.
      // If the fee is zero, set the discount to 100% for convenience.
      uint256 _feeDiscount = fee == 0
        ? JBConstants.MAX_FEE_DISCOUNT
        : _currentFeeDiscount(_projectId);

      // The amount distributed that is eligible for incurring fees.
      uint256 _feeEligibleDistributionAmount;

      // The amount leftover after distributing to the splits.
      uint256 _leftoverDistributionAmount;

      // Payout to splits and get a reference to the leftover transfer amount after all splits have been paid.
      // Also get a reference to the amount that was distributed to splits from which fees should be taken.
      (_leftoverDistributionAmount, _feeEligibleDistributionAmount) = _distributeToPayoutSplitsOf(
        _projectId,
        _fundingCycle.configuration,
        payoutSplitsGroup,
        _distributedAmount,
        _feeDiscount
      );

      if (_feeDiscount != JBConstants.MAX_FEE_DISCOUNT) {
        // Leftover distribution amount is also eligible for a fee since the funds are going out of the ecosystem to _beneficiary.
        unchecked {
          _feeEligibleDistributionAmount += _leftoverDistributionAmount;
        }
      }

      // Take the fee.
      _fee = _feeEligibleDistributionAmount != 0
        ? _takeFeeFrom(
          _projectId,
          _fundingCycle,
          _feeEligibleDistributionAmount,
          _projectOwner,
          _feeDiscount
        )
        : 0;

      // Transfer any remaining balance to the project owner and update returned leftover accordingly.
      if (_leftoverDistributionAmount != 0) {
        // Subtract the fee from the net leftover amount.
        netLeftoverDistributionAmount =
          _leftoverDistributionAmount -
          _feeAmount(_leftoverDistributionAmount, fee, _feeDiscount);

        // Transfer the amount to the project owner.
        _transferFrom(address(this), _projectOwner, netLeftoverDistributionAmount);
      }
    }

    emit DistributePayouts(
      _fundingCycle.configuration,
      _fundingCycle.number,
      _projectId,
      _projectOwner,
      _amount,
      _distributedAmount,
      _fee,
      netLeftoverDistributionAmount,
      _memo,
      msg.sender
    );
  }

  /**
    @notice
    Allows a project to send funds from its overflow up to the preconfigured allowance.

    @dev
    Only a project's owner or a designated operator can use its allowance.

    @dev
    Incurs the protocol fee.

    @param _projectId The ID of the project to use the allowance of.
    @param _amount The amount of terminal tokens to use from this project's current allowance, as a fixed point number with the same amount of decimals as this terminal.
    @param _currency The expected currency of the amount being distributed. Must match the project's current funding cycle's overflow allowance currency.
    @param _minReturnedTokens The minimum number of tokens that the `_amount` should be valued at in terms of this terminal's currency, as a fixed point number with 18 decimals.
    @param _beneficiary The address to send the funds to.
    @param _memo A memo to pass along to the emitted event.

    @return netDistributedAmount The amount of tokens that was distributed to the beneficiary, as a fixed point number with the same amount of decimals as the terminal.
  */
  function _useAllowanceOf(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency,
    uint256 _minReturnedTokens,
    address payable _beneficiary,
    string memory _memo
  ) internal returns (uint256 netDistributedAmount) {
    // Record the use of the allowance.
    (JBFundingCycle memory _fundingCycle, uint256 _distributedAmount) = store.recordUsedAllowanceOf(
      _projectId,
      _amount,
      _currency
    );

    // The amount being withdrawn must be at least as much as was expected.
    if (_distributedAmount < _minReturnedTokens) revert INADEQUATE_DISTRIBUTION_AMOUNT();

    // Scoped section prevents stack too deep. `_fee`, `_projectOwner`, `_feeDiscount`, and `_netAmount` only used within scope.
    {
      // Keep a reference to the fee amount that was paid.
      uint256 _fee;

      // Get a reference to the project owner, which will receive tokens from paying the platform fee.
      address _projectOwner = projects.ownerOf(_projectId);

      // Get the amount of discount that should be applied to any fees taken.
      // If the fee is zero or if the fee is being used by an address that doesn't incur fees, set the discount to 100% for convenience.
      uint256 _feeDiscount = fee == 0 || isFeelessAddress[msg.sender]
        ? JBConstants.MAX_FEE_DISCOUNT
        : _currentFeeDiscount(_projectId);

      // Take a fee from the `_distributedAmount`, if needed.
      _fee = _feeDiscount == JBConstants.MAX_FEE_DISCOUNT
        ? 0
        : _takeFeeFrom(_projectId, _fundingCycle, _distributedAmount, _projectOwner, _feeDiscount);

      unchecked {
        // The net amount is the withdrawn amount without the fee.
        netDistributedAmount = _distributedAmount - _fee;
      }

      // Transfer any remaining balance to the beneficiary.
      if (netDistributedAmount > 0)
        _transferFrom(address(this), _beneficiary, netDistributedAmount);
    }

    emit UseAllowance(
      _fundingCycle.configuration,
      _fundingCycle.number,
      _projectId,
      _beneficiary,
      _amount,
      _distributedAmount,
      netDistributedAmount,
      _memo,
      msg.sender
    );
  }

  /**
    @notice
    Pays out splits for a project's funding cycle configuration.

    @param _projectId The ID of the project for which payout splits are being distributed.
    @param _domain The domain of the splits to distribute the payout between.
    @param _group The group of the splits to distribute the payout between.
    @param _amount The total amount being distributed, as a fixed point number with the same number of decimals as this terminal.
    @param _feeDiscount The amount of discount to apply to the fee, out of the MAX_FEE.

    @return leftoverAmount If the leftover amount if the splits don't add up to 100%.
    @return feeEligibleDistributionAmount The total amount of distributions that are eligible to have fees taken from.
  */
  function _distributeToPayoutSplitsOf(
    uint256 _projectId,
    uint256 _domain,
    uint256 _group,
    uint256 _amount,
    uint256 _feeDiscount
  ) internal returns (uint256 leftoverAmount, uint256 feeEligibleDistributionAmount) {
    // Set the leftover amount to the initial amount.
    leftoverAmount = _amount;
    // The total percentage available to split
    uint256 leftoverPercentage = JBConstants.SPLITS_TOTAL_PERCENT;

    // Get a reference to the project's payout splits.
    JBSplit[] memory _splits = splitsStore.splitsOf(_projectId, _domain, _group);

    // Transfer between all splits.
    for (uint256 _i; _i < _splits.length; ) {
      // Get a reference to the split being iterated on.
      JBSplit memory _split = _splits[_i];

      // The amount to send towards the split.
      uint256 _payoutAmount = _split.percent == leftoverPercentage
        ? leftoverAmount
        : PRBMath.mulDiv(_amount, _split.percent, JBConstants.SPLITS_TOTAL_PERCENT);

      // Decrement the leftover percentage.
      leftoverPercentage -= _split.percent;

      // The payout amount substracting any applicable incurred fees.
      uint256 _netPayoutAmount;

      if (_payoutAmount > 0) {
        // Transfer tokens to the split.
        // If there's an allocator set, transfer to its `allocate` function.
        if (_split.allocator != IJBSplitAllocator(address(0))) {
          // If the split allocator is set as feeless, this distribution is not eligible for a fee.
          if (
            _feeDiscount == JBConstants.MAX_FEE_DISCOUNT ||
            isFeelessAddress[address(_split.allocator)]
          )
            _netPayoutAmount = _payoutAmount;
            // This distribution is eligible for a fee since the funds are leaving this contract and the allocator isn't listed as feeless.
          else {
            unchecked {
              _netPayoutAmount = _payoutAmount - _feeAmount(_payoutAmount, fee, _feeDiscount);
            }

            // This distribution is eligible for a fee since the funds are leaving the ecosystem.
            feeEligibleDistributionAmount += _payoutAmount;
          }

          // Trigger any inherited pre-transfer logic.
          _beforeTransferTo(address(_split.allocator), _netPayoutAmount);

          // Create the data to send to the allocator.
          JBSplitAllocationData memory _data = JBSplitAllocationData(
            token,
            _netPayoutAmount,
            decimals,
            _projectId,
            _group,
            _split
          );

          // Trigger the allocator's `allocate` function.
          // If this terminal's token is ETH, send it in msg.value.
          uint256 amount = token == JBTokens.ETH ? _netPayoutAmount : 0;
          _split.allocator.allocate{value: amount}(_data);

          // Otherwise, if a project is specified, make a payment to it.
        } else if (_split.projectId != 0) {
          // Get a reference to the Juicebox terminal being used.
          IJBPaymentTerminal _terminal = directory.primaryTerminalOf(_split.projectId, token);

          // The project must have a terminal to send funds to.
          if (_terminal == IJBPaymentTerminal(address(0))) revert TERMINAL_IN_SPLIT_ZERO_ADDRESS();

          // Save gas if this contract is being used as the terminal.
          if (_terminal == this) {
            // This distribution does not incur a fee.
            _netPayoutAmount = _payoutAmount;

            // Send the projectId in the metadata.
            bytes memory _projectMetadata = new bytes(32);
            _projectMetadata = bytes(abi.encodePacked(_projectId));

            // Add to balance if prefered.
            if (_split.preferAddToBalance)
              _addToBalanceOf(_split.projectId, _netPayoutAmount, false, '', _projectMetadata);
            else
              _pay(
                _netPayoutAmount,
                address(this),
                _split.projectId,
                (_split.beneficiary != address(0)) ? _split.beneficiary : msg.sender,
                0,
                _split.preferClaimed,
                '',
                _projectMetadata
              );
          } else {
            // If the terminal is set as feeless, this distribution is not eligible for a fee.
            if (
              _feeDiscount == JBConstants.MAX_FEE_DISCOUNT || isFeelessAddress[address(_terminal)]
            )
              _netPayoutAmount = _payoutAmount;
              // This distribution is eligible for a fee since the funds are leaving this contract and the terminal isn't listed as feeless.
            else {
              unchecked {
                _netPayoutAmount = _payoutAmount - _feeAmount(_payoutAmount, fee, _feeDiscount);
              }

              feeEligibleDistributionAmount += _payoutAmount;
            }

            // Trigger any inherited pre-transfer logic.
            _beforeTransferTo(address(_terminal), _netPayoutAmount);

            // If this terminal's token is ETH, send it in msg.value.
            uint256 _payableValue = token == JBTokens.ETH ? _netPayoutAmount : 0;

            // Send the projectId in the metadata.
            bytes memory _projectMetadata = new bytes(32);
            _projectMetadata = bytes(abi.encodePacked(_projectId));

            // Add to balance if prefered.
            if (_split.preferAddToBalance)
              _terminal.addToBalanceOf{value: _payableValue}(
                _split.projectId,
                _netPayoutAmount,
                token,
                '',
                _projectMetadata
              );
            else
              _terminal.pay{value: _payableValue}(
                _split.projectId,
                _netPayoutAmount,
                token,
                _split.beneficiary != address(0) ? _split.beneficiary : msg.sender,
                0,
                _split.preferClaimed,
                '',
                _projectMetadata
              );
          }
        } else {
          // Keep a reference to the beneficiary.
          address payable _beneficiary = _split.beneficiary != address(0)
            ? _split.beneficiary
            : payable(msg.sender);

          // If there's a full discount, this distribution is not eligible for a fee.
          // Don't enforce feeless address for the beneficiary since the funds are leaving the ecosystem.
          if (_feeDiscount == JBConstants.MAX_FEE_DISCOUNT)
            _netPayoutAmount = _payoutAmount;
            // This distribution is eligible for a fee since the funds are leaving this contract and the beneficiary isn't listed as feeless.
          else {
            unchecked {
              _netPayoutAmount = _payoutAmount - _feeAmount(_payoutAmount, fee, _feeDiscount);
            }
            feeEligibleDistributionAmount += _payoutAmount;
          }

          // If there's a beneficiary, send the funds directly to the beneficiary. Otherwise send to the msg.sender.
          _transferFrom(address(this), _beneficiary, _netPayoutAmount);
        }

        // Subtract from the amount to be sent to the beneficiary.
        unchecked {
          leftoverAmount = leftoverAmount - _payoutAmount;
        }
      }

      emit DistributeToPayoutSplit(
        _projectId,
        _domain,
        _group,
        _split,
        _netPayoutAmount,
        msg.sender
      );

      unchecked {
        ++_i;
      }
    }
  }

  /**
    @notice
    Takes a fee into the platform's project, which has an id of _FEE_BENEFICIARY_PROJECT_ID.

    @param _projectId The ID of the project having fees taken from.
    @param _fundingCycle The funding cycle during which the fee is being taken.
    @param _amount The amount of the fee to take, as a floating point number with 18 decimals.
    @param _beneficiary The address to mint the platforms tokens for.
    @param _feeDiscount The amount of discount to apply to the fee, out of the MAX_FEE.

    @return feeAmount The amount of the fee taken.
  */
  function _takeFeeFrom(
    uint256 _projectId,
    JBFundingCycle memory _fundingCycle,
    uint256 _amount,
    address _beneficiary,
    uint256 _feeDiscount
  ) internal returns (uint256 feeAmount) {
    feeAmount = _feeAmount(_amount, fee, _feeDiscount);

    // check for soft-block: allow payment, but don't take a free
    // check for hard-block: block payment

    if (_fundingCycle.shouldHoldFees()) {
      // Store the held fee.
      _heldFeesOf[_projectId].push(JBFee(_amount, uint32(fee), uint32(_feeDiscount), _beneficiary));

      emit HoldFee(_projectId, _amount, fee, _feeDiscount, _beneficiary, msg.sender);
    } else {
      // Process the fee.
      _processFee(feeAmount, _beneficiary); // Take the fee.

      emit ProcessFee(_projectId, feeAmount, false, _beneficiary, msg.sender);
    }
  }

  /**
    @notice
    Process a fee of the specified amount.

    @dev
    Fee distribution to the parent project does not generate tokens to the beneficiary in this implementation.

    @param _amount The fee amount, as a floating point number with 18 decimals.
    @param _beneficiary The address to mint the platform's tokens for. Unused in this implementation.
  */
  function _processFee(uint256 _amount, address _beneficiary) internal {
    _beneficiary; // Prevents unused var compiler and natspec complaints.
    // Get the terminal for the protocol project.
    IJBPaymentTerminal _terminal = directory.primaryTerminalOf(_FEE_BENEFICIARY_PROJECT_ID, token);

    // When processing the admin fee, save gas if the admin is using this contract as its terminal.
    if (_terminal == this)
      _addToBalanceOf(_FEE_BENEFICIARY_PROJECT_ID, _amount, false, '', bytes('')); // Use the local addToBalanceOf call.
    else {
      // Trigger any inherited pre-transfer logic.
      _beforeTransferTo(address(_terminal), _amount);

      // If this terminal's token is ETH, send it in msg.value.
      uint256 _payableValue = token == JBTokens.ETH ? _amount : 0;

      // Send the funds.
      _terminal.addToBalanceOf{value: _payableValue}(
        _FEE_BENEFICIARY_PROJECT_ID,
        _amount,
        token,
        '',
        bytes('')
      ); // Use the external addToBalanceOf call of the correct terminal.
    }
  }

  /**
    @notice
    Contribute tokens to a project.

    @param _amount The amount of terminal tokens being received, as a fixed point number with the same amount of decimals as this terminal. If this terminal's token is ETH, this is ignored and msg.value is used in its place.
    @param _payer The address making the payment.
    @param _projectId The ID of the project being paid.
    @param _beneficiary The address to mint tokens for and pass along to the funding cycle's data source and delegate.
    @param _minReturnedTokens The minimum number of project tokens expected in return, as a fixed point number with the same amount of decimals as this terminal.
    @param _preferClaimedTokens A flag indicating whether the request prefers to mint project tokens into the beneficiaries wallet rather than leaving them unclaimed. This is only possible if the project has an attached token contract. Leaving them unclaimed saves gas.
    @param _memo A memo to pass along to the emitted event, and passed along the the funding cycle's data source and delegate.  A data source can alter the memo before emitting in the event and forwarding to the delegate.
    @param _metadata Bytes to send along to the data source, delegate, and emitted event, if provided.

    @return beneficiaryTokenCount The number of tokens minted for the beneficiary, as a fixed point number with 18 decimals.
  */
  function _pay(
    uint256 _amount,
    address _payer,
    uint256 _projectId,
    address _beneficiary,
    uint256 _minReturnedTokens,
    bool _preferClaimedTokens,
    string memory _memo,
    bytes memory _metadata
  ) internal returns (uint256 beneficiaryTokenCount) {
    // Cant send tokens to the zero address.
    if (_beneficiary == address(0)) revert PAY_TO_ZERO_ADDRESS();

    // Define variables that will be needed outside the scoped section below.
    // Keep a reference to the funding cycle during which the payment is being made.
    JBFundingCycle memory _fundingCycle;

    // Scoped section prevents stack too deep. `_delegateAllocations` and `_tokenCount` only used within scope.
    {
      JBPayDelegateAllocation[] memory _delegateAllocations;
      uint256 _tokenCount;

      // Bundle the amount info into a JBTokenAmount struct.
      JBTokenAmount memory _bundledAmount = JBTokenAmount(token, _amount, decimals, currency);

      // Record the payment.
      (_fundingCycle, _tokenCount, _delegateAllocations, _memo) = store.recordPaymentFrom(
        _payer,
        _bundledAmount,
        _projectId,
        baseWeightCurrency,
        _beneficiary,
        _memo,
        _metadata
      );

      // Mint the tokens if needed.
      if (_tokenCount > 0)
        // Set token count to be the number of tokens minted for the beneficiary instead of the total amount.
        beneficiaryTokenCount = IJBController(directory.controllerOf(_projectId)).mintTokensOf(
          _projectId,
          _tokenCount,
          _beneficiary,
          '',
          _preferClaimedTokens,
          true
        );

      // The token count for the beneficiary must be greater than or equal to the minimum expected.
      if (beneficiaryTokenCount < _minReturnedTokens) revert INADEQUATE_TOKEN_COUNT();

      // If delegate allocations were specified by the data source, fulfill them.
      if (_delegateAllocations.length != 0) {
        // Keep a reference to the token amount being forwarded to the delegate.
        JBTokenAmount memory _forwardedAmount = JBTokenAmount(token, _amount, decimals, currency);

        JBDidPayData memory _data = JBDidPayData(
          _payer,
          _projectId,
          _fundingCycle.configuration,
          _bundledAmount,
          _forwardedAmount,
          beneficiaryTokenCount,
          _beneficiary,
          _preferClaimedTokens,
          _memo,
          _metadata
        );

        // Get a reference to the number of delegates to allocate to.
        uint256 _numDelegates = _delegateAllocations.length;

        for (uint256 _i; _i < _numDelegates; ) {
          // Get a reference to the delegate being iterated on.
          JBPayDelegateAllocation memory _delegateAllocation = _delegateAllocations[_i];

          // Trigger any inherited pre-transfer logic.
          _beforeTransferTo(address(_delegateAllocation.delegate), _delegateAllocation.amount);

          // Keep track of the msg.value to use in the delegate call
          uint256 _payableValue;

          // If this terminal's token is ETH, send it in msg.value.
          if (token == JBTokens.ETH) _payableValue = _delegateAllocation.amount;

          // Pass the correct token forwardedAmount to the delegate
          _data.forwardedAmount.value = _delegateAllocation.amount;

          _delegateAllocation.delegate.didPay{value: _payableValue}(_data);

          emit DelegateDidPay(
            _delegateAllocation.delegate,
            _data,
            _delegateAllocation.amount,
            msg.sender
          );

          unchecked {
            ++_i;
          }
        }
      }
    }

    emit Pay(
      _fundingCycle.configuration,
      _fundingCycle.number,
      _projectId,
      _payer,
      _beneficiary,
      _amount,
      beneficiaryTokenCount,
      _memo,
      _metadata,
      msg.sender
    );
  }

  /**
    @notice
    Receives funds belonging to the specified project.

    @param _projectId The ID of the project to which the funds received belong.
    @param _amount The amount of tokens to add, as a fixed point number with the same number of decimals as this terminal. If this is an ETH terminal, this is ignored and msg.value is used instead.
    @param _shouldRefundHeldFees A flag indicating if held fees should be refunded based on the amount being added.
    @param _memo A memo to pass along to the emitted event.
    @param _metadata Extra data to pass along to the emitted event.
  */
  function _addToBalanceOf(
    uint256 _projectId,
    uint256 _amount,
    bool _shouldRefundHeldFees,
    string memory _memo,
    bytes memory _metadata
  ) internal {
    // Refund any held fees to make sure the project doesn't pay double for funds going in and out of the protocol.
    uint256 _refundedFees = _shouldRefundHeldFees ? _refundHeldFees(_projectId, _amount) : 0;

    // Record the added funds with any refunded fees.
    store.recordAddedBalanceFor(_projectId, _amount + _refundedFees);

    emit AddToBalance(_projectId, _amount, _refundedFees, _memo, _metadata, msg.sender);
  }

  /**
    @notice
    Refund fees based on the specified amount.

    @param _projectId The project for which fees are being refunded.
    @param _amount The amount to base the refund on, as a fixed point number with the same amount of decimals as this terminal.

    @return refundedFees How much fees were refunded, as a fixed point number with the same number of decimals as this terminal
  */
  function _refundHeldFees(
    uint256 _projectId,
    uint256 _amount
  ) internal returns (uint256 refundedFees) {
    // Get a reference to the project's held fees.
    JBFee[] memory _heldFees = _heldFeesOf[_projectId];

    // Delete the current held fees.
    delete _heldFeesOf[_projectId];

    // Get a reference to the leftover amount once all fees have been settled.
    uint256 leftoverAmount = _amount;

    // Push length in stack
    uint256 _heldFeesLength = _heldFees.length;

    // Process each fee.
    for (uint256 _i; _i < _heldFeesLength; ) {
      if (leftoverAmount == 0) _heldFeesOf[_projectId].push(_heldFees[_i]);
      else if (leftoverAmount >= _heldFees[_i].amount) {
        unchecked {
          leftoverAmount = leftoverAmount - _heldFees[_i].amount;
          refundedFees += _feeAmount(
            _heldFees[_i].amount,
            _heldFees[_i].fee,
            _heldFees[_i].feeDiscount
          );
        }
      } else {
        unchecked {
          _heldFeesOf[_projectId].push(
            JBFee(
              _heldFees[_i].amount - leftoverAmount,
              _heldFees[_i].fee,
              _heldFees[_i].feeDiscount,
              _heldFees[_i].beneficiary
            )
          );
          refundedFees += _feeAmount(leftoverAmount, _heldFees[_i].fee, _heldFees[_i].feeDiscount);
        }
        leftoverAmount = 0;
      }

      unchecked {
        ++_i;
      }
    }

    emit RefundHeldFees(_projectId, _amount, refundedFees, leftoverAmount, msg.sender);
  }

  /** 
    @notice 
    Returns the fee amount based on the provided amount for the specified project.

    @param _amount The amount that the fee is based on, as a fixed point number with the same amount of decimals as this terminal.
    @param _fee The percentage of the fee, out of MAX_FEE. 
    @param _feeDiscount The percentage discount that should be applied out of the max amount, out of MAX_FEE_DISCOUNT.

    @return The amount of the fee, as a fixed point number with the same amount of decimals as this terminal.
  */
  function _feeAmount(
    uint256 _amount,
    uint256 _fee,
    uint256 _feeDiscount
  ) internal pure returns (uint256) {
    // Calculate the discounted fee.
    uint256 _discountedFee = _fee -
      PRBMath.mulDiv(_fee, _feeDiscount, JBConstants.MAX_FEE_DISCOUNT);

    // The amount of tokens from the `_amount` to pay as a fee.
    return
      _amount - PRBMath.mulDiv(_amount, JBConstants.MAX_FEE, _discountedFee + JBConstants.MAX_FEE);
  }

  /** 
    @notice
    Get the fee discount from the fee gauge for the specified project.

    @param _projectId The ID of the project to get a fee discount for.
    
    @return feeDiscount The fee discount, which should be interpreted as a percentage out MAX_FEE_DISCOUNT.
  */
  function _currentFeeDiscount(uint256 _projectId) internal view returns (uint256) {
    // Can't take a fee if the protocol project doesn't have a terminal that accepts the token.
    if (
      directory.primaryTerminalOf(_FEE_BENEFICIARY_PROJECT_ID, token) ==
      IJBPaymentTerminal(address(0))
    ) return JBConstants.MAX_FEE_DISCOUNT;

    // Get the fee discount.
    if (feeGauge != IJBFeeGauge(address(0)))
      // If the guage reverts, keep the discount at 0.
      try feeGauge.currentDiscountFor(_projectId) returns (uint256 discount) {
        // If the fee discount is greater than the max, we ignore the return value
        if (discount <= JBConstants.MAX_FEE_DISCOUNT) return discount;
      } catch {
        return 0;
      }

    return 0;
  }
}

File 11 of 62 : JBSingleTokenPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import './../interfaces/IJBSingleTokenPaymentTerminal.sol';

/**
  @notice
  Generic terminal managing all inflows of funds into the protocol ecosystem for one token.

  @dev
  Adheres to -
  IJBSingleTokenPaymentTerminals: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.

  @dev
  Inherits from -
  ERC165: Introspection on interface adherance. 
*/
abstract contract JBSingleTokenPaymentTerminal is ERC165, IJBSingleTokenPaymentTerminal {
  //*********************************************************************//
  // ---------------- public immutable stored properties --------------- //
  //*********************************************************************//

  /**
    @notice
    The token that this terminal accepts.
  */
  address public immutable override token;

  /**
    @notice
    The number of decimals the token fixed point amounts are expected to have.
  */
  uint256 public immutable override decimals;

  /**
    @notice
    The currency to use when resolving price feeds for this terminal.
  */
  uint256 public immutable override currency;

  //*********************************************************************//
  // ------------------------- external views -------------------------- //
  //*********************************************************************//

  /** 
    @notice
    A flag indicating if this terminal accepts the specified token.

    @param _token The token to check if this terminal accepts or not.
    @param _projectId The project ID to check for token acceptance.

    @return The flag.
  */
  function acceptsToken(address _token, uint256 _projectId) external view override returns (bool) {
    _projectId; // Prevents unused var compiler and natspec complaints.

    return _token == token;
  }

  /** 
    @notice
    The decimals that should be used in fixed number accounting for the specified token.

    @param _token The token to check for the decimals of.

    @return The number of decimals for the token.
  */
  function decimalsForToken(address _token) external view override returns (uint256) {
    _token; // Prevents unused var compiler and natspec complaints.

    return decimals;
  }

  /** 
    @notice
    The currency that should be used for the specified token.

    @param _token The token to check for the currency of.

    @return The currency index.
  */
  function currencyForToken(address _token) external view override returns (uint256) {
    _token; // Prevents unused var compiler and natspec complaints.

    return currency;
  }

  //*********************************************************************//
  // -------------------------- public views --------------------------- //
  //*********************************************************************//

  /**
    @notice
    Indicates if this contract adheres to the specified interface.

    @dev 
    See {IERC165-supportsInterface}.

    @param _interfaceId The ID of the interface to check for adherance to.
  */
  function supportsInterface(bytes4 _interfaceId)
    public
    view
    virtual
    override(ERC165, IERC165)
    returns (bool)
  {
    return
      _interfaceId == type(IJBPaymentTerminal).interfaceId ||
      _interfaceId == type(IJBSingleTokenPaymentTerminal).interfaceId ||
      super.supportsInterface(_interfaceId);
  }

  //*********************************************************************//
  // -------------------------- constructor ---------------------------- //
  //*********************************************************************//

  /**
    @param _token The token that this terminal manages.
    @param _decimals The number of decimals the token fixed point amounts are expected to have.
    @param _currency The currency that this terminal's token adheres to for price feeds.
  */
  constructor(
    address _token,
    uint256 _decimals,
    uint256 _currency
  ) {
    token = _token;
    decimals = _decimals;
    currency = _currency;
  }
}

File 12 of 62 : JBBallotState.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

enum JBBallotState {
  Active,
  Approved,
  Failed
}

File 13 of 62 : IJBAllowanceTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBAllowanceTerminal {
  function useAllowanceOf(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency,
    address _token,
    uint256 _minReturnedTokens,
    address payable _beneficiary,
    string calldata _memo
  ) external returns (uint256 netDistributedAmount);
}

File 14 of 62 : IJBController.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import './../structs/JBFundAccessConstraints.sol';
import './../structs/JBFundingCycleData.sol';
import './../structs/JBFundingCycleMetadata.sol';
import './../structs/JBGroupedSplits.sol';
import './../structs/JBProjectMetadata.sol';
import './IJBDirectory.sol';
import './IJBFundingCycleStore.sol';
import './IJBMigratable.sol';
import './IJBPaymentTerminal.sol';
import './IJBSplitsStore.sol';
import './IJBTokenStore.sol';

interface IJBController is IERC165 {
  event LaunchProject(uint256 configuration, uint256 projectId, string memo, address caller);

  event LaunchFundingCycles(uint256 configuration, uint256 projectId, string memo, address caller);

  event ReconfigureFundingCycles(
    uint256 configuration,
    uint256 projectId,
    string memo,
    address caller
  );

  event SetFundAccessConstraints(
    uint256 indexed fundingCycleConfiguration,
    uint256 indexed fundingCycleNumber,
    uint256 indexed projectId,
    JBFundAccessConstraints constraints,
    address caller
  );

  event DistributeReservedTokens(
    uint256 indexed fundingCycleConfiguration,
    uint256 indexed fundingCycleNumber,
    uint256 indexed projectId,
    address beneficiary,
    uint256 tokenCount,
    uint256 beneficiaryTokenCount,
    string memo,
    address caller
  );

  event DistributeToReservedTokenSplit(
    uint256 indexed projectId,
    uint256 indexed domain,
    uint256 indexed group,
    JBSplit split,
    uint256 tokenCount,
    address caller
  );

  event MintTokens(
    address indexed beneficiary,
    uint256 indexed projectId,
    uint256 tokenCount,
    uint256 beneficiaryTokenCount,
    string memo,
    uint256 reservedRate,
    address caller
  );

  event BurnTokens(
    address indexed holder,
    uint256 indexed projectId,
    uint256 tokenCount,
    string memo,
    address caller
  );

  event Migrate(uint256 indexed projectId, IJBMigratable to, address caller);

  event PrepMigration(uint256 indexed projectId, address from, address caller);

  function projects() external view returns (IJBProjects);

  function fundingCycleStore() external view returns (IJBFundingCycleStore);

  function tokenStore() external view returns (IJBTokenStore);

  function splitsStore() external view returns (IJBSplitsStore);

  function directory() external view returns (IJBDirectory);

  function reservedTokenBalanceOf(uint256 _projectId, uint256 _reservedRate)
    external
    view
    returns (uint256);

  function distributionLimitOf(
    uint256 _projectId,
    uint256 _configuration,
    IJBPaymentTerminal _terminal,
    address _token
  ) external view returns (uint256 distributionLimit, uint256 distributionLimitCurrency);

  function overflowAllowanceOf(
    uint256 _projectId,
    uint256 _configuration,
    IJBPaymentTerminal _terminal,
    address _token
  ) external view returns (uint256 overflowAllowance, uint256 overflowAllowanceCurrency);

  function totalOutstandingTokensOf(uint256 _projectId, uint256 _reservedRate)
    external
    view
    returns (uint256);

  function getFundingCycleOf(uint256 _projectId, uint256 _configuration)
    external
    view
    returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata memory metadata);

  function latestConfiguredFundingCycleOf(uint256 _projectId)
    external
    view
    returns (
      JBFundingCycle memory,
      JBFundingCycleMetadata memory metadata,
      JBBallotState
    );

  function currentFundingCycleOf(uint256 _projectId)
    external
    view
    returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata memory metadata);

  function queuedFundingCycleOf(uint256 _projectId)
    external
    view
    returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata memory metadata);

  function launchProjectFor(
    address _owner,
    JBProjectMetadata calldata _projectMetadata,
    JBFundingCycleData calldata _data,
    JBFundingCycleMetadata calldata _metadata,
    uint256 _mustStartAtOrAfter,
    JBGroupedSplits[] memory _groupedSplits,
    JBFundAccessConstraints[] memory _fundAccessConstraints,
    IJBPaymentTerminal[] memory _terminals,
    string calldata _memo
  ) external returns (uint256 projectId);

  function launchFundingCyclesFor(
    uint256 _projectId,
    JBFundingCycleData calldata _data,
    JBFundingCycleMetadata calldata _metadata,
    uint256 _mustStartAtOrAfter,
    JBGroupedSplits[] memory _groupedSplits,
    JBFundAccessConstraints[] memory _fundAccessConstraints,
    IJBPaymentTerminal[] memory _terminals,
    string calldata _memo
  ) external returns (uint256 configuration);

  function reconfigureFundingCyclesOf(
    uint256 _projectId,
    JBFundingCycleData calldata _data,
    JBFundingCycleMetadata calldata _metadata,
    uint256 _mustStartAtOrAfter,
    JBGroupedSplits[] memory _groupedSplits,
    JBFundAccessConstraints[] memory _fundAccessConstraints,
    string calldata _memo
  ) external returns (uint256);

  function mintTokensOf(
    uint256 _projectId,
    uint256 _tokenCount,
    address _beneficiary,
    string calldata _memo,
    bool _preferClaimedTokens,
    bool _useReservedRate
  ) external returns (uint256 beneficiaryTokenCount);

  function burnTokensOf(
    address _holder,
    uint256 _projectId,
    uint256 _tokenCount,
    string calldata _memo,
    bool _preferClaimedTokens
  ) external;

  function distributeReservedTokensOf(uint256 _projectId, string memory _memo)
    external
    returns (uint256);

  function migrate(uint256 _projectId, IJBMigratable _to) external;
}

File 15 of 62 : IJBDirectory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './IJBFundingCycleStore.sol';
import './IJBPaymentTerminal.sol';
import './IJBProjects.sol';

interface IJBDirectory {
  event SetController(uint256 indexed projectId, address indexed controller, address caller);

  event AddTerminal(uint256 indexed projectId, IJBPaymentTerminal indexed terminal, address caller);

  event SetTerminals(uint256 indexed projectId, IJBPaymentTerminal[] terminals, address caller);

  event SetPrimaryTerminal(
    uint256 indexed projectId,
    address indexed token,
    IJBPaymentTerminal indexed terminal,
    address caller
  );

  event SetIsAllowedToSetFirstController(address indexed addr, bool indexed flag, address caller);

  function projects() external view returns (IJBProjects);

  function fundingCycleStore() external view returns (IJBFundingCycleStore);

  function controllerOf(uint256 _projectId) external view returns (address);

  function isAllowedToSetFirstController(address _address) external view returns (bool);

  function terminalsOf(uint256 _projectId) external view returns (IJBPaymentTerminal[] memory);

  function isTerminalOf(uint256 _projectId, IJBPaymentTerminal _terminal)
    external
    view
    returns (bool);

  function primaryTerminalOf(uint256 _projectId, address _token)
    external
    view
    returns (IJBPaymentTerminal);

  function setControllerOf(uint256 _projectId, address _controller) external;

  function setTerminalsOf(uint256 _projectId, IJBPaymentTerminal[] calldata _terminals) external;

  function setPrimaryTerminalOf(
    uint256 _projectId,
    address _token,
    IJBPaymentTerminal _terminal
  ) external;

  function setIsAllowedToSetFirstController(address _address, bool _flag) external;
}

File 16 of 62 : IJBFeeGauge.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBFeeGauge {
  function currentDiscountFor(uint256 _projectId) external view returns (uint256);
}

File 17 of 62 : IJBFundingCycleBallot.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import './../enums/JBBallotState.sol';

interface IJBFundingCycleBallot is IERC165 {
  function duration() external view returns (uint256);

  function stateOf(
    uint256 _projectId,
    uint256 _configuration,
    uint256 _start
  ) external view returns (JBBallotState);
}

File 18 of 62 : IJBFundingCycleStore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../enums/JBBallotState.sol';
import './../structs/JBFundingCycle.sol';
import './../structs/JBFundingCycleData.sol';

interface IJBFundingCycleStore {
  event Configure(
    uint256 indexed configuration,
    uint256 indexed projectId,
    JBFundingCycleData data,
    uint256 metadata,
    uint256 mustStartAtOrAfter,
    address caller
  );

  event Init(uint256 indexed configuration, uint256 indexed projectId, uint256 indexed basedOn);

  function latestConfigurationOf(uint256 _projectId) external view returns (uint256);

  function get(uint256 _projectId, uint256 _configuration)
    external
    view
    returns (JBFundingCycle memory);

  function latestConfiguredOf(uint256 _projectId)
    external
    view
    returns (JBFundingCycle memory fundingCycle, JBBallotState ballotState);

  function queuedOf(uint256 _projectId) external view returns (JBFundingCycle memory fundingCycle);

  function currentOf(uint256 _projectId) external view returns (JBFundingCycle memory fundingCycle);

  function currentBallotStateOf(uint256 _projectId) external view returns (JBBallotState);

  function configureFor(
    uint256 _projectId,
    JBFundingCycleData calldata _data,
    uint256 _metadata,
    uint256 _mustStartAtOrAfter
  ) external returns (JBFundingCycle memory fundingCycle);
}

File 19 of 62 : IJBMigratable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBMigratable {
  function prepForMigrationOf(uint256 _projectId, address _from) external;
}

File 20 of 62 : IJBOperatable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './IJBOperatorStore.sol';

interface IJBOperatable {
  function operatorStore() external view returns (IJBOperatorStore);
}

File 21 of 62 : IJBOperatorStore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../structs/JBOperatorData.sol';

interface IJBOperatorStore {
  event SetOperator(
    address indexed operator,
    address indexed account,
    uint256 indexed domain,
    uint256[] permissionIndexes,
    uint256 packed
  );

  function permissionsOf(
    address _operator,
    address _account,
    uint256 _domain
  ) external view returns (uint256);

  function hasPermission(
    address _operator,
    address _account,
    uint256 _domain,
    uint256 _permissionIndex
  ) external view returns (bool);

  function hasPermissions(
    address _operator,
    address _account,
    uint256 _domain,
    uint256[] calldata _permissionIndexes
  ) external view returns (bool);

  function setOperator(JBOperatorData calldata _operatorData) external;

  function setOperators(JBOperatorData[] calldata _operatorData) external;
}

File 22 of 62 : IJBPayDelegate.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import './../structs/JBDidPayData.sol';

/**
  @title
  Pay delegate

  @notice
  Delegate called after JBTerminal.pay(..) logic completion (if passed by the funding cycle datasource)

  @dev
  Adheres to:
  IERC165 for adequate interface integration
*/
interface IJBPayDelegate is IERC165 {
  /**
    @notice
    This function is called by JBPaymentTerminal.pay(..), after the execution of its logic

    @dev
    Critical business logic should be protected by an appropriate access control
    
    @param _data the data passed by the terminal, as a JBDidPayData struct:
                  address payer;
                  uint256 projectId;
                  uint256 currentFundingCycleConfiguration;
                  JBTokenAmount amount;
                  JBTokenAmount forwardedAmount;
                  uint256 projectTokenCount;
                  address beneficiary;
                  bool preferClaimedTokens;
                  string memo;
                  bytes metadata;
  */
  function didPay(JBDidPayData calldata _data) external payable;
}

File 23 of 62 : IJBPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/introspection/IERC165.sol';

interface IJBPaymentTerminal is IERC165 {
  function acceptsToken(address _token, uint256 _projectId) external view returns (bool);

  function currencyForToken(address _token) external view returns (uint256);

  function decimalsForToken(address _token) external view returns (uint256);

  // Return value must be a fixed point number with 18 decimals.
  function currentEthOverflowOf(uint256 _projectId) external view returns (uint256);

  function pay(
    uint256 _projectId,
    uint256 _amount,
    address _token,
    address _beneficiary,
    uint256 _minReturnedTokens,
    bool _preferClaimedTokens,
    string calldata _memo,
    bytes calldata _metadata
  ) external payable returns (uint256 beneficiaryTokenCount);

  function addToBalanceOf(
    uint256 _projectId,
    uint256 _amount,
    address _token,
    string calldata _memo,
    bytes calldata _metadata
  ) external payable;
}

File 24 of 62 : IJBPayoutRedemptionPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../structs/JBFee.sol';
import './IJBAllowanceTerminal.sol';
import './IJBDirectory.sol';
import './IJBFeeGauge.sol';
import './IJBPayDelegate.sol';
import './IJBPaymentTerminal.sol';
import './IJBPayoutTerminal.sol';
import './IJBPrices.sol';
import './IJBProjects.sol';
import './IJBRedemptionDelegate.sol';
import './IJBRedemptionTerminal.sol';
import './IJBSingleTokenPaymentTerminalStore.sol';
import './IJBSplitsStore.sol';

interface IJBPayoutRedemptionPaymentTerminal is
  IJBPaymentTerminal,
  IJBPayoutTerminal,
  IJBAllowanceTerminal,
  IJBRedemptionTerminal
{
  event AddToBalance(
    uint256 indexed projectId,
    uint256 amount,
    uint256 refundedFees,
    string memo,
    bytes metadata,
    address caller
  );

  event Migrate(
    uint256 indexed projectId,
    IJBPaymentTerminal indexed to,
    uint256 amount,
    address caller
  );

  event DistributePayouts(
    uint256 indexed fundingCycleConfiguration,
    uint256 indexed fundingCycleNumber,
    uint256 indexed projectId,
    address beneficiary,
    uint256 amount,
    uint256 distributedAmount,
    uint256 fee,
    uint256 beneficiaryDistributionAmount,
    string memo,
    address caller
  );

  event UseAllowance(
    uint256 indexed fundingCycleConfiguration,
    uint256 indexed fundingCycleNumber,
    uint256 indexed projectId,
    address beneficiary,
    uint256 amount,
    uint256 distributedAmount,
    uint256 netDistributedamount,
    string memo,
    address caller
  );

  event HoldFee(
    uint256 indexed projectId,
    uint256 indexed amount,
    uint256 indexed fee,
    uint256 feeDiscount,
    address beneficiary,
    address caller
  );

  event ProcessFee(
    uint256 indexed projectId,
    uint256 indexed amount,
    bool indexed wasHeld,
    address beneficiary,
    address caller
  );

  event RefundHeldFees(
    uint256 indexed projectId,
    uint256 indexed amount,
    uint256 indexed refundedFees,
    uint256 leftoverAmount,
    address caller
  );

  event Pay(
    uint256 indexed fundingCycleConfiguration,
    uint256 indexed fundingCycleNumber,
    uint256 indexed projectId,
    address payer,
    address beneficiary,
    uint256 amount,
    uint256 beneficiaryTokenCount,
    string memo,
    bytes metadata,
    address caller
  );

  event DelegateDidPay(
    IJBPayDelegate indexed delegate,
    JBDidPayData data,
    uint256 delegatedAmount,
    address caller
  );

  event RedeemTokens(
    uint256 indexed fundingCycleConfiguration,
    uint256 indexed fundingCycleNumber,
    uint256 indexed projectId,
    address holder,
    address beneficiary,
    uint256 tokenCount,
    uint256 reclaimedAmount,
    string memo,
    bytes metadata,
    address caller
  );

  event DelegateDidRedeem(
    IJBRedemptionDelegate indexed delegate,
    JBDidRedeemData data,
    uint256 delegatedAmount,
    address caller
  );

  event DistributeToPayoutSplit(
    uint256 indexed projectId,
    uint256 indexed domain,
    uint256 indexed group,
    JBSplit split,
    uint256 amount,
    address caller
  );

  event SetFee(uint256 fee, address caller);

  event SetFeeGauge(IJBFeeGauge indexed feeGauge, address caller);

  event SetFeelessAddress(address indexed addrs, bool indexed flag, address caller);

  function projects() external view returns (IJBProjects);

  function splitsStore() external view returns (IJBSplitsStore);

  function directory() external view returns (IJBDirectory);

  function prices() external view returns (IJBPrices);

  function store() external view returns (IJBSingleTokenPaymentTerminalStore);

  function baseWeightCurrency() external view returns (uint256);

  function payoutSplitsGroup() external view returns (uint256);

  function heldFeesOf(uint256 _projectId) external view returns (JBFee[] memory);

  function fee() external view returns (uint256);

  function feeGauge() external view returns (IJBFeeGauge);

  function isFeelessAddress(address _contract) external view returns (bool);

  function migrate(uint256 _projectId, IJBPaymentTerminal _to) external returns (uint256 balance);

  function processFees(uint256 _projectId) external;

  function setFee(uint256 _fee) external;

  function setFeeGauge(IJBFeeGauge _feeGauge) external;

  function setFeelessAddress(address _contract, bool _flag) external;
}

File 25 of 62 : IJBPayoutTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBPayoutTerminal {
  function distributePayoutsOf(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency,
    address _token,
    uint256 _minReturnedTokens,
    string calldata _memo
  ) external returns (uint256 netLeftoverDistributionAmount);
}

File 26 of 62 : IJBPriceFeed.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBPriceFeed {
  function currentPrice(uint256 _targetDecimals) external view returns (uint256);
}

File 27 of 62 : IJBPrices.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './IJBPriceFeed.sol';

interface IJBPrices {
  event AddFeed(uint256 indexed currency, uint256 indexed base, IJBPriceFeed feed);

  function feedFor(uint256 _currency, uint256 _base) external view returns (IJBPriceFeed);

  function priceFor(
    uint256 _currency,
    uint256 _base,
    uint256 _decimals
  ) external view returns (uint256);

  function addFeedFor(
    uint256 _currency,
    uint256 _base,
    IJBPriceFeed _priceFeed
  ) external;
}

File 28 of 62 : IJBProjects.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import './../structs/JBProjectMetadata.sol';
import './IJBTokenUriResolver.sol';

interface IJBProjects is IERC721 {
  event Create(
    uint256 indexed projectId,
    address indexed owner,
    JBProjectMetadata metadata,
    address caller
  );

  event SetMetadata(uint256 indexed projectId, JBProjectMetadata metadata, address caller);

  event SetTokenUriResolver(IJBTokenUriResolver indexed resolver, address caller);

  function count() external view returns (uint256);

  function metadataContentOf(uint256 _projectId, uint256 _domain)
    external
    view
    returns (string memory);

  function tokenUriResolver() external view returns (IJBTokenUriResolver);

  function createFor(address _owner, JBProjectMetadata calldata _metadata)
    external
    returns (uint256 projectId);

  function setMetadataOf(uint256 _projectId, JBProjectMetadata calldata _metadata) external;

  function setTokenUriResolver(IJBTokenUriResolver _newResolver) external;
}

File 29 of 62 : IJBRedemptionDelegate.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import './../structs/JBDidRedeemData.sol';

/**
  @title
  Redemption delegate

  @notice
  Delegate called after JBTerminal.redeemTokensOf(..) logic completion (if passed by the funding cycle datasource)

  @dev
  Adheres to:
  IERC165 for adequate interface integration
*/
interface IJBRedemptionDelegate is IERC165 {
  /**
    @notice
    This function is called by JBPaymentTerminal.redeemTokensOf(..), after the execution of its logic

    @dev
    Critical business logic should be protected by an appropriate access control
    
    @param _data the data passed by the terminal, as a JBDidRedeemData struct:
                address holder;
                uint256 projectId;
                uint256 currentFundingCycleConfiguration;
                uint256 projectTokenCount;
                JBTokenAmount reclaimedAmount;
                JBTokenAmount forwardedAmount;
                address payable beneficiary;
                string memo;
                bytes metadata;
  */
  function didRedeem(JBDidRedeemData calldata _data) external payable;
}

File 30 of 62 : IJBRedemptionTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBRedemptionTerminal {
  function redeemTokensOf(
    address _holder,
    uint256 _projectId,
    uint256 _tokenCount,
    address _token,
    uint256 _minReturnedTokens,
    address payable _beneficiary,
    string calldata _memo,
    bytes calldata _metadata
  ) external returns (uint256 reclaimAmount);
}

File 31 of 62 : IJBSingleTokenPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './IJBPaymentTerminal.sol';

interface IJBSingleTokenPaymentTerminal is IJBPaymentTerminal {
  function token() external view returns (address);

  function currency() external view returns (uint256);

  function decimals() external view returns (uint256);
}

File 32 of 62 : IJBSingleTokenPaymentTerminalStore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../structs/JBFundingCycle.sol';
import './../structs/JBPayDelegateAllocation.sol';
import './../structs/JBRedemptionDelegateAllocation.sol';
import './../structs/JBTokenAmount.sol';
import './IJBDirectory.sol';
import './IJBFundingCycleStore.sol';
import './IJBPrices.sol';
import './IJBSingleTokenPaymentTerminal.sol';

interface IJBSingleTokenPaymentTerminalStore {
  function fundingCycleStore() external view returns (IJBFundingCycleStore);

  function directory() external view returns (IJBDirectory);

  function prices() external view returns (IJBPrices);

  function balanceOf(IJBSingleTokenPaymentTerminal _terminal, uint256 _projectId)
    external
    view
    returns (uint256);

  function usedDistributionLimitOf(
    IJBSingleTokenPaymentTerminal _terminal,
    uint256 _projectId,
    uint256 _fundingCycleNumber
  ) external view returns (uint256);

  function usedOverflowAllowanceOf(
    IJBSingleTokenPaymentTerminal _terminal,
    uint256 _projectId,
    uint256 _fundingCycleConfiguration
  ) external view returns (uint256);

  function currentOverflowOf(IJBSingleTokenPaymentTerminal _terminal, uint256 _projectId)
    external
    view
    returns (uint256);

  function currentTotalOverflowOf(
    uint256 _projectId,
    uint256 _decimals,
    uint256 _currency
  ) external view returns (uint256);

  function currentReclaimableOverflowOf(
    IJBSingleTokenPaymentTerminal _terminal,
    uint256 _projectId,
    uint256 _tokenCount,
    bool _useTotalOverflow
  ) external view returns (uint256);

  function currentReclaimableOverflowOf(
    uint256 _projectId,
    uint256 _tokenCount,
    uint256 _totalSupply,
    uint256 _overflow
  ) external view returns (uint256);

  function recordPaymentFrom(
    address _payer,
    JBTokenAmount memory _amount,
    uint256 _projectId,
    uint256 _baseWeightCurrency,
    address _beneficiary,
    string calldata _memo,
    bytes calldata _metadata
  )
    external
    returns (
      JBFundingCycle memory fundingCycle,
      uint256 tokenCount,
      JBPayDelegateAllocation[] memory delegateAllocations,
      string memory memo
    );

  function recordRedemptionFor(
    address _holder,
    uint256 _projectId,
    uint256 _tokenCount,
    string calldata _memo,
    bytes calldata _metadata
  )
    external
    returns (
      JBFundingCycle memory fundingCycle,
      uint256 reclaimAmount,
      JBRedemptionDelegateAllocation[] memory delegateAllocations,
      string memory memo
    );

  function recordDistributionFor(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency
  ) external returns (JBFundingCycle memory fundingCycle, uint256 distributedAmount);

  function recordUsedAllowanceOf(
    uint256 _projectId,
    uint256 _amount,
    uint256 _currency
  ) external returns (JBFundingCycle memory fundingCycle, uint256 withdrawnAmount);

  function recordAddedBalanceFor(uint256 _projectId, uint256 _amount) external;

  function recordMigration(uint256 _projectId) external returns (uint256 balance);
}

File 33 of 62 : IJBSplitAllocator.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import '../structs/JBSplitAllocationData.sol';

/**
  @title
  Split allocator

  @notice
  Provide a way to process a single split with extra logic

  @dev
  Adheres to:
  IERC165 for adequate interface integration

  @dev
  The contract address should be set as an allocator in the adequate split
*/
interface IJBSplitAllocator is IERC165 {
  /**
    @notice
    This function is called by JBPaymentTerminal.distributePayoutOf(..), during the processing of the split including it

    @dev
    Critical business logic should be protected by an appropriate access control. The token and/or eth are optimistically transfered
    to the allocator for its logic.
    
    @param _data the data passed by the terminal, as a JBSplitAllocationData struct:
                  address token;
                  uint256 amount;
                  uint256 decimals;
                  uint256 projectId;
                  uint256 group;
                  JBSplit split;
  */
  function allocate(JBSplitAllocationData calldata _data) external payable;
}

File 34 of 62 : IJBSplitsStore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../structs/JBGroupedSplits.sol';
import './../structs/JBSplit.sol';
import './IJBDirectory.sol';
import './IJBProjects.sol';

interface IJBSplitsStore {
  event SetSplit(
    uint256 indexed projectId,
    uint256 indexed domain,
    uint256 indexed group,
    JBSplit split,
    address caller
  );

  function projects() external view returns (IJBProjects);

  function directory() external view returns (IJBDirectory);

  function splitsOf(
    uint256 _projectId,
    uint256 _domain,
    uint256 _group
  ) external view returns (JBSplit[] memory);

  function set(
    uint256 _projectId,
    uint256 _domain,
    JBGroupedSplits[] memory _groupedSplits
  ) external;
}

File 35 of 62 : IJBToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBToken {
  function projectId() external view returns (uint256);

  function decimals() external view returns (uint8);

  function totalSupply(uint256 _projectId) external view returns (uint256);

  function balanceOf(address _account, uint256 _projectId) external view returns (uint256);

  function mint(
    uint256 _projectId,
    address _account,
    uint256 _amount
  ) external;

  function burn(
    uint256 _projectId,
    address _account,
    uint256 _amount
  ) external;

  function approve(
    uint256,
    address _spender,
    uint256 _amount
  ) external;

  function transfer(
    uint256 _projectId,
    address _to,
    uint256 _amount
  ) external;

  function transferFrom(
    uint256 _projectId,
    address _from,
    address _to,
    uint256 _amount
  ) external;
}

File 36 of 62 : IJBTokenStore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './IJBFundingCycleStore.sol';
import './IJBProjects.sol';
import './IJBToken.sol';

interface IJBTokenStore {
  event Issue(
    uint256 indexed projectId,
    IJBToken indexed token,
    string name,
    string symbol,
    address caller
  );

  event Mint(
    address indexed holder,
    uint256 indexed projectId,
    uint256 amount,
    bool tokensWereClaimed,
    bool preferClaimedTokens,
    address caller
  );

  event Burn(
    address indexed holder,
    uint256 indexed projectId,
    uint256 amount,
    uint256 initialUnclaimedBalance,
    uint256 initialClaimedBalance,
    bool preferClaimedTokens,
    address caller
  );

  event Claim(
    address indexed holder,
    uint256 indexed projectId,
    uint256 initialUnclaimedBalance,
    uint256 amount,
    address caller
  );

  event Set(uint256 indexed projectId, IJBToken indexed newToken, address caller);

  event Transfer(
    address indexed holder,
    uint256 indexed projectId,
    address indexed recipient,
    uint256 amount,
    address caller
  );

  function tokenOf(uint256 _projectId) external view returns (IJBToken);

  function projects() external view returns (IJBProjects);

  function fundingCycleStore() external view returns (IJBFundingCycleStore);

  function unclaimedBalanceOf(address _holder, uint256 _projectId) external view returns (uint256);

  function unclaimedTotalSupplyOf(uint256 _projectId) external view returns (uint256);

  function totalSupplyOf(uint256 _projectId) external view returns (uint256);

  function balanceOf(address _holder, uint256 _projectId) external view returns (uint256 _result);

  function issueFor(
    uint256 _projectId,
    string calldata _name,
    string calldata _symbol
  ) external returns (IJBToken token);

  function setFor(uint256 _projectId, IJBToken _token) external;

  function burnFrom(
    address _holder,
    uint256 _projectId,
    uint256 _amount,
    bool _preferClaimedTokens
  ) external;

  function mintFor(
    address _holder,
    uint256 _projectId,
    uint256 _amount,
    bool _preferClaimedTokens
  ) external;

  function claimFor(
    address _holder,
    uint256 _projectId,
    uint256 _amount
  ) external;

  function transferFrom(
    address _holder,
    uint256 _projectId,
    address _recipient,
    uint256 _amount
  ) external;
}

File 37 of 62 : IJBTokenUriResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBTokenUriResolver {
  function getUri(uint256 _projectId) external view returns (string memory tokenUri);
}

File 38 of 62 : JBConstants.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
  @notice
  Global constants used across Juicebox contracts.
*/
library JBConstants {
  uint256 public constant MAX_RESERVED_RATE = 10_000;
  uint256 public constant MAX_REDEMPTION_RATE = 10_000;
  uint256 public constant MAX_DISCOUNT_RATE = 1_000_000_000;
  uint256 public constant SPLITS_TOTAL_PERCENT = 1_000_000_000;
  uint256 public constant MAX_FEE = 1_000_000_000;
  uint256 public constant MAX_FEE_DISCOUNT = 1_000_000_000;
}

File 39 of 62 : JBCurrencies.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library JBCurrencies {
  uint256 public constant ETH = 1;
  uint256 public constant USD = 2;
}

File 40 of 62 : JBFixedPointNumber.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library JBFixedPointNumber {
  function adjustDecimals(
    uint256 _value,
    uint256 _decimals,
    uint256 _targetDecimals
  ) internal pure returns (uint256) {
    // If decimals need adjusting, multiply or divide the price by the decimal adjuster to get the normalized result.
    if (_targetDecimals == _decimals) return _value;
    else if (_targetDecimals > _decimals) return _value * 10**(_targetDecimals - _decimals);
    else return _value / 10**(_decimals - _targetDecimals);
  }
}

File 41 of 62 : JBFundingCycleMetadataResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../structs/JBFundingCycle.sol';
import './../structs/JBFundingCycleMetadata.sol';
import './../structs/JBGlobalFundingCycleMetadata.sol';
import './JBConstants.sol';
import './JBGlobalFundingCycleMetadataResolver.sol';

library JBFundingCycleMetadataResolver {
  function shared(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (JBGlobalFundingCycleMetadata memory)
  {
    return JBGlobalFundingCycleMetadataResolver.expandMetadata(uint8(_fundingCycle.metadata >> 8));
  }

  function reservedRate(JBFundingCycle memory _fundingCycle) internal pure returns (uint256) {
    return uint256(uint16(_fundingCycle.metadata >> 24));
  }

  function redemptionRate(JBFundingCycle memory _fundingCycle) internal pure returns (uint256) {
    // Redemption rate is a number 0-10000. It's inverse was stored so the most common case of 100% results in no storage needs.
    return JBConstants.MAX_REDEMPTION_RATE - uint256(uint16(_fundingCycle.metadata >> 40));
  }

  function ballotRedemptionRate(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (uint256)
  {
    // Redemption rate is a number 0-10000. It's inverse was stored so the most common case of 100% results in no storage needs.
    return JBConstants.MAX_REDEMPTION_RATE - uint256(uint16(_fundingCycle.metadata >> 56));
  }

  function payPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {
    return ((_fundingCycle.metadata >> 72) & 1) == 1;
  }

  function distributionsPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {
    return ((_fundingCycle.metadata >> 73) & 1) == 1;
  }

  function redeemPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {
    return ((_fundingCycle.metadata >> 74) & 1) == 1;
  }

  function burnPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {
    return ((_fundingCycle.metadata >> 75) & 1) == 1;
  }

  function mintingAllowed(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {
    return ((_fundingCycle.metadata >> 76) & 1) == 1;
  }

  function terminalMigrationAllowed(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (bool)
  {
    return ((_fundingCycle.metadata >> 77) & 1) == 1;
  }

  function controllerMigrationAllowed(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (bool)
  {
    return ((_fundingCycle.metadata >> 78) & 1) == 1;
  }

  function shouldHoldFees(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {
    return ((_fundingCycle.metadata >> 79) & 1) == 1;
  }

  function preferClaimedTokenOverride(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (bool)
  {
    return ((_fundingCycle.metadata >> 80) & 1) == 1;
  }

  function useTotalOverflowForRedemptions(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (bool)
  {
    return ((_fundingCycle.metadata >> 81) & 1) == 1;
  }

  function useDataSourceForPay(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {
    return (_fundingCycle.metadata >> 82) & 1 == 1;
  }

  function useDataSourceForRedeem(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (bool)
  {
    return (_fundingCycle.metadata >> 83) & 1 == 1;
  }

  function dataSource(JBFundingCycle memory _fundingCycle) internal pure returns (address) {
    return address(uint160(_fundingCycle.metadata >> 84));
  }

  function metadata(JBFundingCycle memory _fundingCycle) internal pure returns (uint256) {
    return uint256(uint8(_fundingCycle.metadata >> 244));
  }

  /**
    @notice
    Pack the funding cycle metadata.

    @param _metadata The metadata to validate and pack.

    @return packed The packed uint256 of all metadata params. The first 8 bits specify the version.
  */
  function packFundingCycleMetadata(JBFundingCycleMetadata memory _metadata)
    internal
    pure
    returns (uint256 packed)
  {
    // version 1 in the bits 0-7 (8 bits).
    packed = 1;
    // global metadta in bits 8-23 (16 bits).
    packed |=
      JBGlobalFundingCycleMetadataResolver.packFundingCycleGlobalMetadata(_metadata.global) <<
      8;
    // reserved rate in bits 24-39 (16 bits).
    packed |= _metadata.reservedRate << 24;
    // redemption rate in bits 40-55 (16 bits).
    // redemption rate is a number 0-10000. Store the reverse so the most common case of 100% results in no storage needs.
    packed |= (JBConstants.MAX_REDEMPTION_RATE - _metadata.redemptionRate) << 40;
    // ballot redemption rate rate in bits 56-71 (16 bits).
    // ballot redemption rate is a number 0-10000. Store the reverse so the most common case of 100% results in no storage needs.
    packed |= (JBConstants.MAX_REDEMPTION_RATE - _metadata.ballotRedemptionRate) << 56;
    // pause pay in bit 72.
    if (_metadata.pausePay) packed |= 1 << 72;
    // pause tap in bit 73.
    if (_metadata.pauseDistributions) packed |= 1 << 73;
    // pause redeem in bit 74.
    if (_metadata.pauseRedeem) packed |= 1 << 74;
    // pause burn in bit 75.
    if (_metadata.pauseBurn) packed |= 1 << 75;
    // allow minting in bit 76.
    if (_metadata.allowMinting) packed |= 1 << 76;
    // allow terminal migration in bit 77.
    if (_metadata.allowTerminalMigration) packed |= 1 << 77;
    // allow controller migration in bit 78.
    if (_metadata.allowControllerMigration) packed |= 1 << 78;
    // hold fees in bit 79.
    if (_metadata.holdFees) packed |= 1 << 79;
    // prefer claimed token override in bit 80.
    if (_metadata.preferClaimedTokenOverride) packed |= 1 << 80;
    // useTotalOverflowForRedemptions in bit 81.
    if (_metadata.useTotalOverflowForRedemptions) packed |= 1 << 81;
    // use pay data source in bit 82.
    if (_metadata.useDataSourceForPay) packed |= 1 << 82;
    // use redeem data source in bit 83.
    if (_metadata.useDataSourceForRedeem) packed |= 1 << 83;
    // data source address in bits 84-243.
    packed |= uint256(uint160(address(_metadata.dataSource))) << 84;
    // metadata in bits 244-252 (8 bits).
    packed |= _metadata.metadata << 244;
  }

  /**
    @notice
    Expand the funding cycle metadata.

    @param _fundingCycle The funding cycle having its metadata expanded.

    @return metadata The metadata object.
  */
  function expandMetadata(JBFundingCycle memory _fundingCycle)
    internal
    pure
    returns (JBFundingCycleMetadata memory)
  {
    return
      JBFundingCycleMetadata(
        shared(_fundingCycle),
        reservedRate(_fundingCycle),
        redemptionRate(_fundingCycle),
        ballotRedemptionRate(_fundingCycle),
        payPaused(_fundingCycle),
        distributionsPaused(_fundingCycle),
        redeemPaused(_fundingCycle),
        burnPaused(_fundingCycle),
        mintingAllowed(_fundingCycle),
        terminalMigrationAllowed(_fundingCycle),
        controllerMigrationAllowed(_fundingCycle),
        shouldHoldFees(_fundingCycle),
        preferClaimedTokenOverride(_fundingCycle),
        useTotalOverflowForRedemptions(_fundingCycle),
        useDataSourceForPay(_fundingCycle),
        useDataSourceForRedeem(_fundingCycle),
        dataSource(_fundingCycle),
        metadata(_fundingCycle)
      );
  }
}

File 42 of 62 : JBGlobalFundingCycleMetadataResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../structs/JBFundingCycleMetadata.sol';

library JBGlobalFundingCycleMetadataResolver {
  function setTerminalsAllowed(uint8 _data) internal pure returns (bool) {
    return (_data & 1) == 1;
  }

  function setControllerAllowed(uint8 _data) internal pure returns (bool) {
    return ((_data >> 1) & 1) == 1;
  }

  function transfersPaused(uint8 _data) internal pure returns (bool) {
    return ((_data >> 2) & 1) == 1;
  }

  /**
    @notice
    Pack the global funding cycle metadata.

    @param _metadata The metadata to validate and pack.

    @return packed The packed uint256 of all global metadata params. The first 8 bits specify the version.
  */
  function packFundingCycleGlobalMetadata(JBGlobalFundingCycleMetadata memory _metadata)
    internal
    pure
    returns (uint256 packed)
  {
    // allow set terminals in bit 0.
    if (_metadata.allowSetTerminals) packed |= 1;
    // allow set controller in bit 1.
    if (_metadata.allowSetController) packed |= 1 << 1;
    // pause transfers in bit 2.
    if (_metadata.pauseTransfers) packed |= 1 << 2;
  }

  /**
    @notice
    Expand the global funding cycle metadata.

    @param _packedMetadata The packed metadata to expand.

    @return metadata The global metadata object.
  */
  function expandMetadata(uint8 _packedMetadata)
    internal
    pure
    returns (JBGlobalFundingCycleMetadata memory metadata)
  {
    return
      JBGlobalFundingCycleMetadata(
        setTerminalsAllowed(_packedMetadata),
        setControllerAllowed(_packedMetadata),
        transfersPaused(_packedMetadata)
      );
  }
}

File 43 of 62 : JBOperations.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @notice Defines permissions as indicies in a uint256, as such, must be between 1 and 255.
 */
library JBOperations {
  uint256 public constant RECONFIGURE = 1;
  uint256 public constant REDEEM = 2;
  uint256 public constant MIGRATE_CONTROLLER = 3;
  uint256 public constant MIGRATE_TERMINAL = 4;
  uint256 public constant PROCESS_FEES = 5;
  uint256 public constant SET_METADATA = 6;
  uint256 public constant ISSUE = 7;
  uint256 public constant SET_TOKEN = 8;
  uint256 public constant MINT = 9;
  uint256 public constant BURN = 10;
  uint256 public constant CLAIM = 11;
  uint256 public constant TRANSFER = 12;
  uint256 public constant REQUIRE_CLAIM = 13; // unused in v3
  uint256 public constant SET_CONTROLLER = 14;
  uint256 public constant SET_TERMINALS = 15;
  uint256 public constant SET_PRIMARY_TERMINAL = 16;
  uint256 public constant USE_ALLOWANCE = 17;
  uint256 public constant SET_SPLITS = 18;
  uint256 public constant MANAGE_PAYMENTS = 254;
  uint256 public constant MANAGE_ROLES = 255;
}

File 44 of 62 : JBSplitsGroups.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library JBSplitsGroups {
  uint256 public constant ETH_PAYOUT = 1;
  uint256 public constant RESERVED_TOKENS = 2;
}

File 45 of 62 : JBTokens.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library JBTokens {
  /** 
    @notice 
    The ETH token address in Juicebox is represented by 0x000000000000000000000000000000000000EEEe.
  */
  address public constant ETH = address(0x000000000000000000000000000000000000EEEe);
}

File 46 of 62 : JBDidPayData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './JBTokenAmount.sol';

/** 
  @member payer The address from which the payment originated.
  @member projectId The ID of the project for which the payment was made.
  @member currentFundingCycleConfiguration The configuration of the funding cycle during which the payment is being made.
  @member amount The amount of the payment. Includes the token being paid, the value, the number of decimals included, and the currency of the amount.
  @member forwardedAmount The amount of the payment that is being sent to the delegate. Includes the token being paid, the value, the number of decimals included, and the currency of the amount.
  @member projectTokenCount The number of project tokens minted for the beneficiary.
  @member beneficiary The address to which the tokens were minted.
  @member preferClaimedTokens A flag indicating whether the request prefered to mint project tokens into the beneficiaries wallet rather than leaving them unclaimed. This is only possible if the project has an attached token contract.
  @member memo The memo that is being emitted alongside the payment.
  @member metadata Extra data to send to the delegate.
*/
struct JBDidPayData {
  address payer;
  uint256 projectId;
  uint256 currentFundingCycleConfiguration;
  JBTokenAmount amount;
  JBTokenAmount forwardedAmount;
  uint256 projectTokenCount;
  address beneficiary;
  bool preferClaimedTokens;
  string memo;
  bytes metadata;
}

File 47 of 62 : JBDidRedeemData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './JBTokenAmount.sol';

/** 
  @member holder The holder of the tokens being redeemed.
  @member projectId The ID of the project with which the redeemed tokens are associated.
  @member currentFundingCycleConfiguration The configuration of the funding cycle during which the redemption is being made.
  @member projectTokenCount The number of project tokens being redeemed.
  @member reclaimedAmount The amount reclaimed from the treasury. Includes the token being reclaimed, the value, the number of decimals included, and the currency of the amount.
  @member forwardedAmount The amount of the payment that is being sent to the delegate. Includes the token being paid, the value, the number of decimals included, and the currency of the amount.
  @member beneficiary The address to which the reclaimed amount will be sent.
  @member memo The memo that is being emitted alongside the redemption.
  @member metadata Extra data to send to the delegate.
*/
struct JBDidRedeemData {
  address holder;
  uint256 projectId;
  uint256 currentFundingCycleConfiguration;
  uint256 projectTokenCount;
  JBTokenAmount reclaimedAmount;
  JBTokenAmount forwardedAmount;
  address payable beneficiary;
  string memo;
  bytes metadata;
}

File 48 of 62 : JBFee.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/** 
  @member amount The total amount the fee was taken from, as a fixed point number with the same number of decimals as the terminal in which this struct was created.
  @member fee The percent of the fee, out of MAX_FEE.
  @member feeDiscount The discount of the fee.
  @member beneficiary The address that will receive the tokens that are minted as a result of the fee payment.
*/
struct JBFee {
  uint256 amount;
  uint32 fee;
  uint32 feeDiscount;
  address beneficiary;
}

File 49 of 62 : JBFundAccessConstraints.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../interfaces/IJBPaymentTerminal.sol';

/** 
  @member terminal The terminal within which the distribution limit and the overflow allowance applies.
  @member token The token for which the fund access constraints apply.
  @member distributionLimit The amount of the distribution limit, as a fixed point number with the same number of decimals as the terminal within which the limit applies.
  @member distributionLimitCurrency The currency of the distribution limit.
  @member overflowAllowance The amount of the allowance, as a fixed point number with the same number of decimals as the terminal within which the allowance applies.
  @member overflowAllowanceCurrency The currency of the overflow allowance.
*/
struct JBFundAccessConstraints {
  IJBPaymentTerminal terminal;
  address token;
  uint256 distributionLimit;
  uint256 distributionLimitCurrency;
  uint256 overflowAllowance;
  uint256 overflowAllowanceCurrency;
}

File 50 of 62 : JBFundingCycle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../interfaces/IJBFundingCycleBallot.sol';

/** 
  @member number The funding cycle number for the cycle's project. Each funding cycle has a number that is an increment of the cycle that directly preceded it. Each project's first funding cycle has a number of 1.
  @member configuration The timestamp when the parameters for this funding cycle were configured. This value will stay the same for subsequent funding cycles that roll over from an originally configured cycle.
  @member basedOn The `configuration` of the funding cycle that was active when this cycle was created.
  @member start The timestamp marking the moment from which the funding cycle is considered active. It is a unix timestamp measured in seconds.
  @member duration The number of seconds the funding cycle lasts for, after which a new funding cycle will start. A duration of 0 means that the funding cycle will stay active until the project owner explicitly issues a reconfiguration, at which point a new funding cycle will immediately start with the updated properties. If the duration is greater than 0, a project owner cannot make changes to a funding cycle's parameters while it is active – any proposed changes will apply to the subsequent cycle. If no changes are proposed, a funding cycle rolls over to another one with the same properties but new `start` timestamp and a discounted `weight`.
  @member weight A fixed point number with 18 decimals that contracts can use to base arbitrary calculations on. For example, payment terminals can use this to determine how many tokens should be minted when a payment is received.
  @member discountRate A percent by how much the `weight` of the subsequent funding cycle should be reduced, if the project owner hasn't configured the subsequent funding cycle with an explicit `weight`. If it's 0, each funding cycle will have equal weight. If the number is 90%, the next funding cycle will have a 10% smaller weight. This weight is out of `JBConstants.MAX_DISCOUNT_RATE`.
  @member ballot An address of a contract that says whether a proposed reconfiguration should be accepted or rejected. It can be used to create rules around how a project owner can change funding cycle parameters over time.
  @member metadata Extra data that can be associated with a funding cycle.
*/
struct JBFundingCycle {
  uint256 number;
  uint256 configuration;
  uint256 basedOn;
  uint256 start;
  uint256 duration;
  uint256 weight;
  uint256 discountRate;
  IJBFundingCycleBallot ballot;
  uint256 metadata;
}

File 51 of 62 : JBFundingCycleData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../interfaces/IJBFundingCycleBallot.sol';

/** 
  @member duration The number of seconds the funding cycle lasts for, after which a new funding cycle will start. A duration of 0 means that the funding cycle will stay active until the project owner explicitly issues a reconfiguration, at which point a new funding cycle will immediately start with the updated properties. If the duration is greater than 0, a project owner cannot make changes to a funding cycle's parameters while it is active – any proposed changes will apply to the subsequent cycle. If no changes are proposed, a funding cycle rolls over to another one with the same properties but new `start` timestamp and a discounted `weight`.
  @member weight A fixed point number with 18 decimals that contracts can use to base arbitrary calculations on. For example, payment terminals can use this to determine how many tokens should be minted when a payment is received.
  @member discountRate A percent by how much the `weight` of the subsequent funding cycle should be reduced, if the project owner hasn't configured the subsequent funding cycle with an explicit `weight`. If it's 0, each funding cycle will have equal weight. If the number is 90%, the next funding cycle will have a 10% smaller weight. This weight is out of `JBConstants.MAX_DISCOUNT_RATE`.
  @member ballot An address of a contract that says whether a proposed reconfiguration should be accepted or rejected. It can be used to create rules around how a project owner can change funding cycle parameters over time.
*/
struct JBFundingCycleData {
  uint256 duration;
  uint256 weight;
  uint256 discountRate;
  IJBFundingCycleBallot ballot;
}

File 52 of 62 : JBFundingCycleMetadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './JBGlobalFundingCycleMetadata.sol';

/** 
  @member global Data used globally in non-migratable ecosystem contracts.
  @member reservedRate The reserved rate of the funding cycle. This number is a percentage calculated out of `JBConstants.MAX_RESERVED_RATE`.
  @member redemptionRate The redemption rate of the funding cycle. This number is a percentage calculated out of `JBConstants.MAX_REDEMPTION_RATE`.
  @member ballotRedemptionRate The redemption rate to use during an active ballot of the funding cycle. This number is a percentage calculated out of `JBConstants.MAX_REDEMPTION_RATE`.
  @member pausePay A flag indicating if the pay functionality should be paused during the funding cycle.
  @member pauseDistributions A flag indicating if the distribute functionality should be paused during the funding cycle.
  @member pauseRedeem A flag indicating if the redeem functionality should be paused during the funding cycle.
  @member pauseBurn A flag indicating if the burn functionality should be paused during the funding cycle.
  @member allowMinting A flag indicating if minting tokens should be allowed during this funding cycle.
  @member allowTerminalMigration A flag indicating if migrating terminals should be allowed during this funding cycle.
  @member allowControllerMigration A flag indicating if migrating controllers should be allowed during this funding cycle.
  @member holdFees A flag indicating if fees should be held during this funding cycle.
  @member preferClaimedTokenOverride A flag indicating if claimed tokens should always be prefered to unclaimed tokens when minting.
  @member useTotalOverflowForRedemptions A flag indicating if redemptions should use the project's balance held in all terminals instead of the project's local terminal balance from which the redemption is being fulfilled.
  @member useDataSourceForPay A flag indicating if the data source should be used for pay transactions during this funding cycle.
  @member useDataSourceForRedeem A flag indicating if the data source should be used for redeem transactions during this funding cycle.
  @member dataSource The data source to use during this funding cycle.
  @member metadata Metadata of the metadata, up to uint8 in size.
*/
struct JBFundingCycleMetadata {
  JBGlobalFundingCycleMetadata global;
  uint256 reservedRate;
  uint256 redemptionRate;
  uint256 ballotRedemptionRate;
  bool pausePay;
  bool pauseDistributions;
  bool pauseRedeem;
  bool pauseBurn;
  bool allowMinting;
  bool allowTerminalMigration;
  bool allowControllerMigration;
  bool holdFees;
  bool preferClaimedTokenOverride;
  bool useTotalOverflowForRedemptions;
  bool useDataSourceForPay;
  bool useDataSourceForRedeem;
  address dataSource;
  uint256 metadata;
}

File 53 of 62 : JBGlobalFundingCycleMetadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/** 
  @member allowSetTerminals A flag indicating if setting terminals should be allowed during this funding cycle.
  @member allowSetController A flag indicating if setting a new controller should be allowed during this funding cycle.
  @member pauseTransfers A flag indicating if the project token transfer functionality should be paused during the funding cycle.
*/
struct JBGlobalFundingCycleMetadata {
  bool allowSetTerminals;
  bool allowSetController;
  bool pauseTransfers;
}

File 54 of 62 : JBGroupedSplits.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './JBSplit.sol';

/** 
  @member group The group indentifier.
  @member splits The splits to associate with the group.
*/
struct JBGroupedSplits {
  uint256 group;
  JBSplit[] splits;
}

File 55 of 62 : JBOperatorData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/** 
  @member operator The address of the operator.
  @member domain The domain within which the operator is being given permissions. A domain of 0 is a wildcard domain, which gives an operator access to all domains.
  @member permissionIndexes The indexes of the permissions the operator is being given.
*/
struct JBOperatorData {
  address operator;
  uint256 domain;
  uint256[] permissionIndexes;
}

File 56 of 62 : JBPayDelegateAllocation.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '../interfaces/IJBPayDelegate.sol';

/** 
 @member delegate A delegate contract to use for subsequent calls.
 @member amount The amount to send to the delegate.
*/
struct JBPayDelegateAllocation {
  IJBPayDelegate delegate;
  uint256 amount;
}

File 57 of 62 : JBProjectMetadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/** 
  @member content The metadata content.
  @member domain The domain within which the metadata applies.
*/
struct JBProjectMetadata {
  string content;
  uint256 domain;
}

File 58 of 62 : JBRedemptionDelegateAllocation.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '../interfaces/IJBRedemptionDelegate.sol';

/** 
 @member delegate A delegate contract to use for subsequent calls.
 @member amount The amount to send to the delegate.
*/
struct JBRedemptionDelegateAllocation {
  IJBRedemptionDelegate delegate;
  uint256 amount;
}

File 59 of 62 : JBSplit.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './../interfaces/IJBSplitAllocator.sol';

/** 
  @member preferClaimed A flag that only has effect if a projectId is also specified, and the project has a token contract attached. If so, this flag indicates if the tokens that result from making a payment to the project should be delivered claimed into the beneficiary's wallet, or unclaimed to save gas.
  @member preferAddToBalance A flag indicating if a distribution to a project should prefer triggering it's addToBalance function instead of its pay function.
  @member percent The percent of the whole group that this split occupies. This number is out of `JBConstants.SPLITS_TOTAL_PERCENT`.
  @member projectId The ID of a project. If an allocator is not set but a projectId is set, funds will be sent to the protocol treasury belonging to the project who's ID is specified. Resulting tokens will be routed to the beneficiary with the claimed token preference respected.
  @member beneficiary An address. The role the of the beneficary depends on whether or not projectId is specified, and whether or not an allocator is specified. If allocator is set, the beneficiary will be forwarded to the allocator for it to use. If allocator is not set but projectId is set, the beneficiary is the address to which the project's tokens will be sent that result from a payment to it. If neither allocator or projectId are set, the beneficiary is where the funds from the split will be sent.
  @member lockedUntil Specifies if the split should be unchangeable until the specified time, with the exception of extending the locked period.
  @member allocator If an allocator is specified, funds will be sent to the allocator contract along with all properties of this split.
*/
struct JBSplit {
  bool preferClaimed;
  bool preferAddToBalance;
  uint256 percent;
  uint256 projectId;
  address payable beneficiary;
  uint256 lockedUntil;
  IJBSplitAllocator allocator;
}

File 60 of 62 : JBSplitAllocationData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './JBSplit.sol';

/** 
  @member token The token being sent to the split allocator.
  @member amount The amount being sent to the split allocator, as a fixed point number.
  @member decimals The number of decimals in the amount.
  @member projectId The project to which the split belongs.
  @member group The group to which the split belongs.
  @member split The split that caused the allocation.
*/
struct JBSplitAllocationData {
  address token;
  uint256 amount;
  uint256 decimals;
  uint256 projectId;
  uint256 group;
  JBSplit split;
}

File 61 of 62 : JBTokenAmount.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/* 
  @member token The token the payment was made in.
  @member value The amount of tokens that was paid, as a fixed point number.
  @member decimals The number of decimals included in the value fixed point number.
  @member currency The expected currency of the value.
**/
struct JBTokenAmount {
  address token;
  uint256 value;
  uint256 decimals;
  uint256 currency;
}

File 62 of 62 : PRBMath.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;

/// @notice Emitted when the result overflows uint256.
error PRBMath__MulDivFixedPointOverflow(uint256 prod1);

/// @notice Emitted when the result overflows uint256.
error PRBMath__MulDivOverflow(uint256 prod1, uint256 denominator);

/// @notice Emitted when one of the inputs is type(int256).min.
error PRBMath__MulDivSignedInputTooSmall();

/// @notice Emitted when the intermediary absolute result overflows int256.
error PRBMath__MulDivSignedOverflow(uint256 rAbs);

/// @notice Emitted when the input is MIN_SD59x18.
error PRBMathSD59x18__AbsInputTooSmall();

/// @notice Emitted when ceiling a number overflows SD59x18.
error PRBMathSD59x18__CeilOverflow(int256 x);

/// @notice Emitted when one of the inputs is MIN_SD59x18.
error PRBMathSD59x18__DivInputTooSmall();

/// @notice Emitted when one of the intermediary unsigned results overflows SD59x18.
error PRBMathSD59x18__DivOverflow(uint256 rAbs);

/// @notice Emitted when the input is greater than 133.084258667509499441.
error PRBMathSD59x18__ExpInputTooBig(int256 x);

/// @notice Emitted when the input is greater than 192.
error PRBMathSD59x18__Exp2InputTooBig(int256 x);

/// @notice Emitted when flooring a number underflows SD59x18.
error PRBMathSD59x18__FloorUnderflow(int256 x);

/// @notice Emitted when converting a basic integer to the fixed-point format overflows SD59x18.
error PRBMathSD59x18__FromIntOverflow(int256 x);

/// @notice Emitted when converting a basic integer to the fixed-point format underflows SD59x18.
error PRBMathSD59x18__FromIntUnderflow(int256 x);

/// @notice Emitted when the product of the inputs is negative.
error PRBMathSD59x18__GmNegativeProduct(int256 x, int256 y);

/// @notice Emitted when multiplying the inputs overflows SD59x18.
error PRBMathSD59x18__GmOverflow(int256 x, int256 y);

/// @notice Emitted when the input is less than or equal to zero.
error PRBMathSD59x18__LogInputTooSmall(int256 x);

/// @notice Emitted when one of the inputs is MIN_SD59x18.
error PRBMathSD59x18__MulInputTooSmall();

/// @notice Emitted when the intermediary absolute result overflows SD59x18.
error PRBMathSD59x18__MulOverflow(uint256 rAbs);

/// @notice Emitted when the intermediary absolute result overflows SD59x18.
error PRBMathSD59x18__PowuOverflow(uint256 rAbs);

/// @notice Emitted when the input is negative.
error PRBMathSD59x18__SqrtNegativeInput(int256 x);

/// @notice Emitted when the calculating the square root overflows SD59x18.
error PRBMathSD59x18__SqrtOverflow(int256 x);

/// @notice Emitted when addition overflows UD60x18.
error PRBMathUD60x18__AddOverflow(uint256 x, uint256 y);

/// @notice Emitted when ceiling a number overflows UD60x18.
error PRBMathUD60x18__CeilOverflow(uint256 x);

/// @notice Emitted when the input is greater than 133.084258667509499441.
error PRBMathUD60x18__ExpInputTooBig(uint256 x);

/// @notice Emitted when the input is greater than 192.
error PRBMathUD60x18__Exp2InputTooBig(uint256 x);

/// @notice Emitted when converting a basic integer to the fixed-point format format overflows UD60x18.
error PRBMathUD60x18__FromUintOverflow(uint256 x);

/// @notice Emitted when multiplying the inputs overflows UD60x18.
error PRBMathUD60x18__GmOverflow(uint256 x, uint256 y);

/// @notice Emitted when the input is less than 1.
error PRBMathUD60x18__LogInputTooSmall(uint256 x);

/// @notice Emitted when the calculating the square root overflows UD60x18.
error PRBMathUD60x18__SqrtOverflow(uint256 x);

/// @notice Emitted when subtraction underflows UD60x18.
error PRBMathUD60x18__SubUnderflow(uint256 x, uint256 y);

/// @dev Common mathematical functions used in both PRBMathSD59x18 and PRBMathUD60x18. Note that this shared library
/// does not always assume the signed 59.18-decimal fixed-point or the unsigned 60.18-decimal fixed-point
/// representation. When it does not, it is explicitly mentioned in the NatSpec documentation.
library PRBMath {
    /// STRUCTS ///

    struct SD59x18 {
        int256 value;
    }

    struct UD60x18 {
        uint256 value;
    }

    /// STORAGE ///

    /// @dev How many trailing decimals can be represented.
    uint256 internal constant SCALE = 1e18;

    /// @dev Largest power of two divisor of SCALE.
    uint256 internal constant SCALE_LPOTD = 262144;

    /// @dev SCALE inverted mod 2^256.
    uint256 internal constant SCALE_INVERSE =
        78156646155174841979727994598816262306175212592076161876661_508869554232690281;

    /// FUNCTIONS ///

    /// @notice Calculates the binary exponent of x using the binary fraction method.
    /// @dev Has to use 192.64-bit fixed-point numbers.
    /// See https://ethereum.stackexchange.com/a/96594/24693.
    /// @param x The exponent as an unsigned 192.64-bit fixed-point number.
    /// @return result The result as an unsigned 60.18-decimal fixed-point number.
    function exp2(uint256 x) internal pure returns (uint256 result) {
        unchecked {
            // Start from 0.5 in the 192.64-bit fixed-point format.
            result = 0x800000000000000000000000000000000000000000000000;

            // Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows
            // because the initial result is 2^191 and all magic factors are less than 2^65.
            if (x & 0x8000000000000000 > 0) {
                result = (result * 0x16A09E667F3BCC909) >> 64;
            }
            if (x & 0x4000000000000000 > 0) {
                result = (result * 0x1306FE0A31B7152DF) >> 64;
            }
            if (x & 0x2000000000000000 > 0) {
                result = (result * 0x1172B83C7D517ADCE) >> 64;
            }
            if (x & 0x1000000000000000 > 0) {
                result = (result * 0x10B5586CF9890F62A) >> 64;
            }
            if (x & 0x800000000000000 > 0) {
                result = (result * 0x1059B0D31585743AE) >> 64;
            }
            if (x & 0x400000000000000 > 0) {
                result = (result * 0x102C9A3E778060EE7) >> 64;
            }
            if (x & 0x200000000000000 > 0) {
                result = (result * 0x10163DA9FB33356D8) >> 64;
            }
            if (x & 0x100000000000000 > 0) {
                result = (result * 0x100B1AFA5ABCBED61) >> 64;
            }
            if (x & 0x80000000000000 > 0) {
                result = (result * 0x10058C86DA1C09EA2) >> 64;
            }
            if (x & 0x40000000000000 > 0) {
                result = (result * 0x1002C605E2E8CEC50) >> 64;
            }
            if (x & 0x20000000000000 > 0) {
                result = (result * 0x100162F3904051FA1) >> 64;
            }
            if (x & 0x10000000000000 > 0) {
                result = (result * 0x1000B175EFFDC76BA) >> 64;
            }
            if (x & 0x8000000000000 > 0) {
                result = (result * 0x100058BA01FB9F96D) >> 64;
            }
            if (x & 0x4000000000000 > 0) {
                result = (result * 0x10002C5CC37DA9492) >> 64;
            }
            if (x & 0x2000000000000 > 0) {
                result = (result * 0x1000162E525EE0547) >> 64;
            }
            if (x & 0x1000000000000 > 0) {
                result = (result * 0x10000B17255775C04) >> 64;
            }
            if (x & 0x800000000000 > 0) {
                result = (result * 0x1000058B91B5BC9AE) >> 64;
            }
            if (x & 0x400000000000 > 0) {
                result = (result * 0x100002C5C89D5EC6D) >> 64;
            }
            if (x & 0x200000000000 > 0) {
                result = (result * 0x10000162E43F4F831) >> 64;
            }
            if (x & 0x100000000000 > 0) {
                result = (result * 0x100000B1721BCFC9A) >> 64;
            }
            if (x & 0x80000000000 > 0) {
                result = (result * 0x10000058B90CF1E6E) >> 64;
            }
            if (x & 0x40000000000 > 0) {
                result = (result * 0x1000002C5C863B73F) >> 64;
            }
            if (x & 0x20000000000 > 0) {
                result = (result * 0x100000162E430E5A2) >> 64;
            }
            if (x & 0x10000000000 > 0) {
                result = (result * 0x1000000B172183551) >> 64;
            }
            if (x & 0x8000000000 > 0) {
                result = (result * 0x100000058B90C0B49) >> 64;
            }
            if (x & 0x4000000000 > 0) {
                result = (result * 0x10000002C5C8601CC) >> 64;
            }
            if (x & 0x2000000000 > 0) {
                result = (result * 0x1000000162E42FFF0) >> 64;
            }
            if (x & 0x1000000000 > 0) {
                result = (result * 0x10000000B17217FBB) >> 64;
            }
            if (x & 0x800000000 > 0) {
                result = (result * 0x1000000058B90BFCE) >> 64;
            }
            if (x & 0x400000000 > 0) {
                result = (result * 0x100000002C5C85FE3) >> 64;
            }
            if (x & 0x200000000 > 0) {
                result = (result * 0x10000000162E42FF1) >> 64;
            }
            if (x & 0x100000000 > 0) {
                result = (result * 0x100000000B17217F8) >> 64;
            }
            if (x & 0x80000000 > 0) {
                result = (result * 0x10000000058B90BFC) >> 64;
            }
            if (x & 0x40000000 > 0) {
                result = (result * 0x1000000002C5C85FE) >> 64;
            }
            if (x & 0x20000000 > 0) {
                result = (result * 0x100000000162E42FF) >> 64;
            }
            if (x & 0x10000000 > 0) {
                result = (result * 0x1000000000B17217F) >> 64;
            }
            if (x & 0x8000000 > 0) {
                result = (result * 0x100000000058B90C0) >> 64;
            }
            if (x & 0x4000000 > 0) {
                result = (result * 0x10000000002C5C860) >> 64;
            }
            if (x & 0x2000000 > 0) {
                result = (result * 0x1000000000162E430) >> 64;
            }
            if (x & 0x1000000 > 0) {
                result = (result * 0x10000000000B17218) >> 64;
            }
            if (x & 0x800000 > 0) {
                result = (result * 0x1000000000058B90C) >> 64;
            }
            if (x & 0x400000 > 0) {
                result = (result * 0x100000000002C5C86) >> 64;
            }
            if (x & 0x200000 > 0) {
                result = (result * 0x10000000000162E43) >> 64;
            }
            if (x & 0x100000 > 0) {
                result = (result * 0x100000000000B1721) >> 64;
            }
            if (x & 0x80000 > 0) {
                result = (result * 0x10000000000058B91) >> 64;
            }
            if (x & 0x40000 > 0) {
                result = (result * 0x1000000000002C5C8) >> 64;
            }
            if (x & 0x20000 > 0) {
                result = (result * 0x100000000000162E4) >> 64;
            }
            if (x & 0x10000 > 0) {
                result = (result * 0x1000000000000B172) >> 64;
            }
            if (x & 0x8000 > 0) {
                result = (result * 0x100000000000058B9) >> 64;
            }
            if (x & 0x4000 > 0) {
                result = (result * 0x10000000000002C5D) >> 64;
            }
            if (x & 0x2000 > 0) {
                result = (result * 0x1000000000000162E) >> 64;
            }
            if (x & 0x1000 > 0) {
                result = (result * 0x10000000000000B17) >> 64;
            }
            if (x & 0x800 > 0) {
                result = (result * 0x1000000000000058C) >> 64;
            }
            if (x & 0x400 > 0) {
                result = (result * 0x100000000000002C6) >> 64;
            }
            if (x & 0x200 > 0) {
                result = (result * 0x10000000000000163) >> 64;
            }
            if (x & 0x100 > 0) {
                result = (result * 0x100000000000000B1) >> 64;
            }
            if (x & 0x80 > 0) {
                result = (result * 0x10000000000000059) >> 64;
            }
            if (x & 0x40 > 0) {
                result = (result * 0x1000000000000002C) >> 64;
            }
            if (x & 0x20 > 0) {
                result = (result * 0x10000000000000016) >> 64;
            }
            if (x & 0x10 > 0) {
                result = (result * 0x1000000000000000B) >> 64;
            }
            if (x & 0x8 > 0) {
                result = (result * 0x10000000000000006) >> 64;
            }
            if (x & 0x4 > 0) {
                result = (result * 0x10000000000000003) >> 64;
            }
            if (x & 0x2 > 0) {
                result = (result * 0x10000000000000001) >> 64;
            }
            if (x & 0x1 > 0) {
                result = (result * 0x10000000000000001) >> 64;
            }

            // We're doing two things at the same time:
            //
            //   1. Multiply the result by 2^n + 1, where "2^n" is the integer part and the one is added to account for
            //      the fact that we initially set the result to 0.5. This is accomplished by subtracting from 191
            //      rather than 192.
            //   2. Convert the result to the unsigned 60.18-decimal fixed-point format.
            //
            // This works because 2^(191-ip) = 2^ip / 2^191, where "ip" is the integer part "2^n".
            result *= SCALE;
            result >>= (191 - (x >> 64));
        }
    }

    /// @notice Finds the zero-based index of the first one in the binary representation of x.
    /// @dev See the note on msb in the "Find First Set" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set
    /// @param x The uint256 number for which to find the index of the most significant bit.
    /// @return msb The index of the most significant bit as an uint256.
    function mostSignificantBit(uint256 x) internal pure returns (uint256 msb) {
        if (x >= 2**128) {
            x >>= 128;
            msb += 128;
        }
        if (x >= 2**64) {
            x >>= 64;
            msb += 64;
        }
        if (x >= 2**32) {
            x >>= 32;
            msb += 32;
        }
        if (x >= 2**16) {
            x >>= 16;
            msb += 16;
        }
        if (x >= 2**8) {
            x >>= 8;
            msb += 8;
        }
        if (x >= 2**4) {
            x >>= 4;
            msb += 4;
        }
        if (x >= 2**2) {
            x >>= 2;
            msb += 2;
        }
        if (x >= 2**1) {
            // No need to shift x any more.
            msb += 1;
        }
    }

    /// @notice Calculates floor(x*y÷denominator) with full precision.
    ///
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.
    ///
    /// Requirements:
    /// - The denominator cannot be zero.
    /// - The result must fit within uint256.
    ///
    /// Caveats:
    /// - This function does not work with fixed-point numbers.
    ///
    /// @param x The multiplicand as an uint256.
    /// @param y The multiplier as an uint256.
    /// @param denominator The divisor as an uint256.
    /// @return result The result as an uint256.
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
        // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
        // variables such that product = prod1 * 2^256 + prod0.
        uint256 prod0; // Least significant 256 bits of the product
        uint256 prod1; // Most significant 256 bits of the product
        assembly {
            let mm := mulmod(x, y, not(0))
            prod0 := mul(x, y)
            prod1 := sub(sub(mm, prod0), lt(mm, prod0))
        }

        // Handle non-overflow cases, 256 by 256 division.
        if (prod1 == 0) {
            unchecked {
                result = prod0 / denominator;
            }
            return result;
        }

        // Make sure the result is less than 2^256. Also prevents denominator == 0.
        if (prod1 >= denominator) {
            revert PRBMath__MulDivOverflow(prod1, denominator);
        }

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

        // Make division exact by subtracting the remainder from [prod1 prod0].
        uint256 remainder;
        assembly {
            // Compute remainder using mulmod.
            remainder := mulmod(x, y, denominator)

            // Subtract 256 bit number from 512 bit number.
            prod1 := sub(prod1, gt(remainder, prod0))
            prod0 := sub(prod0, remainder)
        }

        // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
        // See https://cs.stackexchange.com/q/138556/92363.
        unchecked {
            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 lpotdod = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by lpotdod.
                denominator := div(denominator, lpotdod)

                // Divide [prod1 prod0] by lpotdod.
                prod0 := div(prod0, lpotdod)

                // Flip lpotdod such that it is 2^256 / lpotdod. If lpotdod is zero, then it becomes one.
                lpotdod := add(div(sub(0, lpotdod), lpotdod), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * lpotdod;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

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

    /// @notice Calculates floor(x*y÷1e18) with full precision.
    ///
    /// @dev Variant of "mulDiv" with constant folding, i.e. in which the denominator is always 1e18. Before returning the
    /// final result, we add 1 if (x * y) % SCALE >= HALF_SCALE. Without this, 6.6e-19 would be truncated to 0 instead of
    /// being rounded to 1e-18.  See "Listing 6" and text above it at https://accu.org/index.php/journals/1717.
    ///
    /// Requirements:
    /// - The result must fit within uint256.
    ///
    /// Caveats:
    /// - The body is purposely left uncommented; see the NatSpec comments in "PRBMath.mulDiv" to understand how this works.
    /// - It is assumed that the result can never be type(uint256).max when x and y solve the following two equations:
    ///     1. x * y = type(uint256).max * SCALE
    ///     2. (x * y) % SCALE >= SCALE / 2
    ///
    /// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.
    /// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.
    /// @return result The result as an unsigned 60.18-decimal fixed-point number.
    function mulDivFixedPoint(uint256 x, uint256 y) internal pure returns (uint256 result) {
        uint256 prod0;
        uint256 prod1;
        assembly {
            let mm := mulmod(x, y, not(0))
            prod0 := mul(x, y)
            prod1 := sub(sub(mm, prod0), lt(mm, prod0))
        }

        if (prod1 >= SCALE) {
            revert PRBMath__MulDivFixedPointOverflow(prod1);
        }

        uint256 remainder;
        uint256 roundUpUnit;
        assembly {
            remainder := mulmod(x, y, SCALE)
            roundUpUnit := gt(remainder, 499999999999999999)
        }

        if (prod1 == 0) {
            unchecked {
                result = (prod0 / SCALE) + roundUpUnit;
                return result;
            }
        }

        assembly {
            result := add(
                mul(
                    or(
                        div(sub(prod0, remainder), SCALE_LPOTD),
                        mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, SCALE_LPOTD), SCALE_LPOTD), 1))
                    ),
                    SCALE_INVERSE
                ),
                roundUpUnit
            )
        }
    }

    /// @notice Calculates floor(x*y÷denominator) with full precision.
    ///
    /// @dev An extension of "mulDiv" for signed numbers. Works by computing the signs and the absolute values separately.
    ///
    /// Requirements:
    /// - None of the inputs can be type(int256).min.
    /// - The result must fit within int256.
    ///
    /// @param x The multiplicand as an int256.
    /// @param y The multiplier as an int256.
    /// @param denominator The divisor as an int256.
    /// @return result The result as an int256.
    function mulDivSigned(
        int256 x,
        int256 y,
        int256 denominator
    ) internal pure returns (int256 result) {
        if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {
            revert PRBMath__MulDivSignedInputTooSmall();
        }

        // Get hold of the absolute values of x, y and the denominator.
        uint256 ax;
        uint256 ay;
        uint256 ad;
        unchecked {
            ax = x < 0 ? uint256(-x) : uint256(x);
            ay = y < 0 ? uint256(-y) : uint256(y);
            ad = denominator < 0 ? uint256(-denominator) : uint256(denominator);
        }

        // Compute the absolute value of (x*y)÷denominator. The result must fit within int256.
        uint256 rAbs = mulDiv(ax, ay, ad);
        if (rAbs > uint256(type(int256).max)) {
            revert PRBMath__MulDivSignedOverflow(rAbs);
        }

        // Get the signs of x, y and the denominator.
        uint256 sx;
        uint256 sy;
        uint256 sd;
        assembly {
            sx := sgt(x, sub(0, 1))
            sy := sgt(y, sub(0, 1))
            sd := sgt(denominator, sub(0, 1))
        }

        // XOR over sx, sy and sd. This is checking whether there are one or three negative signs in the inputs.
        // If yes, the result should be negative.
        result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs);
    }

    /// @notice Calculates the square root of x, rounding down.
    /// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.
    ///
    /// Caveats:
    /// - This function does not work with fixed-point numbers.
    ///
    /// @param x The uint256 number for which to calculate the square root.
    /// @return result The result as an uint256.
    function sqrt(uint256 x) internal pure returns (uint256 result) {
        if (x == 0) {
            return 0;
        }

        // Set the initial guess to the least power of two that is greater than or equal to sqrt(x).
        uint256 xAux = uint256(x);
        result = 1;
        if (xAux >= 0x100000000000000000000000000000000) {
            xAux >>= 128;
            result <<= 64;
        }
        if (xAux >= 0x10000000000000000) {
            xAux >>= 64;
            result <<= 32;
        }
        if (xAux >= 0x100000000) {
            xAux >>= 32;
            result <<= 16;
        }
        if (xAux >= 0x10000) {
            xAux >>= 16;
            result <<= 8;
        }
        if (xAux >= 0x100) {
            xAux >>= 8;
            result <<= 4;
        }
        if (xAux >= 0x10) {
            xAux >>= 4;
            result <<= 2;
        }
        if (xAux >= 0x8) {
            result <<= 1;
        }

        // The operations can never overflow because the result is max 2^127 when it enters this block.
        unchecked {
            result = (result + x / result) >> 1;
            result = (result + x / result) >> 1;
            result = (result + x / result) >> 1;
            result = (result + x / result) >> 1;
            result = (result + x / result) >> 1;
            result = (result + x / result) >> 1;
            result = (result + x / result) >> 1; // Seven iterations should be enough
            uint256 roundedDownResult = x / result;
            return result >= roundedDownResult ? roundedDownResult : result;
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 400
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_baseWeightCurrency","type":"uint256"},{"internalType":"contract IJBOperatorStore","name":"_operatorStore","type":"address"},{"internalType":"contract IJBProjects","name":"_projects","type":"address"},{"internalType":"contract IJBDirectory","name":"_directory","type":"address"},{"internalType":"contract IJBSplitsStore","name":"_splitsStore","type":"address"},{"internalType":"contract IJBPrices","name":"_prices","type":"address"},{"internalType":"contract IJBSingleTokenPaymentTerminalStore","name":"_store","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FEE_TOO_HIGH","type":"error"},{"inputs":[],"name":"INADEQUATE_DISTRIBUTION_AMOUNT","type":"error"},{"inputs":[],"name":"INADEQUATE_RECLAIM_AMOUNT","type":"error"},{"inputs":[],"name":"INADEQUATE_TOKEN_COUNT","type":"error"},{"inputs":[],"name":"NO_MSG_VALUE_ALLOWED","type":"error"},{"inputs":[],"name":"PAY_TO_ZERO_ADDRESS","type":"error"},{"inputs":[{"internalType":"uint256","name":"prod1","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"PRBMath__MulDivOverflow","type":"error"},{"inputs":[],"name":"PROJECT_TERMINAL_MISMATCH","type":"error"},{"inputs":[],"name":"REDEEM_TO_ZERO_ADDRESS","type":"error"},{"inputs":[],"name":"TERMINAL_IN_SPLIT_ZERO_ADDRESS","type":"error"},{"inputs":[],"name":"TERMINAL_TOKENS_INCOMPATIBLE","type":"error"},{"inputs":[],"name":"UNAUTHORIZED","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"refundedFees","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"AddToBalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IJBPayDelegate","name":"delegate","type":"address"},{"components":[{"internalType":"address","name":"payer","type":"address"},{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint256","name":"currentFundingCycleConfiguration","type":"uint256"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"currency","type":"uint256"}],"internalType":"struct JBTokenAmount","name":"amount","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"currency","type":"uint256"}],"internalType":"struct JBTokenAmount","name":"forwardedAmount","type":"tuple"},{"internalType":"uint256","name":"projectTokenCount","type":"uint256"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"bool","name":"preferClaimedTokens","type":"bool"},{"internalType":"string","name":"memo","type":"string"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"indexed":false,"internalType":"struct JBDidPayData","name":"data","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"delegatedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"DelegateDidPay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IJBRedemptionDelegate","name":"delegate","type":"address"},{"components":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint256","name":"currentFundingCycleConfiguration","type":"uint256"},{"internalType":"uint256","name":"projectTokenCount","type":"uint256"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"currency","type":"uint256"}],"internalType":"struct JBTokenAmount","name":"reclaimedAmount","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"uint256","name":"currency","type":"uint256"}],"internalType":"struct JBTokenAmount","name":"forwardedAmount","type":"tuple"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"string","name":"memo","type":"string"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"indexed":false,"internalType":"struct JBDidRedeemData","name":"data","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"delegatedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"DelegateDidRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleConfiguration","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"fundingCycleNumber","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"distributedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beneficiaryDistributionAmount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"DistributePayouts","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"domain","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"group","type":"uint256"},{"components":[{"internalType":"bool","name":"preferClaimed","type":"bool"},{"internalType":"bool","name":"preferAddToBalance","type":"bool"},{"internalType":"uint256","name":"percent","type":"uint256"},{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"uint256","name":"lockedUntil","type":"uint256"},{"internalType":"contract IJBSplitAllocator","name":"allocator","type":"address"}],"indexed":false,"internalType":"struct JBSplit","name":"split","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"DistributeToPayoutSplit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeDiscount","type":"uint256"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"HoldFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"contract IJBPaymentTerminal","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Migrate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleConfiguration","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"fundingCycleNumber","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beneficiaryTokenCount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Pay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"bool","name":"wasHeld","type":"bool"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"ProcessFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleConfiguration","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"fundingCycleNumber","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"address","name":"holder","type":"address"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenCount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reclaimedAmount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"RedeemTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"refundedFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"leftoverAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"RefundHeldFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"SetFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IJBFeeGauge","name":"feeGauge","type":"address"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"SetFeeGauge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addrs","type":"address"},{"indexed":true,"internalType":"bool","name":"flag","type":"bool"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"SetFeelessAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleConfiguration","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"fundingCycleNumber","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"distributedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netDistributedamount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"UseAllowance","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"acceptsToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_memo","type":"string"},{"internalType":"bytes","name":"_metadata","type":"bytes"}],"name":"addToBalanceOf","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"baseWeightCurrency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"currencyForToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"currentEthOverflowOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"decimalsForToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"directory","outputs":[{"internalType":"contract IJBDirectory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_currency","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_minReturnedTokens","type":"uint256"},{"internalType":"string","name":"_memo","type":"string"}],"name":"distributePayoutsOf","outputs":[{"internalType":"uint256","name":"netLeftoverDistributionAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeGauge","outputs":[{"internalType":"contract IJBFeeGauge","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"heldFeesOf","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint32","name":"fee","type":"uint32"},{"internalType":"uint32","name":"feeDiscount","type":"uint32"},{"internalType":"address","name":"beneficiary","type":"address"}],"internalType":"struct JBFee[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isFeelessAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"contract IJBPaymentTerminal","name":"_to","type":"address"}],"name":"migrate","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"operatorStore","outputs":[{"internalType":"contract IJBOperatorStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_minReturnedTokens","type":"uint256"},{"internalType":"bool","name":"_preferClaimedTokens","type":"bool"},{"internalType":"string","name":"_memo","type":"string"},{"internalType":"bytes","name":"_metadata","type":"bytes"}],"name":"pay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"payoutSplitsGroup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prices","outputs":[{"internalType":"contract IJBPrices","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"processFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"projects","outputs":[{"internalType":"contract IJBProjects","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_holder","type":"address"},{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_tokenCount","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_minReturnedTokens","type":"uint256"},{"internalType":"address payable","name":"_beneficiary","type":"address"},{"internalType":"string","name":"_memo","type":"string"},{"internalType":"bytes","name":"_metadata","type":"bytes"}],"name":"redeemTokensOf","outputs":[{"internalType":"uint256","name":"reclaimAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IJBFeeGauge","name":"_feeGauge","type":"address"}],"name":"setFeeGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"_flag","type":"bool"}],"name":"setFeelessAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"splitsStore","outputs":[{"internalType":"contract IJBSplitsStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"store","outputs":[{"internalType":"contract IJBSingleTokenPaymentTerminalStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_currency","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_minReturnedTokens","type":"uint256"},{"internalType":"address payable","name":"_beneficiary","type":"address"},{"internalType":"string","name":"_memo","type":"string"}],"name":"useAllowanceOf","outputs":[{"internalType":"uint256","name":"netDistributedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

6101c06040526302faf0806003553480156200001a57600080fd5b5060405162005590380380620055908339810160408190526200003d9162000222565b61eeee6080819052601260a0819052600160c08190528a818b8b8b8b8b8b8b6200006733620000d9565b600080546001600160a01b0319166001600160a01b03898116919091179091556101808a90526101a089905286811660e052858116610100528481166101205283811661014052821661016052620000bf816200012b565b5050505050505050505050505050505050505050620002d7565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b62000135620001ae565b6001600160a01b038116620001a05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b620001ab81620000d9565b50565b6001546001600160a01b031633146200020a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000197565b565b6001600160a01b0381168114620001ab57600080fd5b600080600080600080600080610100898b0312156200024057600080fd5b88519750602089015162000254816200020c565b60408a015190975062000267816200020c565b60608a01519096506200027a816200020c565b60808a01519095506200028d816200020c565b60a08a0151909450620002a0816200020c565b60c08a0151909350620002b3816200020c565b60e08a0151909250620002c6816200020c565b809150509295985092959890939650565b60805160a05160c05160e05161010051610120516101405161016051610180516101a05161508b62000505600039600081816103c40152611f3701526000818161031c01526119400152600081816104ec01528181610cf7015281816113480152818161172c0152818161190e01528181611de5015281816126ca015261295801526000818161062401526114cd0152600081816102d001526134bc0152600081816105f001528181610827015281816109e8015281816119f1015281816123e901528181612a230152818161336c01526137e201526000818161049a01528181610bb201528181610ff20152818161156d01528181611e91015261278001526000818161025b015281816106dc015281816114180152818161147a015281816118e801528181611b9201528181612b890152612c480152600081816103500152818161059c015281816113b9015281816113e501528181611445015281816114a7015281816118c201528181611b6c01528181612b6301528181612c22015261365101526000818161069a01528181610730015281816108b901528181610a7201528181610c4a01528181610d7801528181610deb0152818161188d01528181611b3701528181611c52015281816123be015281816124990152818161250d01528181612b2d01528181612bed01528181612cca0152818161333f0152818161361c015281816136970152818161380f015281816139ed01528181613aa60152613b1f015261508b6000f3fe6080604052600436106101ee5760003560e01c80638b79543c1161010d578063c41c2f24116100a0578063df21a7dd1161006f578063df21a7dd1461067c578063e5a6b10f146106ca578063f2fde38b146106fe578063fc0c546a1461071e578063fe663f0f1461075257600080fd5b8063c41c2f24146105de578063d3419bf314610612578063d6dacc5314610646578063ddca3f431461066657600080fd5b8063ad007d63116100dc578063ad007d631461052e578063b631b5001461054e578063b7bad1b11461057e578063bc8926e9146105be57600080fd5b80638b79543c146104885780638da5cb5b146104bc578063975057e7146104da578063a32e1e961461050e57600080fd5b8063405b84fa11610185578063715018a611610154578063715018a6146104065780637258002c1461041b57806389701db51461043b5780638af560941461045b57600080fd5b8063405b84fa14610372578063637913ac1461039257806366248b86146103b257806369fe0e2d146103e657600080fd5b80632b267b4e116101c15780632b267b4e1461029e5780632bdfe004146102be5780632d1a59031461030a578063313ce5671461033e57600080fd5b806301ffc9a7146101f35780630cf8e858146102285780631982d6791461023d5780631ebc263f1461028b575b600080fd5b3480156101ff57600080fd5b5061021361020e366004613e65565b610772565b60405190151581526020015b60405180910390f35b61023b610236366004613eed565b610809565b005b34801561024957600080fd5b5061027d610258366004613f83565b507f000000000000000000000000000000000000000000000000000000000000000090565b60405190815260200161021f565b61027d610299366004613fae565b6109bf565b3480156102aa57600080fd5b5061027d6102b9366004614076565b610b7d565b3480156102ca57600080fd5b506102f27f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161021f565b34801561031657600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561034a57600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561037e57600080fd5b5061027d61038d3660046140e0565b610b99565b34801561039e57600080fd5b5061023b6103ad366004613f83565b610e95565b3480156103be57600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156103f257600080fd5b5061023b610401366004614110565b610ef1565b34801561041257600080fd5b5061023b610f5e565b34801561042757600080fd5b5061023b610436366004614129565b610f72565b34801561044757600080fd5b5061023b610456366004614110565b610fdc565b34801561046757600080fd5b5061047b610476366004614110565b611272565b60405161021f9190614157565b34801561049457600080fd5b506102f27f000000000000000000000000000000000000000000000000000000000000000081565b3480156104c857600080fd5b506001546001600160a01b03166102f2565b3480156104e657600080fd5b506102f27f000000000000000000000000000000000000000000000000000000000000000081565b34801561051a57600080fd5b5061027d610529366004614110565b61131f565b34801561053a57600080fd5b506000546102f2906001600160a01b031681565b34801561055a57600080fd5b50610213610569366004613f83565b60056020526000908152604090205460ff1681565b34801561058a57600080fd5b5061027d610599366004613f83565b507f000000000000000000000000000000000000000000000000000000000000000090565b3480156105ca57600080fd5b5061027d6105d9366004614302565b611554565b3480156105ea57600080fd5b506102f27f000000000000000000000000000000000000000000000000000000000000000081565b34801561061e57600080fd5b506102f27f000000000000000000000000000000000000000000000000000000000000000081565b34801561065257600080fd5b506004546102f2906001600160a01b031681565b34801561067257600080fd5b5061027d60035481565b34801561068857600080fd5b5061021361069736600461438b565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b3480156106d657600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561070a57600080fd5b5061023b610719366004613f83565b61160b565b34801561072a57600080fd5b506102f27f000000000000000000000000000000000000000000000000000000000000000081565b34801561075e57600080fd5b5061027d61076d3660046143b7565b611689565b60006001600160e01b0319821663edb527eb60e01b14806107a357506001600160e01b031982166315933da760e11b145b806107be57506001600160e01b0319821663bc8926e960e01b145b806107d957506001600160e01b0319821663fe663f0f60e01b145b806107f457506001600160e01b0319821663ad007d6360e01b145b806108035750610803826116a9565b92915050565b604051636e49181f60e01b81526004810188905230602482015287907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636e49181f90604401602060405180830381865afa158015610876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089a9190614470565b6108b757604051631b1d5a5960e31b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee1461092657341561090857604051635e7e9adf60e11b815260040160405180910390fd5b4761091433308a6116f9565b61091e81476144a3565b97505061092a565b3496505b33600090815260056020908152604091829020548251601f88018390048302810183019093528683526109b5928b928b9260ff161591908a908a908190840183828082843760009201919091525050604080516020601f8c018190048102820181019092528a815292508a915089908190840183828082843760009201919091525061170892505050565b5050505050505050565b604051636e49181f60e01b8152600481018b90523060248201526000908b906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636e49181f90604401602060405180830381865afa158015610a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a539190614470565b610a7057604051631b1d5a5960e31b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee14610adf573415610ac157604051635e7e9adf60e11b815260040160405180910390fd5b47610acd33308e6116f9565b610ad781476144a3565b9b5050610ae3565b349a505b610b6d8b338e8c8c8c8c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506117fa92505050565b9c9b505050505050505050505050565b6000610b8d888888878787611db2565b98975050505050505050565b6040516331a9108f60e11b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2591906144b6565b836004610c3383838361201a565b60405163df21a7dd60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820188905286169063df21a7dd90604401602060405180830381865afa158015610ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc49190614470565b610ce15760405163581010ed60e01b815260040160405180910390fd5b604051636bb6a5ad60e01b8152600481018790527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636bb6a5ad906024016020604051808303816000875af1158015610d48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6c91906144d3565b93508315610e475760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee14610daf576000610db1565b845b6040805160208101825260008152905163019f1d0b60e31b81529192506001600160a01b03881691630cf8e858918491610e13918c918b917f00000000000000000000000000000000000000000000000000000000000000009160040161453c565b6000604051808303818588803b158015610e2c57600080fd5b505af1158015610e40573d6000803e3d6000fd5b5050505050505b604080518581523360208201526001600160a01b0387169188917fa7519e5f94697b7f53e97c5eb46a0c730a296ab686ab8fd333835c5f735784eb910160405180910390a350505092915050565b610e9d61215c565b600480546001600160a01b0319166001600160a01b0383169081179091556040513381527f0a9a80fe9716605b3e52abb3d792d6a4e7816d6afc02a5a4ef023081feaf9f609060200160405180910390a250565b610ef961215c565b6305f5e100811115610f1e576040516345fbd9c160e01b815260040160405180910390fd5b6003819055604080518281523360208201527fd7414e590e1cb532989ab2a34c8f4c2c17f7ab6f006efeeaef2e87cd5008c202910160405180910390a150565b610f6661215c565b610f7060006121b6565b565b610f7a61215c565b6001600160a01b038216600081815260056020908152604091829020805460ff191685151590811790915591513381529192917fa2653e25a502c023a5830d0de847ef6f458387865b1f4f575d7594f9f2c0d71e910160405180910390a35050565b6040516331a9108f60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015611041573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106591906144b6565b81600561107a6001546001600160a01b031690565b6001600160a01b0316336001600160a01b03161461109a84848484612208565b600085815260026020908152604080832080548251818502810185019093528083529192909190849084015b8282101561113357600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b0316606083015290835290920191016110c6565b5050506000888152600260205260408120929350611152929150613e1e565b805160005b818110156109b55760006111cf84838151811061117657611176614582565b60200260200101516000015185848151811061119457611194614582565b60200260200101516020015163ffffffff168685815181106111b8576111b8614582565b60200260200101516040015163ffffffff1661235a565b90506111f8818584815181106111e7576111e7614582565b6020026020010151606001516123a0565b60011515818a7fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a3525187868151811061123157611231614582565b602002602001015160600151336040516112619291906001600160a01b0392831681529116602082015260400190565b60405180910390a450600101611157565b606060026000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561131457600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b0316606083015290835290920191016112a7565b505050509050919050565b60405163035240c760e61b81523060048201526024810182905260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d49031c090604401602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b391906144d3565b905060007f00000000000000000000000000000000000000000000000000000000000000006012146114105761140b827f0000000000000000000000000000000000000000000000000000000000000000601261256d565b611412565b815b905060017f00000000000000000000000000000000000000000000000000000000000000001461154a576115458161146b7f0000000000000000000000000000000000000000000000000000000000000000600a61467c565b604051635268657960e11b81527f00000000000000000000000000000000000000000000000000000000000000006004820152600160248201527f000000000000000000000000000000000000000000000000000000000000000060448201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a4d0caf290606401602060405180830381865afa15801561151c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154091906144d3565b6125ca565b61154c565b805b949350505050565b6040516331a9108f60e11b8152600481018890526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa1580156115bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e091906144b6565b8860116115ee83838361201a565b6115fc8b8b8b8a8a8a612697565b9b9a5050505050505050505050565b61161361215c565b6001600160a01b03811661167d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b611686816121b6565b50565b60008888600261169a83838361201a565b610b6d8c8c8c8b8b8b8b6128bd565b60006001600160e01b0319821663301cdc3960e21b14806116da57506001600160e01b0319821663144b000160e11b145b8061080357506301ffc9a760e01b6001600160e01b0319831614610803565b6117038282612e38565b505050565b600083611716576000611720565b6117208686612f51565b90506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663e7c8e3e38761175c8489614688565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561179a57600080fd5b505af11580156117ae573d6000803e3d6000fd5b50505050857f9ecaf7fc3dfffd6867c175d6e684b1f1e3aef019398ba8db2c1ffab4a09db25386838686336040516117ea95949392919061469b565b60405180910390a2505050505050565b60006001600160a01b0386166118235760405163a762251360e01b815260040160405180910390fd5b61187b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b606060008060405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018e81526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f000000000000000000000000000000000000000000000000000000000000000081525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632fa1b3918d838e7f00000000000000000000000000000000000000000000000000000000000000008f8d8d6040518863ffffffff1660e01b815260040161198497969594939291906146e8565b6000604051808303816000875af11580156119a3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119cb9190810190614875565b995091955090935091508115611b0057604051632eec7b5560e11b8152600481018c90527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015611a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6491906144b6565b604051638ae9c07b60e01b8152600481018d9052602481018490526001600160a01b038c8116604483015260c06064830152600060c48301528a15156084830152600160a48301529190911690638ae9c07b9060e4016020604051808303816000875af1158015611ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611afd91906144d3565b94505b88851015611b2157604051633dca309360e11b815260040160405180910390fd5b825115611d5457600060405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018f81526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f0000000000000000000000000000000000000000000000000000000000000000815250905060006040518061014001604052808f6001600160a01b031681526020018e8152602001876020015181526020018481526020018381526020018881526020018d6001600160a01b031681526020018b151581526020018a815260200189815250905060008551905060005b81811015611d4f576000878281518110611c3d57611c3d614582565b60209081029190910101519050600061eeed197f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031601611c86575060208101515b602080830151608087015190910152815160405163da9ee8b760e01b81526001600160a01b039091169063da9ee8b7908390611cc6908990600401614a71565b6000604051808303818588803b158015611cdf57600080fd5b505af1158015611cf3573d6000803e3d6000fd5b505050505081600001516001600160a01b03167f16112c26e14efc4be6c690149aa5a1ba75160de245f60d2273e28adb277b9e1286846020015133604051611d3d93929190614a84565b60405180910390a25050600101611c21565b505050505b50505087816000015182602001517f133161f1c9161488f777ab9a26aae91d47c0d9a3fafb398960f138db02c737978c8b8f888b8b33604051611d9d9796959493929190614ab6565b60405180910390a45098975050505050505050565b60405163c664459760e01b8152600481018790526024810186905260448101859052600090819081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c664459790606401610140604051808303816000875af1158015611e2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e539190614b17565b9150915085811015611e785760405163b01493c160e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018a90526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015611ee0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0491906144b6565b9050600080600354600014611f2157611f1c8c613321565b611f27565b633b9aca005b9050600080611f5d8e88602001517f0000000000000000000000000000000000000000000000000000000000000000898761348b565b92509050633b9aca008314611f7157908101905b81600003611f80576000611f8d565b611f8d8e88848887613ca1565b93508015611fb957611fa2816003548561235a565b611fac90826144a3565b9750611fb930868a6116f9565b5050508a846000015185602001517f24352f49df447b14e0e08a323625c663d865ce20c343c4638af12e1dc48aa760858e88878c8f8f33604051612004989796959493929190614b46565b60405180910390a4505050509695505050505050565b336001600160a01b038416148015906120b2575060005460405163c161c93f60e01b81523360048201526001600160a01b03858116602483015260448201859052606482018490529091169063c161c93f90608401602060405180830381865afa15801561208c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b09190614470565b155b801561213e57506000805460405163c161c93f60e01b81523360048201526001600160a01b03868116602483015260448201939093526064810184905291169063c161c93f90608401602060405180830381865afa158015612118573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213c9190614470565b155b156117035760405163075fd2b160e01b815260040160405180910390fd5b6001546001600160a01b03163314610f705760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611674565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8015801561221f5750336001600160a01b03851614155b80156122aa575060005460405163c161c93f60e01b81523360048201526001600160a01b03868116602483015260448201869052606482018590529091169063c161c93f90608401602060405180830381865afa158015612284573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a89190614470565b155b801561233657506000805460405163c161c93f60e01b81523360048201526001600160a01b03878116602483015260448201939093526064810185905291169063c161c93f90608401602060405180830381865afa158015612310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123349190614470565b155b156123545760405163075fd2b160e01b815260040160405180910390fd5b50505050565b60008061236c8484633b9aca006125ca565b61237690856144a3565b905061238b85633b9aca006115408185614688565b61239590866144a3565b9150505b9392505050565b604051630862026560e41b8152600160048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660248301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638620265090604401602060405180830381865afa158015612432573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245691906144b6565b9050306001600160a01b038216036124955761170360018460006040518060200160405280600081525060405180602001604052806000815250611708565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee146124d05760006124d2565b835b6040805160208101825260008152905163019f1d0b60e31b81529192506001600160a01b03841691630cf8e858918491612535916001918a917f00000000000000000000000000000000000000000000000000000000000000009160040161453c565b6000604051808303818588803b15801561254e57600080fd5b505af1158015612562573d6000803e3d6000fd5b505050505050505050565b600082820361257d575082612399565b828211156125ab5761258f83836144a3565b61259a90600a61467c565b6125a49085614baa565b9050612399565b6125b582846144a3565b6125c090600a61467c565b6125a49085614bdf565b6000808060001985870985870292508281108382030391505080600003612604578382816125fa576125fa614bc9565b0492505050612399565b83811061262e57604051631dcf306360e21b81526004810182905260248101859052604401611674565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b604051632538671560e01b8152600481018790526024810186905260448101859052600090819081906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632538671590606401610140604051808303816000875af1158015612714573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127389190614b17565b915091508581101561275d5760405163b01493c160e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018a905260009081906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa1580156127c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127eb91906144b6565b905060006003546000148061280f57503360009081526005602052604090205460ff165b6128215761281c8c613321565b612827565b633b9aca005b9050633b9aca008114612846576128418c86868585613ca1565b612849565b60005b80850396509250838314612862576128623089886116f9565b50505088826000015183602001517f8657a0c05a68a912c23c1bd00124afaa8c669063b046bd9bfd22b21d573c5e6d888c86898b336040516128a996959493929190614c01565b60405180910390a450509695505050505050565b60006001600160a01b0384166128e657604051637ba50db360e11b815260040160405180910390fd5b61293e6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b60405163a2df1f9560e01b81526060906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a2df1f9590612995908d908d908d908b908b90600401614c4c565b6000604051808303816000875af11580156129b4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526129dc9190810190614c8c565b9750909450909250905086831015612a075760405163f896960b60e01b815260040160405180910390fd5b8715612b1757604051632eec7b5560e11b8152600481018a90527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015612a72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9691906144b6565b604051631665bc0f60e01b81526001600160a01b038c81166004830152602482018c9052604482018b905260a06064830152600060a4830181905260848301529190911690631665bc0f9060c401600060405180830381600087803b158015612afe57600080fd5b505af1158015612b12573d6000803e3d6000fd5b505050505b805115612dcc57600060405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602001600081526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f0000000000000000000000000000000000000000000000000000000000000000815250905060006040518061012001604052808d6001600160a01b031681526020018c8152602001856020015181526020018b815260200160405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018881526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f00000000000000000000000000000000000000000000000000000000000000008152508152602001838152602001896001600160a01b0316815260200188815260200187815250905060008351905060005b81811015612dc7576000858281518110612cb557612cb5614582565b60209081029190910101519050600061eeed197f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031601612cfe575060208101515b60208083015160a0870151909101528151604051632b13c58f60e01b81526001600160a01b0390911690632b13c58f908390612d3e908990600401614e4f565b6000604051808303818588803b158015612d5757600080fd5b505af1158015612d6b573d6000803e3d6000fd5b505050505081600001516001600160a01b03167f54b3744c489f40987dd2726ca12131243334e8292f567389f761c5a432d813e486846020015133604051612db593929190614e62565b60405180910390a25050600101612c99565b505050505b508115612dde57612dde3086846116f9565b87816000015182602001517f2be10f2a0203c77d0fcaa9fd6484a8a1d6904de31cd820587f60c1c8c338c8148c898c888b8b33604051612e249796959493929190614ab6565b60405180910390a450979650505050505050565b80471015612e885760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611674565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612ed5576040519150601f19603f3d011682016040523d82523d6000602084013e612eda565b606091505b50509050806117035760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401611674565b600082815260026020908152604080832080548251818502810185019093528083528493849084015b82821015612fe757600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b031660608301529083529092019101612f7a565b5050506000868152600260205260408120929350613006929150613e1e565b8051839060005b818110156132d957826000036130cc576000878152600260205260409020845185908390811061303f5761303f614582565b60209081029190910181015182546001818101855560009485529383902082516002909202019081559181015191909201805460408401516060909401516001600160a01b0316600160401b02600160401b600160e01b031963ffffffff9586166401000000000267ffffffffffffffff19909316959094169490941717919091169190911790556132d1565b8381815181106130de576130de614582565b60200260200101516000015183106131725783818151811061310257613102614582565b6020026020010151600001518303925061316984828151811061312757613127614582565b60200260200101516000015185838151811061314557613145614582565b60200260200101516020015163ffffffff168684815181106111b8576111b8614582565b850194506132d1565b600260008881526020019081526020016000206040518060800160405280858785815181106131a3576131a3614582565b6020026020010151600001510381526020018684815181106131c7576131c7614582565b60200260200101516020015163ffffffff1681526020018684815181106131f0576131f0614582565b60200260200101516040015163ffffffff16815260200186848151811061321957613219614582565b6020908102919091018101516060908101516001600160a01b0390811690935284546001818101875560009687529583902085516002909202019081559184015191909401805460408501519490950151909216600160401b02600160401b600160e01b031963ffffffff9485166401000000000267ffffffffffffffff199096169490921693909317939093179290921617905583516132c890849086908490811061314557613145614582565b85019450600092505b60010161300d565b50604080518381523360208201528591879189917f59860d79d97c1fce2be7f987915c631471f4b08f671200463cc40a3380194ffb910160405180910390a450505092915050565b604051630862026560e41b8152600160048201526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116602483015260009182917f00000000000000000000000000000000000000000000000000000000000000001690638620265090604401602060405180830381865afa1580156133b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d791906144b6565b6001600160a01b0316036133f05750633b9aca00919050565b6004546001600160a01b0316156134835760048054604051633bb4ac4b60e11b81529182018490526001600160a01b031690637769589690602401602060405180830381865afa925050508015613464575060408051601f3d908101601f19168201909252613461918101906144d3565b60015b61347057506000919050565b633b9aca0081116134815792915050565b505b506000919050565b6040516369e11cc560e01b81526004810186905260248101859052604481018490528290600090633b9aca009082907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906369e11cc590606401600060405180830381865afa15801561350b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135339190810190614e75565b905060005b8151811015613c9457600082828151811061355557613555614582565b602002602001015190506000848260400151146135845761357f898360400151633b9aca006125ca565b613586565b865b905081604001518561359891906144a3565b945060008115613c485760c08301516001600160a01b0316156137b957633b9aca008914806135e3575060c08301516001600160a01b031660009081526005602052604090205460ff165b156135ef57508061360d565b6135fc826003548b61235a565b8203905061360a8288614688565b96505b60006040518060c001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018381526020017f000000000000000000000000000000000000000000000000000000000000000081526020018f81526020018d8152602001858152509050600061eeee6001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316146136cb5760006136cd565b825b60c08087015160408051634eba05fd60e11b815286516001600160a01b03908116600483015260208089015160248401528389015160448401526060808a015160648501526080808b0151608486015260a0808c01518051151560a488015293840151151560c48701529583015160e486015290820151610104850152810151821661012484015292830151610144830152919093015181166101648401529293509190911690639d740bfa908390610184016000604051808303818588803b15801561379957600080fd5b505af11580156137ad573d6000803e3d6000fd5b50505050505050613c42565b606083015115613be1576060830151604051630862026560e41b81526000916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691638620265091613849917f0000000000000000000000000000000000000000000000000000000000000000906004019182526001600160a01b0316602082015260400190565b602060405180830381865afa158015613866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388a91906144b6565b90506001600160a01b0381166138b357604051636921234360e01b815260040160405180910390fd5b306001600160a01b03821603613994576040805160208082528183019092528493506000916020820181803683370190505090508e6040516020016138fa91815260200190565b604051602081830303815290604052905084602001511561393b5761393685606001518460006040518060200160405280600081525085611708565b61398e565b61398c8330876060015160006001600160a01b031689608001516001600160a01b031603613969573361396f565b88608001515b60008a6000015160405180602001604052806000815250886117fa565b505b50613bdb565b633b9aca008a14806139be57506001600160a01b03811660009081526005602052604090205460ff165b156139cb578291506139e9565b6139d8836003548c61235a565b830391506139e68389614688565b97505b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee14613a24576000613a26565b825b604080516020808252818301909252919250600091906020820181803683370190505090508f604051602001613a5e91815260200190565b6040516020818303038152906040529050856020015115613b0757606086015160405163019f1d0b60e31b81526001600160a01b03851691630cf8e858918591613ad09189907f000000000000000000000000000000000000000000000000000000000000000090889060040161453c565b6000604051808303818588803b158015613ae957600080fd5b505af1158015613afd573d6000803e3d6000fd5b5050505050613bd8565b826001600160a01b0316631ebc263f838860600151877f000000000000000000000000000000000000000000000000000000000000000060006001600160a01b03168c608001516001600160a01b031603613b625733613b68565b8b608001515b8c516040516001600160e01b031960e089901b168152613b9395949392916000918b90600401614f7f565b60206040518083038185885af1158015613bb1573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613bd691906144d3565b505b50505b50613c42565b60808301516000906001600160a01b0316613bfc5733613c02565b83608001515b9050633b9aca008a03613c1757829150613c35565b613c24836003548c61235a565b83039150613c328389614688565b97505b613c403082846116f9565b505b81880397505b8a8c8e7f2a1f2df21da49f011c6165709ae4b279f8d6d7cffe9043c582352882d8c9698b868533604051613c7e93929190614fd6565b60405180910390a4836001019350505050613538565b5050509550959350505050565b6000613cb0846003548461235a565b610100860151909150604f1c600190811603613dc257600086815260026020818152604080842081516080810183528981526003805463ffffffff9081168387019081528a82168487019081526001600160a01b038d81166060808801828152895460018082018c559a8f529d8c902098519d909c029097019b8c5592519a909601805491519951909616600160401b02600160401b600160e01b03199984166401000000000267ffffffffffffffff199092169a9093169990991798909817969096169590951790915592548151878152928301949094523390820152869189917f77813be0661650ddc1a5193ff2837df4162b251cb432651e2c060c3fc39756be910160405180910390a4613e15565b613dcc81846123a0565b604080516001600160a01b0385168152336020820152600091839189917fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a35251910160405180910390a45b95945050505050565b508054600082556002029060005260206000209081019061168691905b80821115613e6157600081556001810180546001600160e01b0319169055600201613e3b565b5090565b600060208284031215613e7757600080fd5b81356001600160e01b03198116811461239957600080fd5b6001600160a01b038116811461168657600080fd5b60008083601f840112613eb657600080fd5b50813567ffffffffffffffff811115613ece57600080fd5b602083019150836020828501011115613ee657600080fd5b9250929050565b600080600080600080600060a0888a031215613f0857600080fd5b87359650602088013595506040880135613f2181613e8f565b9450606088013567ffffffffffffffff80821115613f3e57600080fd5b613f4a8b838c01613ea4565b909650945060808a0135915080821115613f6357600080fd5b50613f708a828b01613ea4565b989b979a50959850939692959293505050565b600060208284031215613f9557600080fd5b813561239981613e8f565b801515811461168657600080fd5b6000806000806000806000806000806101008b8d031215613fce57600080fd5b8a35995060208b0135985060408b0135613fe781613e8f565b975060608b0135613ff781613e8f565b965060808b0135955060a08b013561400e81613fa0565b945060c08b013567ffffffffffffffff8082111561402b57600080fd5b6140378e838f01613ea4565b909650945060e08d013591508082111561405057600080fd5b5061405d8d828e01613ea4565b915080935050809150509295989b9194979a5092959850565b600080600080600080600060c0888a03121561409157600080fd5b87359650602088013595506040880135945060608801356140b181613e8f565b93506080880135925060a088013567ffffffffffffffff8111156140d457600080fd5b613f708a828b01613ea4565b600080604083850312156140f357600080fd5b82359150602083013561410581613e8f565b809150509250929050565b60006020828403121561412257600080fd5b5035919050565b6000806040838503121561413c57600080fd5b823561414781613e8f565b9150602083013561410581613fa0565b602080825282518282018190526000919060409081850190868401855b828110156141c0578151805185528681015163ffffffff908116888701528682015116868601526060908101516001600160a01b03169085015260809093019290850190600101614174565b5091979650505050505050565b634e487b7160e01b600052604160045260246000fd5b604051610120810167ffffffffffffffff81118282101715614207576142076141cd565b60405290565b6040805190810167ffffffffffffffff81118282101715614207576142076141cd565b60405160e0810167ffffffffffffffff81118282101715614207576142076141cd565b604051601f8201601f1916810167ffffffffffffffff8111828210171561427c5761427c6141cd565b604052919050565b600067ffffffffffffffff82111561429e5761429e6141cd565b50601f01601f191660200190565b600082601f8301126142bd57600080fd5b81356142d06142cb82614284565b614253565b8181528460208386010111156142e557600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a03121561431d57600080fd5b873596506020880135955060408801359450606088013561433d81613e8f565b93506080880135925060a088013561435481613e8f565b915060c088013567ffffffffffffffff81111561437057600080fd5b61437c8a828b016142ac565b91505092959891949750929550565b6000806040838503121561439e57600080fd5b82356143a981613e8f565b946020939093013593505050565b600080600080600080600080610100898b0312156143d457600080fd5b88356143df81613e8f565b9750602089013596506040890135955060608901356143fd81613e8f565b94506080890135935060a089013561441481613e8f565b925060c089013567ffffffffffffffff8082111561443157600080fd5b61443d8c838d016142ac565b935060e08b013591508082111561445357600080fd5b506144608b828c016142ac565b9150509295985092959890939650565b60006020828403121561448257600080fd5b815161239981613fa0565b634e487b7160e01b600052601160045260246000fd5b818103818111156108035761080361448d565b6000602082840312156144c857600080fd5b815161239981613e8f565b6000602082840312156144e557600080fd5b5051919050565b60005b838110156145075781810151838201526020016144ef565b50506000910152565b600081518084526145288160208601602086016144ec565b601f01601f19169290920160200192915050565b8481528360208201526001600160a01b038316604082015260a06060820152600060a082015260c06080820152600061457860c0830184614510565b9695505050505050565b634e487b7160e01b600052603260045260246000fd5b600181815b808511156145d35781600019048211156145b9576145b961448d565b808516156145c657918102915b93841c939080029061459d565b509250929050565b6000826145ea57506001610803565b816145f757506000610803565b816001811461460d576002811461461757614633565b6001915050610803565b60ff8411156146285761462861448d565b50506001821b610803565b5060208310610133831016604e8410600b8410161715614656575081810a610803565b6146608383614598565b80600019048211156146745761467461448d565b029392505050565b600061239983836145db565b808201808211156108035761080361448d565b85815284602082015260a0604082015260006146ba60a0830186614510565b82810360608401526146cc8186614510565b9150506001600160a01b03831660808301529695505050505050565b60006101406001600160a01b03808b168452614731602085018b6001600160a01b0381511682526020810151602083015260408101516040830152606081015160608301525050565b8860a08501528760c085015280871660e0850152508061010084015261475981840186614510565b905082810361012084015261476e8185614510565b9a9950505050505050505050565b805161478781613e8f565b919050565b6000610120828403121561479f57600080fd5b6147a76141e3565b9050815181526020820151602082015260408201516040820152606082015160608201526080820151608082015260a082015160a082015260c082015160c08201526147f560e0830161477c565b60e082015261010080830151818301525092915050565b600067ffffffffffffffff821115614826576148266141cd565b5060051b60200190565b600082601f83011261484157600080fd5b815161484f6142cb82614284565b81815284602083860101111561486457600080fd5b61154c8260208301602087016144ec565b600080600080610180858703121561488c57600080fd5b614896868661478c565b9350610120850151925061014085015167ffffffffffffffff808211156148bc57600080fd5b818701915087601f8301126148d057600080fd5b815160206148e06142cb8361480c565b82815260069290921b8401810191818101908b8411156148ff57600080fd5b948201945b8386101561494b576040868d03121561491d5760008081fd5b61492561420d565b865161493081613e8f565b81528684015184820152825260409095019490820190614904565b6101608b015190975094505050508082111561496657600080fd5b5061497387828801614830565b91505092959194509250565b80516001600160a01b031682526000610200602083810151858201526040808501518187015260608086015180516001600160a01b0316828901529283015160808801529082015160a087015281015160c086015250608083015180516001600160a01b031660e08601526020810151610100860152604081015161012086015260608101516101408601525060a083015161016085015260c08301516001600160a01b0381166101808601525060e08301518015156101a086015250610100830151816101c0860152614a5582860182614510565b9150506101208301518482036101e0860152613e158282614510565b602081526000612399602083018461497f565b606081526000614a97606083018661497f565b90508360208301526001600160a01b0383166040830152949350505050565b60006001600160a01b03808a168352808916602084015287604084015286606084015260e06080840152614aed60e0840187614510565b83810360a0850152614aff8187614510565b92505080841660c08401525098975050505050505050565b6000806101408385031215614b2b57600080fd5b614b35848461478c565b915061012083015190509250929050565b60006001600160a01b03808b16835289602084015288604084015287606084015286608084015260e060a08401528460e08401526101008587828601376000848701820152931660c083015250601f909201601f1916909101019695505050505050565b6000816000190483118215151615614bc457614bc461448d565b500290565b634e487b7160e01b600052601260045260246000fd5b600082614bfc57634e487b7160e01b600052601260045260246000fd5b500490565b60006001600160a01b03808916835287602084015286604084015285606084015260c06080840152614c3660c0840186614510565b915080841660a084015250979650505050505050565b6001600160a01b038616815284602082015283604082015260a060608201526000614c7a60a0830185614510565b8281036080840152610b8d8185614510565b6000806000806101808587031215614ca357600080fd5b614cad868661478c565b9350610120850151925061014085015167ffffffffffffffff80821115614cd357600080fd5b818701915087601f830112614ce757600080fd5b81516020614cf76142cb8361480c565b82815260069290921b8401810191818101908b841115614d1657600080fd5b948201945b8386101561494b576040868d031215614d345760008081fd5b614d3c61420d565b8651614d4781613e8f565b81528684015184820152825260409095019490820190614d1b565b80516001600160a01b0316825260006101e06020830151602085015260408301516040850152606083015160608501526080830151614dce60808601826001600160a01b0381511682526020810151602083015260408101516040830152606081015160608301525050565b5060a083015180516001600160a01b03908116610100878101919091526020830151610120880152604083015161014088015260609092015161016087015260c08501511661018086015260e08401516101a0860183905290614e3383870183614510565b9250808501519150508482036101c0860152613e158282614510565b6020815260006123996020830184614d62565b606081526000614a976060830186614d62565b60006020808385031215614e8857600080fd5b825167ffffffffffffffff811115614e9f57600080fd5b8301601f81018513614eb057600080fd5b8051614ebe6142cb8261480c565b81815260e09182028301840191848201919088841115614edd57600080fd5b938501935b83851015614f735780858a031215614efa5760008081fd5b614f02614230565b8551614f0d81613fa0565b815285870151614f1c81613fa0565b818801526040868101519082015260608087015190820152608080870151614f4381613e8f565b9082015260a0868101519082015260c080870151614f6081613e8f565b9082015283529384019391850191614ee2565b50979650505050505050565b60006101008983528860208401526001600160a01b03808916604085015280881660608501525085608084015284151560a08401528060c0840152600081840152506101208060e084015261476e81840185614510565b61012081016150378286805115158252602081015115156020830152604081015160408301526060810151606083015260808101516001600160a01b03808216608085015260a083015160a08501528060c08401511660c085015250505050565b8360e08301526001600160a01b03831661010083015294935050505056fea26469706673582212201c3c1bf3a0f5332d1a05914202d6b3864096e115dcb5d0456350f9cfc0bae9f164736f6c6343000810003300000000000000000000000000000000000000000000000000000000000000010000000000000000000000004ad6d7b702f40e203e4acac94f74a0e533410d9d0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca1000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb00000000000000000000000086bb6f3658af2bf921b9b383d28eb691a792ab700000000000000000000000008edc511cb591268bb172196a385ba62802e780f5000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d30000000000000000000000008c0deb14f9bb6660eedd29da658ec256a4a095b5

Deployed Bytecode

0x6080604052600436106101ee5760003560e01c80638b79543c1161010d578063c41c2f24116100a0578063df21a7dd1161006f578063df21a7dd1461067c578063e5a6b10f146106ca578063f2fde38b146106fe578063fc0c546a1461071e578063fe663f0f1461075257600080fd5b8063c41c2f24146105de578063d3419bf314610612578063d6dacc5314610646578063ddca3f431461066657600080fd5b8063ad007d63116100dc578063ad007d631461052e578063b631b5001461054e578063b7bad1b11461057e578063bc8926e9146105be57600080fd5b80638b79543c146104885780638da5cb5b146104bc578063975057e7146104da578063a32e1e961461050e57600080fd5b8063405b84fa11610185578063715018a611610154578063715018a6146104065780637258002c1461041b57806389701db51461043b5780638af560941461045b57600080fd5b8063405b84fa14610372578063637913ac1461039257806366248b86146103b257806369fe0e2d146103e657600080fd5b80632b267b4e116101c15780632b267b4e1461029e5780632bdfe004146102be5780632d1a59031461030a578063313ce5671461033e57600080fd5b806301ffc9a7146101f35780630cf8e858146102285780631982d6791461023d5780631ebc263f1461028b575b600080fd5b3480156101ff57600080fd5b5061021361020e366004613e65565b610772565b60405190151581526020015b60405180910390f35b61023b610236366004613eed565b610809565b005b34801561024957600080fd5b5061027d610258366004613f83565b507f000000000000000000000000000000000000000000000000000000000000000190565b60405190815260200161021f565b61027d610299366004613fae565b6109bf565b3480156102aa57600080fd5b5061027d6102b9366004614076565b610b7d565b3480156102ca57600080fd5b506102f27f00000000000000000000000086bb6f3658af2bf921b9b383d28eb691a792ab7081565b6040516001600160a01b03909116815260200161021f565b34801561031657600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000000181565b34801561034a57600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000001281565b34801561037e57600080fd5b5061027d61038d3660046140e0565b610b99565b34801561039e57600080fd5b5061023b6103ad366004613f83565b610e95565b3480156103be57600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000000181565b3480156103f257600080fd5b5061023b610401366004614110565b610ef1565b34801561041257600080fd5b5061023b610f5e565b34801561042757600080fd5b5061023b610436366004614129565b610f72565b34801561044757600080fd5b5061023b610456366004614110565b610fdc565b34801561046757600080fd5b5061047b610476366004614110565b611272565b60405161021f9190614157565b34801561049457600080fd5b506102f27f0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca181565b3480156104c857600080fd5b506001546001600160a01b03166102f2565b3480156104e657600080fd5b506102f27f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d381565b34801561051a57600080fd5b5061027d610529366004614110565b61131f565b34801561053a57600080fd5b506000546102f2906001600160a01b031681565b34801561055a57600080fd5b50610213610569366004613f83565b60056020526000908152604090205460ff1681565b34801561058a57600080fd5b5061027d610599366004613f83565b507f000000000000000000000000000000000000000000000000000000000000001290565b3480156105ca57600080fd5b5061027d6105d9366004614302565b611554565b3480156105ea57600080fd5b506102f27f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb81565b34801561061e57600080fd5b506102f27f0000000000000000000000008edc511cb591268bb172196a385ba62802e780f581565b34801561065257600080fd5b506004546102f2906001600160a01b031681565b34801561067257600080fd5b5061027d60035481565b34801561068857600080fd5b5061021361069736600461438b565b507f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b0390811691161490565b3480156106d657600080fd5b5061027d7f000000000000000000000000000000000000000000000000000000000000000181565b34801561070a57600080fd5b5061023b610719366004613f83565b61160b565b34801561072a57600080fd5b506102f27f000000000000000000000000000000000000000000000000000000000000eeee81565b34801561075e57600080fd5b5061027d61076d3660046143b7565b611689565b60006001600160e01b0319821663edb527eb60e01b14806107a357506001600160e01b031982166315933da760e11b145b806107be57506001600160e01b0319821663bc8926e960e01b145b806107d957506001600160e01b0319821663fe663f0f60e01b145b806107f457506001600160e01b0319821663ad007d6360e01b145b806108035750610803826116a9565b92915050565b604051636e49181f60e01b81526004810188905230602482015287907f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb6001600160a01b031690636e49181f90604401602060405180830381865afa158015610876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089a9190614470565b6108b757604051631b1d5a5960e31b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee1461092657341561090857604051635e7e9adf60e11b815260040160405180910390fd5b4761091433308a6116f9565b61091e81476144a3565b97505061092a565b3496505b33600090815260056020908152604091829020548251601f88018390048302810183019093528683526109b5928b928b9260ff161591908a908a908190840183828082843760009201919091525050604080516020601f8c018190048102820181019092528a815292508a915089908190840183828082843760009201919091525061170892505050565b5050505050505050565b604051636e49181f60e01b8152600481018b90523060248201526000908b906001600160a01b037f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb1690636e49181f90604401602060405180830381865afa158015610a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a539190614470565b610a7057604051631b1d5a5960e31b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee14610adf573415610ac157604051635e7e9adf60e11b815260040160405180910390fd5b47610acd33308e6116f9565b610ad781476144a3565b9b5050610ae3565b349a505b610b6d8b338e8c8c8c8c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506117fa92505050565b9c9b505050505050505050505050565b6000610b8d888888878787611db2565b98975050505050505050565b6040516331a9108f60e11b8152600481018390526000907f0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca16001600160a01b031690636352211e90602401602060405180830381865afa158015610c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2591906144b6565b836004610c3383838361201a565b60405163df21a7dd60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000eeee811660048301526024820188905286169063df21a7dd90604401602060405180830381865afa158015610ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc49190614470565b610ce15760405163581010ed60e01b815260040160405180910390fd5b604051636bb6a5ad60e01b8152600481018790527f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d36001600160a01b031690636bb6a5ad906024016020604051808303816000875af1158015610d48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6c91906144d3565b93508315610e475760007f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee14610daf576000610db1565b845b6040805160208101825260008152905163019f1d0b60e31b81529192506001600160a01b03881691630cf8e858918491610e13918c918b917f000000000000000000000000000000000000000000000000000000000000eeee9160040161453c565b6000604051808303818588803b158015610e2c57600080fd5b505af1158015610e40573d6000803e3d6000fd5b5050505050505b604080518581523360208201526001600160a01b0387169188917fa7519e5f94697b7f53e97c5eb46a0c730a296ab686ab8fd333835c5f735784eb910160405180910390a350505092915050565b610e9d61215c565b600480546001600160a01b0319166001600160a01b0383169081179091556040513381527f0a9a80fe9716605b3e52abb3d792d6a4e7816d6afc02a5a4ef023081feaf9f609060200160405180910390a250565b610ef961215c565b6305f5e100811115610f1e576040516345fbd9c160e01b815260040160405180910390fd5b6003819055604080518281523360208201527fd7414e590e1cb532989ab2a34c8f4c2c17f7ab6f006efeeaef2e87cd5008c202910160405180910390a150565b610f6661215c565b610f7060006121b6565b565b610f7a61215c565b6001600160a01b038216600081815260056020908152604091829020805460ff191685151590811790915591513381529192917fa2653e25a502c023a5830d0de847ef6f458387865b1f4f575d7594f9f2c0d71e910160405180910390a35050565b6040516331a9108f60e11b8152600481018290527f0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca16001600160a01b031690636352211e90602401602060405180830381865afa158015611041573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106591906144b6565b81600561107a6001546001600160a01b031690565b6001600160a01b0316336001600160a01b03161461109a84848484612208565b600085815260026020908152604080832080548251818502810185019093528083529192909190849084015b8282101561113357600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b0316606083015290835290920191016110c6565b5050506000888152600260205260408120929350611152929150613e1e565b805160005b818110156109b55760006111cf84838151811061117657611176614582565b60200260200101516000015185848151811061119457611194614582565b60200260200101516020015163ffffffff168685815181106111b8576111b8614582565b60200260200101516040015163ffffffff1661235a565b90506111f8818584815181106111e7576111e7614582565b6020026020010151606001516123a0565b60011515818a7fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a3525187868151811061123157611231614582565b602002602001015160600151336040516112619291906001600160a01b0392831681529116602082015260400190565b60405180910390a450600101611157565b606060026000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561131457600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b0316606083015290835290920191016112a7565b505050509050919050565b60405163035240c760e61b81523060048201526024810182905260009081906001600160a01b037f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d3169063d49031c090604401602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b391906144d3565b905060007f00000000000000000000000000000000000000000000000000000000000000126012146114105761140b827f0000000000000000000000000000000000000000000000000000000000000012601261256d565b611412565b815b905060017f00000000000000000000000000000000000000000000000000000000000000011461154a576115458161146b7f0000000000000000000000000000000000000000000000000000000000000012600a61467c565b604051635268657960e11b81527f00000000000000000000000000000000000000000000000000000000000000016004820152600160248201527f000000000000000000000000000000000000000000000000000000000000001260448201527f0000000000000000000000008edc511cb591268bb172196a385ba62802e780f56001600160a01b03169063a4d0caf290606401602060405180830381865afa15801561151c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154091906144d3565b6125ca565b61154c565b805b949350505050565b6040516331a9108f60e11b8152600481018890526000907f0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca16001600160a01b031690636352211e90602401602060405180830381865afa1580156115bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e091906144b6565b8860116115ee83838361201a565b6115fc8b8b8b8a8a8a612697565b9b9a5050505050505050505050565b61161361215c565b6001600160a01b03811661167d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b611686816121b6565b50565b60008888600261169a83838361201a565b610b6d8c8c8c8b8b8b8b6128bd565b60006001600160e01b0319821663301cdc3960e21b14806116da57506001600160e01b0319821663144b000160e11b145b8061080357506301ffc9a760e01b6001600160e01b0319831614610803565b6117038282612e38565b505050565b600083611716576000611720565b6117208686612f51565b90506001600160a01b037f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d31663e7c8e3e38761175c8489614688565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561179a57600080fd5b505af11580156117ae573d6000803e3d6000fd5b50505050857f9ecaf7fc3dfffd6867c175d6e684b1f1e3aef019398ba8db2c1ffab4a09db25386838686336040516117ea95949392919061469b565b60405180910390a2505050505050565b60006001600160a01b0386166118235760405163a762251360e01b815260040160405180910390fd5b61187b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b606060008060405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031681526020018e81526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f000000000000000000000000000000000000000000000000000000000000000181525090507f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d36001600160a01b0316632fa1b3918d838e7f00000000000000000000000000000000000000000000000000000000000000018f8d8d6040518863ffffffff1660e01b815260040161198497969594939291906146e8565b6000604051808303816000875af11580156119a3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119cb9190810190614875565b995091955090935091508115611b0057604051632eec7b5560e11b8152600481018c90527f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb6001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015611a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6491906144b6565b604051638ae9c07b60e01b8152600481018d9052602481018490526001600160a01b038c8116604483015260c06064830152600060c48301528a15156084830152600160a48301529190911690638ae9c07b9060e4016020604051808303816000875af1158015611ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611afd91906144d3565b94505b88851015611b2157604051633dca309360e11b815260040160405180910390fd5b825115611d5457600060405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031681526020018f81526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f0000000000000000000000000000000000000000000000000000000000000001815250905060006040518061014001604052808f6001600160a01b031681526020018e8152602001876020015181526020018481526020018381526020018881526020018d6001600160a01b031681526020018b151581526020018a815260200189815250905060008551905060005b81811015611d4f576000878281518110611c3d57611c3d614582565b60209081029190910101519050600061eeed197f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031601611c86575060208101515b602080830151608087015190910152815160405163da9ee8b760e01b81526001600160a01b039091169063da9ee8b7908390611cc6908990600401614a71565b6000604051808303818588803b158015611cdf57600080fd5b505af1158015611cf3573d6000803e3d6000fd5b505050505081600001516001600160a01b03167f16112c26e14efc4be6c690149aa5a1ba75160de245f60d2273e28adb277b9e1286846020015133604051611d3d93929190614a84565b60405180910390a25050600101611c21565b505050505b50505087816000015182602001517f133161f1c9161488f777ab9a26aae91d47c0d9a3fafb398960f138db02c737978c8b8f888b8b33604051611d9d9796959493929190614ab6565b60405180910390a45098975050505050505050565b60405163c664459760e01b8152600481018790526024810186905260448101859052600090819081906001600160a01b037f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d3169063c664459790606401610140604051808303816000875af1158015611e2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e539190614b17565b9150915085811015611e785760405163b01493c160e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018a90526000907f0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca16001600160a01b031690636352211e90602401602060405180830381865afa158015611ee0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0491906144b6565b9050600080600354600014611f2157611f1c8c613321565b611f27565b633b9aca005b9050600080611f5d8e88602001517f0000000000000000000000000000000000000000000000000000000000000001898761348b565b92509050633b9aca008314611f7157908101905b81600003611f80576000611f8d565b611f8d8e88848887613ca1565b93508015611fb957611fa2816003548561235a565b611fac90826144a3565b9750611fb930868a6116f9565b5050508a846000015185602001517f24352f49df447b14e0e08a323625c663d865ce20c343c4638af12e1dc48aa760858e88878c8f8f33604051612004989796959493929190614b46565b60405180910390a4505050509695505050505050565b336001600160a01b038416148015906120b2575060005460405163c161c93f60e01b81523360048201526001600160a01b03858116602483015260448201859052606482018490529091169063c161c93f90608401602060405180830381865afa15801561208c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b09190614470565b155b801561213e57506000805460405163c161c93f60e01b81523360048201526001600160a01b03868116602483015260448201939093526064810184905291169063c161c93f90608401602060405180830381865afa158015612118573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213c9190614470565b155b156117035760405163075fd2b160e01b815260040160405180910390fd5b6001546001600160a01b03163314610f705760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611674565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8015801561221f5750336001600160a01b03851614155b80156122aa575060005460405163c161c93f60e01b81523360048201526001600160a01b03868116602483015260448201869052606482018590529091169063c161c93f90608401602060405180830381865afa158015612284573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a89190614470565b155b801561233657506000805460405163c161c93f60e01b81523360048201526001600160a01b03878116602483015260448201939093526064810185905291169063c161c93f90608401602060405180830381865afa158015612310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123349190614470565b155b156123545760405163075fd2b160e01b815260040160405180910390fd5b50505050565b60008061236c8484633b9aca006125ca565b61237690856144a3565b905061238b85633b9aca006115408185614688565b61239590866144a3565b9150505b9392505050565b604051630862026560e41b8152600160048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000eeee811660248301526000917f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb90911690638620265090604401602060405180830381865afa158015612432573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245691906144b6565b9050306001600160a01b038216036124955761170360018460006040518060200160405280600081525060405180602001604052806000815250611708565b60007f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee146124d05760006124d2565b835b6040805160208101825260008152905163019f1d0b60e31b81529192506001600160a01b03841691630cf8e858918491612535916001918a917f000000000000000000000000000000000000000000000000000000000000eeee9160040161453c565b6000604051808303818588803b15801561254e57600080fd5b505af1158015612562573d6000803e3d6000fd5b505050505050505050565b600082820361257d575082612399565b828211156125ab5761258f83836144a3565b61259a90600a61467c565b6125a49085614baa565b9050612399565b6125b582846144a3565b6125c090600a61467c565b6125a49085614bdf565b6000808060001985870985870292508281108382030391505080600003612604578382816125fa576125fa614bc9565b0492505050612399565b83811061262e57604051631dcf306360e21b81526004810182905260248101859052604401611674565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b604051632538671560e01b8152600481018790526024810186905260448101859052600090819081906001600160a01b037f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d31690632538671590606401610140604051808303816000875af1158015612714573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127389190614b17565b915091508581101561275d5760405163b01493c160e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018a905260009081906001600160a01b037f0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca11690636352211e90602401602060405180830381865afa1580156127c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127eb91906144b6565b905060006003546000148061280f57503360009081526005602052604090205460ff165b6128215761281c8c613321565b612827565b633b9aca005b9050633b9aca008114612846576128418c86868585613ca1565b612849565b60005b80850396509250838314612862576128623089886116f9565b50505088826000015183602001517f8657a0c05a68a912c23c1bd00124afaa8c669063b046bd9bfd22b21d573c5e6d888c86898b336040516128a996959493929190614c01565b60405180910390a450509695505050505050565b60006001600160a01b0384166128e657604051637ba50db360e11b815260040160405180910390fd5b61293e6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b60405163a2df1f9560e01b81526060906001600160a01b037f000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d3169063a2df1f9590612995908d908d908d908b908b90600401614c4c565b6000604051808303816000875af11580156129b4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526129dc9190810190614c8c565b9750909450909250905086831015612a075760405163f896960b60e01b815260040160405180910390fd5b8715612b1757604051632eec7b5560e11b8152600481018a90527f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb6001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015612a72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9691906144b6565b604051631665bc0f60e01b81526001600160a01b038c81166004830152602482018c9052604482018b905260a06064830152600060a4830181905260848301529190911690631665bc0f9060c401600060405180830381600087803b158015612afe57600080fd5b505af1158015612b12573d6000803e3d6000fd5b505050505b805115612dcc57600060405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b03168152602001600081526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f0000000000000000000000000000000000000000000000000000000000000001815250905060006040518061012001604052808d6001600160a01b031681526020018c8152602001856020015181526020018b815260200160405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031681526020018881526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f00000000000000000000000000000000000000000000000000000000000000018152508152602001838152602001896001600160a01b0316815260200188815260200187815250905060008351905060005b81811015612dc7576000858281518110612cb557612cb5614582565b60209081029190910101519050600061eeed197f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031601612cfe575060208101515b60208083015160a0870151909101528151604051632b13c58f60e01b81526001600160a01b0390911690632b13c58f908390612d3e908990600401614e4f565b6000604051808303818588803b158015612d5757600080fd5b505af1158015612d6b573d6000803e3d6000fd5b505050505081600001516001600160a01b03167f54b3744c489f40987dd2726ca12131243334e8292f567389f761c5a432d813e486846020015133604051612db593929190614e62565b60405180910390a25050600101612c99565b505050505b508115612dde57612dde3086846116f9565b87816000015182602001517f2be10f2a0203c77d0fcaa9fd6484a8a1d6904de31cd820587f60c1c8c338c8148c898c888b8b33604051612e249796959493929190614ab6565b60405180910390a450979650505050505050565b80471015612e885760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611674565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612ed5576040519150601f19603f3d011682016040523d82523d6000602084013e612eda565b606091505b50509050806117035760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401611674565b600082815260026020908152604080832080548251818502810185019093528083528493849084015b82821015612fe757600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b031660608301529083529092019101612f7a565b5050506000868152600260205260408120929350613006929150613e1e565b8051839060005b818110156132d957826000036130cc576000878152600260205260409020845185908390811061303f5761303f614582565b60209081029190910181015182546001818101855560009485529383902082516002909202019081559181015191909201805460408401516060909401516001600160a01b0316600160401b02600160401b600160e01b031963ffffffff9586166401000000000267ffffffffffffffff19909316959094169490941717919091169190911790556132d1565b8381815181106130de576130de614582565b60200260200101516000015183106131725783818151811061310257613102614582565b6020026020010151600001518303925061316984828151811061312757613127614582565b60200260200101516000015185838151811061314557613145614582565b60200260200101516020015163ffffffff168684815181106111b8576111b8614582565b850194506132d1565b600260008881526020019081526020016000206040518060800160405280858785815181106131a3576131a3614582565b6020026020010151600001510381526020018684815181106131c7576131c7614582565b60200260200101516020015163ffffffff1681526020018684815181106131f0576131f0614582565b60200260200101516040015163ffffffff16815260200186848151811061321957613219614582565b6020908102919091018101516060908101516001600160a01b0390811690935284546001818101875560009687529583902085516002909202019081559184015191909401805460408501519490950151909216600160401b02600160401b600160e01b031963ffffffff9485166401000000000267ffffffffffffffff199096169490921693909317939093179290921617905583516132c890849086908490811061314557613145614582565b85019450600092505b60010161300d565b50604080518381523360208201528591879189917f59860d79d97c1fce2be7f987915c631471f4b08f671200463cc40a3380194ffb910160405180910390a450505092915050565b604051630862026560e41b8152600160048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000eeee8116602483015260009182917f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb1690638620265090604401602060405180830381865afa1580156133b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d791906144b6565b6001600160a01b0316036133f05750633b9aca00919050565b6004546001600160a01b0316156134835760048054604051633bb4ac4b60e11b81529182018490526001600160a01b031690637769589690602401602060405180830381865afa925050508015613464575060408051601f3d908101601f19168201909252613461918101906144d3565b60015b61347057506000919050565b633b9aca0081116134815792915050565b505b506000919050565b6040516369e11cc560e01b81526004810186905260248101859052604481018490528290600090633b9aca009082907f00000000000000000000000086bb6f3658af2bf921b9b383d28eb691a792ab706001600160a01b0316906369e11cc590606401600060405180830381865afa15801561350b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135339190810190614e75565b905060005b8151811015613c9457600082828151811061355557613555614582565b602002602001015190506000848260400151146135845761357f898360400151633b9aca006125ca565b613586565b865b905081604001518561359891906144a3565b945060008115613c485760c08301516001600160a01b0316156137b957633b9aca008914806135e3575060c08301516001600160a01b031660009081526005602052604090205460ff165b156135ef57508061360d565b6135fc826003548b61235a565b8203905061360a8288614688565b96505b60006040518060c001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031681526020018381526020017f000000000000000000000000000000000000000000000000000000000000001281526020018f81526020018d8152602001858152509050600061eeee6001600160a01b03167f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b0316146136cb5760006136cd565b825b60c08087015160408051634eba05fd60e11b815286516001600160a01b03908116600483015260208089015160248401528389015160448401526060808a015160648501526080808b0151608486015260a0808c01518051151560a488015293840151151560c48701529583015160e486015290820151610104850152810151821661012484015292830151610144830152919093015181166101648401529293509190911690639d740bfa908390610184016000604051808303818588803b15801561379957600080fd5b505af11580156137ad573d6000803e3d6000fd5b50505050505050613c42565b606083015115613be1576060830151604051630862026560e41b81526000916001600160a01b037f000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb1691638620265091613849917f000000000000000000000000000000000000000000000000000000000000eeee906004019182526001600160a01b0316602082015260400190565b602060405180830381865afa158015613866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388a91906144b6565b90506001600160a01b0381166138b357604051636921234360e01b815260040160405180910390fd5b306001600160a01b03821603613994576040805160208082528183019092528493506000916020820181803683370190505090508e6040516020016138fa91815260200190565b604051602081830303815290604052905084602001511561393b5761393685606001518460006040518060200160405280600081525085611708565b61398e565b61398c8330876060015160006001600160a01b031689608001516001600160a01b031603613969573361396f565b88608001515b60008a6000015160405180602001604052806000815250886117fa565b505b50613bdb565b633b9aca008a14806139be57506001600160a01b03811660009081526005602052604090205460ff165b156139cb578291506139e9565b6139d8836003548c61235a565b830391506139e68389614688565b97505b60007f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee14613a24576000613a26565b825b604080516020808252818301909252919250600091906020820181803683370190505090508f604051602001613a5e91815260200190565b6040516020818303038152906040529050856020015115613b0757606086015160405163019f1d0b60e31b81526001600160a01b03851691630cf8e858918591613ad09189907f000000000000000000000000000000000000000000000000000000000000eeee90889060040161453c565b6000604051808303818588803b158015613ae957600080fd5b505af1158015613afd573d6000803e3d6000fd5b5050505050613bd8565b826001600160a01b0316631ebc263f838860600151877f000000000000000000000000000000000000000000000000000000000000eeee60006001600160a01b03168c608001516001600160a01b031603613b625733613b68565b8b608001515b8c516040516001600160e01b031960e089901b168152613b9395949392916000918b90600401614f7f565b60206040518083038185885af1158015613bb1573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613bd691906144d3565b505b50505b50613c42565b60808301516000906001600160a01b0316613bfc5733613c02565b83608001515b9050633b9aca008a03613c1757829150613c35565b613c24836003548c61235a565b83039150613c328389614688565b97505b613c403082846116f9565b505b81880397505b8a8c8e7f2a1f2df21da49f011c6165709ae4b279f8d6d7cffe9043c582352882d8c9698b868533604051613c7e93929190614fd6565b60405180910390a4836001019350505050613538565b5050509550959350505050565b6000613cb0846003548461235a565b610100860151909150604f1c600190811603613dc257600086815260026020818152604080842081516080810183528981526003805463ffffffff9081168387019081528a82168487019081526001600160a01b038d81166060808801828152895460018082018c559a8f529d8c902098519d909c029097019b8c5592519a909601805491519951909616600160401b02600160401b600160e01b03199984166401000000000267ffffffffffffffff199092169a9093169990991798909817969096169590951790915592548151878152928301949094523390820152869189917f77813be0661650ddc1a5193ff2837df4162b251cb432651e2c060c3fc39756be910160405180910390a4613e15565b613dcc81846123a0565b604080516001600160a01b0385168152336020820152600091839189917fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a35251910160405180910390a45b95945050505050565b508054600082556002029060005260206000209081019061168691905b80821115613e6157600081556001810180546001600160e01b0319169055600201613e3b565b5090565b600060208284031215613e7757600080fd5b81356001600160e01b03198116811461239957600080fd5b6001600160a01b038116811461168657600080fd5b60008083601f840112613eb657600080fd5b50813567ffffffffffffffff811115613ece57600080fd5b602083019150836020828501011115613ee657600080fd5b9250929050565b600080600080600080600060a0888a031215613f0857600080fd5b87359650602088013595506040880135613f2181613e8f565b9450606088013567ffffffffffffffff80821115613f3e57600080fd5b613f4a8b838c01613ea4565b909650945060808a0135915080821115613f6357600080fd5b50613f708a828b01613ea4565b989b979a50959850939692959293505050565b600060208284031215613f9557600080fd5b813561239981613e8f565b801515811461168657600080fd5b6000806000806000806000806000806101008b8d031215613fce57600080fd5b8a35995060208b0135985060408b0135613fe781613e8f565b975060608b0135613ff781613e8f565b965060808b0135955060a08b013561400e81613fa0565b945060c08b013567ffffffffffffffff8082111561402b57600080fd5b6140378e838f01613ea4565b909650945060e08d013591508082111561405057600080fd5b5061405d8d828e01613ea4565b915080935050809150509295989b9194979a5092959850565b600080600080600080600060c0888a03121561409157600080fd5b87359650602088013595506040880135945060608801356140b181613e8f565b93506080880135925060a088013567ffffffffffffffff8111156140d457600080fd5b613f708a828b01613ea4565b600080604083850312156140f357600080fd5b82359150602083013561410581613e8f565b809150509250929050565b60006020828403121561412257600080fd5b5035919050565b6000806040838503121561413c57600080fd5b823561414781613e8f565b9150602083013561410581613fa0565b602080825282518282018190526000919060409081850190868401855b828110156141c0578151805185528681015163ffffffff908116888701528682015116868601526060908101516001600160a01b03169085015260809093019290850190600101614174565b5091979650505050505050565b634e487b7160e01b600052604160045260246000fd5b604051610120810167ffffffffffffffff81118282101715614207576142076141cd565b60405290565b6040805190810167ffffffffffffffff81118282101715614207576142076141cd565b60405160e0810167ffffffffffffffff81118282101715614207576142076141cd565b604051601f8201601f1916810167ffffffffffffffff8111828210171561427c5761427c6141cd565b604052919050565b600067ffffffffffffffff82111561429e5761429e6141cd565b50601f01601f191660200190565b600082601f8301126142bd57600080fd5b81356142d06142cb82614284565b614253565b8181528460208386010111156142e557600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a03121561431d57600080fd5b873596506020880135955060408801359450606088013561433d81613e8f565b93506080880135925060a088013561435481613e8f565b915060c088013567ffffffffffffffff81111561437057600080fd5b61437c8a828b016142ac565b91505092959891949750929550565b6000806040838503121561439e57600080fd5b82356143a981613e8f565b946020939093013593505050565b600080600080600080600080610100898b0312156143d457600080fd5b88356143df81613e8f565b9750602089013596506040890135955060608901356143fd81613e8f565b94506080890135935060a089013561441481613e8f565b925060c089013567ffffffffffffffff8082111561443157600080fd5b61443d8c838d016142ac565b935060e08b013591508082111561445357600080fd5b506144608b828c016142ac565b9150509295985092959890939650565b60006020828403121561448257600080fd5b815161239981613fa0565b634e487b7160e01b600052601160045260246000fd5b818103818111156108035761080361448d565b6000602082840312156144c857600080fd5b815161239981613e8f565b6000602082840312156144e557600080fd5b5051919050565b60005b838110156145075781810151838201526020016144ef565b50506000910152565b600081518084526145288160208601602086016144ec565b601f01601f19169290920160200192915050565b8481528360208201526001600160a01b038316604082015260a06060820152600060a082015260c06080820152600061457860c0830184614510565b9695505050505050565b634e487b7160e01b600052603260045260246000fd5b600181815b808511156145d35781600019048211156145b9576145b961448d565b808516156145c657918102915b93841c939080029061459d565b509250929050565b6000826145ea57506001610803565b816145f757506000610803565b816001811461460d576002811461461757614633565b6001915050610803565b60ff8411156146285761462861448d565b50506001821b610803565b5060208310610133831016604e8410600b8410161715614656575081810a610803565b6146608383614598565b80600019048211156146745761467461448d565b029392505050565b600061239983836145db565b808201808211156108035761080361448d565b85815284602082015260a0604082015260006146ba60a0830186614510565b82810360608401526146cc8186614510565b9150506001600160a01b03831660808301529695505050505050565b60006101406001600160a01b03808b168452614731602085018b6001600160a01b0381511682526020810151602083015260408101516040830152606081015160608301525050565b8860a08501528760c085015280871660e0850152508061010084015261475981840186614510565b905082810361012084015261476e8185614510565b9a9950505050505050505050565b805161478781613e8f565b919050565b6000610120828403121561479f57600080fd5b6147a76141e3565b9050815181526020820151602082015260408201516040820152606082015160608201526080820151608082015260a082015160a082015260c082015160c08201526147f560e0830161477c565b60e082015261010080830151818301525092915050565b600067ffffffffffffffff821115614826576148266141cd565b5060051b60200190565b600082601f83011261484157600080fd5b815161484f6142cb82614284565b81815284602083860101111561486457600080fd5b61154c8260208301602087016144ec565b600080600080610180858703121561488c57600080fd5b614896868661478c565b9350610120850151925061014085015167ffffffffffffffff808211156148bc57600080fd5b818701915087601f8301126148d057600080fd5b815160206148e06142cb8361480c565b82815260069290921b8401810191818101908b8411156148ff57600080fd5b948201945b8386101561494b576040868d03121561491d5760008081fd5b61492561420d565b865161493081613e8f565b81528684015184820152825260409095019490820190614904565b6101608b015190975094505050508082111561496657600080fd5b5061497387828801614830565b91505092959194509250565b80516001600160a01b031682526000610200602083810151858201526040808501518187015260608086015180516001600160a01b0316828901529283015160808801529082015160a087015281015160c086015250608083015180516001600160a01b031660e08601526020810151610100860152604081015161012086015260608101516101408601525060a083015161016085015260c08301516001600160a01b0381166101808601525060e08301518015156101a086015250610100830151816101c0860152614a5582860182614510565b9150506101208301518482036101e0860152613e158282614510565b602081526000612399602083018461497f565b606081526000614a97606083018661497f565b90508360208301526001600160a01b0383166040830152949350505050565b60006001600160a01b03808a168352808916602084015287604084015286606084015260e06080840152614aed60e0840187614510565b83810360a0850152614aff8187614510565b92505080841660c08401525098975050505050505050565b6000806101408385031215614b2b57600080fd5b614b35848461478c565b915061012083015190509250929050565b60006001600160a01b03808b16835289602084015288604084015287606084015286608084015260e060a08401528460e08401526101008587828601376000848701820152931660c083015250601f909201601f1916909101019695505050505050565b6000816000190483118215151615614bc457614bc461448d565b500290565b634e487b7160e01b600052601260045260246000fd5b600082614bfc57634e487b7160e01b600052601260045260246000fd5b500490565b60006001600160a01b03808916835287602084015286604084015285606084015260c06080840152614c3660c0840186614510565b915080841660a084015250979650505050505050565b6001600160a01b038616815284602082015283604082015260a060608201526000614c7a60a0830185614510565b8281036080840152610b8d8185614510565b6000806000806101808587031215614ca357600080fd5b614cad868661478c565b9350610120850151925061014085015167ffffffffffffffff80821115614cd357600080fd5b818701915087601f830112614ce757600080fd5b81516020614cf76142cb8361480c565b82815260069290921b8401810191818101908b841115614d1657600080fd5b948201945b8386101561494b576040868d031215614d345760008081fd5b614d3c61420d565b8651614d4781613e8f565b81528684015184820152825260409095019490820190614d1b565b80516001600160a01b0316825260006101e06020830151602085015260408301516040850152606083015160608501526080830151614dce60808601826001600160a01b0381511682526020810151602083015260408101516040830152606081015160608301525050565b5060a083015180516001600160a01b03908116610100878101919091526020830151610120880152604083015161014088015260609092015161016087015260c08501511661018086015260e08401516101a0860183905290614e3383870183614510565b9250808501519150508482036101c0860152613e158282614510565b6020815260006123996020830184614d62565b606081526000614a976060830186614d62565b60006020808385031215614e8857600080fd5b825167ffffffffffffffff811115614e9f57600080fd5b8301601f81018513614eb057600080fd5b8051614ebe6142cb8261480c565b81815260e09182028301840191848201919088841115614edd57600080fd5b938501935b83851015614f735780858a031215614efa5760008081fd5b614f02614230565b8551614f0d81613fa0565b815285870151614f1c81613fa0565b818801526040868101519082015260608087015190820152608080870151614f4381613e8f565b9082015260a0868101519082015260c080870151614f6081613e8f565b9082015283529384019391850191614ee2565b50979650505050505050565b60006101008983528860208401526001600160a01b03808916604085015280881660608501525085608084015284151560a08401528060c0840152600081840152506101208060e084015261476e81840185614510565b61012081016150378286805115158252602081015115156020830152604081015160408301526060810151606083015260808101516001600160a01b03808216608085015260a083015160a08501528060c08401511660c085015250505050565b8360e08301526001600160a01b03831661010083015294935050505056fea26469706673582212201c3c1bf3a0f5332d1a05914202d6b3864096e115dcb5d0456350f9cfc0bae9f164736f6c63430008100033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000000000000000000000000000000000000000000010000000000000000000000004ad6d7b702f40e203e4acac94f74a0e533410d9d0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca1000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb00000000000000000000000086bb6f3658af2bf921b9b383d28eb691a792ab700000000000000000000000008edc511cb591268bb172196a385ba62802e780f5000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d30000000000000000000000008c0deb14f9bb6660eedd29da658ec256a4a095b5

-----Decoded View---------------
Arg [0] : _baseWeightCurrency (uint256): 1
Arg [1] : _operatorStore (address): 0x4Ad6d7b702f40e203E4aCaC94f74a0E533410D9d
Arg [2] : _projects (address): 0x8A9896b8d61cA66A231E9CF224DD4d80643e3CA1
Arg [3] : _directory (address): 0xc39b7Eb7e398efC0b165A2AD43B5F05a5d9dBCCb
Arg [4] : _splitsStore (address): 0x86BB6f3658af2Bf921B9B383d28EB691A792ab70
Arg [5] : _prices (address): 0x8EdC511cb591268bB172196A385Ba62802E780f5
Arg [6] : _store (address): 0xA8755E8CD84dEA26F49Dd503CE085d5bC8AAa0d3
Arg [7] : _owner (address): 0x8C0Deb14F9bb6660EEdd29Da658eC256a4a095b5

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [1] : 0000000000000000000000004ad6d7b702f40e203e4acac94f74a0e533410d9d
Arg [2] : 0000000000000000000000008a9896b8d61ca66a231e9cf224dd4d80643e3ca1
Arg [3] : 000000000000000000000000c39b7eb7e398efc0b165a2ad43b5f05a5d9dbccb
Arg [4] : 00000000000000000000000086bb6f3658af2bf921b9b383d28eb691a792ab70
Arg [5] : 0000000000000000000000008edc511cb591268bb172196a385ba62802e780f5
Arg [6] : 000000000000000000000000a8755e8cd84dea26f49dd503ce085d5bc8aaa0d3
Arg [7] : 0000000000000000000000008c0deb14f9bb6660eedd29da658ec256a4a095b5


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.