Goerli Testnet

Contract

0xd89Ed8008961F68Aab849f49e122f9a1266240Db
Transaction Hash
Method
Block
From
To
Value
Pay104613702024-01-31 9:02:0032 days ago1706691720IN
0xd89Ed800...1266240Db
0.1 ETH0.000238061.50000004
Pay104613582024-01-31 8:59:1232 days ago1706691552IN
0xd89Ed800...1266240Db
0.001 ETH0.000336531.50000004
Pay104501002024-01-29 6:04:2434 days ago1706508264IN
0xd89Ed800...1266240Db
0.00099999 ETH0.000344311.50000001
Pay104335942024-01-25 22:28:4838 days ago1706221728IN
0xd89Ed800...1266240Db
0.009 ETH0.000351451.50000001
Pay104335842024-01-25 22:26:3638 days ago1706221596IN
0xd89Ed800...1266240Db
0.001 ETH0.000241651.50000001
Pay104335712024-01-25 22:22:3638 days ago1706221356IN
0xd89Ed800...1266240Db
0.009 ETH0.000377121.50000001
Pay104332112024-01-25 20:44:0038 days ago1706215440IN
0xd89Ed800...1266240Db
0.001 ETH0.00026731.5
Pay104322632024-01-25 16:28:2438 days ago1706200104IN
0xd89Ed800...1266240Db
0.005 ETH0.000340951.50000001
Pay104302452024-01-25 7:30:4838 days ago1706167848IN
0xd89Ed800...1266240Db
0 ETH0.00029381.50000001
Pay104302062024-01-25 7:19:0038 days ago1706167140IN
0xd89Ed800...1266240Db
0.001 ETH0.000346281.50000001
Pay104301842024-01-25 7:12:4838 days ago1706166768IN
0xd89Ed800...1266240Db
0.001 ETH0.000342921.50000001
Distribute Payou...103913772024-01-17 22:16:1246 days ago1705529772IN
0xd89Ed800...1266240Db
0 ETH0.000267471.5
Pay103913652024-01-17 22:13:3646 days ago1705529616IN
0xd89Ed800...1266240Db
0.0001 ETH0.000195431.5
Process Fees103908762024-01-17 19:54:0046 days ago1705521240IN
0xd89Ed800...1266240Db
0 ETH0.000278521.50000001
Pay103872562024-01-17 2:44:0046 days ago1705459440IN
0xd89Ed800...1266240Db
0.001 ETH0.000291641.5
Pay103872382024-01-17 2:40:0046 days ago1705459200IN
0xd89Ed800...1266240Db
0.0001 ETH00.00000001
Pay103872262024-01-17 2:36:2446 days ago1705458984IN
0xd89Ed800...1266240Db
0.001 ETH00.00000001
Distribute Payou...103799382024-01-15 18:36:0048 days ago1705343760IN
0xd89Ed800...1266240Db
0 ETH0.000267471.50000001
Pay103799322024-01-15 18:34:2448 days ago1705343664IN
0xd89Ed800...1266240Db
0.01 ETH0.000196731.5
Process Fees103798772024-01-15 18:19:4848 days ago1705342788IN
0xd89Ed800...1266240Db
0 ETH0.000278521.50000001
Distribute Payou...103794112024-01-15 16:24:3648 days ago1705335876IN
0xd89Ed800...1266240Db
0 ETH0.000293121.5
Pay103794082024-01-15 16:24:0048 days ago1705335840IN
0xd89Ed800...1266240Db
0.01 ETH0.000247851.5
Pay103784342024-01-15 12:13:0048 days ago1705320780IN
0xd89Ed800...1266240Db
0.001 ETH00.00000001
Pay103778012024-01-15 9:23:2448 days ago1705310604IN
0xd89Ed800...1266240Db
0.0001 ETH0.000291791.50000001
Pay103777222024-01-15 9:00:3648 days ago1705309236IN
0xd89Ed800...1266240Db
0.001 ETH0.000401211.50000001
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Txn Hash Block From To Value
104613702024-01-31 9:02:0032 days ago1706691720
0xd89Ed800...1266240Db
0 ETH
104613702024-01-31 9:02:0032 days ago1706691720
0xd89Ed800...1266240Db
0 ETH
104613702024-01-31 9:02:0032 days ago1706691720
0xd89Ed800...1266240Db
0 ETH
104613582024-01-31 8:59:1232 days ago1706691552
0xd89Ed800...1266240Db
0 ETH
104613582024-01-31 8:59:1232 days ago1706691552
0xd89Ed800...1266240Db
0 ETH
104613582024-01-31 8:59:1232 days ago1706691552
0xd89Ed800...1266240Db
0 ETH
104501002024-01-29 6:04:2434 days ago1706508264
0xd89Ed800...1266240Db
0 ETH
104501002024-01-29 6:04:2434 days ago1706508264
0xd89Ed800...1266240Db
0 ETH
104501002024-01-29 6:04:2434 days ago1706508264
0xd89Ed800...1266240Db
0 ETH
104501002024-01-29 6:04:2434 days ago1706508264
0xd89Ed800...1266240Db
0 ETH
104335942024-01-25 22:28:4838 days ago1706221728
0xd89Ed800...1266240Db
0 ETH
104335942024-01-25 22:28:4838 days ago1706221728
0xd89Ed800...1266240Db
0 ETH
104335942024-01-25 22:28:4838 days ago1706221728
0xd89Ed800...1266240Db
0 ETH
104335942024-01-25 22:28:4838 days ago1706221728
0xd89Ed800...1266240Db
0 ETH
104335842024-01-25 22:26:3638 days ago1706221596
0xd89Ed800...1266240Db
0 ETH
104335842024-01-25 22:26:3638 days ago1706221596
0xd89Ed800...1266240Db
0 ETH
104335842024-01-25 22:26:3638 days ago1706221596
0xd89Ed800...1266240Db
0 ETH
104335842024-01-25 22:26:3638 days ago1706221596
0xd89Ed800...1266240Db
0 ETH
104335712024-01-25 22:22:3638 days ago1706221356
0xd89Ed800...1266240Db
0 ETH
104335712024-01-25 22:22:3638 days ago1706221356
0xd89Ed800...1266240Db
0 ETH
104335712024-01-25 22:22:3638 days ago1706221356
0xd89Ed800...1266240Db
0 ETH
104335712024-01-25 22:22:3638 days ago1706221356
0xd89Ed800...1266240Db
0 ETH
104332112024-01-25 20:44:0038 days ago1706215440
0xd89Ed800...1266240Db
0 ETH
104332112024-01-25 20:44:0038 days ago1706215440
0xd89Ed800...1266240Db
0 ETH
104332112024-01-25 20:44:0038 days ago1706215440
0xd89Ed800...1266240Db
0 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
JBETHPaymentTerminal3_1_2

Compiler Version
v0.8.16+commit.07a7930e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 9 of 71 : JBETHPaymentTerminal3_1_2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import {Address} from '@openzeppelin/contracts/utils/Address.sol';
import {JBPayoutRedemptionPaymentTerminal3_1_2} from './abstract/JBPayoutRedemptionPaymentTerminal3_1_2.sol';
import {IJBDirectory} from './interfaces/IJBDirectory.sol';
import {IJBOperatorStore} from './interfaces/IJBOperatorStore.sol';
import {IJBProjects} from './interfaces/IJBProjects.sol';
import {IJBSplitsStore} from './interfaces/IJBSplitsStore.sol';
import {IJBPrices} from './interfaces/IJBPrices.sol';
import {JBCurrencies} from './libraries/JBCurrencies.sol';
import {JBSplitsGroups} from './libraries/JBSplitsGroups.sol';
import {JBTokens} from './libraries/JBTokens.sol';

/// @notice Manages all inflows and outflows of ETH funds into the protocol ecosystem.
contract JBETHPaymentTerminal3_1_2 is JBPayoutRedemptionPaymentTerminal3_1_2 {
  //*********************************************************************//
  // -------------------------- 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,
    address _store,
    address _owner
  )
    JBPayoutRedemptionPaymentTerminal3_1_2(
      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 71 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        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 71 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

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

File 4 of 71 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0-rc.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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 5 of 71 : 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 71 : 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 71 : ERC165Checker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Library used to query support of an interface declared via {IERC165}.
 *
 * Note that these functions return the actual result of the query: they do not
 * `revert` if an interface is not supported. It is up to the caller to decide
 * what to do in these cases.
 */
library ERC165Checker {
    // As per the EIP-165 spec, no interface should ever match 0xffffffff
    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;

    /**
     * @dev Returns true if `account` supports the {IERC165} interface,
     */
    function supportsERC165(address account) internal view returns (bool) {
        // Any contract that implements ERC165 must explicitly indicate support of
        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
        return
            _supportsERC165Interface(account, type(IERC165).interfaceId) &&
            !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
    }

    /**
     * @dev Returns true if `account` supports the interface defined by
     * `interfaceId`. Support for {IERC165} itself is queried automatically.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
        // query support of both ERC165 as per the spec and support of _interfaceId
        return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);
    }

    /**
     * @dev Returns a boolean array where each value corresponds to the
     * interfaces passed in and whether they're supported or not. This allows
     * you to batch check interfaces for a contract where your expectation
     * is that some interfaces may not be supported.
     *
     * See {IERC165-supportsInterface}.
     *
     * _Available since v3.4._
     */
    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
        internal
        view
        returns (bool[] memory)
    {
        // an array of booleans corresponding to interfaceIds and whether they're supported or not
        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);

        // query support of ERC165 itself
        if (supportsERC165(account)) {
            // query support of each interface in interfaceIds
            for (uint256 i = 0; i < interfaceIds.length; i++) {
                interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
            }
        }

        return interfaceIdsSupported;
    }

    /**
     * @dev Returns true if `account` supports all the interfaces defined in
     * `interfaceIds`. Support for {IERC165} itself is queried automatically.
     *
     * Batch-querying can lead to gas savings by skipping repeated checks for
     * {IERC165} support.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
        // query support of ERC165 itself
        if (!supportsERC165(account)) {
            return false;
        }

        // query support of each interface in _interfaceIds
        for (uint256 i = 0; i < interfaceIds.length; i++) {
            if (!_supportsERC165Interface(account, interfaceIds[i])) {
                return false;
            }
        }

        // all interfaces supported
        return true;
    }

    /**
     * @notice Query if a contract implements an interface, does not check ERC165 support
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return true if the contract at account indicates support of the interface with
     * identifier interfaceId, false otherwise
     * @dev Assumes that account contains a contract that supports ERC165, otherwise
     * the behavior of this method is undefined. This precondition can be checked
     * with {supportsERC165}.
     * Interface identification is specified in ERC-165.
     */
    function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
        bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
        (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
        if (result.length < 32) return false;
        return success && abi.decode(result, (bool));
    }
}

File 8 of 71 : 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 9 of 71 : PRBMath.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;

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

File 10 of 71 : JBOperatable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import {IJBOperatable} from './../interfaces/IJBOperatable.sol';
import {IJBOperatorStore} from './../interfaces/IJBOperatorStore.sol';

/// @notice Modifiers to allow access to functions based on the message sender's operator status.
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 immutable override operatorStore;

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

  /// @param _operatorStore A contract storing operator assignments.
  constructor(IJBOperatorStore _operatorStore) {
    operatorStore = _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 11 of 71 : JBPayoutRedemptionPaymentTerminal3_1_2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import {ERC165Checker} from '@openzeppelin/contracts/utils/introspection/ERC165Checker.sol';
import {PRBMath} from '@paulrberg/contracts/math/PRBMath.sol';
import {JBFeeType} from './../enums/JBFeeType.sol';
import {IJBAllowanceTerminal3_1} from './../interfaces/IJBAllowanceTerminal3_1.sol';
import {IJBController} from './../interfaces/IJBController.sol';
import {IJBDirectory} from './../interfaces/IJBDirectory.sol';
import {IJBPayoutRedemptionPaymentTerminal3_1} from './../interfaces/IJBPayoutRedemptionPaymentTerminal3_1.sol';
import {IJBPayoutRedemptionPaymentTerminal3_1_1} from './../interfaces/IJBPayoutRedemptionPaymentTerminal3_1_1.sol';
import {IJBSplitsStore} from './../interfaces/IJBSplitsStore.sol';
import {IJBFeeGauge3_1} from './../interfaces/IJBFeeGauge3_1.sol';
import {IJBOperatable} from './../interfaces/IJBOperatable.sol';
import {IJBOperatorStore} from './../interfaces/IJBOperatorStore.sol';
import {IJBPaymentTerminal} from './../interfaces/IJBPaymentTerminal.sol';
import {IJBPayoutTerminal3_1} from './../interfaces/IJBPayoutTerminal3_1.sol';
import {IJBPrices} from './../interfaces/IJBPrices.sol';
import {IJBProjects} from './../interfaces/IJBProjects.sol';
import {IJBRedemptionTerminal} from './../interfaces/IJBRedemptionTerminal.sol';
import {IJBSingleTokenPaymentTerminalStore3_1_1} from './../interfaces/IJBSingleTokenPaymentTerminalStore3_1_1.sol';
import {IJBSplitAllocator} from './../interfaces/IJBSplitAllocator.sol';
import {JBConstants} from './../libraries/JBConstants.sol';
import {JBCurrencies} from './../libraries/JBCurrencies.sol';
import {JBFees} from './../libraries/JBFees.sol';
import {JBFixedPointNumber} from './../libraries/JBFixedPointNumber.sol';
import {JBFundingCycleMetadataResolver} from './../libraries/JBFundingCycleMetadataResolver.sol';
import {JBOperations} from './../libraries/JBOperations.sol';
import {JBTokens} from './../libraries/JBTokens.sol';
import {JBDidRedeemData3_1_1} from './../structs/JBDidRedeemData3_1_1.sol';
import {JBDidPayData3_1_1} from './../structs/JBDidPayData3_1_1.sol';
import {JBFee} from './../structs/JBFee.sol';
import {JBFundingCycle} from './../structs/JBFundingCycle.sol';
import {JBPayDelegateAllocation3_1_1} from './../structs/JBPayDelegateAllocation3_1_1.sol';
import {JBRedemptionDelegateAllocation3_1_1} from './../structs/JBRedemptionDelegateAllocation3_1_1.sol';
import {JBSplit} from './../structs/JBSplit.sol';
import {JBSplitAllocationData} from './../structs/JBSplitAllocationData.sol';
import {JBTokenAmount} from './../structs/JBTokenAmount.sol';
import {JBOperatable} from './JBOperatable.sol';
import {JBSingleTokenPaymentTerminal} from './JBSingleTokenPaymentTerminal.sol';

/// @notice Generic terminal managing all inflows and outflows of funds into the protocol ecosystem.
abstract contract JBPayoutRedemptionPaymentTerminal3_1_2 is
  JBSingleTokenPaymentTerminal,
  JBOperatable,
  Ownable,
  IJBPayoutRedemptionPaymentTerminal3_1_1
{
  // 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_TOKENS_INCOMPATIBLE();

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

  /// @notice Maximum fee that can be set for a funding cycle configuration.
  /// @dev Out of MAX_FEE (50_000_000 / 1_000_000_000).
  uint256 internal constant _FEE_CAP = 50_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.
  /// @custom:param _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.
  address 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 (25_000_000 / 1_000_000_000)
  uint256 public override fee = 25_000_000; // 2.5%

  /// @notice The data source that returns a discount to apply to a project's fee.
  address 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.
  /// @custom:param _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 = IJBSingleTokenPaymentTerminalStore3_1_1(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.
  /// @return A flag indicating if the provided interface ID is supported.
  function supportsInterface(
    bytes4 _interfaceId
  ) public view virtual override(JBSingleTokenPaymentTerminal, IERC165) returns (bool) {
    return
      _interfaceId == type(IJBPayoutRedemptionPaymentTerminal3_1_1).interfaceId ||
      _interfaceId == type(IJBPayoutRedemptionPaymentTerminal3_1).interfaceId ||
      _interfaceId == type(IJBPayoutTerminal3_1).interfaceId ||
      _interfaceId == type(IJBAllowanceTerminal3_1).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,
    address _store,
    address _owner
  )
    payable
    JBSingleTokenPaymentTerminal(_token, _decimals, _currency)
    JBOperatable(_operatorStore)
  {
    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 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 _metadata Bytes to send along to the emitted event, if provided.
  /// @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,
    bytes calldata _metadata
  ) external virtual override returns (uint256 netLeftoverDistributionAmount) {
    _token; // Prevents unused var compiler and natspec complaints.

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

  /// @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.
  /// @param _metadata Bytes to send along to the emitted event, if provided.
  /// @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,
    bytes calldata _metadata
  )
    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,
        _metadata
      );
  }

  /// @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 = IJBSingleTokenPaymentTerminalStore3_1_1(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 {
    // Do not refund held fees by default.
    addToBalanceOf(_projectId, _amount, _token, false, _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;

    // Keep a reference to the amount.
    uint256 _amount;

    // Process each fee.
    for (uint256 _i; _i < _heldFeeLength; ) {
      // Get the fee amount.
      _amount = (
        _heldFees[_i].fee == 0 || _heldFees[_i].feeDiscount == JBConstants.MAX_FEE_DISCOUNT
          ? 0
          : JBFees.feeIn(_heldFees[_i].amount, _heldFees[_i].fee, _heldFees[_i].feeDiscount)
      );

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

      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(address _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);
  }

  //*********************************************************************//
  // ----------------------- public transactions ----------------------- //
  //*********************************************************************//

  /// @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 _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,
    address _token,
    bool _shouldRefundHeldFees,
    string calldata _memo,
    bytes calldata _metadata
  ) public payable virtual override {
    _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.
    _addToBalanceOf(_projectId, _amount, _shouldRefundHeldFees, _memo, _metadata);
  }

  //*********************************************************************//
  // ---------------------- 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 Logic to be triggered if a transfer should be undone
  /// @param _to The address to which the transfer went.
  /// @param _amount The amount of the transfer, as a fixed point number with the same number of decimals as this terminal.
  function _cancelTransferTo(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. `_feeEligibleDistributionAmount`, `_feeDiscount` and `_feePercent` only used within scope.
    {
      // Keep a reference to the amount being reclaimed that should have fees withheld from.
      uint256 _feeEligibleDistributionAmount;

      // Keep a reference to the amount of discount to apply to the fee.
      uint256 _feeDiscount;

      // Keep a reference to the fee.
      uint256 _feePercent = fee;

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

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

        // Set the reference to the fee discount to apply. No fee if the beneficiary is feeless or if the redemption rate is at its max.
        _feeDiscount = isFeelessAddress[_beneficiary] ||
          (_fundingCycle.redemptionRate() == JBConstants.MAX_REDEMPTION_RATE &&
            _fundingCycle.ballotRedemptionRate() == JBConstants.MAX_REDEMPTION_RATE) ||
          _feePercent == 0
          ? JBConstants.MAX_FEE_DISCOUNT
          : _currentFeeDiscount(_projectId, JBFeeType.REDEMPTION);

        // 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) {
          JBDidRedeemData3_1_1 memory _data = JBDidRedeemData3_1_1(
            _holder,
            _projectId,
            _fundingCycle.configuration,
            _tokenCount,
            JBTokenAmount(token, reclaimAmount, decimals, currency),
            JBTokenAmount(token, 0, decimals, currency),
            _beneficiary,
            _memo,
            bytes(''),
            _metadata
          );

          // Keep a reference to the allocation.
          JBRedemptionDelegateAllocation3_1_1 memory _delegateAllocation;

          // Keep a reference to the fee.
          uint256 _delegatedAmountFee;

          // Keep a reference to the number of allocations.
          uint256 _numDelegates = _delegateAllocations.length;

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

            // Get the fee for the delegated amount.
            _delegatedAmountFee = _feePercent == 0
              ? 0
              : JBFees.feeIn(_delegateAllocation.amount, _feePercent, _feeDiscount);

            // Add the delegated amount to the amount eligible for having a fee taken.
            if (_delegatedAmountFee != 0) {
              _feeEligibleDistributionAmount += _delegateAllocation.amount;
              _delegateAllocation.amount -= _delegatedAmountFee;
            }

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

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

            // Pass the correct metadata from the data source.
            _data.dataSourceMetadata = _delegateAllocation.metadata;

            _delegateAllocation.delegate.didRedeem{
              value: token == JBTokens.ETH ? _delegateAllocation.amount : 0
            }(_data);

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

            unchecked {
              ++_i;
            }
          }
        }
      }

      // Send the reclaimed funds to the beneficiary.
      if (reclaimAmount != 0) {
        // Get the fee for the reclaimed amount.
        uint256 _reclaimAmountFee = _feeDiscount == JBConstants.MAX_FEE_DISCOUNT
          ? 0
          : JBFees.feeIn(reclaimAmount, _feePercent, _feeDiscount);

        if (_reclaimAmountFee != 0) {
          _feeEligibleDistributionAmount += reclaimAmount;
          reclaimAmount -= _reclaimAmountFee;
        }

        // Subtract the fee from the reclaim amount.
        if (reclaimAmount != 0) _transferFrom(address(this), _beneficiary, reclaimAmount);
      }

      // Take the fee from all outbound reclaimations.
      _feeEligibleDistributionAmount != 0
        ? _takeFeeFrom(
          _projectId,
          false,
          _feeEligibleDistributionAmount,
          _feePercent,
          _beneficiary,
          _feeDiscount
        )
        : 0;
    }

    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 _metadata Bytes to send along to the emitted event, if provided.
  /// @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,
    bytes calldata _metadata
  ) internal returns (uint256 netLeftoverDistributionAmount) {
    // Record the distribution.
    (
      JBFundingCycle memory _fundingCycle,
      uint256 _distributedAmount
    ) = IJBSingleTokenPaymentTerminalStore3_1_1(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 _feeTaken;

    // Scoped section prevents stack too deep. `_feePercent`, `_feeDiscount`, `_feeEligibleDistributionAmount`, and `_leftoverDistributionAmount` only used within scope.
    {
      // Keep a reference to the fee.
      uint256 _feePercent = fee;

      // 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 = _feePercent == 0
        ? JBConstants.MAX_FEE_DISCOUNT
        : _currentFeeDiscount(_projectId, JBFeeType.PAYOUT);

      // 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,
        _feePercent,
        _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.
      _feeTaken = _feeEligibleDistributionAmount != 0
        ? _takeFeeFrom(
          _projectId,
          _fundingCycle.shouldHoldFees(),
          _feeEligibleDistributionAmount,
          _feePercent,
          _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 -
          (
            _feeDiscount == JBConstants.MAX_FEE_DISCOUNT
              ? 0
              : JBFees.feeIn(_leftoverDistributionAmount, _feePercent, _feeDiscount)
          );

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

    emit DistributePayouts(
      _fundingCycle.configuration,
      _fundingCycle.number,
      _projectId,
      _projectOwner,
      _amount,
      _distributedAmount,
      _feeTaken,
      netLeftoverDistributionAmount,
      _metadata,
      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.
  /// @param _metadata Bytes to send along to the emitted event, if provided.
  /// @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,
    bytes calldata _metadata
  ) internal returns (uint256 netDistributedAmount) {
    // Record the use of the allowance.
    (
      JBFundingCycle memory _fundingCycle,
      uint256 _distributedAmount
    ) = IJBSingleTokenPaymentTerminalStore3_1_1(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 _feeTaken;

      // Keep a reference to the fee.
      uint256 _feePercent = 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 = _feePercent == 0 || isFeelessAddress[msg.sender]
        ? JBConstants.MAX_FEE_DISCOUNT
        : _currentFeeDiscount(_projectId, JBFeeType.ALLOWANCE);

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

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

      // 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,
      _metadata,
      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.
  /// @param _feePercent The percent of fees to take, out of MAX_FEE.
  /// @return 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 _feePercent,
    uint256 _feeDiscount
  ) internal returns (uint256, uint256 feeEligibleDistributionAmount) {
    // 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);

    // Keep a reference to the split being iterated on.
    JBSplit memory _split;

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

      // The amount to send towards the split.
      uint256 _payoutAmount = PRBMath.mulDiv(_amount, _split.percent, _leftoverPercentage);

      // The payout amount substracting any applicable incurred fees.
      uint256 _netPayoutAmount = _distributeToPayoutSplit(
        _split,
        _projectId,
        _group,
        _payoutAmount,
        _feePercent,
        _feeDiscount
      );

      // If the split allocator is set as feeless, this distribution is not eligible for a fee.
      if (_netPayoutAmount != 0 && _netPayoutAmount != _payoutAmount)
        feeEligibleDistributionAmount += _payoutAmount;

      if (_payoutAmount != 0) {
        // Subtract from the amount to be sent to the beneficiary.
        unchecked {
          _amount -= _payoutAmount;
        }
      }

      unchecked {
        // Decrement the leftover percentage.
        _leftoverPercentage -= _split.percent;
      }

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

      unchecked {
        ++_i;
      }
    }

    return (_amount, feeEligibleDistributionAmount);
  }

  /// @notice Pays out a split for a project's funding cycle configuration.
  /// @param _split The split to distribute payouts to.
  /// @param _amount The total amount being distributed to the split, as a fixed point number with the same number of decimals as this terminal.
  /// @param _feePercent The percent of fees to take, out of MAX_FEE.
  /// @param _feeDiscount The amount of discount to apply to the fee, out of the MAX_FEE.
  /// @return netPayoutAmount The amount sent to the split after subtracting fees.
  function _distributeToPayoutSplit(
    JBSplit memory _split,
    uint256 _projectId,
    uint256 _group,
    uint256 _amount,
    uint256 _feePercent,
    uint256 _feeDiscount
  ) internal returns (uint256 netPayoutAmount) {
    // By default, the net payout amount is the full amount. This will be adjusted if fees are taken.
    netPayoutAmount = _amount;

    // If there's an allocator set, transfer to its `allocate` function.
    if (_split.allocator != IJBSplitAllocator(address(0))) {
      // This distribution is eligible for a fee since the funds are leaving this contract and the allocator isn't listed as feeless.
      if (
        _feeDiscount != JBConstants.MAX_FEE_DISCOUNT && !isFeelessAddress[address(_split.allocator)]
      ) {
        unchecked {
          netPayoutAmount -= JBFees.feeIn(_amount, _feePercent, _feeDiscount);
        }
      }

      // 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.
      bytes memory _reason;

      if (
        ERC165Checker.supportsInterface(
          address(_split.allocator),
          type(IJBSplitAllocator).interfaceId
        )
      )
        // If this terminal's token is ETH, send it in msg.value.
        try
          _split.allocator.allocate{value: token == JBTokens.ETH ? netPayoutAmount : 0}(_data)
        {} catch (bytes memory __reason) {
          _reason = __reason.length == 0 ? abi.encode('Allocate fail') : __reason;
        }
      else {
        _reason = abi.encode('IERC165 fail');
      }

      if (_reason.length != 0) {
        // Revert the payout.
        _revertTransferFrom(_projectId, address(_split.allocator), netPayoutAmount, _amount);

        // Set the net payout amount to 0 to signal the reversion.
        netPayoutAmount = 0;

        emit PayoutReverted(_projectId, _split, _amount, _reason, msg.sender);
      }

      // 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))) {
        // Set the net payout amount to 0 to signal the reversion.
        netPayoutAmount = 0;

        // Revert the payout.
        _revertTransferFrom(_projectId, address(0), 0, _amount);

        emit PayoutReverted(_projectId, _split, _amount, 'Terminal not found', msg.sender);
      } else {
        // This distribution is eligible for a fee since the funds are leaving this contract and the terminal isn't listed as feeless.
        if (
          _terminal != this &&
          _feeDiscount != JBConstants.MAX_FEE_DISCOUNT &&
          !isFeelessAddress[address(_terminal)]
        ) {
          unchecked {
            netPayoutAmount -= JBFees.feeIn(_amount, _feePercent, _feeDiscount);
          }
        }

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

        // Add to balance if prefered.
        if (_split.preferAddToBalance)
          try
            _terminal.addToBalanceOf{value: token == JBTokens.ETH ? netPayoutAmount : 0}(
              _split.projectId,
              netPayoutAmount,
              token,
              '',
              // Send the projectId in the metadata as a referral.
              bytes(abi.encodePacked(_projectId))
            )
          {} catch (bytes memory _reason) {
            // Revert the payout.
            _revertTransferFrom(_projectId, address(_terminal), netPayoutAmount, _amount);

            // Set the net payout amount to 0 to signal the reversion.
            netPayoutAmount = 0;

            emit PayoutReverted(_projectId, _split, _amount, _reason, msg.sender);
          }
        else
          try
            _terminal.pay{value: token == JBTokens.ETH ? netPayoutAmount : 0}(
              _split.projectId,
              netPayoutAmount,
              token,
              _split.beneficiary != address(0) ? _split.beneficiary : msg.sender,
              0,
              _split.preferClaimed,
              '',
              // Send the projectId in the metadata as a referral.
              bytes(abi.encodePacked(_projectId))
            )
          {} catch (bytes memory _reason) {
            // Revert the payout.
            _revertTransferFrom(_projectId, address(_terminal), netPayoutAmount, _amount);

            // Set the net payout amount to 0 to signal the reversion.
            netPayoutAmount = 0;

            emit PayoutReverted(_projectId, _split, _amount, _reason, msg.sender);
          }
      }
    } else {
      // This distribution is eligible for a fee since the funds are leaving this contract and the beneficiary isn't listed as feeless.
      // Don't enforce feeless address for the beneficiary since the funds are leaving the ecosystem.
      if (_feeDiscount != JBConstants.MAX_FEE_DISCOUNT) {
        unchecked {
          netPayoutAmount -= JBFees.feeIn(_amount, _feePercent, _feeDiscount);
        }
      }

      // If there's a beneficiary, send the funds directly to the beneficiary. Otherwise send to the msg.sender.
      _transferFrom(
        address(this),
        _split.beneficiary != address(0) ? _split.beneficiary : payable(msg.sender),
        netPayoutAmount
      );
    }
  }

  /// @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 _shouldHoldFees If fees should be tracked and held back.
  /// @param _feePercent The percent of fees to take, out of MAX_FEE.
  /// @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,
    bool _shouldHoldFees,
    uint256 _amount,
    uint256 _feePercent,
    address _beneficiary,
    uint256 _feeDiscount
  ) internal returns (uint256 feeAmount) {
    feeAmount = JBFees.feeIn(_amount, _feePercent, _feeDiscount);

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

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

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

  /// @notice Process a fee of the specified amount.
  /// @param _amount The fee amount, as a floating point number with 18 decimals.
  /// @param _beneficiary The address to mint the platform's tokens for.
  /// @param _from The project ID the fee is being paid from.
  function _processFee(uint256 _amount, address _beneficiary, uint256 _from) internal {
    // Get the terminal for the protocol project.
    IJBPaymentTerminal _terminal = directory.primaryTerminalOf(_FEE_BENEFICIARY_PROJECT_ID, token);

    // Trigger any inherited pre-transfer logic if funds will be transferred.
    if (address(_terminal) != address(this)) _beforeTransferTo(address(_terminal), _amount);

    try
      // Send the fee.
      // If this terminal's token is ETH, send it in msg.value.
      _terminal.pay{value: token == JBTokens.ETH ? _amount : 0}(
        _FEE_BENEFICIARY_PROJECT_ID,
        _amount,
        token,
        _beneficiary,
        0,
        false,
        '',
        // Send the projectId in the metadata.
        bytes(abi.encodePacked(_from))
      )
    {} catch (bytes memory _reason) {
      _revertTransferFrom(
        _from,
        address(_terminal) != address(this) ? address(_terminal) : address(0),
        address(_terminal) != address(this) ? _amount : 0,
        _amount
      );
      emit FeeReverted(_from, _FEE_BENEFICIARY_PROJECT_ID, _amount, _reason, msg.sender);
    }
  }

  /// @notice Reverts an expected payout.
  /// @param _projectId The ID of the project having paying out.
  /// @param _expectedDestination The address the payout was expected to go to.
  /// @param _allowanceAmount The amount that the destination has been allowed to use.
  /// @param _depositAmount The amount of the payout as debited from the project's balance.
  function _revertTransferFrom(
    uint256 _projectId,
    address _expectedDestination,
    uint256 _allowanceAmount,
    uint256 _depositAmount
  ) internal {
    // Cancel allowance if needed.
    if (_allowanceAmount != 0) _cancelTransferTo(_expectedDestination, _allowanceAmount);

    // Add undistributed amount back to project's balance.
    IJBSingleTokenPaymentTerminalStore3_1_1(store).recordAddedBalanceFor(
      _projectId,
      _depositAmount
    );
  }

  /// @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.
    {
      JBPayDelegateAllocation3_1_1[] 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
      ) = IJBSingleTokenPaymentTerminalStore3_1_1(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) {
        JBDidPayData3_1_1 memory _data = JBDidPayData3_1_1(
          _payer,
          _projectId,
          _fundingCycle.configuration,
          _bundledAmount,
          JBTokenAmount(token, 0, decimals, currency),
          beneficiaryTokenCount,
          _beneficiary,
          _preferClaimedTokens,
          _memo,
          bytes(''),
          _metadata
        );

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

        // Keep a reference to the allocation.
        JBPayDelegateAllocation3_1_1 memory _delegateAllocation;

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

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

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

          // Pass the correct metadata from the data source.
          _data.dataSourceMetadata = _delegateAllocation.metadata;

          _delegateAllocation.delegate.didPay{
            value: token == JBTokens.ETH ? _delegateAllocation.amount : 0
          }(_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.
    IJBSingleTokenPaymentTerminalStore3_1_1(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 {
        // Notice here we take feeIn the stored .amount
        uint256 _feeAmount = (
          _heldFees[_i].fee == 0 || _heldFees[_i].feeDiscount == JBConstants.MAX_FEE_DISCOUNT
            ? 0
            : JBFees.feeIn(_heldFees[_i].amount, _heldFees[_i].fee, _heldFees[_i].feeDiscount)
        );

        if (leftoverAmount >= _heldFees[_i].amount - _feeAmount) {
          unchecked {
            leftoverAmount = leftoverAmount - (_heldFees[_i].amount - _feeAmount);
            refundedFees += _feeAmount;
          }
        } else {
          // And here we overwrite with feeFrom the leftoverAmount
          _feeAmount = (
            _heldFees[_i].fee == 0 || _heldFees[_i].feeDiscount == JBConstants.MAX_FEE_DISCOUNT
              ? 0
              : JBFees.feeFrom(leftoverAmount, _heldFees[_i].fee, _heldFees[_i].feeDiscount)
          );

          unchecked {
            _heldFeesOf[_projectId].push(
              JBFee(
                _heldFees[_i].amount - (leftoverAmount + _feeAmount),
                _heldFees[_i].fee,
                _heldFees[_i].feeDiscount,
                _heldFees[_i].beneficiary
              )
            );
            refundedFees += _feeAmount;
          }
          leftoverAmount = 0;
        }
        
      }

      unchecked {
        ++_i;
      }
    }

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

  /// @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.
  /// @param _feeType The type of fee the discount is being applied to.
  /// @return feeDiscount The fee discount, which should be interpreted as a percentage out MAX_FEE_DISCOUNT.
  function _currentFeeDiscount(
    uint256 _projectId,
    JBFeeType _feeType
  ) 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 != address(0))
      // If the guage reverts, keep the discount at 0.
      try IJBFeeGauge3_1(feeGauge).currentDiscountFor(_projectId, _feeType) 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 12 of 71 : JBSingleTokenPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import {ERC165} from '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import {IERC165} from '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import {IJBPaymentTerminal} from './../interfaces/IJBPaymentTerminal.sol';
import {IJBSingleTokenPaymentTerminal} from './../interfaces/IJBSingleTokenPaymentTerminal.sol';

/// @notice Generic terminal managing all inflows of funds into the protocol ecosystem for one token.
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.
  /// @return A flag indicating if the provided interface ID is supported.
  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 13 of 71 : JBBallotState.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

enum JBBallotState {
  Active,
  Approved,
  Failed
}

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

enum JBFeeType {
  PAYOUT,
  ALLOWANCE,
  REDEMPTION
}

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

interface IJBAllowanceTerminal3_1 {
  function useAllowanceOf(
    uint256 projectId,
    uint256 amount,
    uint256 currency,
    address token,
    uint256 minReturnedTokens,
    address payable beneficiary,
    string calldata memo,
    bytes calldata metadata
  ) external returns (uint256 netDistributedAmount);
}

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

import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import {JBBallotState} from './../enums/JBBallotState.sol';
import {JBFundAccessConstraints} from './../structs/JBFundAccessConstraints.sol';
import {JBFundingCycle} from './../structs/JBFundingCycle.sol';
import {JBFundingCycleData} from './../structs/JBFundingCycleData.sol';
import {JBFundingCycleMetadata} from './../structs/JBFundingCycleMetadata.sol';
import {JBGroupedSplits} from './../structs/JBGroupedSplits.sol';
import {JBProjectMetadata} from './../structs/JBProjectMetadata.sol';
import {JBSplit} from './../structs/JBSplit.sol';
import {IJBDirectory} from './IJBDirectory.sol';
import {IJBFundingCycleStore} from './IJBFundingCycleStore.sol';
import {IJBMigratable} from './IJBMigratable.sol';
import {IJBPaymentTerminal} from './IJBPaymentTerminal.sol';
import {IJBProjects} from './IJBProjects.sol';
import {IJBSplitsStore} from './IJBSplitsStore.sol';
import {IJBTokenStore} from './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 17 of 71 : IJBDirectory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJBFundingCycleStore} from './IJBFundingCycleStore.sol';
import {IJBPaymentTerminal} from './IJBPaymentTerminal.sol';
import {IJBProjects} from './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 account) 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 account, bool flag) external;
}

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

import {JBFeeType} from './../enums/JBFeeType.sol';

interface IJBFeeGauge3_1 {
  function currentDiscountFor(uint256 projectId, JBFeeType feeType) external view returns (uint256);
}

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

interface IJBFeeHoldingTerminal {
  function addToBalanceOf(
    uint256 projectId,
    uint256 amount,
    address token,
    bool shouldRefundHeldFees,
    string calldata memo,
    bytes calldata metadata
  ) external payable;
}

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

import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import {JBBallotState} from './../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 21 of 71 : IJBFundingCycleStore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBBallotState} from './../enums/JBBallotState.sol';
import {JBFundingCycle} from './../structs/JBFundingCycle.sol';
import {JBFundingCycleData} from './../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 22 of 71 : IJBMigratable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IJBMigratable {
  function prepForMigrationOf(uint256 projectId, address from) external;
}

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

import {IJBOperatorStore} from './IJBOperatorStore.sol';

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

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

import {JBOperatorData} from './../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 25 of 71 : IJBPayDelegate.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/// @title Pay delegate
/// @notice Delegate called after JBTerminal.pay(..) logic completion (if passed by the funding cycle datasource)
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:
  function didPay(JBDidPayData calldata data) external payable;
}

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

import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import {JBDidPayData3_1_1} from './../structs/JBDidPayData3_1_1.sol';

/// @title Pay delegate
/// @notice Delegate called after JBTerminal.pay(..) logic completion (if passed by the funding cycle datasource)
interface IJBPayDelegate3_1_1 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 JBDidPayData3_1_1 struct:
  function didPay(JBDidPayData3_1_1 calldata data) external payable;
}

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

import {IERC165} from '@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 28 of 71 : IJBPayoutRedemptionPaymentTerminal3_1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBFee} from './../structs/JBFee.sol';
import {IJBAllowanceTerminal3_1} from './IJBAllowanceTerminal3_1.sol';
import {IJBDirectory} from './IJBDirectory.sol';
import {IJBFeeHoldingTerminal} from './IJBFeeHoldingTerminal.sol';
import {IJBPayDelegate} from './IJBPayDelegate.sol';
import {IJBPaymentTerminal} from './IJBPaymentTerminal.sol';
import {IJBPayoutTerminal3_1} from './IJBPayoutTerminal3_1.sol';
import {IJBPrices} from './IJBPrices.sol';
import {IJBProjects} from './IJBProjects.sol';
import {IJBRedemptionDelegate} from './IJBRedemptionDelegate.sol';
import {IJBRedemptionTerminal} from './IJBRedemptionTerminal.sol';
import {IJBSplitsStore} from './IJBSplitsStore.sol';
import {JBDidPayData} from './../structs/JBDidPayData.sol';
import {JBDidRedeemData} from './../structs/JBDidRedeemData.sol';
import {JBSplit} from './../structs/JBSplit.sol';

interface IJBPayoutRedemptionPaymentTerminal3_1 is
  IJBPaymentTerminal,
  IJBPayoutTerminal3_1,
  IJBAllowanceTerminal3_1,
  IJBRedemptionTerminal,
  IJBFeeHoldingTerminal
{
  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,
    bytes metadata,
    address caller
  );

  event UseAllowance(
    uint256 indexed fundingCycleConfiguration,
    uint256 indexed fundingCycleNumber,
    uint256 indexed projectId,
    address beneficiary,
    uint256 amount,
    uint256 distributedAmount,
    uint256 netDistributedamount,
    string memo,
    bytes metadata,
    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,
    uint256 netAmount,
    address caller
  );

  event SetFee(uint256 fee, address caller);

  event SetFeeGauge(address indexed feeGauge, address caller);

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

  event PayoutReverted(
    uint256 indexed projectId,
    JBSplit split,
    uint256 amount,
    bytes reason,
    address caller
  );

  event FeeReverted(
    uint256 indexed projectId,
    uint256 indexed feeProjectId,
    uint256 amount,
    bytes reason,
    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 (address);

  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 (address);

  function isFeelessAddress(address account) 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(address feeGauge) external;

  function setFeelessAddress(address account, bool flag) external;
}

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

import {JBFee} from './../structs/JBFee.sol';
import {JBDidRedeemData3_1_1} from './../structs/JBDidRedeemData3_1_1.sol';
import {JBDidPayData3_1_1} from './../structs/JBDidPayData3_1_1.sol';
import {IJBPayDelegate3_1_1} from './IJBPayDelegate3_1_1.sol';
import {IJBRedemptionDelegate3_1_1} from './IJBRedemptionDelegate3_1_1.sol';
import {IJBPayoutRedemptionPaymentTerminal3_1} from './IJBPayoutRedemptionPaymentTerminal3_1.sol';

interface IJBPayoutRedemptionPaymentTerminal3_1_1 is IJBPayoutRedemptionPaymentTerminal3_1 {
  event DelegateDidRedeem(
    IJBRedemptionDelegate3_1_1 indexed delegate,
    JBDidRedeemData3_1_1 data,
    uint256 delegatedAmount,
    uint256 fee,
    address caller
  );

  event DelegateDidPay(
    IJBPayDelegate3_1_1 indexed delegate,
    JBDidPayData3_1_1 data,
    uint256 delegatedAmount,
    address caller
  );
}

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

interface IJBPayoutTerminal3_1 {
  function distributePayoutsOf(
    uint256 projectId,
    uint256 amount,
    uint256 currency,
    address token,
    uint256 minReturnedTokens,
    bytes calldata metadata
  ) external returns (uint256 netLeftoverDistributionAmount);
}

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

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

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

import {IJBPriceFeed} from './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 33 of 71 : IJBProjects.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import {JBProjectMetadata} from './../structs/JBProjectMetadata.sol';
import {IJBTokenUriResolver} from './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 34 of 71 : IJBRedemptionDelegate.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/// @title Redemption delegate
/// @notice Delegate called after JBTerminal.redeemTokensOf(..) logic completion (if passed by the funding cycle datasource)
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:
  function didRedeem(JBDidRedeemData calldata data) external payable;
}

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

import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import {JBDidRedeemData3_1_1} from './../structs/JBDidRedeemData3_1_1.sol';

/// @title Redemption delegate
/// @notice Delegate called after JBTerminal.redeemTokensOf(..) logic completion (if passed by the funding cycle datasource)
interface IJBRedemptionDelegate3_1_1 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:
  function didRedeem(JBDidRedeemData3_1_1 calldata data) external payable;
}

File 36 of 71 : 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 37 of 71 : IJBSingleTokenPaymentTerminal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJBPaymentTerminal} from './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 38 of 71 : IJBSingleTokenPaymentTerminalStore3_1_1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBFundingCycle} from './../structs/JBFundingCycle.sol';
import {JBPayDelegateAllocation3_1_1} from './../structs/JBPayDelegateAllocation3_1_1.sol';
import {JBRedemptionDelegateAllocation3_1_1} from './../structs/JBRedemptionDelegateAllocation3_1_1.sol';
import {JBTokenAmount} from './../structs/JBTokenAmount.sol';
import {IJBDirectory} from './IJBDirectory.sol';
import {IJBFundingCycleStore} from './IJBFundingCycleStore.sol';
import {IJBPrices} from './IJBPrices.sol';
import {IJBSingleTokenPaymentTerminal} from './IJBSingleTokenPaymentTerminal.sol';

interface IJBSingleTokenPaymentTerminalStore3_1_1 {
  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 inputMemo,
    bytes calldata metadata
  )
    external
    returns (
      JBFundingCycle memory fundingCycle,
      uint256 tokenCount,
      JBPayDelegateAllocation3_1_1[] memory delegateAllocations,
      string memory outputMemo
    );

  function recordRedemptionFor(
    address holder,
    uint256 projectId,
    uint256 tokenCount,
    string calldata inputMemo,
    bytes calldata metadata
  )
    external
    returns (
      JBFundingCycle memory fundingCycle,
      uint256 reclaimAmount,
      JBRedemptionDelegateAllocation3_1_1[] memory delegateAllocations,
      string memory outputMemo
    );

  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 39 of 71 : IJBSplitAllocator.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/// @title Split allocator
/// @notice Provide a way to process a single split with extra logic
/// @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:
  function allocate(JBSplitAllocationData calldata data) external payable;
}

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

import {JBGroupedSplits} from './../structs/JBGroupedSplits.sol';
import {JBSplit} from './../structs/JBSplit.sol';
import {IJBDirectory} from './IJBDirectory.sol';
import {IJBProjects} from './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 41 of 71 : 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 42 of 71 : IJBTokenStore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJBFundingCycleStore} from './IJBFundingCycleStore.sol';
import {IJBProjects} from './IJBProjects.sol';
import {IJBToken} from './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 43 of 71 : IJBTokenUriResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

File 44 of 71 : 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 45 of 71 : JBCurrencies.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

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

import {PRBMath} from '@paulrberg/contracts/math/PRBMath.sol';
import {JBConstants} from './../libraries/JBConstants.sol';

/// @notice Fee calculations.
library JBFees {
  /// @notice Returns the fee included in the specified _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 _feePercent 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 feeIn(
    uint256 _amount,
    uint256 _feePercent,
    uint256 _feeDiscount
  ) internal pure returns (uint256) {
    // Calculate the discounted fee.
    uint256 _discountedFeePercent = _feePercent -
      PRBMath.mulDiv(_feePercent, _feeDiscount, JBConstants.MAX_FEE_DISCOUNT);

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

  /// @notice Returns the fee amount paid from a payouts of _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 _feePercent 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 feeFrom(
    uint256 _amount,
    uint256 _feePercent,
    uint256 _feeDiscount
  ) internal pure returns (uint256) {
    // Calculate the discounted fee.
    uint256 _discountedFeePercent = _feePercent -
      PRBMath.mulDiv(_feePercent, _feeDiscount, JBConstants.MAX_FEE_DISCOUNT);

    // The amount of tokens from the `_amount` to pay as a fee. If reverse, the fee taken from a payout of `_amount`.
    return PRBMath.mulDiv(_amount, _discountedFeePercent, JBConstants.MAX_FEE);
  }
}

File 47 of 71 : JBFixedPointNumber.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

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 48 of 71 : JBFundingCycleMetadataResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

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

library JBFundingCycleMetadataResolver {
  function global(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(
        global(_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 49 of 71 : JBGlobalFundingCycleMetadataResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import {JBFundingCycleMetadata} from './../structs/JBFundingCycleMetadata.sol';
import {JBGlobalFundingCycleMetadata} from './../structs/JBGlobalFundingCycleMetadata.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 50 of 71 : JBOperations.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

File 51 of 71 : 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 52 of 71 : 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 53 of 71 : JBDidPayData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBTokenAmount} from './JBTokenAmount.sol';

/// @custom:member payer The address from which the payment originated.
/// @custom:member projectId The ID of the project for which the payment was made.
/// @custom:member currentFundingCycleConfiguration The configuration of the funding cycle during which the payment is being made.
/// @custom: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.
/// @custom: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.
/// @custom:member projectTokenCount The number of project tokens minted for the beneficiary.
/// @custom:member beneficiary The address to which the tokens were minted.
/// @custom: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.
/// @custom:member memo The memo that is being emitted alongside the payment.
/// @custom: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 54 of 71 : JBDidPayData3_1_1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBTokenAmount} from './JBTokenAmount.sol';

/// @custom:member payer The address from which the payment originated.
/// @custom:member projectId The ID of the project for which the payment was made.
/// @custom:member currentFundingCycleConfiguration The configuration of the funding cycle during which the payment is being made.
/// @custom: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.
/// @custom: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.
/// @custom:member projectTokenCount The number of project tokens minted for the beneficiary.
/// @custom:member beneficiary The address to which the tokens were minted.
/// @custom: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.
/// @custom:member memo The memo that is being emitted alongside the payment.
/// @custom:member dataSourceMetadata Extra data to send to the delegate sent by the data source.
/// @custom:member payerMetadata Extra data to send to the delegate sent by the payer.
struct JBDidPayData3_1_1 {
  address payer;
  uint256 projectId;
  uint256 currentFundingCycleConfiguration;
  JBTokenAmount amount;
  JBTokenAmount forwardedAmount;
  uint256 projectTokenCount;
  address beneficiary;
  bool preferClaimedTokens;
  string memo;
  bytes dataSourceMetadata;
  bytes payerMetadata;
}

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

import {JBTokenAmount} from './JBTokenAmount.sol';

/// @custom:member holder The holder of the tokens being redeemed.
/// @custom:member projectId The ID of the project with which the redeemed tokens are associated.
/// @custom:member currentFundingCycleConfiguration The configuration of the funding cycle during which the redemption is being made.
/// @custom:member projectTokenCount The number of project tokens being redeemed.
/// @custom: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.
/// @custom: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.
/// @custom:member beneficiary The address to which the reclaimed amount will be sent.
/// @custom:member memo The memo that is being emitted alongside the redemption.
/// @custom: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 56 of 71 : JBDidRedeemData3_1_1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBTokenAmount} from './JBTokenAmount.sol';

/// @custom:member holder The holder of the tokens being redeemed.
/// @custom:member projectId The ID of the project with which the redeemed tokens are associated.
/// @custom:member currentFundingCycleConfiguration The configuration of the funding cycle during which the redemption is being made.
/// @custom:member projectTokenCount The number of project tokens being redeemed.
/// @custom: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.
/// @custom: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.
/// @custom:member beneficiary The address to which the reclaimed amount will be sent.
/// @custom:member memo The memo that is being emitted alongside the redemption.
/// @custom:member dataSourceMetadata Extra data to send to the delegate sent by the data source.
/// @custom:member redeemerMetadata Extra data to send to the delegate sent by the redeemer.
struct JBDidRedeemData3_1_1 {
  address holder;
  uint256 projectId;
  uint256 currentFundingCycleConfiguration;
  uint256 projectTokenCount;
  JBTokenAmount reclaimedAmount;
  JBTokenAmount forwardedAmount;
  address payable beneficiary;
  string memo;
  bytes dataSourceMetadata;
  bytes redeemerMetadata;
}

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

/// @custom: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.
/// @custom:member fee The percent of the fee, out of MAX_FEE.
/// @custom:member feeDiscount The discount of the fee.
/// @custom: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 58 of 71 : JBFundAccessConstraints.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJBPaymentTerminal} from './../interfaces/IJBPaymentTerminal.sol';

/// @custom:member terminal The terminal within which the distribution limit and the overflow allowance applies.
/// @custom:member token The token for which the fund access constraints apply.
/// @custom: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.
/// @custom:member distributionLimitCurrency The currency of the distribution limit.
/// @custom: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.
/// @custom:member overflowAllowanceCurrency The currency of the overflow allowance.
struct JBFundAccessConstraints {
  IJBPaymentTerminal terminal;
  address token;
  uint256 distributionLimit;
  uint256 distributionLimitCurrency;
  uint256 overflowAllowance;
  uint256 overflowAllowanceCurrency;
}

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

import {IJBFundingCycleBallot} from './../interfaces/IJBFundingCycleBallot.sol';

/// @custom: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.
/// @custom: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.
/// @custom:member basedOn The `configuration` of the funding cycle that was active when this cycle was created.
/// @custom:member start The timestamp marking the moment from which the funding cycle is considered active. It is a unix timestamp measured in seconds.
/// @custom: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`.
/// @custom: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.
/// @custom: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`.
/// @custom: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.
/// @custom: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 60 of 71 : JBFundingCycleData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJBFundingCycleBallot} from './../interfaces/IJBFundingCycleBallot.sol';

/// @custom: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`.
/// @custom: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.
/// @custom: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`.
/// @custom: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 61 of 71 : JBFundingCycleMetadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBGlobalFundingCycleMetadata} from './JBGlobalFundingCycleMetadata.sol';

/// @custom:member global Data used globally in non-migratable ecosystem contracts.
/// @custom:member reservedRate The reserved rate of the funding cycle. This number is a percentage calculated out of `JBConstants.MAX_RESERVED_RATE`.
/// @custom:member redemptionRate The redemption rate of the funding cycle. This number is a percentage calculated out of `JBConstants.MAX_REDEMPTION_RATE`.
/// @custom: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`.
/// @custom:member pausePay A flag indicating if the pay functionality should be paused during the funding cycle.
/// @custom:member pauseDistributions A flag indicating if the distribute functionality should be paused during the funding cycle.
/// @custom:member pauseRedeem A flag indicating if the redeem functionality should be paused during the funding cycle.
/// @custom:member pauseBurn A flag indicating if the burn functionality should be paused during the funding cycle.
/// @custom:member allowMinting A flag indicating if minting tokens should be allowed during this funding cycle.
/// @custom:member allowTerminalMigration A flag indicating if migrating terminals should be allowed during this funding cycle.
/// @custom:member allowControllerMigration A flag indicating if migrating controllers should be allowed during this funding cycle.
/// @custom:member holdFees A flag indicating if fees should be held during this funding cycle.
/// @custom:member preferClaimedTokenOverride A flag indicating if claimed tokens should always be prefered to unclaimed tokens when minting.
/// @custom: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.
/// @custom:member useDataSourceForPay A flag indicating if the data source should be used for pay transactions during this funding cycle.
/// @custom:member useDataSourceForRedeem A flag indicating if the data source should be used for redeem transactions during this funding cycle.
/// @custom:member dataSource The data source to use during this funding cycle.
/// @custom: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 62 of 71 : JBGlobalFundingCycleMetadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @custom:member allowSetTerminals A flag indicating if setting terminals should be allowed during this funding cycle.
/// @custom:member allowSetController A flag indicating if setting a new controller should be allowed during this funding cycle.
/// @custom: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 63 of 71 : JBGroupedSplits.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBSplit} from './JBSplit.sol';

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

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

/// @custom:member operator The address of the operator.
/// @custom: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.
/// @custom:member permissionIndexes The indexes of the permissions the operator is being given.
struct JBOperatorData {
  address operator;
  uint256 domain;
  uint256[] permissionIndexes;
}

File 65 of 71 : JBPayDelegateAllocation3_1_1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJBPayDelegate3_1_1} from '../interfaces/IJBPayDelegate3_1_1.sol';

/// @custom:member delegate A delegate contract to use for subsequent calls.
/// @custom:member amount The amount to send to the delegate.
/// @custom:member metadata Metadata to pass the delegate.
struct JBPayDelegateAllocation3_1_1 {
  IJBPayDelegate3_1_1 delegate;
  uint256 amount;
  bytes metadata;
}

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

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

File 67 of 71 : JBRedemptionDelegateAllocation3_1_1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJBRedemptionDelegate3_1_1} from '../interfaces/IJBRedemptionDelegate3_1_1.sol';

/// @custom:member delegate A delegate contract to use for subsequent calls.
/// @custom:member amount The amount to send to the delegate.
/// @custom:member metadata Metadata to pass the delegate.
struct JBRedemptionDelegateAllocation3_1_1 {
  IJBRedemptionDelegate3_1_1 delegate;
  uint256 amount;
  bytes metadata;
}

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

import {IJBSplitAllocator} from './../interfaces/IJBSplitAllocator.sol';

/// @custom: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.
/// @custom:member preferAddToBalance A flag indicating if a distribution to a project should prefer triggering it's addToBalance function instead of its pay function.
/// @custom:member percent The percent of the whole group that this split occupies. This number is out of `JBConstants.SPLITS_TOTAL_PERCENT`.
/// @custom: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.
/// @custom: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.
/// @custom:member lockedUntil Specifies if the split should be unchangeable until the specified time, with the exception of extending the locked period.
/// @custom: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 69 of 71 : JBSplitAllocationData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {JBSplit} from './JBSplit.sol';

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

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

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

File 71 of 71 : 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 closest power of two that is higher than 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
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

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":"address","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_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 IJBPayDelegate3_1_1","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":"dataSourceMetadata","type":"bytes"},{"internalType":"bytes","name":"payerMetadata","type":"bytes"}],"indexed":false,"internalType":"struct JBDidPayData3_1_1","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 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 IJBRedemptionDelegate3_1_1","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":"dataSourceMetadata","type":"bytes"},{"internalType":"bytes","name":"redeemerMetadata","type":"bytes"}],"indexed":false,"internalType":"struct JBDidRedeemData3_1_1","name":"data","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"delegatedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"DelegateDidRedeem","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":"bytes","name":"metadata","type":"bytes"},{"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":"uint256","name":"netAmount","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":"feeProjectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"reason","type":"bytes"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"FeeReverted","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"},{"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":"bytes","name":"reason","type":"bytes"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"PayoutReverted","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":"address","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":"bytes","name":"metadata","type":"bytes"},{"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":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"bool","name":"_shouldRefundHeldFees","type":"bool"},{"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":"bytes","name":"_metadata","type":"bytes"}],"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":"address","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":"address","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":"address","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"},{"internalType":"bytes","name":"_metadata","type":"bytes"}],"name":"useAllowanceOf","outputs":[{"internalType":"uint256","name":"netDistributedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

6101e060405263017d78406002553480156200001a57600080fd5b5060405162005f3438038062005f348339810160408190526200003d916200020a565b61eeee6080819052601260a0819052600160c08190526001600160a01b038a1660e0528a818b8b8b8b8b8b8b6200007433620000cf565b6101a08990526101c08890526001600160a01b0380871661010052858116610120528481166101405283811661016052821661018052620000b5816200011f565b5050505050505050505050505050505050505050620002bf565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000546001600160a01b031633146200017f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6001600160a01b038116620001e65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840162000176565b620001f181620000cf565b50565b6001600160a01b0381168114620001f157600080fd5b600080600080600080600080610100898b0312156200022857600080fd5b8851975060208901516200023c81620001f4565b60408a01519097506200024f81620001f4565b60608a01519096506200026281620001f4565b60808a01519095506200027581620001f4565b60a08a01519094506200028881620001f4565b60c08a01519093506200029b81620001f4565b60e08a0151909250620002ae81620001f4565b809150509295985092959890939650565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c051615a2062000514600039600081816103cf0152611fa701526000818161030701526118090152600081816104f701528181610ac3015281816112ea015281816117d701528181611e520152818161255e015281816128c0015281816129cd015261360a015260008181610656015261146f0152600081816102bb01526132e101526000818161060f015281816118ba0152818161230701528181612b18015281816131870152613e6c0152600081816104a50152818161097e01528181610e6b0152818161121f01528181611efe015261261801526000818161056b01528181611ce601528181611d820152818161213901526121d50152600081816102660152818161070e015281816113ba0152818161141c015281816117b101528181611a8d01528181612cae0152612d3e01526000818161033b015281816105db0152818161135b01528181611387015281816113e7015281816114490152818161178b01528181611a6701528181612c8801528181612d180152613c200152600081816106cc015281816107620152818161086c01528181610a1601528181610b4401528181610bb7015281816114f80152818161175601528181611a3101528181611b7f015281816122dc01528181612393015281816123ce01528181612c5301528181612ce201528181612e6b0152818161315a01528181613beb01528181613c9301528181613e9901528181613ff4015281816140320152818161416701526141ab0152615a206000f3fe6080604052600436106101f95760003560e01c80638da5cb5b1161010d578063c715967a116100a0578063df21a7dd1161006f578063df21a7dd146106ae578063e5a6b10f146106fc578063f2fde38b14610730578063fc0c546a14610750578063fe663f0f1461078457600080fd5b8063c715967a14610631578063d3419bf314610644578063d6dacc5314610678578063ddca3f431461069857600080fd5b8063ad007d63116100dc578063ad007d6314610559578063b631b5001461058d578063b7bad1b1146105bd578063c41c2f24146105fd57600080fd5b80638da5cb5b146104c7578063975057e7146104e5578063a02f801c14610519578063a32e1e961461053957600080fd5b80634a4305c011610190578063715018a61161015f578063715018a6146104115780637258002c1461042657806389701db5146104465780638af56094146104665780638b79543c1461049357600080fd5b80634a4305c01461037d578063637913ac1461039d57806366248b86146103bd57806369fe0e2d146103f157600080fd5b80632bdfe004116101cc5780632bdfe004146102a95780632d1a5903146102f5578063313ce56714610329578063405b84fa1461035d57600080fd5b806301ffc9a7146101fe5780630cf8e858146102335780631982d679146102485780631ebc263f14610296575b600080fd5b34801561020a57600080fd5b5061021e6102193660046144dd565b6107a4565b60405190151581526020015b60405180910390f35b610246610241366004614564565b61084e565b005b34801561025457600080fd5b506102886102633660046145f9565b507f000000000000000000000000000000000000000000000000000000000000000090565b60405190815260200161022a565b6102886102a4366004614624565b610868565b3480156102b557600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161022a565b34801561030157600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000081565b34801561033557600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000081565b34801561036957600080fd5b506102886103783660046146eb565b610965565b34801561038957600080fd5b5061028861039836600461471b565b610c61565b3480156103a957600080fd5b506102466103b83660046145f9565b610c7d565b3480156103c957600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000081565b3480156103fd57600080fd5b5061024661040c366004614784565b610d04565b34801561041d57600080fd5b50610246610d93565b34801561043257600080fd5b5061024661044136600461479d565b610dc9565b34801561045257600080fd5b50610246610461366004614784565b610e55565b34801561047257600080fd5b50610486610481366004614784565b611159565b60405161022a91906147cb565b34801561049f57600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b3480156104d357600080fd5b506000546001600160a01b03166102dd565b3480156104f157600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561052557600080fd5b50610288610534366004614971565b611206565b34801561054557600080fd5b50610288610554366004614784565b6112c1565b34801561056557600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561059957600080fd5b5061021e6105a83660046145f9565b60046020526000908152604090205460ff1681565b3480156105c957600080fd5b506102886105d83660046145f9565b507f000000000000000000000000000000000000000000000000000000000000000090565b34801561060957600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b61024661063f366004614a29565b6114f6565b34801561065057600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561068457600080fd5b506003546102dd906001600160a01b031681565b3480156106a457600080fd5b5061028860025481565b3480156106ba57600080fd5b5061021e6106c9366004614ad0565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b34801561070857600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000081565b34801561073c57600080fd5b5061024661074b3660046145f9565b6115e9565b34801561075c57600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561079057600080fd5b5061028861079f366004614afc565b611684565b60006001600160e01b0319821615806107cd57506001600160e01b0319821663edb527eb60e01b145b806107e857506001600160e01b031982166301290c1760e61b145b8061080357506001600160e01b0319821663280be00760e21b145b8061081e57506001600160e01b0319821663fe663f0f60e01b145b8061083957506001600160e01b0319821663ad007d6360e01b145b806108485750610848826116b4565b92915050565b61085f8787876000888888886114f6565b50505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee146108d95734156108bb57604051635e7e9adf60e11b815260040160405180910390fd5b476108c733308d611704565b6108d18147614bca565b9a50506108dd565b3499505b6109568a338d8b8b8b8b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8f018190048102820181019092528d815292508d91508c908190840183828082843760009201919091525061171392505050565b9b9a5050505050505050505050565b6040516331a9108f60e11b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa1580156109cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f19190614bdd565b8360046109ff838383611cbb565b60405163df21a7dd60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820188905286169063df21a7dd90604401602060405180830381865afa158015610a6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a909190614bfa565b610aad5760405163581010ed60e01b815260040160405180910390fd5b604051636bb6a5ad60e01b8152600481018790527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636bb6a5ad906024016020604051808303816000875af1158015610b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b389190614c17565b93508315610c135760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee14610b7b576000610b7d565b845b6040805160208101825260008152905163019f1d0b60e31b81529192506001600160a01b03881691630cf8e858918491610bdf918c918b917f000000000000000000000000000000000000000000000000000000000000000091600401614c80565b6000604051808303818588803b158015610bf857600080fd5b505af1158015610c0c573d6000803e3d6000fd5b5050505050505b604080518581523360208201526001600160a01b0387169188917fa7519e5f94697b7f53e97c5eb46a0c730a296ab686ab8fd333835c5f735784eb910160405180910390a350505092915050565b6000610c71888888878787611e1f565b98975050505050505050565b6000546001600160a01b03163314610cb05760405162461bcd60e51b8152600401610ca790614cbb565b60405180910390fd5b600380546001600160a01b0319166001600160a01b0383169081179091556040513381527f0a9a80fe9716605b3e52abb3d792d6a4e7816d6afc02a5a4ef023081feaf9f609060200160405180910390a250565b6000546001600160a01b03163314610d2e5760405162461bcd60e51b8152600401610ca790614cbb565b6302faf080811115610d53576040516345fbd9c160e01b815260040160405180910390fd5b6002819055604080518281523360208201527fd7414e590e1cb532989ab2a34c8f4c2c17f7ab6f006efeeaef2e87cd5008c202910160405180910390a150565b6000546001600160a01b03163314610dbd5760405162461bcd60e51b8152600401610ca790614cbb565b610dc760006120b4565b565b6000546001600160a01b03163314610df35760405162461bcd60e51b8152600401610ca790614cbb565b6001600160a01b038216600081815260046020908152604091829020805460ff191685151590811790915591513381529192917fa2653e25a502c023a5830d0de847ef6f458387865b1f4f575d7594f9f2c0d71e910160405180910390a35050565b6040516331a9108f60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ede9190614bdd565b816005610ef36000546001600160a01b031690565b6001600160a01b0316336001600160a01b031614610f1384848484612104565b600085815260016020908152604080832080548251818502810185019093528083529192909190849084015b82821015610fac57600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b031660608301529083529092019101610f3f565b5050506000888152600160205260408120929350610fcb92915061443c565b80516000805b8281101561114e57838181518110610feb57610feb614cf0565b60200260200101516020015163ffffffff16600014806110315750633b9aca0084828151811061101d5761101d614cf0565b60200260200101516040015163ffffffff16145b6110a8576110a384828151811061104a5761104a614cf0565b60200260200101516000015185838151811061106857611068614cf0565b60200260200101516020015163ffffffff1686848151811061108c5761108c614cf0565b60200260200101516040015163ffffffff16612278565b6110ab565b60005b91506110d5828583815181106110c3576110c3614cf0565b6020026020010151606001518b6122be565b60011515828a7fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a3525187858151811061110e5761110e614cf0565b6020026020010151606001513360405161113e9291906001600160a01b0392831681529116602082015260400190565b60405180910390a4600101610fd1565b505050505050505050565b606060016000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fb57600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b03166060830152908352909201910161118e565b505050509050919050565b6040516331a9108f60e11b8152600481018a90526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa15801561126e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112929190614bdd565b8a60116112a0838383611cbb565b6112b08d8d8d8c8c8c8c8c61252b565b9d9c50505050505050505050505050565b60405163035240c760e61b81523060048201526024810182905260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d49031c090604401602060405180830381865afa158015611331573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113559190614c17565b905060007f00000000000000000000000000000000000000000000000000000000000000006012146113b2576113ad827f00000000000000000000000000000000000000000000000000000000000000006012612772565b6113b4565b815b905060017f0000000000000000000000000000000000000000000000000000000000000000146114ec576114e78161140d7f0000000000000000000000000000000000000000000000000000000000000000600a614dea565b604051635268657960e11b81527f00000000000000000000000000000000000000000000000000000000000000006004820152600160248201527f000000000000000000000000000000000000000000000000000000000000000060448201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a4d0caf290606401602060405180830381865afa1580156114be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e29190614c17565b6127cf565b6114ee565b805b949350505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661eeee1461156557341561154757604051635e7e9adf60e11b815260040160405180910390fd5b4761155333308a611704565b61155d8147614bca565b975050611569565b3496505b6115df88888787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b01819004810282018101909252898152925089915088908190840183828082843760009201919091525061289c92505050565b5050505050505050565b6000546001600160a01b031633146116135760405162461bcd60e51b8152600401610ca790614cbb565b6001600160a01b0381166116785760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610ca7565b611681816120b4565b50565b600088886002611695838383611cbb565b6116a48c8c8c8b8b8b8b61298e565b9c9b505050505050505050505050565b60006001600160e01b0319821663301cdc3960e21b14806116e557506001600160e01b0319821663144b000160e11b145b8061084857506301ffc9a760e01b6001600160e01b0319831614610848565b61170e8282613023565b505050565b60006001600160a01b03861661173c5760405163a762251360e01b815260040160405180910390fd5b61174461445d565b606060008060405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018e81526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f000000000000000000000000000000000000000000000000000000000000000081525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632fa1b3918d838e7f00000000000000000000000000000000000000000000000000000000000000008f8d8d6040518863ffffffff1660e01b815260040161184d9796959493929190614e22565b6000604051808303816000875af115801561186c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118949190810190614f86565b9950919550909350915081156119c957604051632eec7b5560e11b8152600481018c90527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015611909573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192d9190614bdd565b604051638ae9c07b60e01b8152600481018d9052602481018490526001600160a01b038c8116604483015260c06064830152600060c48301528a15156084830152600160a48301529190911690638ae9c07b9060e4016020604051808303816000875af11580156119a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c69190614c17565b94505b888510156119ea57604051633dca309360e11b815260040160405180910390fd5b825115611c5d5760006040518061016001604052808e6001600160a01b031681526020018d81526020018660200151815260200183815260200160405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602001600081526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f000000000000000000000000000000000000000000000000000000000000000081525081526020018781526020018c6001600160a01b031681526020018a15158152602001898152602001604051806020016040528060008152508152602001888152509050600084519050611b25604051806060016040528060006001600160a01b0316815260200160008152602001606081525090565b60005b82811015611c5857868181518110611b4257611b42614cf0565b60209081029190910101519150602080830151608086015190910152604082015161012085015281516001600160a01b0390811690636b204943907f00000000000000000000000000000000000000000000000000000000000000001661eeee14611bae576000611bb4565b83602001515b866040518363ffffffff1660e01b8152600401611bd191906151a1565b6000604051808303818588803b158015611bea57600080fd5b505af1158015611bfe573d6000803e3d6000fd5b505050505081600001516001600160a01b03167f232bbbe420e7bac6f941dc82678daec2b4c712378d91e864b69aab6e26cdd42485846020015133604051611c48939291906151b4565b60405180910390a2600101611b28565b505050505b50505087816000015182602001517f133161f1c9161488f777ab9a26aae91d47c0d9a3fafb398960f138db02c737978c8b8f888b8b33604051611ca697969594939291906151e7565b60405180910390a45098975050505050505050565b336001600160a01b03841614801590611d64575060405163c161c93f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f90611d21903390879087908790600401615247565b602060405180830381865afa158015611d3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d629190614bfa565b155b8015611e01575060405163c161c93f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f90611dbe90339087906000908790600401615247565b602060405180830381865afa158015611ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dff9190614bfa565b155b1561170e5760405163075fd2b160e01b815260040160405180910390fd5b60405163c664459760e01b8152600481018790526024810186905260448101859052600090819081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c664459790606401610140604051808303816000875af1158015611e9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec09190615270565b9150915085811015611ee55760405163b01493c160e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018a90526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015611f4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f719190614bdd565b600254909150600090818115611f9157611f8c8d600061313c565b611f97565b633b9aca005b9050600080611fce8f89602001517f00000000000000000000000000000000000000000000000000000000000000008a88886132b0565b92509050633b9aca008314611fe257908101905b81600003611ff1576000612015565b6120158f61200c8a61010001516001604f9190911c81161490565b84878a88613470565b9450801561205257633b9aca00831461203857612033818585612278565b61203b565b60005b6120459082614bca565b985061205230878b611704565b505050508a846000015185602001517fc41a8d26c70cfcf1b9ea10f82482ac947b8be5bea2750bc729af844bbfde1e28858e88878c8f8f3360405161209e9897969594939291906152c8565b60405180910390a4505050509695505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8015801561211b5750336001600160a01b03851614155b80156121b7575060405163c161c93f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f90612174903390889088908890600401615247565b602060405180830381865afa158015612191573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b59190614bfa565b155b8015612254575060405163c161c93f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f9061221190339088906000908890600401615247565b602060405180830381865afa15801561222e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122529190614bfa565b155b156122725760405163075fd2b160e01b815260040160405180910390fd5b50505050565b60008061228a8484633b9aca006127cf565b6122949085614bca565b90506122a985633b9aca006114e2818561531b565b6122b39086614bca565b9150505b9392505050565b604051630862026560e41b8152600160048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660248301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638620265090604401602060405180830381865afa158015612350573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123749190614bdd565b9050806001600160a01b0316631ebc263f61eeee6001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316146123c75760006123c9565b855b6001877f0000000000000000000000000000000000000000000000000000000000000000886000808a60405160200161240491815260200190565b6040516020818303038152906040526040518963ffffffff1660e01b8152600401612435979695949392919061532e565b60206040518083038185885af193505050508015612470575060408051601f3d908101601f1916820190925261246d91810190614c17565b60015b612524573d80801561249e576040519150601f19603f3d011682016040523d82523d6000602084013e6124a3565b606091505b506124e083306001600160a01b038516036124bf5760006124c1565b835b306001600160a01b038616036124d85760006124da565b875b886135ed565b6001837f80a889d08f0d59eb962335b57fb1d5b29e86e3d23f15087b5541fddf15422bbe87843360405161251693929190615386565b60405180910390a350612272565b5050505050565b604051632538671560e01b8152600481018990526024810188905260448101879052600090819081906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632538671590606401610140604051808303816000875af11580156125a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125cc9190615270565b91509150878110156125f15760405163b01493c160e01b815260040160405180910390fd5b6002546040516331a9108f60e11b8152600481018d90526000919082906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa15801561265f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126839190614bdd565b905060008215806126a357503360009081526004602052604090205460ff165b6126b7576126b28f600161313c565b6126bd565b633b9aca005b9050633b9aca0081146126f3576126ee8f6126e58861010001516001604f9190911c81161490565b87868686613470565b6126f6565b60005b935083850396508660001461271057612710308c89611704565b505050508a826000015183602001517f2eeee47c6d8d31c3523c3aa07b4c3e3795db36be4c04546ef3e30a5102f568e18a8e86898d8d8d3360405161275c9897969594939291906153b7565b60405180910390a4505098975050505050505050565b60008282036127825750826122b7565b828211156127b0576127948383614bca565b61279f90600a614dea565b6127a99085615417565b90506122b7565b6127ba8284614bca565b6127c590600a614dea565b6127a9908561544c565b6000808060001985870985870292508281108382030391505080600003612809578382816127ff576127ff615436565b04925050506122b7565b83811061283357604051631dcf306360e21b81526004810182905260248101859052604401610ca7565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6000836128aa5760006128b4565b6128b4868661366a565b90506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663e7c8e3e3876128f0848961531b565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561292e57600080fd5b505af1158015612942573d6000803e3d6000fd5b50505050857f9ecaf7fc3dfffd6867c175d6e684b1f1e3aef019398ba8db2c1ffab4a09db253868386863360405161297e95949392919061546e565b60405180910390a2505050505050565b60006001600160a01b0384166129b757604051637ba50db360e11b815260040160405180910390fd5b6129bf61445d565b6000806000600254905060607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a2df1f958e8e8e8c8c6040518663ffffffff1660e01b8152600401612a1f9594939291906154ba565b6000604051808303816000875af1158015612a3e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a6691908101906154f9565b6001600160a01b038d16600090815260046020526040902054909b5091985091965090915060ff1680612ab65750612710612aa086613b49565b148015612ab65750612710612ab486613b66565b145b80612abf575081155b612ad357612ace8c600261313c565b612ad9565b633b9aca005b925089861015612afc5760405163f896960b60e01b815260040160405180910390fd5b8a15612c0c57604051632eec7b5560e11b8152600481018d90527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015612b67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b8b9190614bdd565b604051631665bc0f60e01b81526001600160a01b038f81166004830152602482018f9052604482018e905260a06064830152600060a4830181905260848301529190911690631665bc0f9060c401600060405180830381600087803b158015612bf357600080fd5b505af1158015612c07573d6000803e3d6000fd5b505050505b805115612f4c5760006040518061014001604052808f6001600160a01b031681526020018e8152602001876020015181526020018d815260200160405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018a81526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f0000000000000000000000000000000000000000000000000000000000000000815250815260200160405180608001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602001600081526020017f000000000000000000000000000000000000000000000000000000000000000081526020017f000000000000000000000000000000000000000000000000000000000000000081525081526020018b6001600160a01b031681526020018a8152602001604051806020016040528060008152508152602001898152509050612dc2604051806060016040528060006001600160a01b0316815260200160008152602001606081525090565b8251600090815b81811015612f4657858181518110612de357612de3614cf0565b6020026020010151935086600014612e0957612e048460200151888a612278565b612e0c565b60005b92508215612e3b576020840151612e23908a61531b565b98508284602001818151612e379190614bca565b9052505b60208085015160a087015190910152604084015161010086015283516001600160a01b0390811690630bf46e59907f00000000000000000000000000000000000000000000000000000000000000001661eeee14612e9a576000612ea0565b85602001515b876040518363ffffffff1660e01b8152600401612ebd91906156cb565b6000604051808303818588803b158015612ed657600080fd5b505af1158015612eea573d6000803e3d6000fd5b505050505083600001516001600160a01b03167f6596068545b2541b0aff5579d91f991d0fe5957df8e2082483ef361953e1f9978686602001518633604051612f3694939291906156de565b60405180910390a2600101612dc9565b50505050505b508415612fa7576000633b9aca008314612f7057612f6b868385612278565b612f73565b60005b90508015612f9457612f85868561531b565b9350612f918187614bca565b95505b8515612fa557612fa5308a88611704565b505b82600003612fb6576000612fc5565b612fc58b600085848c87613470565b5050505087816000015182602001517f2be10f2a0203c77d0fcaa9fd6484a8a1d6904de31cd820587f60c1c8c338c8148c898c888b8b3360405161300f97969594939291906151e7565b60405180910390a450979650505050505050565b804710156130735760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610ca7565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146130c0576040519150601f19603f3d011682016040523d82523d6000602084013e6130c5565b606091505b505090508061170e5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610ca7565b604051630862026560e41b8152600160048201526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116602483015260009182917f00000000000000000000000000000000000000000000000000000000000000001690638620265090604401602060405180830381865afa1580156131ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f29190614bdd565b6001600160a01b03160361320b5750633b9aca00610848565b6003546001600160a01b0316156132a75760035460405163192dd60960e01b81526001600160a01b039091169063192dd6099061324e9086908690600401615716565b602060405180830381865afa925050508015613287575060408051601f3d908101601f1916820190925261328491810190614c17565b60015b61329357506000610848565b633b9aca0081116132a5579050610848565b505b50600092915050565b6040516369e11cc560e01b81526004810187905260248101869052604481018590526000908190633b9aca009082907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906369e11cc590606401600060405180830381865afa158015613330573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526133589190810190615748565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529192505b825181101561345e578281815181106133af576133af614cf0565b6020026020010151915060006133ca8a8460400151876127cf565b905060006133dc848f8e858e8e613b83565b905080158015906133ed5750818114155b156133ff576133fc828861531b565b96505b811561340b57818b039a505b8360400151860395508b8d8f7f0d31ab573f6daa4b1edba8d31973b4ba9f98fbfecc47010c1533eeefd2a1225a8786863360405161344c94939291906158a5565b60405180910390a45050600101613394565b50879450505050965096945050505050565b600061347d858584612278565b9050851561358f57600087815260016020818152604080842081516080810183528a815263ffffffff808b168286019081528982168386019081526001600160a01b03808d16606086019081528654808b018855968b5297909920935160029095029093019384555192909501805491519451909616600160401b02600160401b600160e01b03199486166401000000000267ffffffffffffffff199092169290951691909117179190911691909117909155518490869089907f77813be0661650ddc1a5193ff2837df4162b251cb432651e2c060c3fc39756be90613582908790899033909283526001600160a01b03918216602084015216604082015260600190565b60405180910390a46135e3565b61359a8184896122be565b604080516001600160a01b038516815233602082015260009183918a917fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a35251910160405180910390a45b9695505050505050565b60405163e7c8e3e360e01b815260048101859052602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e7c8e3e390604401600060405180830381600087803b15801561365657600080fd5b505af11580156115df573d6000803e3d6000fd5b600082815260016020908152604080832080548251818502810185019093528083528493849084015b8282101561370057600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b031660608301529083529092019101613693565b505050600086815260016020526040812092935061371f92915061443c565b8051839060005b81811015613b0157826000036137e5576000878152600160205260409020845185908390811061375857613758614cf0565b60209081029190910181015182546001818101855560009485529383902082516002909202019081559181015191909201805460408401516060909401516001600160a01b0316600160401b02600160401b600160e01b031963ffffffff9586166401000000000267ffffffffffffffff1990931695909416949094171791909116919091179055613af9565b60008482815181106137f9576137f9614cf0565b60200260200101516020015163ffffffff166000148061383f5750633b9aca0085838151811061382b5761382b614cf0565b60200260200101516040015163ffffffff16145b61389f5761389a85838151811061385857613858614cf0565b60200260200101516000015186848151811061387657613876614cf0565b60200260200101516020015163ffffffff1687858151811061108c5761108c614cf0565b6138a2565b60005b9050808583815181106138b7576138b7614cf0565b6020026020010151600001516138cd9190614bca565b841061390157808583815181106138e6576138e6614cf0565b60200260200101516000015103840393508086019550613af7565b84828151811061391357613913614cf0565b60200260200101516020015163ffffffff16600014806139595750633b9aca0085838151811061394557613945614cf0565b60200260200101516040015163ffffffff16145b6139b3576139ae8486848151811061397357613973614cf0565b60200260200101516020015163ffffffff1687858151811061399757613997614cf0565b60200260200101516040015163ffffffff166142e1565b6139b6565b60005b90506001600089815260200190815260200160002060405180608001604052808387018886815181106139eb576139eb614cf0565b602002602001015160000151038152602001878581518110613a0f57613a0f614cf0565b60200260200101516020015163ffffffff168152602001878581518110613a3857613a38614cf0565b60200260200101516040015163ffffffff168152602001878581518110613a6157613a61614cf0565b6020908102919091018101516060908101516001600160a01b0390811690935284546001818101875560009687528387208651600290930201918255928501519201805460408601519590920151909316600160401b02600160401b600160e01b031963ffffffff9586166401000000000267ffffffffffffffff19909316959093169490941717169190911790559581019593505b505b600101613726565b50604080518381523360208201528591879189917f59860d79d97c1fce2be7f987915c631471f4b08f671200463cc40a3380194ffb910160405180910390a450505092915050565b60006028826101000151901c61ffff166127106108489190614bca565b60006038826101000151901c61ffff166127106108489190614bca565b60c086015183906001600160a01b031615613e4357633b9aca008214158015613bc9575060c08701516001600160a01b031660009081526004602052604090205460ff16155b15613bdc57613bd9848484612278565b90035b60006040518060c001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018381526020017f000000000000000000000000000000000000000000000000000000000000000081526020018881526020018781526020018981525090506060613c6d8960c00151634eba05fd60e11b61430e565b15613da0578860c001516001600160a01b0316639d740bfa61eeee6001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031614613cc7576000613cc9565b845b846040518363ffffffff1660e01b8152600401613ce691906158da565b6000604051808303818588803b158015613cff57600080fd5b505af193505050508015613d11575060015b613d9b573d808015613d3f576040519150601f19603f3d011682016040523d82523d6000602084013e613d44565b606091505b50805115613d525780613d93565b604051602001613d83906020808252600d908201526c105b1b1bd8d85d194819985a5b609a1b604082015260600190565b6040516020818303038152906040525b915050613de2565b613de2565b604051602001613dd0906020808252600c908201526b12515490cc4d8d4819985a5b60a21b604082015260600190565b60405160208183030381529060405290505b805115613e3c57613df9888a60c0015185896135ed565b60009250877f290b5df59e172593762964e4f8ed2b4a9192d3197bfd2be4bae123908f8007968a888433604051613e33949392919061592e565b60405180910390a25b50506135e3565b60608701511561429e576060870151604051630862026560e41b81526000916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691638620265091613ed3917f0000000000000000000000000000000000000000000000000000000000000000906004019182526001600160a01b0316602082015260400190565b602060405180830381865afa158015613ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f149190614bdd565b90506001600160a01b038116613f765760009150613f3587600080886135ed565b867f290b5df59e172593762964e4f8ed2b4a9192d3197bfd2be4bae123908f800796898733604051613f6993929190615971565b60405180910390a2614298565b6001600160a01b0381163014801590613f935750633b9aca008314155b8015613fb857506001600160a01b03811660009081526004602052604090205460ff16155b15613fcd57613fc8858585612278565b820391505b87602001511561414a57806001600160a01b0316630cf8e85861eeee6001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161461402857600061402a565b835b8a60600151857f00000000000000000000000000000000000000000000000000000000000000008c60405160200161406491815260200190565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016140929493929190614c80565b6000604051808303818588803b1580156140ab57600080fd5b505af1935050505080156140bd575060015b614145573d8080156140eb576040519150601f19603f3d011682016040523d82523d6000602084013e6140f0565b606091505b506140fd888385896135ed565b60009250877f290b5df59e172593762964e4f8ed2b4a9192d3197bfd2be4bae123908f8007968a888433604051614137949392919061592e565b60405180910390a250614298565b614298565b806001600160a01b0316631ebc263f61eeee6001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161461419b57600061419d565b835b60608b015160808c015186907f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b03166141de57336141e4565b8d608001515b60008f600001518f6040516020016141fe91815260200190565b6040516020818303038152906040526040518963ffffffff1660e01b815260040161422f979695949392919061532e565b60206040518083038185885af19350505050801561426a575060408051601f3d908101601f1916820190925261426791810190614c17565b60015b613e3c573d8080156140eb576040519150601f19603f3d011682016040523d82523d6000602084013e6140f0565b506135e3565b633b9aca0082146142b7576142b4848484612278565b90035b60808701516135e39030906001600160a01b03166142d557336142db565b88608001515b83611704565b6000806142f38484633b9aca006127cf565b6142fd9085614bca565b90506122b38582633b9aca006127cf565b60006143198361432a565b80156122b757506122b7838361435d565b600061433d826301ffc9a760e01b61435d565b80156108485750614356826001600160e01b031961435d565b1592915050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b179052905160009190829081906001600160a01b03871690617530906143c49086906159ce565b6000604051808303818686fa925050503d8060008114614400576040519150601f19603f3d011682016040523d82523d6000602084013e614405565b606091505b50915091506020815110156144205760009350505050610848565b8180156135e35750808060200190518101906135e39190614bfa565b508054600082556002029060005260206000209081019061168191906144b2565b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b5b808211156144d957600081556001810180546001600160e01b03191690556002016144b3565b5090565b6000602082840312156144ef57600080fd5b81356001600160e01b0319811681146122b757600080fd5b6001600160a01b038116811461168157600080fd5b60008083601f84011261452e57600080fd5b5081356001600160401b0381111561454557600080fd5b60208301915083602082850101111561455d57600080fd5b9250929050565b600080600080600080600060a0888a03121561457f57600080fd5b8735965060208801359550604088013561459881614507565b945060608801356001600160401b03808211156145b457600080fd5b6145c08b838c0161451c565b909650945060808a01359150808211156145d957600080fd5b506145e68a828b0161451c565b989b979a50959850939692959293505050565b60006020828403121561460b57600080fd5b81356122b781614507565b801515811461168157600080fd5b6000806000806000806000806000806101008b8d03121561464457600080fd5b8a35995060208b0135985060408b013561465d81614507565b975060608b013561466d81614507565b965060808b0135955060a08b013561468481614616565b945060c08b01356001600160401b03808211156146a057600080fd5b6146ac8e838f0161451c565b909650945060e08d01359150808211156146c557600080fd5b506146d28d828e0161451c565b915080935050809150509295989b9194979a5092959850565b600080604083850312156146fe57600080fd5b82359150602083013561471081614507565b809150509250929050565b600080600080600080600060c0888a03121561473657600080fd5b873596506020880135955060408801359450606088013561475681614507565b93506080880135925060a08801356001600160401b0381111561477857600080fd5b6145e68a828b0161451c565b60006020828403121561479657600080fd5b5035919050565b600080604083850312156147b057600080fd5b82356147bb81614507565b9150602083013561471081614616565b602080825282518282018190526000919060409081850190868401855b82811015614834578151805185528681015163ffffffff908116888701528682015116868601526060908101516001600160a01b031690850152608090930192908501906001016147e8565b5091979650505050505050565b634e487b7160e01b600052604160045260246000fd5b60405161012081016001600160401b038111828210171561487a5761487a614841565b60405290565b604051606081016001600160401b038111828210171561487a5761487a614841565b60405160e081016001600160401b038111828210171561487a5761487a614841565b604051601f8201601f191681016001600160401b03811182821017156148ec576148ec614841565b604052919050565b60006001600160401b0382111561490d5761490d614841565b50601f01601f191660200190565b600082601f83011261492c57600080fd5b813561493f61493a826148f4565b6148c4565b81815284602083860101111561495457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060008060006101008a8c03121561499057600080fd5b8935985060208a0135975060408a0135965060608a01356149b081614507565b955060808a0135945060a08a01356149c781614507565b935060c08a01356001600160401b03808211156149e357600080fd5b6149ef8d838e0161491b565b945060e08c0135915080821115614a0557600080fd5b50614a128c828d0161451c565b915080935050809150509295985092959850929598565b60008060008060008060008060c0898b031215614a4557600080fd5b88359750602089013596506040890135614a5e81614507565b95506060890135614a6e81614616565b945060808901356001600160401b0380821115614a8a57600080fd5b614a968c838d0161451c565b909650945060a08b0135915080821115614aaf57600080fd5b50614abc8b828c0161451c565b999c989b5096995094979396929594505050565b60008060408385031215614ae357600080fd5b8235614aee81614507565b946020939093013593505050565b600080600080600080600080610100898b031215614b1957600080fd5b8835614b2481614507565b975060208901359650604089013595506060890135614b4281614507565b94506080890135935060a0890135614b5981614507565b925060c08901356001600160401b0380821115614b7557600080fd5b614b818c838d0161491b565b935060e08b0135915080821115614b9757600080fd5b50614ba48b828c0161491b565b9150509295985092959890939650565b634e487b7160e01b600052601160045260246000fd5b8181038181111561084857610848614bb4565b600060208284031215614bef57600080fd5b81516122b781614507565b600060208284031215614c0c57600080fd5b81516122b781614616565b600060208284031215614c2957600080fd5b5051919050565b60005b83811015614c4b578181015183820152602001614c33565b50506000910152565b60008151808452614c6c816020860160208601614c30565b601f01601f19169290920160200192915050565b84815283602082015260018060a01b038316604082015260a06060820152600060a082015260c0608082015260006135e360c0830184614c54565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600181815b80851115614d41578160001904821115614d2757614d27614bb4565b80851615614d3457918102915b93841c9390800290614d0b565b509250929050565b600082614d5857506001610848565b81614d6557506000610848565b8160018114614d7b5760028114614d8557614da1565b6001915050610848565b60ff841115614d9657614d96614bb4565b50506001821b610848565b5060208310610133831016604e8410600b8410161715614dc4575081810a610848565b614dce8383614d06565b8060001904821115614de257614de2614bb4565b029392505050565b60006122b78383614d49565b80516001600160a01b031682526020808201519083015260408082015190830152606090810151910152565b6001600160a01b03888116825260009061014090614e43602085018b614df6565b8860a08501528760c085015280871660e08501525080610100840152614e6b81840186614c54565b9050828103610120840152614e808185614c54565b9a9950505050505050505050565b8051614e9981614507565b919050565b60006101208284031215614eb157600080fd5b614eb9614857565b9050815181526020820151602082015260408201516040820152606082015160608201526080820151608082015260a082015160a082015260c082015160c0820152614f0760e08301614e8e565b60e082015261010080830151818301525092915050565b60006001600160401b03821115614f3757614f37614841565b5060051b60200190565b600082601f830112614f5257600080fd5b8151614f6061493a826148f4565b818152846020838601011115614f7557600080fd5b6114ee826020830160208701614c30565b6000806000806101808587031215614f9d57600080fd5b614fa78686614e9e565b935061012085015192506101408501516001600160401b0380821115614fcc57600080fd5b818701915087601f830112614fe057600080fd5b8151614fee61493a82614f1e565b8082825260208201915060208360051b86010192508a83111561501057600080fd5b602085015b8381101561509a5780518581111561502c57600080fd5b86016060818e03601f1901121561504257600080fd5b61504a614880565b602082015161505881614507565b81526040820151602082015260608201518781111561507657600080fd5b6150858f602083860101614f41565b60408301525084525060209283019201615015565b506101608a015190965093505050808211156150b557600080fd5b506150c287828801614f41565b91505092959194509250565b80516001600160a01b031682526000610220602083015160208501526040830151604085015260608301516151066060860182614df6565b50608083015161511960e0860182614df6565b5060a083015161016085015260c08301516001600160a01b031661018085015260e083015115156101a08501526101008301516101c0850182905261516082860182614c54565b9150506101208301518482036101e086015261517c8282614c54565b9150506101408301518482036102008601526151988282614c54565b95945050505050565b6020815260006122b760208301846150ce565b6060815260006151c760608301866150ce565b6020830194909452506001600160a01b0391909116604090910152919050565b600060018060a01b03808a168352808916602084015287604084015286606084015260e0608084015261521d60e0840187614c54565b83810360a085015261522f8187614c54565b92505080841660c08401525098975050505050505050565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b600080610140838503121561528457600080fd5b61528e8484614e9e565b915061012083015190509250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600060018060a01b03808b16835289602084015288604084015287606084015286608084015260e060a084015261530360e08401868861529f565b915080841660c0840152509998505050505050505050565b8082018082111561084857610848614bb4565b878152602081018790526001600160a01b038681166040830152851660608201526080810184905282151560a082015261010060c08201819052600090820181905261012060e08301819052614e8081840185614c54565b83815260606020820152600061539f6060830185614c54565b905060018060a01b0383166040830152949350505050565b600060018060a01b03808b16835289602084015288604084015287606084015260e060808401526153eb60e0840188614c54565b83810360a08501526153fe81878961529f565b92505080841660c0840152509998505050505050505050565b600081600019048311821515161561543157615431614bb4565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261546957634e487b7160e01b600052601260045260246000fd5b500490565b85815284602082015260a06040820152600061548d60a0830186614c54565b828103606084015261549f8186614c54565b91505060018060a01b03831660808301529695505050505050565b60018060a01b038616815284602082015283604082015260a0606082015260006154e760a0830185614c54565b8281036080840152610c718185614c54565b600080600080610180858703121561551057600080fd5b61551a8686614e9e565b935061012085015192506101408501516001600160401b038082111561553f57600080fd5b818701915087601f83011261555357600080fd5b815161556161493a82614f1e565b8082825260208201915060208360051b86010192508a83111561558357600080fd5b602085015b8381101561509a5780518581111561559f57600080fd5b86016060818e03601f190112156155b557600080fd5b6155bd614880565b60208201516155cb81614507565b8152604082015160208201526060820151878111156155e957600080fd5b6155f88f602083860101614f41565b60408301525084525060209283019201615588565b80516001600160a01b031682526000610200602083015160208501526040830151604085015260608301516060850152608083015161564f6080860182614df6565b5060a083015161010061566481870183614df6565b60c08501516001600160a01b031661018087015260e08501516101a08701849052915061569383870183614c54565b9250808501519150508482036101c08601526156af8282614c54565b9150506101208301518482036101e08601526151988282614c54565b6020815260006122b7602083018461560d565b6080815260006156f1608083018761560d565b60208301959095525060408101929092526001600160a01b0316606090910152919050565b828152604081016003831061573b57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b6000602080838503121561575b57600080fd5b82516001600160401b0381111561577157600080fd5b8301601f8101851361578257600080fd5b805161579061493a82614f1e565b81815260e091820283018401918482019190888411156157af57600080fd5b938501935b838510156158455780858a0312156157cc5760008081fd5b6157d46148a2565b85516157df81614616565b8152858701516157ee81614616565b81880152604086810151908201526060808701519082015260808087015161581581614507565b9082015260a0868101519082015260c08087015161583281614507565b90820152835293840193918501916157b4565b50979650505050505050565b80511515825260208082015115159083015260408082015190830152606080820151908301526080808201516001600160a01b039081169184019190915260a0808301519084015260c09182015116910152565b61014081016158b48287615851565b60e08201949094526101008101929092526001600160a01b031661012090910152919050565b81516001600160a01b031681526020808301519082015260408083015190820152606080830151908201526080808301519082015260a08281015161018083019161592790840182615851565b5092915050565b600061014061593d8388615851565b8560e08401528061010084015261595681840186614c54565b91505060018060a01b03831661012083015295945050505050565b60006101406159808387615851565b60e08301949094525061010081018390526012928101929092527115195c9b5a5b985b081b9bdd08199bdd5b9960721b6101608301526001600160a01b031661012082015261018001919050565b600082516159e0818460208701614c30565b919091019291505056fea2646970667358221220dbb5a4d937c7da0dca41d1328db9b1ff46a6507fe2074b39180782d13afdbde364736f6c63430008100033000000000000000000000000000000000000000000000000000000000000000100000000000000000000000099db6b517683237de9c494bbd17861f3608f358500000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a99000000000000000000000000ce2ce2f37fe5b2c2dd047908b2f61c9c3f7072720000000000000000000000009f0ec91d28ffc54874e9ff11a316ba2537acd72c0000000000000000000000005d8ec74256db2326843714b852df3ace4514449200000000000000000000000046d623731e179faf971cda04ff8c499c95461b3c

Deployed Bytecode

0x6080604052600436106101f95760003560e01c80638da5cb5b1161010d578063c715967a116100a0578063df21a7dd1161006f578063df21a7dd146106ae578063e5a6b10f146106fc578063f2fde38b14610730578063fc0c546a14610750578063fe663f0f1461078457600080fd5b8063c715967a14610631578063d3419bf314610644578063d6dacc5314610678578063ddca3f431461069857600080fd5b8063ad007d63116100dc578063ad007d6314610559578063b631b5001461058d578063b7bad1b1146105bd578063c41c2f24146105fd57600080fd5b80638da5cb5b146104c7578063975057e7146104e5578063a02f801c14610519578063a32e1e961461053957600080fd5b80634a4305c011610190578063715018a61161015f578063715018a6146104115780637258002c1461042657806389701db5146104465780638af56094146104665780638b79543c1461049357600080fd5b80634a4305c01461037d578063637913ac1461039d57806366248b86146103bd57806369fe0e2d146103f157600080fd5b80632bdfe004116101cc5780632bdfe004146102a95780632d1a5903146102f5578063313ce56714610329578063405b84fa1461035d57600080fd5b806301ffc9a7146101fe5780630cf8e858146102335780631982d679146102485780631ebc263f14610296575b600080fd5b34801561020a57600080fd5b5061021e6102193660046144dd565b6107a4565b60405190151581526020015b60405180910390f35b610246610241366004614564565b61084e565b005b34801561025457600080fd5b506102886102633660046145f9565b507f000000000000000000000000000000000000000000000000000000000000000190565b60405190815260200161022a565b6102886102a4366004614624565b610868565b3480156102b557600080fd5b506102dd7f000000000000000000000000ce2ce2f37fe5b2c2dd047908b2f61c9c3f70727281565b6040516001600160a01b03909116815260200161022a565b34801561030157600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000181565b34801561033557600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000001281565b34801561036957600080fd5b506102886103783660046146eb565b610965565b34801561038957600080fd5b5061028861039836600461471b565b610c61565b3480156103a957600080fd5b506102466103b83660046145f9565b610c7d565b3480156103c957600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000181565b3480156103fd57600080fd5b5061024661040c366004614784565b610d04565b34801561041d57600080fd5b50610246610d93565b34801561043257600080fd5b5061024661044136600461479d565b610dc9565b34801561045257600080fd5b50610246610461366004614784565b610e55565b34801561047257600080fd5b50610486610481366004614784565b611159565b60405161022a91906147cb565b34801561049f57600080fd5b506102dd7f00000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b81565b3480156104d357600080fd5b506000546001600160a01b03166102dd565b3480156104f157600080fd5b506102dd7f0000000000000000000000005d8ec74256db2326843714b852df3ace4514449281565b34801561052557600080fd5b50610288610534366004614971565b611206565b34801561054557600080fd5b50610288610554366004614784565b6112c1565b34801561056557600080fd5b506102dd7f00000000000000000000000099db6b517683237de9c494bbd17861f3608f358581565b34801561059957600080fd5b5061021e6105a83660046145f9565b60046020526000908152604090205460ff1681565b3480156105c957600080fd5b506102886105d83660046145f9565b507f000000000000000000000000000000000000000000000000000000000000001290565b34801561060957600080fd5b506102dd7f0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a9981565b61024661063f366004614a29565b6114f6565b34801561065057600080fd5b506102dd7f0000000000000000000000009f0ec91d28ffc54874e9ff11a316ba2537acd72c81565b34801561068457600080fd5b506003546102dd906001600160a01b031681565b3480156106a457600080fd5b5061028860025481565b3480156106ba57600080fd5b5061021e6106c9366004614ad0565b507f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b0390811691161490565b34801561070857600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000181565b34801561073c57600080fd5b5061024661074b3660046145f9565b6115e9565b34801561075c57600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000eeee81565b34801561079057600080fd5b5061028861079f366004614afc565b611684565b60006001600160e01b0319821615806107cd57506001600160e01b0319821663edb527eb60e01b145b806107e857506001600160e01b031982166301290c1760e61b145b8061080357506001600160e01b0319821663280be00760e21b145b8061081e57506001600160e01b0319821663fe663f0f60e01b145b8061083957506001600160e01b0319821663ad007d6360e01b145b806108485750610848826116b4565b92915050565b61085f8787876000888888886114f6565b50505050505050565b60007f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee146108d95734156108bb57604051635e7e9adf60e11b815260040160405180910390fd5b476108c733308d611704565b6108d18147614bca565b9a50506108dd565b3499505b6109568a338d8b8b8b8b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8f018190048102820181019092528d815292508d91508c908190840183828082843760009201919091525061171392505050565b9b9a5050505050505050505050565b6040516331a9108f60e11b8152600481018390526000907f00000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b6001600160a01b031690636352211e90602401602060405180830381865afa1580156109cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f19190614bdd565b8360046109ff838383611cbb565b60405163df21a7dd60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000eeee811660048301526024820188905286169063df21a7dd90604401602060405180830381865afa158015610a6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a909190614bfa565b610aad5760405163581010ed60e01b815260040160405180910390fd5b604051636bb6a5ad60e01b8152600481018790527f0000000000000000000000005d8ec74256db2326843714b852df3ace451444926001600160a01b031690636bb6a5ad906024016020604051808303816000875af1158015610b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b389190614c17565b93508315610c135760007f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee14610b7b576000610b7d565b845b6040805160208101825260008152905163019f1d0b60e31b81529192506001600160a01b03881691630cf8e858918491610bdf918c918b917f000000000000000000000000000000000000000000000000000000000000eeee91600401614c80565b6000604051808303818588803b158015610bf857600080fd5b505af1158015610c0c573d6000803e3d6000fd5b5050505050505b604080518581523360208201526001600160a01b0387169188917fa7519e5f94697b7f53e97c5eb46a0c730a296ab686ab8fd333835c5f735784eb910160405180910390a350505092915050565b6000610c71888888878787611e1f565b98975050505050505050565b6000546001600160a01b03163314610cb05760405162461bcd60e51b8152600401610ca790614cbb565b60405180910390fd5b600380546001600160a01b0319166001600160a01b0383169081179091556040513381527f0a9a80fe9716605b3e52abb3d792d6a4e7816d6afc02a5a4ef023081feaf9f609060200160405180910390a250565b6000546001600160a01b03163314610d2e5760405162461bcd60e51b8152600401610ca790614cbb565b6302faf080811115610d53576040516345fbd9c160e01b815260040160405180910390fd5b6002819055604080518281523360208201527fd7414e590e1cb532989ab2a34c8f4c2c17f7ab6f006efeeaef2e87cd5008c202910160405180910390a150565b6000546001600160a01b03163314610dbd5760405162461bcd60e51b8152600401610ca790614cbb565b610dc760006120b4565b565b6000546001600160a01b03163314610df35760405162461bcd60e51b8152600401610ca790614cbb565b6001600160a01b038216600081815260046020908152604091829020805460ff191685151590811790915591513381529192917fa2653e25a502c023a5830d0de847ef6f458387865b1f4f575d7594f9f2c0d71e910160405180910390a35050565b6040516331a9108f60e11b8152600481018290527f00000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b6001600160a01b031690636352211e90602401602060405180830381865afa158015610eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ede9190614bdd565b816005610ef36000546001600160a01b031690565b6001600160a01b0316336001600160a01b031614610f1384848484612104565b600085815260016020908152604080832080548251818502810185019093528083529192909190849084015b82821015610fac57600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b031660608301529083529092019101610f3f565b5050506000888152600160205260408120929350610fcb92915061443c565b80516000805b8281101561114e57838181518110610feb57610feb614cf0565b60200260200101516020015163ffffffff16600014806110315750633b9aca0084828151811061101d5761101d614cf0565b60200260200101516040015163ffffffff16145b6110a8576110a384828151811061104a5761104a614cf0565b60200260200101516000015185838151811061106857611068614cf0565b60200260200101516020015163ffffffff1686848151811061108c5761108c614cf0565b60200260200101516040015163ffffffff16612278565b6110ab565b60005b91506110d5828583815181106110c3576110c3614cf0565b6020026020010151606001518b6122be565b60011515828a7fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a3525187858151811061110e5761110e614cf0565b6020026020010151606001513360405161113e9291906001600160a01b0392831681529116602082015260400190565b60405180910390a4600101610fd1565b505050505050505050565b606060016000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156111fb57600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b03166060830152908352909201910161118e565b505050509050919050565b6040516331a9108f60e11b8152600481018a90526000907f00000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b6001600160a01b031690636352211e90602401602060405180830381865afa15801561126e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112929190614bdd565b8a60116112a0838383611cbb565b6112b08d8d8d8c8c8c8c8c61252b565b9d9c50505050505050505050505050565b60405163035240c760e61b81523060048201526024810182905260009081906001600160a01b037f0000000000000000000000005d8ec74256db2326843714b852df3ace45144492169063d49031c090604401602060405180830381865afa158015611331573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113559190614c17565b905060007f00000000000000000000000000000000000000000000000000000000000000126012146113b2576113ad827f00000000000000000000000000000000000000000000000000000000000000126012612772565b6113b4565b815b905060017f0000000000000000000000000000000000000000000000000000000000000001146114ec576114e78161140d7f0000000000000000000000000000000000000000000000000000000000000012600a614dea565b604051635268657960e11b81527f00000000000000000000000000000000000000000000000000000000000000016004820152600160248201527f000000000000000000000000000000000000000000000000000000000000001260448201527f0000000000000000000000009f0ec91d28ffc54874e9ff11a316ba2537acd72c6001600160a01b03169063a4d0caf290606401602060405180830381865afa1580156114be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e29190614c17565b6127cf565b6114ee565b805b949350505050565b7f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031661eeee1461156557341561154757604051635e7e9adf60e11b815260040160405180910390fd5b4761155333308a611704565b61155d8147614bca565b975050611569565b3496505b6115df88888787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b01819004810282018101909252898152925089915088908190840183828082843760009201919091525061289c92505050565b5050505050505050565b6000546001600160a01b031633146116135760405162461bcd60e51b8152600401610ca790614cbb565b6001600160a01b0381166116785760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610ca7565b611681816120b4565b50565b600088886002611695838383611cbb565b6116a48c8c8c8b8b8b8b61298e565b9c9b505050505050505050505050565b60006001600160e01b0319821663301cdc3960e21b14806116e557506001600160e01b0319821663144b000160e11b145b8061084857506301ffc9a760e01b6001600160e01b0319831614610848565b61170e8282613023565b505050565b60006001600160a01b03861661173c5760405163a762251360e01b815260040160405180910390fd5b61174461445d565b606060008060405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031681526020018e81526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f000000000000000000000000000000000000000000000000000000000000000181525090507f0000000000000000000000005d8ec74256db2326843714b852df3ace451444926001600160a01b0316632fa1b3918d838e7f00000000000000000000000000000000000000000000000000000000000000018f8d8d6040518863ffffffff1660e01b815260040161184d9796959493929190614e22565b6000604051808303816000875af115801561186c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118949190810190614f86565b9950919550909350915081156119c957604051632eec7b5560e11b8152600481018c90527f0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a996001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015611909573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192d9190614bdd565b604051638ae9c07b60e01b8152600481018d9052602481018490526001600160a01b038c8116604483015260c06064830152600060c48301528a15156084830152600160a48301529190911690638ae9c07b9060e4016020604051808303816000875af11580156119a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c69190614c17565b94505b888510156119ea57604051633dca309360e11b815260040160405180910390fd5b825115611c5d5760006040518061016001604052808e6001600160a01b031681526020018d81526020018660200151815260200183815260200160405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b03168152602001600081526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f000000000000000000000000000000000000000000000000000000000000000181525081526020018781526020018c6001600160a01b031681526020018a15158152602001898152602001604051806020016040528060008152508152602001888152509050600084519050611b25604051806060016040528060006001600160a01b0316815260200160008152602001606081525090565b60005b82811015611c5857868181518110611b4257611b42614cf0565b60209081029190910101519150602080830151608086015190910152604082015161012085015281516001600160a01b0390811690636b204943907f000000000000000000000000000000000000000000000000000000000000eeee1661eeee14611bae576000611bb4565b83602001515b866040518363ffffffff1660e01b8152600401611bd191906151a1565b6000604051808303818588803b158015611bea57600080fd5b505af1158015611bfe573d6000803e3d6000fd5b505050505081600001516001600160a01b03167f232bbbe420e7bac6f941dc82678daec2b4c712378d91e864b69aab6e26cdd42485846020015133604051611c48939291906151b4565b60405180910390a2600101611b28565b505050505b50505087816000015182602001517f133161f1c9161488f777ab9a26aae91d47c0d9a3fafb398960f138db02c737978c8b8f888b8b33604051611ca697969594939291906151e7565b60405180910390a45098975050505050505050565b336001600160a01b03841614801590611d64575060405163c161c93f60e01b81526001600160a01b037f00000000000000000000000099db6b517683237de9c494bbd17861f3608f3585169063c161c93f90611d21903390879087908790600401615247565b602060405180830381865afa158015611d3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d629190614bfa565b155b8015611e01575060405163c161c93f60e01b81526001600160a01b037f00000000000000000000000099db6b517683237de9c494bbd17861f3608f3585169063c161c93f90611dbe90339087906000908790600401615247565b602060405180830381865afa158015611ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dff9190614bfa565b155b1561170e5760405163075fd2b160e01b815260040160405180910390fd5b60405163c664459760e01b8152600481018790526024810186905260448101859052600090819081906001600160a01b037f0000000000000000000000005d8ec74256db2326843714b852df3ace45144492169063c664459790606401610140604051808303816000875af1158015611e9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec09190615270565b9150915085811015611ee55760405163b01493c160e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018a90526000907f00000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b6001600160a01b031690636352211e90602401602060405180830381865afa158015611f4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f719190614bdd565b600254909150600090818115611f9157611f8c8d600061313c565b611f97565b633b9aca005b9050600080611fce8f89602001517f00000000000000000000000000000000000000000000000000000000000000018a88886132b0565b92509050633b9aca008314611fe257908101905b81600003611ff1576000612015565b6120158f61200c8a61010001516001604f9190911c81161490565b84878a88613470565b9450801561205257633b9aca00831461203857612033818585612278565b61203b565b60005b6120459082614bca565b985061205230878b611704565b505050508a846000015185602001517fc41a8d26c70cfcf1b9ea10f82482ac947b8be5bea2750bc729af844bbfde1e28858e88878c8f8f3360405161209e9897969594939291906152c8565b60405180910390a4505050509695505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8015801561211b5750336001600160a01b03851614155b80156121b7575060405163c161c93f60e01b81526001600160a01b037f00000000000000000000000099db6b517683237de9c494bbd17861f3608f3585169063c161c93f90612174903390889088908890600401615247565b602060405180830381865afa158015612191573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b59190614bfa565b155b8015612254575060405163c161c93f60e01b81526001600160a01b037f00000000000000000000000099db6b517683237de9c494bbd17861f3608f3585169063c161c93f9061221190339088906000908890600401615247565b602060405180830381865afa15801561222e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122529190614bfa565b155b156122725760405163075fd2b160e01b815260040160405180910390fd5b50505050565b60008061228a8484633b9aca006127cf565b6122949085614bca565b90506122a985633b9aca006114e2818561531b565b6122b39086614bca565b9150505b9392505050565b604051630862026560e41b8152600160048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000eeee811660248301526000917f0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a9990911690638620265090604401602060405180830381865afa158015612350573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123749190614bdd565b9050806001600160a01b0316631ebc263f61eeee6001600160a01b03167f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b0316146123c75760006123c9565b855b6001877f000000000000000000000000000000000000000000000000000000000000eeee886000808a60405160200161240491815260200190565b6040516020818303038152906040526040518963ffffffff1660e01b8152600401612435979695949392919061532e565b60206040518083038185885af193505050508015612470575060408051601f3d908101601f1916820190925261246d91810190614c17565b60015b612524573d80801561249e576040519150601f19603f3d011682016040523d82523d6000602084013e6124a3565b606091505b506124e083306001600160a01b038516036124bf5760006124c1565b835b306001600160a01b038616036124d85760006124da565b875b886135ed565b6001837f80a889d08f0d59eb962335b57fb1d5b29e86e3d23f15087b5541fddf15422bbe87843360405161251693929190615386565b60405180910390a350612272565b5050505050565b604051632538671560e01b8152600481018990526024810188905260448101879052600090819081906001600160a01b037f0000000000000000000000005d8ec74256db2326843714b852df3ace451444921690632538671590606401610140604051808303816000875af11580156125a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125cc9190615270565b91509150878110156125f15760405163b01493c160e01b815260040160405180910390fd5b6002546040516331a9108f60e11b8152600481018d90526000919082906001600160a01b037f00000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b1690636352211e90602401602060405180830381865afa15801561265f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126839190614bdd565b905060008215806126a357503360009081526004602052604090205460ff165b6126b7576126b28f600161313c565b6126bd565b633b9aca005b9050633b9aca0081146126f3576126ee8f6126e58861010001516001604f9190911c81161490565b87868686613470565b6126f6565b60005b935083850396508660001461271057612710308c89611704565b505050508a826000015183602001517f2eeee47c6d8d31c3523c3aa07b4c3e3795db36be4c04546ef3e30a5102f568e18a8e86898d8d8d3360405161275c9897969594939291906153b7565b60405180910390a4505098975050505050505050565b60008282036127825750826122b7565b828211156127b0576127948383614bca565b61279f90600a614dea565b6127a99085615417565b90506122b7565b6127ba8284614bca565b6127c590600a614dea565b6127a9908561544c565b6000808060001985870985870292508281108382030391505080600003612809578382816127ff576127ff615436565b04925050506122b7565b83811061283357604051631dcf306360e21b81526004810182905260248101859052604401610ca7565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6000836128aa5760006128b4565b6128b4868661366a565b90506001600160a01b037f0000000000000000000000005d8ec74256db2326843714b852df3ace451444921663e7c8e3e3876128f0848961531b565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561292e57600080fd5b505af1158015612942573d6000803e3d6000fd5b50505050857f9ecaf7fc3dfffd6867c175d6e684b1f1e3aef019398ba8db2c1ffab4a09db253868386863360405161297e95949392919061546e565b60405180910390a2505050505050565b60006001600160a01b0384166129b757604051637ba50db360e11b815260040160405180910390fd5b6129bf61445d565b6000806000600254905060607f0000000000000000000000005d8ec74256db2326843714b852df3ace451444926001600160a01b031663a2df1f958e8e8e8c8c6040518663ffffffff1660e01b8152600401612a1f9594939291906154ba565b6000604051808303816000875af1158015612a3e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a6691908101906154f9565b6001600160a01b038d16600090815260046020526040902054909b5091985091965090915060ff1680612ab65750612710612aa086613b49565b148015612ab65750612710612ab486613b66565b145b80612abf575081155b612ad357612ace8c600261313c565b612ad9565b633b9aca005b925089861015612afc5760405163f896960b60e01b815260040160405180910390fd5b8a15612c0c57604051632eec7b5560e11b8152600481018d90527f0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a996001600160a01b031690635dd8f6aa90602401602060405180830381865afa158015612b67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b8b9190614bdd565b604051631665bc0f60e01b81526001600160a01b038f81166004830152602482018f9052604482018e905260a06064830152600060a4830181905260848301529190911690631665bc0f9060c401600060405180830381600087803b158015612bf357600080fd5b505af1158015612c07573d6000803e3d6000fd5b505050505b805115612f4c5760006040518061014001604052808f6001600160a01b031681526020018e8152602001876020015181526020018d815260200160405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031681526020018a81526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f0000000000000000000000000000000000000000000000000000000000000001815250815260200160405180608001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b03168152602001600081526020017f000000000000000000000000000000000000000000000000000000000000001281526020017f000000000000000000000000000000000000000000000000000000000000000181525081526020018b6001600160a01b031681526020018a8152602001604051806020016040528060008152508152602001898152509050612dc2604051806060016040528060006001600160a01b0316815260200160008152602001606081525090565b8251600090815b81811015612f4657858181518110612de357612de3614cf0565b6020026020010151935086600014612e0957612e048460200151888a612278565b612e0c565b60005b92508215612e3b576020840151612e23908a61531b565b98508284602001818151612e379190614bca565b9052505b60208085015160a087015190910152604084015161010086015283516001600160a01b0390811690630bf46e59907f000000000000000000000000000000000000000000000000000000000000eeee1661eeee14612e9a576000612ea0565b85602001515b876040518363ffffffff1660e01b8152600401612ebd91906156cb565b6000604051808303818588803b158015612ed657600080fd5b505af1158015612eea573d6000803e3d6000fd5b505050505083600001516001600160a01b03167f6596068545b2541b0aff5579d91f991d0fe5957df8e2082483ef361953e1f9978686602001518633604051612f3694939291906156de565b60405180910390a2600101612dc9565b50505050505b508415612fa7576000633b9aca008314612f7057612f6b868385612278565b612f73565b60005b90508015612f9457612f85868561531b565b9350612f918187614bca565b95505b8515612fa557612fa5308a88611704565b505b82600003612fb6576000612fc5565b612fc58b600085848c87613470565b5050505087816000015182602001517f2be10f2a0203c77d0fcaa9fd6484a8a1d6904de31cd820587f60c1c8c338c8148c898c888b8b3360405161300f97969594939291906151e7565b60405180910390a450979650505050505050565b804710156130735760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610ca7565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146130c0576040519150601f19603f3d011682016040523d82523d6000602084013e6130c5565b606091505b505090508061170e5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610ca7565b604051630862026560e41b8152600160048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000eeee8116602483015260009182917f0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a991690638620265090604401602060405180830381865afa1580156131ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f29190614bdd565b6001600160a01b03160361320b5750633b9aca00610848565b6003546001600160a01b0316156132a75760035460405163192dd60960e01b81526001600160a01b039091169063192dd6099061324e9086908690600401615716565b602060405180830381865afa925050508015613287575060408051601f3d908101601f1916820190925261328491810190614c17565b60015b61329357506000610848565b633b9aca0081116132a5579050610848565b505b50600092915050565b6040516369e11cc560e01b81526004810187905260248101869052604481018590526000908190633b9aca009082907f000000000000000000000000ce2ce2f37fe5b2c2dd047908b2f61c9c3f7072726001600160a01b0316906369e11cc590606401600060405180830381865afa158015613330573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526133589190810190615748565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529192505b825181101561345e578281815181106133af576133af614cf0565b6020026020010151915060006133ca8a8460400151876127cf565b905060006133dc848f8e858e8e613b83565b905080158015906133ed5750818114155b156133ff576133fc828861531b565b96505b811561340b57818b039a505b8360400151860395508b8d8f7f0d31ab573f6daa4b1edba8d31973b4ba9f98fbfecc47010c1533eeefd2a1225a8786863360405161344c94939291906158a5565b60405180910390a45050600101613394565b50879450505050965096945050505050565b600061347d858584612278565b9050851561358f57600087815260016020818152604080842081516080810183528a815263ffffffff808b168286019081528982168386019081526001600160a01b03808d16606086019081528654808b018855968b5297909920935160029095029093019384555192909501805491519451909616600160401b02600160401b600160e01b03199486166401000000000267ffffffffffffffff199092169290951691909117179190911691909117909155518490869089907f77813be0661650ddc1a5193ff2837df4162b251cb432651e2c060c3fc39756be90613582908790899033909283526001600160a01b03918216602084015216604082015260600190565b60405180910390a46135e3565b61359a8184896122be565b604080516001600160a01b038516815233602082015260009183918a917fcf0c92a2c6d7c42f488326b0cb900104b99984b6b218db81cd29371364a35251910160405180910390a45b9695505050505050565b60405163e7c8e3e360e01b815260048101859052602481018290527f0000000000000000000000005d8ec74256db2326843714b852df3ace451444926001600160a01b03169063e7c8e3e390604401600060405180830381600087803b15801561365657600080fd5b505af11580156115df573d6000803e3d6000fd5b600082815260016020908152604080832080548251818502810185019093528083528493849084015b8282101561370057600084815260209081902060408051608081018252600286029092018054835260019081015463ffffffff8082168587015264010000000082041692840192909252600160401b9091046001600160a01b031660608301529083529092019101613693565b505050600086815260016020526040812092935061371f92915061443c565b8051839060005b81811015613b0157826000036137e5576000878152600160205260409020845185908390811061375857613758614cf0565b60209081029190910181015182546001818101855560009485529383902082516002909202019081559181015191909201805460408401516060909401516001600160a01b0316600160401b02600160401b600160e01b031963ffffffff9586166401000000000267ffffffffffffffff1990931695909416949094171791909116919091179055613af9565b60008482815181106137f9576137f9614cf0565b60200260200101516020015163ffffffff166000148061383f5750633b9aca0085838151811061382b5761382b614cf0565b60200260200101516040015163ffffffff16145b61389f5761389a85838151811061385857613858614cf0565b60200260200101516000015186848151811061387657613876614cf0565b60200260200101516020015163ffffffff1687858151811061108c5761108c614cf0565b6138a2565b60005b9050808583815181106138b7576138b7614cf0565b6020026020010151600001516138cd9190614bca565b841061390157808583815181106138e6576138e6614cf0565b60200260200101516000015103840393508086019550613af7565b84828151811061391357613913614cf0565b60200260200101516020015163ffffffff16600014806139595750633b9aca0085838151811061394557613945614cf0565b60200260200101516040015163ffffffff16145b6139b3576139ae8486848151811061397357613973614cf0565b60200260200101516020015163ffffffff1687858151811061399757613997614cf0565b60200260200101516040015163ffffffff166142e1565b6139b6565b60005b90506001600089815260200190815260200160002060405180608001604052808387018886815181106139eb576139eb614cf0565b602002602001015160000151038152602001878581518110613a0f57613a0f614cf0565b60200260200101516020015163ffffffff168152602001878581518110613a3857613a38614cf0565b60200260200101516040015163ffffffff168152602001878581518110613a6157613a61614cf0565b6020908102919091018101516060908101516001600160a01b0390811690935284546001818101875560009687528387208651600290930201918255928501519201805460408601519590920151909316600160401b02600160401b600160e01b031963ffffffff9586166401000000000267ffffffffffffffff19909316959093169490941717169190911790559581019593505b505b600101613726565b50604080518381523360208201528591879189917f59860d79d97c1fce2be7f987915c631471f4b08f671200463cc40a3380194ffb910160405180910390a450505092915050565b60006028826101000151901c61ffff166127106108489190614bca565b60006038826101000151901c61ffff166127106108489190614bca565b60c086015183906001600160a01b031615613e4357633b9aca008214158015613bc9575060c08701516001600160a01b031660009081526004602052604090205460ff16155b15613bdc57613bd9848484612278565b90035b60006040518060c001604052807f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031681526020018381526020017f000000000000000000000000000000000000000000000000000000000000001281526020018881526020018781526020018981525090506060613c6d8960c00151634eba05fd60e11b61430e565b15613da0578860c001516001600160a01b0316639d740bfa61eeee6001600160a01b03167f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b031614613cc7576000613cc9565b845b846040518363ffffffff1660e01b8152600401613ce691906158da565b6000604051808303818588803b158015613cff57600080fd5b505af193505050508015613d11575060015b613d9b573d808015613d3f576040519150601f19603f3d011682016040523d82523d6000602084013e613d44565b606091505b50805115613d525780613d93565b604051602001613d83906020808252600d908201526c105b1b1bd8d85d194819985a5b609a1b604082015260600190565b6040516020818303038152906040525b915050613de2565b613de2565b604051602001613dd0906020808252600c908201526b12515490cc4d8d4819985a5b60a21b604082015260600190565b60405160208183030381529060405290505b805115613e3c57613df9888a60c0015185896135ed565b60009250877f290b5df59e172593762964e4f8ed2b4a9192d3197bfd2be4bae123908f8007968a888433604051613e33949392919061592e565b60405180910390a25b50506135e3565b60608701511561429e576060870151604051630862026560e41b81526000916001600160a01b037f0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a991691638620265091613ed3917f000000000000000000000000000000000000000000000000000000000000eeee906004019182526001600160a01b0316602082015260400190565b602060405180830381865afa158015613ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f149190614bdd565b90506001600160a01b038116613f765760009150613f3587600080886135ed565b867f290b5df59e172593762964e4f8ed2b4a9192d3197bfd2be4bae123908f800796898733604051613f6993929190615971565b60405180910390a2614298565b6001600160a01b0381163014801590613f935750633b9aca008314155b8015613fb857506001600160a01b03811660009081526004602052604090205460ff16155b15613fcd57613fc8858585612278565b820391505b87602001511561414a57806001600160a01b0316630cf8e85861eeee6001600160a01b03167f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b03161461402857600061402a565b835b8a60600151857f000000000000000000000000000000000000000000000000000000000000eeee8c60405160200161406491815260200190565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016140929493929190614c80565b6000604051808303818588803b1580156140ab57600080fd5b505af1935050505080156140bd575060015b614145573d8080156140eb576040519150601f19603f3d011682016040523d82523d6000602084013e6140f0565b606091505b506140fd888385896135ed565b60009250877f290b5df59e172593762964e4f8ed2b4a9192d3197bfd2be4bae123908f8007968a888433604051614137949392919061592e565b60405180910390a250614298565b614298565b806001600160a01b0316631ebc263f61eeee6001600160a01b03167f000000000000000000000000000000000000000000000000000000000000eeee6001600160a01b03161461419b57600061419d565b835b60608b015160808c015186907f000000000000000000000000000000000000000000000000000000000000eeee906001600160a01b03166141de57336141e4565b8d608001515b60008f600001518f6040516020016141fe91815260200190565b6040516020818303038152906040526040518963ffffffff1660e01b815260040161422f979695949392919061532e565b60206040518083038185885af19350505050801561426a575060408051601f3d908101601f1916820190925261426791810190614c17565b60015b613e3c573d8080156140eb576040519150601f19603f3d011682016040523d82523d6000602084013e6140f0565b506135e3565b633b9aca0082146142b7576142b4848484612278565b90035b60808701516135e39030906001600160a01b03166142d557336142db565b88608001515b83611704565b6000806142f38484633b9aca006127cf565b6142fd9085614bca565b90506122b38582633b9aca006127cf565b60006143198361432a565b80156122b757506122b7838361435d565b600061433d826301ffc9a760e01b61435d565b80156108485750614356826001600160e01b031961435d565b1592915050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b179052905160009190829081906001600160a01b03871690617530906143c49086906159ce565b6000604051808303818686fa925050503d8060008114614400576040519150601f19603f3d011682016040523d82523d6000602084013e614405565b606091505b50915091506020815110156144205760009350505050610848565b8180156135e35750808060200190518101906135e39190614bfa565b508054600082556002029060005260206000209081019061168191906144b2565b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b5b808211156144d957600081556001810180546001600160e01b03191690556002016144b3565b5090565b6000602082840312156144ef57600080fd5b81356001600160e01b0319811681146122b757600080fd5b6001600160a01b038116811461168157600080fd5b60008083601f84011261452e57600080fd5b5081356001600160401b0381111561454557600080fd5b60208301915083602082850101111561455d57600080fd5b9250929050565b600080600080600080600060a0888a03121561457f57600080fd5b8735965060208801359550604088013561459881614507565b945060608801356001600160401b03808211156145b457600080fd5b6145c08b838c0161451c565b909650945060808a01359150808211156145d957600080fd5b506145e68a828b0161451c565b989b979a50959850939692959293505050565b60006020828403121561460b57600080fd5b81356122b781614507565b801515811461168157600080fd5b6000806000806000806000806000806101008b8d03121561464457600080fd5b8a35995060208b0135985060408b013561465d81614507565b975060608b013561466d81614507565b965060808b0135955060a08b013561468481614616565b945060c08b01356001600160401b03808211156146a057600080fd5b6146ac8e838f0161451c565b909650945060e08d01359150808211156146c557600080fd5b506146d28d828e0161451c565b915080935050809150509295989b9194979a5092959850565b600080604083850312156146fe57600080fd5b82359150602083013561471081614507565b809150509250929050565b600080600080600080600060c0888a03121561473657600080fd5b873596506020880135955060408801359450606088013561475681614507565b93506080880135925060a08801356001600160401b0381111561477857600080fd5b6145e68a828b0161451c565b60006020828403121561479657600080fd5b5035919050565b600080604083850312156147b057600080fd5b82356147bb81614507565b9150602083013561471081614616565b602080825282518282018190526000919060409081850190868401855b82811015614834578151805185528681015163ffffffff908116888701528682015116868601526060908101516001600160a01b031690850152608090930192908501906001016147e8565b5091979650505050505050565b634e487b7160e01b600052604160045260246000fd5b60405161012081016001600160401b038111828210171561487a5761487a614841565b60405290565b604051606081016001600160401b038111828210171561487a5761487a614841565b60405160e081016001600160401b038111828210171561487a5761487a614841565b604051601f8201601f191681016001600160401b03811182821017156148ec576148ec614841565b604052919050565b60006001600160401b0382111561490d5761490d614841565b50601f01601f191660200190565b600082601f83011261492c57600080fd5b813561493f61493a826148f4565b6148c4565b81815284602083860101111561495457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060008060006101008a8c03121561499057600080fd5b8935985060208a0135975060408a0135965060608a01356149b081614507565b955060808a0135945060a08a01356149c781614507565b935060c08a01356001600160401b03808211156149e357600080fd5b6149ef8d838e0161491b565b945060e08c0135915080821115614a0557600080fd5b50614a128c828d0161451c565b915080935050809150509295985092959850929598565b60008060008060008060008060c0898b031215614a4557600080fd5b88359750602089013596506040890135614a5e81614507565b95506060890135614a6e81614616565b945060808901356001600160401b0380821115614a8a57600080fd5b614a968c838d0161451c565b909650945060a08b0135915080821115614aaf57600080fd5b50614abc8b828c0161451c565b999c989b5096995094979396929594505050565b60008060408385031215614ae357600080fd5b8235614aee81614507565b946020939093013593505050565b600080600080600080600080610100898b031215614b1957600080fd5b8835614b2481614507565b975060208901359650604089013595506060890135614b4281614507565b94506080890135935060a0890135614b5981614507565b925060c08901356001600160401b0380821115614b7557600080fd5b614b818c838d0161491b565b935060e08b0135915080821115614b9757600080fd5b50614ba48b828c0161491b565b9150509295985092959890939650565b634e487b7160e01b600052601160045260246000fd5b8181038181111561084857610848614bb4565b600060208284031215614bef57600080fd5b81516122b781614507565b600060208284031215614c0c57600080fd5b81516122b781614616565b600060208284031215614c2957600080fd5b5051919050565b60005b83811015614c4b578181015183820152602001614c33565b50506000910152565b60008151808452614c6c816020860160208601614c30565b601f01601f19169290920160200192915050565b84815283602082015260018060a01b038316604082015260a06060820152600060a082015260c0608082015260006135e360c0830184614c54565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600181815b80851115614d41578160001904821115614d2757614d27614bb4565b80851615614d3457918102915b93841c9390800290614d0b565b509250929050565b600082614d5857506001610848565b81614d6557506000610848565b8160018114614d7b5760028114614d8557614da1565b6001915050610848565b60ff841115614d9657614d96614bb4565b50506001821b610848565b5060208310610133831016604e8410600b8410161715614dc4575081810a610848565b614dce8383614d06565b8060001904821115614de257614de2614bb4565b029392505050565b60006122b78383614d49565b80516001600160a01b031682526020808201519083015260408082015190830152606090810151910152565b6001600160a01b03888116825260009061014090614e43602085018b614df6565b8860a08501528760c085015280871660e08501525080610100840152614e6b81840186614c54565b9050828103610120840152614e808185614c54565b9a9950505050505050505050565b8051614e9981614507565b919050565b60006101208284031215614eb157600080fd5b614eb9614857565b9050815181526020820151602082015260408201516040820152606082015160608201526080820151608082015260a082015160a082015260c082015160c0820152614f0760e08301614e8e565b60e082015261010080830151818301525092915050565b60006001600160401b03821115614f3757614f37614841565b5060051b60200190565b600082601f830112614f5257600080fd5b8151614f6061493a826148f4565b818152846020838601011115614f7557600080fd5b6114ee826020830160208701614c30565b6000806000806101808587031215614f9d57600080fd5b614fa78686614e9e565b935061012085015192506101408501516001600160401b0380821115614fcc57600080fd5b818701915087601f830112614fe057600080fd5b8151614fee61493a82614f1e565b8082825260208201915060208360051b86010192508a83111561501057600080fd5b602085015b8381101561509a5780518581111561502c57600080fd5b86016060818e03601f1901121561504257600080fd5b61504a614880565b602082015161505881614507565b81526040820151602082015260608201518781111561507657600080fd5b6150858f602083860101614f41565b60408301525084525060209283019201615015565b506101608a015190965093505050808211156150b557600080fd5b506150c287828801614f41565b91505092959194509250565b80516001600160a01b031682526000610220602083015160208501526040830151604085015260608301516151066060860182614df6565b50608083015161511960e0860182614df6565b5060a083015161016085015260c08301516001600160a01b031661018085015260e083015115156101a08501526101008301516101c0850182905261516082860182614c54565b9150506101208301518482036101e086015261517c8282614c54565b9150506101408301518482036102008601526151988282614c54565b95945050505050565b6020815260006122b760208301846150ce565b6060815260006151c760608301866150ce565b6020830194909452506001600160a01b0391909116604090910152919050565b600060018060a01b03808a168352808916602084015287604084015286606084015260e0608084015261521d60e0840187614c54565b83810360a085015261522f8187614c54565b92505080841660c08401525098975050505050505050565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b600080610140838503121561528457600080fd5b61528e8484614e9e565b915061012083015190509250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600060018060a01b03808b16835289602084015288604084015287606084015286608084015260e060a084015261530360e08401868861529f565b915080841660c0840152509998505050505050505050565b8082018082111561084857610848614bb4565b878152602081018790526001600160a01b038681166040830152851660608201526080810184905282151560a082015261010060c08201819052600090820181905261012060e08301819052614e8081840185614c54565b83815260606020820152600061539f6060830185614c54565b905060018060a01b0383166040830152949350505050565b600060018060a01b03808b16835289602084015288604084015287606084015260e060808401526153eb60e0840188614c54565b83810360a08501526153fe81878961529f565b92505080841660c0840152509998505050505050505050565b600081600019048311821515161561543157615431614bb4565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261546957634e487b7160e01b600052601260045260246000fd5b500490565b85815284602082015260a06040820152600061548d60a0830186614c54565b828103606084015261549f8186614c54565b91505060018060a01b03831660808301529695505050505050565b60018060a01b038616815284602082015283604082015260a0606082015260006154e760a0830185614c54565b8281036080840152610c718185614c54565b600080600080610180858703121561551057600080fd5b61551a8686614e9e565b935061012085015192506101408501516001600160401b038082111561553f57600080fd5b818701915087601f83011261555357600080fd5b815161556161493a82614f1e565b8082825260208201915060208360051b86010192508a83111561558357600080fd5b602085015b8381101561509a5780518581111561559f57600080fd5b86016060818e03601f190112156155b557600080fd5b6155bd614880565b60208201516155cb81614507565b8152604082015160208201526060820151878111156155e957600080fd5b6155f88f602083860101614f41565b60408301525084525060209283019201615588565b80516001600160a01b031682526000610200602083015160208501526040830151604085015260608301516060850152608083015161564f6080860182614df6565b5060a083015161010061566481870183614df6565b60c08501516001600160a01b031661018087015260e08501516101a08701849052915061569383870183614c54565b9250808501519150508482036101c08601526156af8282614c54565b9150506101208301518482036101e08601526151988282614c54565b6020815260006122b7602083018461560d565b6080815260006156f1608083018761560d565b60208301959095525060408101929092526001600160a01b0316606090910152919050565b828152604081016003831061573b57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b6000602080838503121561575b57600080fd5b82516001600160401b0381111561577157600080fd5b8301601f8101851361578257600080fd5b805161579061493a82614f1e565b81815260e091820283018401918482019190888411156157af57600080fd5b938501935b838510156158455780858a0312156157cc5760008081fd5b6157d46148a2565b85516157df81614616565b8152858701516157ee81614616565b81880152604086810151908201526060808701519082015260808087015161581581614507565b9082015260a0868101519082015260c08087015161583281614507565b90820152835293840193918501916157b4565b50979650505050505050565b80511515825260208082015115159083015260408082015190830152606080820151908301526080808201516001600160a01b039081169184019190915260a0808301519084015260c09182015116910152565b61014081016158b48287615851565b60e08201949094526101008101929092526001600160a01b031661012090910152919050565b81516001600160a01b031681526020808301519082015260408083015190820152606080830151908201526080808301519082015260a08281015161018083019161592790840182615851565b5092915050565b600061014061593d8388615851565b8560e08401528061010084015261595681840186614c54565b91505060018060a01b03831661012083015295945050505050565b60006101406159808387615851565b60e08301949094525061010081018390526012928101929092527115195c9b5a5b985b081b9bdd08199bdd5b9960721b6101608301526001600160a01b031661012082015261018001919050565b600082516159e0818460208701614c30565b919091019291505056fea2646970667358221220dbb5a4d937c7da0dca41d1328db9b1ff46a6507fe2074b39180782d13afdbde364736f6c63430008100033

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

000000000000000000000000000000000000000000000000000000000000000100000000000000000000000099db6b517683237de9c494bbd17861f3608f358500000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a99000000000000000000000000ce2ce2f37fe5b2c2dd047908b2f61c9c3f7072720000000000000000000000009f0ec91d28ffc54874e9ff11a316ba2537acd72c0000000000000000000000005d8ec74256db2326843714b852df3ace4514449200000000000000000000000046d623731e179faf971cda04ff8c499c95461b3c

-----Decoded View---------------
Arg [0] : _baseWeightCurrency (uint256): 1
Arg [1] : _operatorStore (address): 0x99dB6b517683237dE9C494bbd17861f3608F3585
Arg [2] : _projects (address): 0x21263a042aFE4bAE34F08Bb318056C181bD96D3b
Arg [3] : _directory (address): 0x8E05bcD2812E1449f0EC3aE24E2C395F533d9A99
Arg [4] : _splitsStore (address): 0xce2Ce2F37fE5B2C2Dd047908B2F61c9c3f707272
Arg [5] : _prices (address): 0x9f0eC91d28fFc54874e9fF11A316Ba2537aCD72C
Arg [6] : _store (address): 0x5d8eC74256DB2326843714B852df3acE45144492
Arg [7] : _owner (address): 0x46D623731E179FAF971CdA04fF8c499C95461b3c

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [1] : 00000000000000000000000099db6b517683237de9c494bbd17861f3608f3585
Arg [2] : 00000000000000000000000021263a042afe4bae34f08bb318056c181bd96d3b
Arg [3] : 0000000000000000000000008e05bcd2812e1449f0ec3ae24e2c395f533d9a99
Arg [4] : 000000000000000000000000ce2ce2f37fe5b2c2dd047908b2f61c9c3f707272
Arg [5] : 0000000000000000000000009f0ec91d28ffc54874e9ff11a316ba2537acd72c
Arg [6] : 0000000000000000000000005d8ec74256db2326843714b852df3ace45144492
Arg [7] : 00000000000000000000000046d623731e179faf971cda04ff8c499c95461b3c


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.