File size: 242,909 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
{
  "language": "Solidity",
  "sources": {
    "contracts/JB721GlobalGovernance.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport './abstract/Votes.sol';\nimport './JBTiered721Delegate.sol';\n\n/**\n  @title\n  JB721GlobalGovernance\n\n  @notice\n  A tiered 721 delegate where each NFT can be used for on chain governance, with votes delegatable globally across all tiers.\n\n  @dev\n  Inherits from -\n  JBTiered721Delegate: The tiered 721 delegate.\n  Votes: A helper for voting balance snapshots.\n*/\ncontract JB721GlobalGovernance is Votes, JBTiered721Delegate {\n  //*********************************************************************//\n  // ------------------------ internal functions ----------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice\n    The voting units for an account from its NFTs across all tiers. NFTs have a tier-specific preset number of voting units. \n\n    @param _account The account to get voting units for.\n\n    @return units The voting units for the account.\n  */\n  function _getVotingUnits(address _account)\n    internal\n    view\n    virtual\n    override\n    returns (uint256 units)\n  {\n    return store.votingUnitsOf(address(this), _account);\n  }\n\n  /**\n   @notice\n   handles the tier voting accounting\n\n    @param _from The account to transfer voting units from.\n    @param _to The account to transfer voting units to.\n    @param _tokenId The id of the token for which voting units are being transferred.\n    @param _tier The tier the token id is part of\n   */\n  function _afterTokenTransferAccounting(\n    address _from,\n    address _to,\n    uint256 _tokenId,\n    JB721Tier memory _tier\n  ) internal virtual override {\n    _tokenId; // Prevents unused var compiler and natspec complaints.\n    if (_tier.votingUnits != 0)\n      // Transfer the voting units.\n      _transferVotingUnits(_from, _to, _tier.votingUnits);\n  }\n}\n"
    },
    "contracts/JB721TieredGovernance.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport '@openzeppelin/contracts/utils/Checkpoints.sol';\nimport './interfaces/IJB721TieredGovernance.sol';\nimport './JBTiered721Delegate.sol';\n\n/**\n  @title\n  JB721TieredGovernance\n\n  @notice\n  A tiered 721 delegate where each NFT can be used for on chain governance, with votes delegatable per tier.\n\n  @dev\n  Adheres to -\n  IJB721TieredGovernance: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.\n\n  @dev\n  Inherits from -\n  JBTiered721Delegate: The tiered 721 delegate.\n  Votes: A helper for voting balance snapshots.\n*/\ncontract JB721TieredGovernance is JBTiered721Delegate, IJB721TieredGovernance {\n  using Checkpoints for Checkpoints.History;\n\n  //*********************************************************************//\n  // --------------------------- custom errors ------------------------- //\n  //*********************************************************************//\n\n  error BLOCK_NOT_YET_MINED();\n  error DELEGATE_ADDRESS_ZERO();\n\n  //*********************************************************************//\n  // --------------------- internal stored properties ------------------ //\n  //*********************************************************************//\n\n  /**\n    @notice\n    The delegation status for each address and for each tier.\n\n    _delegator The delegator.\n    _tierId The ID of the tier being delegated.\n  */\n  mapping(address => mapping(uint256 => address)) internal _tierDelegation;\n\n  /**\n    @notice\n    The delegation checkpoints for each address and for each tier.\n\n    _delegator The delegator.\n    _tierId The ID of the tier being delegated.\n  */\n  mapping(address => mapping(uint256 => Checkpoints.History)) internal _delegateTierCheckpoints;\n\n  /**\n    @notice\n    The total delegation status for each tier.\n\n    _tierId The ID of the tier being delegated.\n  */\n  mapping(uint256 => Checkpoints.History) internal _totalTierCheckpoints;\n\n  //*********************************************************************//\n  // ------------------------- external views -------------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice\n    Returns the delegate of an account for specific tier.\n\n    @param _account The account to check for a delegate of.\n    @param _tier the tier to check within.\n  */\n  function getTierDelegate(address _account, uint256 _tier)\n    external\n    view\n    override\n    returns (address)\n  {\n    return _tierDelegation[_account][_tier];\n  }\n\n  /**\n    @notice\n    Returns the current voting power of an address for a specific tier.\n\n    @param _account The address to check.\n    @param _tier The tier to check within.\n  */\n  function getTierVotes(address _account, uint256 _tier) external view override returns (uint256) {\n    return _delegateTierCheckpoints[_account][_tier].latest();\n  }\n\n  /**\n    @notice\n    Returns the past voting power of a specific address for a specific tier.\n\n    @param _account The address to check.\n    @param _tier The tier to check within.\n    @param _blockNumber the blocknumber to check the voting power at.\n  */\n  function getPastTierVotes(\n    address _account,\n    uint256 _tier,\n    uint256 _blockNumber\n  ) external view override returns (uint256) {\n    return _delegateTierCheckpoints[_account][_tier].getAtBlock(_blockNumber);\n  }\n\n  /**\n    @notice\n    Returns the total amount of voting power that exists for a tier.\n\n    @param _tier The tier to check.\n  */\n  function getTierTotalVotes(uint256 _tier) external view override returns (uint256) {\n    return _totalTierCheckpoints[_tier].latest();\n  }\n\n  /**\n    @notice\n    Returns the total amount of voting power that exists for a tier.\n\n    @param _tier The tier to check.\n    @param _blockNumber The blocknumber to check the total voting power at.\n  */\n  function getPastTierTotalVotes(uint256 _tier, uint256 _blockNumber)\n    external\n    view\n    override\n    returns (uint256)\n  {\n    return _totalTierCheckpoints[_tier].getAtBlock(_blockNumber);\n  }\n\n  //*********************************************************************//\n  // ----------------------- public transactions ----------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice \n    Delegates votes from the sender to `delegatee`.\n\n    @param _setTierDelegatesData An array of tiers to set delegates for.\n   */\n  function setTierDelegates(JBTiered721SetTierDelegatesData[] memory _setTierDelegatesData)\n    external\n    virtual\n    override\n  {\n    // Keep a reference to the number of tier delegates.\n    uint256 _numberOfTierDelegates = _setTierDelegatesData.length;\n\n    // Keep a reference to the data being iterated on.\n    JBTiered721SetTierDelegatesData memory _data;\n\n    for (uint256 _i; _i < _numberOfTierDelegates; ) {\n      // Reference the data being iterated on.\n      _data = _setTierDelegatesData[_i];\n\n      // No active delegation to the address 0\n      if (_data.delegatee == address(0)) revert DELEGATE_ADDRESS_ZERO();\n\n      _delegateTier(msg.sender, _data.delegatee, _data.tierId);\n\n      unchecked {\n        ++_i;\n      }\n    }\n  }\n\n  /**\n    @notice \n    Delegates votes from the sender to `delegatee`.\n\n    @param _delegatee The account to delegate tier voting units to.\n    @param _tierId The ID of the tier to delegate voting units for.\n   */\n  function setTierDelegate(address _delegatee, uint256 _tierId) public virtual override {\n    _delegateTier(msg.sender, _delegatee, _tierId);\n  }\n\n  //*********************************************************************//\n  // ------------------------ internal functions ----------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice \n    Gets the amount of voting units an address has for a particular tier.\n\n    @param _account The account to get voting units for.\n    @param _tierId The ID of the tier to get voting units for.\n\n    @return The voting units.\n  */\n  function _getTierVotingUnits(address _account, uint256 _tierId)\n    internal\n    view\n    virtual\n    returns (uint256)\n  {\n    return store.tierVotingUnitsOf(address(this), _account, _tierId);\n  }\n\n  /**\n    @notice \n    Delegate all of `account`'s voting units for the specified tier to `delegatee`.\n\n    @param _account The account delegating tier voting units.\n    @param _delegatee The account to delegate tier voting units to.\n    @param _tierId The ID of the tier for which voting units are being transferred.\n  */\n  function _delegateTier(\n    address _account,\n    address _delegatee,\n    uint256 _tierId\n  ) internal virtual {\n    // Get the current delegatee\n    address _oldDelegate = _tierDelegation[_account][_tierId];\n\n    // Store the new delegatee\n    _tierDelegation[_account][_tierId] = _delegatee;\n\n    emit DelegateChanged(_account, _oldDelegate, _delegatee);\n\n    // Move the votes.\n    _moveTierDelegateVotes(\n      _oldDelegate,\n      _delegatee,\n      _tierId,\n      _getTierVotingUnits(_account, _tierId)\n    );\n  }\n\n  /**\n    @notice \n    Transfers, mints, or burns tier voting units. To register a mint, `from` should be zero. To register a burn, `to` should be zero. Total supply of voting units will be adjusted with mints and burns.\n\n    @param _from The account to transfer tier voting units from.\n    @param _to The account to transfer tier voting units to.\n    @param _tierId The ID of the tier for which voting units are being transferred.\n    @param _amount The amount of voting units to delegate.\n   */\n  function _transferTierVotingUnits(\n    address _from,\n    address _to,\n    uint256 _tierId,\n    uint256 _amount\n  ) internal virtual {\n    // If minting, add to the total tier checkpoints.\n    if (_from == address(0)) _totalTierCheckpoints[_tierId].push(_add, _amount);\n\n    // If burning, subtract from the total tier checkpoints.\n    if (_to == address(0)) _totalTierCheckpoints[_tierId].push(_subtract, _amount);\n\n    // Move delegated votes.\n    _moveTierDelegateVotes(\n      _tierDelegation[_from][_tierId],\n      _tierDelegation[_to][_tierId],\n      _tierId,\n      _amount\n    );\n  }\n\n  /**\n    @notice \n    Moves delegated tier votes from one delegate to another.\n\n    @param _from The account to transfer tier voting units from.\n    @param _to The account to transfer tier voting units to.\n    @param _tierId The ID of the tier for which voting units are being transferred.\n    @param _amount The amount of voting units to delegate.\n  */\n  function _moveTierDelegateVotes(\n    address _from,\n    address _to,\n    uint256 _tierId,\n    uint256 _amount\n  ) internal {\n    // Nothing to do if moving to the same account, or no amount is being moved.\n    if (_from == _to || _amount == 0) return;\n\n    // If not moving from the zero address, update the checkpoints to subtract the amount.\n    if (_from != address(0)) {\n      (uint256 _oldValue, uint256 _newValue) = _delegateTierCheckpoints[_from][_tierId].push(\n        _subtract,\n        _amount\n      );\n      emit TierDelegateVotesChanged(_from, _tierId, _oldValue, _newValue, msg.sender);\n    }\n\n    // If not moving to the zero address, update the checkpoints to add the amount.\n    if (_to != address(0)) {\n      (uint256 _oldValue, uint256 _newValue) = _delegateTierCheckpoints[_to][_tierId].push(\n        _add,\n        _amount\n      );\n      emit TierDelegateVotesChanged(_to, _tierId, _oldValue, _newValue, msg.sender);\n    }\n  }\n\n  /**\n   @notice\n   handles the tier voting accounting\n\n    @param _from The account to transfer voting units from.\n    @param _to The account to transfer voting units to.\n    @param _tokenId The ID of the token for which voting units are being transferred.\n    @param _tier The tier the token ID is part of.\n   */\n  function _afterTokenTransferAccounting(\n    address _from,\n    address _to,\n    uint256 _tokenId,\n    JB721Tier memory _tier\n  ) internal virtual override {\n    _tokenId; // Prevents unused var compiler and natspec complaints.\n    if (_tier.votingUnits != 0)\n      // Transfer the voting units.\n      _transferTierVotingUnits(_from, _to, _tier.id, _tier.votingUnits);\n  }\n\n  // Utils from the Votes extension that is being reused for tier delegation.\n  function _add(uint256 a, uint256 b) internal pure returns (uint256) {\n    return a + b;\n  }\n\n  function _subtract(uint256 a, uint256 b) internal pure returns (uint256) {\n    return a - b;\n  }\n}\n"
    },
    "contracts/JBTiered721Delegate.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport '@jbx-protocol/juice-contracts-v3/contracts/libraries/JBFundingCycleMetadataResolver.sol';\nimport '@openzeppelin/contracts/access/Ownable.sol';\nimport './abstract/JB721Delegate.sol';\nimport './interfaces/IJBTiered721Delegate.sol';\nimport './libraries/JBIpfsDecoder.sol';\nimport './libraries/JBTiered721FundingCycleMetadataResolver.sol';\nimport './structs/JBTiered721Flags.sol';\n\n/**\n  @title\n  JBTiered721Delegate\n\n  @notice\n  Delegate that offers project contributors NFTs with tiered price floors upon payment and the ability to redeem NFTs for treasury assets based based on price floor.\n\n  @dev\n  Adheres to -\n  IJBTiered721Delegate: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.\n\n  @dev\n  Inherits from -\n  JB721Delegate: A generic NFT delegate.\n  Votes: A helper for voting balance snapshots.\n  Ownable: Includes convenience functionality for checking a message sender's permissions before executing certain transactions.\n*/\ncontract JBTiered721Delegate is IJBTiered721Delegate, JB721Delegate, Ownable {\n  //*********************************************************************//\n  // --------------------------- custom errors ------------------------- //\n  //*********************************************************************//\n\n  error NOT_AVAILABLE();\n  error OVERSPENDING();\n  error PRICING_RESOLVER_CHANGES_PAUSED();\n  error RESERVED_TOKEN_MINTING_PAUSED();\n  error TRANSFERS_PAUSED();\n\n  //*********************************************************************//\n  // --------------------- public stored properties -------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice\n    The address of the origin 'JBTiered721Delegate', used to check in the init if the contract is the original or not\n  */\n  address public override codeOrigin;\n\n  /**\n    @notice\n    The contract that stores and manages the NFT's data.\n  */\n  IJBTiered721DelegateStore public override store;\n\n  /**\n    @notice\n    The contract storing all funding cycle configurations.\n  */\n  IJBFundingCycleStore public override fundingCycleStore;\n\n  /**\n    @notice\n    The contract that exposes price feeds.\n  */\n  IJBPrices public override prices;\n\n  /** \n    @notice\n    The currency that is accepted when minting tier NFTs. \n  */\n  uint256 public override pricingCurrency;\n\n  /** \n    @notice\n    The currency that is accepted when minting tier NFTs. \n  */\n  uint256 public override pricingDecimals;\n\n  /** \n    @notice\n    The amount that each address has paid that has not yet contribute to the minting of an NFT. \n\n    _address The address to which the credits belong.\n  */\n  mapping(address => uint256) public override creditsOf;\n\n  //*********************************************************************//\n  // ------------------------- external views -------------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice\n    The first owner of each token ID, which corresponds to the address that originally contributed to the project to receive the NFT.\n\n    @param _tokenId The ID of the token to get the first owner of.\n\n    @return The first owner of the token.\n  */\n  function firstOwnerOf(uint256 _tokenId) external view override returns (address) {\n    // Get a reference to the first owner.\n    address _storedFirstOwner = store.firstOwnerOf(address(this), _tokenId);\n\n    // If the stored first owner is set, return it.\n    if (_storedFirstOwner != address(0)) return _storedFirstOwner;\n\n    // Otherwise, the first owner must be the current owner.\n    return _owners[_tokenId];\n  }\n\n  //*********************************************************************//\n  // -------------------------- public views --------------------------- //\n  //*********************************************************************//\n\n  /** \n    @notice \n    The total number of tokens owned by the given owner across all tiers. \n\n    @param _owner The address to check the balance of.\n\n    @return balance The number of tokens owners by the owner across all tiers.\n  */\n  function balanceOf(address _owner) public view override returns (uint256 balance) {\n    return store.balanceOf(address(this), _owner);\n  }\n\n  /** \n    @notice\n    The metadata URI of the provided token ID.\n\n    @dev\n    Defer to the tokenUriResolver if set, otherwise, use the tokenUri set with the token's tier.\n\n    @param _tokenId The ID of the token to get the tier URI for. \n\n    @return The token URI corresponding with the tier or the tokenUriResolver URI.\n  */\n  function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n    // A token without an owner doesn't have a URI.\n    if (_owners[_tokenId] == address(0)) return '';\n\n    // Get a reference to the URI resolver.\n    IJBTokenUriResolver _resolver = store.tokenUriResolverOf(address(this));\n\n    // If a token URI resolver is provided, use it to resolve the token URI.\n    if (address(_resolver) != address(0)) return _resolver.getUri(_tokenId);\n\n    // Return the token URI for the token's tier.\n    return\n      JBIpfsDecoder.decode(\n        store.baseUriOf(address(this)),\n        store.encodedTierIPFSUriOf(address(this), _tokenId)\n      );\n  }\n\n  /** \n    @notice\n    Returns the URI where contract metadata can be found. \n\n    @return The contract's metadata URI.\n  */\n  function contractURI() external view override returns (string memory) {\n    return store.contractUriOf(address(this));\n  }\n\n  /**\n    @notice\n    Indicates if this contract adheres to the specified interface.\n\n    @dev\n    See {IERC165-supportsInterface}.\n\n    @param _interfaceId The ID of the interface to check for adherence to.\n  */\n  function supportsInterface(bytes4 _interfaceId) public view override returns (bool) {\n    return\n      _interfaceId == type(IJBTiered721Delegate).interfaceId ||\n      super.supportsInterface(_interfaceId);\n  }\n\n  //*********************************************************************//\n  // -------------------------- constructor ---------------------------- //\n  //*********************************************************************//\n\n  constructor() {\n    codeOrigin = address(this);\n  }\n\n  /**\n    @param _projectId The ID of the project this contract's functionality applies to.\n    @param _directory The directory of terminals and controllers for projects.\n    @param _name The name of the token.\n    @param _symbol The symbol that the token should be represented by.\n    @param _fundingCycleStore A contract storing all funding cycle configurations.\n    @param _baseUri A URI to use as a base for full token URIs.\n    @param _tokenUriResolver A contract responsible for resolving the token URI for each token ID.\n    @param _contractUri A URI where contract metadata can be found. \n    @param _pricing The tier pricing according to which token distribution will be made. Must be passed in order of contribution floor, with implied increasing value.\n    @param _store A contract that stores the NFT's data.\n    @param _flags A set of flags that help define how this contract works.\n  */\n  function initialize(\n    uint256 _projectId,\n    IJBDirectory _directory,\n    string memory _name,\n    string memory _symbol,\n    IJBFundingCycleStore _fundingCycleStore,\n    string memory _baseUri,\n    IJBTokenUriResolver _tokenUriResolver,\n    string memory _contractUri,\n    JB721PricingParams memory _pricing,\n    IJBTiered721DelegateStore _store,\n    JBTiered721Flags memory _flags\n  ) public override {\n    // Make the original un-initializable.\n    if (address(this) == codeOrigin) revert();\n\n    // Stop re-initialization.\n    if (address(store) != address(0)) revert();\n\n    // Initialize the superclass.\n    JB721Delegate._initialize(_projectId, _directory, _name, _symbol);\n\n    fundingCycleStore = _fundingCycleStore;\n    store = _store;\n    pricingCurrency = _pricing.currency;\n    pricingDecimals = _pricing.decimals;\n    prices = _pricing.prices;\n\n    // Store the base URI if provided.\n    if (bytes(_baseUri).length != 0) _store.recordSetBaseUri(_baseUri);\n\n    // Set the contract URI if provided.\n    if (bytes(_contractUri).length != 0) _store.recordSetContractUri(_contractUri);\n\n    // Set the token URI resolver if provided.\n    if (_tokenUriResolver != IJBTokenUriResolver(address(0)))\n      _store.recordSetTokenUriResolver(_tokenUriResolver);\n\n    // Record adding the provided tiers.\n    if (_pricing.tiers.length > 0) _store.recordAddTiers(_pricing.tiers);\n\n    // Set the flags if needed.\n    if (\n      _flags.lockReservedTokenChanges ||\n      _flags.lockVotingUnitChanges ||\n      _flags.lockManualMintingChanges\n    ) _store.recordFlags(_flags);\n\n    // Transfer ownership to the initializer.\n    _transferOwnership(msg.sender);\n  }\n\n  //*********************************************************************//\n  // ---------------------- external transactions ---------------------- //\n  //*********************************************************************//\n\n  /** \n    @notice\n    Mint reserved tokens within the tier for the provided value.\n\n    @param _mintReservesForTiersData Contains information about how many reserved tokens to mint for each tier.\n  */\n  function mintReservesFor(JBTiered721MintReservesForTiersData[] calldata _mintReservesForTiersData)\n    external\n    override\n  {\n    // Keep a reference to the number of tiers there are to mint reserves for.\n    uint256 _numberOfTiers = _mintReservesForTiersData.length;\n\n    for (uint256 _i; _i < _numberOfTiers; ) {\n      // Get a reference to the data being iterated on.\n      JBTiered721MintReservesForTiersData memory _data = _mintReservesForTiersData[_i];\n\n      // Mint for the tier.\n      mintReservesFor(_data.tierId, _data.count);\n\n      unchecked {\n        ++_i;\n      }\n    }\n  }\n\n  /** \n    @notice\n    Mint tokens within the tier for the provided beneficiaries.\n\n    @param _mintForTiersData Contains information about how who to mint tokens for from each tier.\n  */\n  function mintFor(JBTiered721MintForTiersData[] calldata _mintForTiersData)\n    external\n    override\n    onlyOwner\n  {\n    // Keep a reference to the number of beneficiaries there are to mint for.\n    uint256 _numberOfBeneficiaries = _mintForTiersData.length;\n\n    for (uint256 _i; _i < _numberOfBeneficiaries; ) {\n      // Get a reference to the data being iterated on.\n      JBTiered721MintForTiersData calldata _data = _mintForTiersData[_i];\n\n      // Mint for the tier.\n      mintFor(_data.tierIds, _data.beneficiary);\n\n      unchecked {\n        ++_i;\n      }\n    }\n  }\n\n  /** \n    @notice\n    Adjust the tiers mintable through this contract, adhering to any locked tier constraints. \n\n    @dev\n    Only the contract's owner can adjust the tiers.\n\n    @param _tiersToAdd An array of tier data to add.\n    @param _tierIdsToRemove An array of tier IDs to remove.\n  */\n  function adjustTiers(JB721TierParams[] calldata _tiersToAdd, uint256[] calldata _tierIdsToRemove)\n    external\n    override\n    onlyOwner\n  {\n    // Get a reference to the number of tiers being added.\n    uint256 _numberOfTiersToAdd = _tiersToAdd.length;\n\n    // Get a reference to the number of tiers being removed.\n    uint256 _numberOfTiersToRemove = _tierIdsToRemove.length;\n\n    // Remove the tiers.\n    if (_numberOfTiersToRemove != 0) {\n      // Record the removed tiers.\n      store.recordRemoveTierIds(_tierIdsToRemove);\n\n      // Emit events for each removed tier.\n      for (uint256 _i; _i < _numberOfTiersToRemove; ) {\n        emit RemoveTier(_tierIdsToRemove[_i], msg.sender);\n        unchecked {\n          ++_i;\n        }\n      }\n    }\n\n    // Add the tiers.\n    if (_numberOfTiersToAdd != 0) {\n      // Record the added tiers in the store.\n      uint256[] memory _tierIdsAdded = store.recordAddTiers(_tiersToAdd);\n\n      // Emit events for each added tier.\n      for (uint256 _i; _i < _numberOfTiersToAdd; ) {\n        emit AddTier(_tierIdsAdded[_i], _tiersToAdd[_i], msg.sender);\n        unchecked {\n          ++_i;\n        }\n      }\n    }\n  }\n\n  /** \n    @notice\n    Sets the beneficiary of the reserved tokens for tiers where a specific beneficiary isn't set. \n\n    @dev\n    Only the contract's owner can set the default reserved token beneficiary.\n\n    @param _beneficiary The default beneficiary of the reserved tokens.\n  */\n  function setDefaultReservedTokenBeneficiary(address _beneficiary) external override onlyOwner {\n    // Set the beneficiary.\n    store.recordSetDefaultReservedTokenBeneficiary(_beneficiary);\n\n    emit SetDefaultReservedTokenBeneficiary(_beneficiary, msg.sender);\n  }\n\n  /**\n    @notice\n    Set a base token URI.\n\n    @dev\n    Only the contract's owner can set the base URI.\n\n    @param _baseUri The new base URI.\n  */\n  function setBaseUri(string calldata _baseUri) external override onlyOwner {\n    // Store the new value.\n    store.recordSetBaseUri(_baseUri);\n\n    emit SetBaseUri(_baseUri, msg.sender);\n  }\n\n  /**\n    @notice\n    Set a contract metadata URI to contain opensea-style metadata.\n\n    @dev\n    Only the contract's owner can set the contract URI.\n\n    @param _contractUri The new contract URI.\n  */\n  function setContractUri(string calldata _contractUri) external override onlyOwner {\n    // Store the new value.\n    store.recordSetContractUri(_contractUri);\n\n    emit SetContractUri(_contractUri, msg.sender);\n  }\n\n  /**\n    @notice\n    Set a token URI resolver.\n\n    @dev\n    Only the contract's owner can set the token URI resolver.\n\n    @param _tokenUriResolver The new URI resolver.\n  */\n  function setTokenUriResolver(IJBTokenUriResolver _tokenUriResolver) external override onlyOwner {\n    // Store the new value.\n    store.recordSetTokenUriResolver(_tokenUriResolver);\n\n    emit SetTokenUriResolver(_tokenUriResolver, msg.sender);\n  }\n\n  //*********************************************************************//\n  // ----------------------- public transactions ----------------------- //\n  //*********************************************************************//\n\n  /** \n    @notice\n    Mint reserved tokens within the tier for the provided value.\n\n    @param _tierId The ID of the tier to mint within.\n    @param _count The number of reserved tokens to mint. \n  */\n  function mintReservesFor(uint256 _tierId, uint256 _count) public override {\n    // Get a reference to the project's current funding cycle.\n    JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(projectId);\n\n    // Minting reserves must not be paused.\n    if (\n      JBTiered721FundingCycleMetadataResolver.mintingReservesPaused(\n        (JBFundingCycleMetadataResolver.metadata(_fundingCycle))\n      )\n    ) revert RESERVED_TOKEN_MINTING_PAUSED();\n\n    // Record the minted reserves for the tier.\n    uint256[] memory _tokenIds = store.recordMintReservesFor(_tierId, _count);\n\n    // Keep a reference to the reserved token beneficiary.\n    address _reservedTokenBeneficiary = store.reservedTokenBeneficiaryOf(address(this), _tierId);\n\n    // Keep a reference to the token ID being iterated on.\n    uint256 _tokenId;\n\n    for (uint256 _i; _i < _count; ) {\n      // Set the token ID.\n      _tokenId = _tokenIds[_i];\n\n      // Mint the token.\n      _mint(_reservedTokenBeneficiary, _tokenId);\n\n      emit MintReservedToken(_tokenId, _tierId, _reservedTokenBeneficiary, msg.sender);\n\n      unchecked {\n        ++_i;\n      }\n    }\n  }\n\n  /** \n    @notice\n    Manually mint NFTs from tiers.\n\n    @param _tierIds The IDs of the tiers to mint from.\n    @param _beneficiary The address to mint to. \n\n    @return tokenIds The IDs of the newly minted tokens.\n  */\n  function mintFor(uint16[] calldata _tierIds, address _beneficiary)\n    public\n    override\n    onlyOwner\n    returns (uint256[] memory tokenIds)\n  {\n    // Record the mint. The returned token IDs correspond to the tiers passed in.\n    (tokenIds, ) = store.recordMint(\n      type(uint256).max, // force the mint.\n      _tierIds,\n      true // manual mint\n    );\n\n    // Keep a reference to the number of tokens being minted.\n    uint256 _numberOfTokens = _tierIds.length;\n\n    // Keep a reference to the token ID being iterated on.\n    uint256 _tokenId;\n\n    for (uint256 _i; _i < _numberOfTokens; ) {\n      // Set the token ID.\n      _tokenId = tokenIds[_i];\n\n      // Mint the token.\n      _mint(_beneficiary, _tokenId);\n\n      emit Mint(_tokenId, _tierIds[_i], _beneficiary, 0, msg.sender);\n\n      unchecked {\n        ++_i;\n      }\n    }\n  }\n\n  //*********************************************************************//\n  // ------------------------ internal functions ----------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice\n    Mints for a given contribution to the beneficiary.\n\n    @param _data The Juicebox standard project contribution data.\n  */\n  function _processPayment(JBDidPayData calldata _data) internal override {\n    // Normalize the currency.\n    uint256 _value;\n    if (_data.amount.currency == pricingCurrency) _value = _data.amount.value;\n    else if (prices != IJBPrices(address(0)))\n      _value = PRBMath.mulDiv(\n        _data.amount.value,\n        10**pricingDecimals,\n        prices.priceFor(_data.amount.currency, pricingCurrency, _data.amount.decimals)\n      );\n    else return;\n\n    // Keep a reference to the amount of credits the beneficiary already has.\n    uint256 _credits = creditsOf[_data.beneficiary];\n\n    // Set the leftover amount as the initial value, including any credits the beneficiary might already have.\n    uint256 _leftoverAmount = _value;\n\n    // If the payer is the beneficiary, combine the credits with the paid amount\n    // if not, then we keep track of the credits that were unused\n    uint256 _stashedCredits;\n    if (_data.payer == _data.beneficiary) {\n      unchecked { _leftoverAmount += _credits; }\n    } else _stashedCredits = _credits;\n    \n    // Keep a reference to a flag indicating if a mint is expected from discretionary funds. Defaults to false, meaning to mint is not expected.\n    bool _expectMintFromExtraFunds;\n\n    // Keep a reference to the flag indicating if the transaction should revert if all provided funds aren't spent. Defaults to false, meaning only a minimum payment is enforced.\n    bool _dontOverspend;\n\n    // Skip the first 32 bytes which are used by the JB protocol to pass the paying project's ID when paying from a JBSplit.\n    // Skip another 32 bytes reserved for generic extension parameters.\n    // Check the 4 bytes interfaceId to verify the metadata is intended for this contract.\n    if (\n      _data.metadata.length > 68 &&\n      bytes4(_data.metadata[64:68]) == type(IJB721Delegate).interfaceId\n    ) {\n      // Keep a reference to the flag indicating if the transaction should not mint anything.\n      bool _dontMint;\n\n      // Keep a reference to the the specific tier IDs to mint.\n      uint16[] memory _tierIdsToMint;\n\n      // Decode the metadata.\n      (, , , _dontMint, _expectMintFromExtraFunds, _dontOverspend, _tierIdsToMint) = abi.decode(\n        _data.metadata,\n        (bytes32, bytes32, bytes4, bool, bool, bool, uint16[])\n      );\n\n      // Don't mint if not desired.\n      if (_dontMint) {\n        // Store credits.\n        unchecked { creditsOf[_data.beneficiary] = _leftoverAmount + _stashedCredits; }\n\n        // Return instead of minting.\n        return;\n      }\n\n      // Mint tiers if they were specified.\n      if (_tierIdsToMint.length != 0)\n        _leftoverAmount = _mintAll(_leftoverAmount, _tierIdsToMint, _data.beneficiary);\n    }\n\n    // If there are funds leftover, mint the best available with it.\n    if (_leftoverAmount != 0) {\n      _leftoverAmount = _mintBestAvailableTier(\n        _leftoverAmount,\n        _data.beneficiary,\n        _expectMintFromExtraFunds\n      );\n\n      if (_leftoverAmount != 0) {\n        // Make sure there are no leftover funds after minting if not expected.\n        if (_dontOverspend) revert OVERSPENDING();\n\n        // Increment the leftover amount.\n        unchecked { creditsOf[_data.beneficiary] = _leftoverAmount + _stashedCredits; }\n      } else if (_credits != _stashedCredits) creditsOf[_data.beneficiary] = _stashedCredits;\n    } else if (_credits != _stashedCredits) creditsOf[_data.beneficiary] = _stashedCredits;\n  }\n\n  /** \n    @notice\n    A function that will run when tokens are burned via redemption.\n\n    @param _tokenIds The IDs of the tokens that were burned.\n  */\n  function _didBurn(uint256[] memory _tokenIds) internal virtual override {\n    // Add to burned counter.\n    store.recordBurn(_tokenIds);\n  }\n\n  /** \n    @notice\n    Mints a token in the best available tier.\n\n    @param _amount The amount to base the mint on.\n    @param _beneficiary The address to mint for.\n    @param _expectMint A flag indicating if a mint was expected.\n\n    @return  leftoverAmount The amount leftover after the mint.\n  */\n  function _mintBestAvailableTier(\n    uint256 _amount,\n    address _beneficiary,\n    bool _expectMint\n  ) internal returns (uint256 leftoverAmount) {\n    // Keep a reference to the token ID.\n    uint256 _tokenId;\n\n    // Keep a reference to the tier ID.\n    uint256 _tierId;\n\n    // Record the mint.\n    (_tokenId, _tierId, leftoverAmount) = store.recordMintBestAvailableTier(_amount);\n\n    // If there's no best tier, return or revert.\n    if (_tokenId == 0) {\n      // Make sure a mint was not expected.\n      if (_expectMint) revert NOT_AVAILABLE();\n      return leftoverAmount;\n    }\n\n    // Mint the tokens.\n    _mint(_beneficiary, _tokenId);\n\n    emit Mint(_tokenId, _tierId, _beneficiary, _amount - leftoverAmount, msg.sender);\n  }\n\n  /** \n    @notice\n    Mints a token in all provided tiers.\n\n    @param _amount The amount to base the mints on. All mints' price floors must fit in this amount.\n    @param _mintTierIds An array of tier IDs that are intended to be minted.\n    @param _beneficiary The address to mint for.\n\n    @return leftoverAmount The amount leftover after the mint.\n  */\n  function _mintAll(\n    uint256 _amount,\n    uint16[] memory _mintTierIds,\n    address _beneficiary\n  ) internal returns (uint256 leftoverAmount) {\n    // Keep a reference to the token ID.\n    uint256[] memory _tokenIds;\n\n    // Record the mint. The returned token IDs correspond to the tiers passed in.\n    (_tokenIds, leftoverAmount) = store.recordMint(\n      _amount,\n      _mintTierIds,\n      false // Not a manual mint\n    );\n\n    // Get a reference to the number of mints.\n    uint256 _mintsLength = _tokenIds.length;\n\n    // Keep a reference to the token ID being iterated on.\n    uint256 _tokenId;\n\n    // Loop through each token ID and mint.\n    for (uint256 _i; _i < _mintsLength; ) {\n      // Get a reference to the tier being iterated on.\n      _tokenId = _tokenIds[_i];\n\n      // Mint the tokens.\n      _mint(_beneficiary, _tokenId);\n\n      emit Mint(_tokenId, _mintTierIds[_i], _beneficiary, _amount, msg.sender);\n\n      unchecked {\n        ++_i;\n      }\n    }\n  }\n\n  /** \n    @notice\n    The cumulative weight the given token IDs have in redemptions compared to the `_totalRedemptionWeight`. \n\n    @param _tokenIds The IDs of the tokens to get the cumulative redemption weight of.\n\n    @return The weight.\n  */\n  function _redemptionWeightOf(uint256[] memory _tokenIds, JBRedeemParamsData calldata)\n    internal\n    view\n    virtual\n    override\n    returns (uint256)\n  {\n    return store.redemptionWeightOf(address(this), _tokenIds);\n  }\n\n  /** \n    @notice\n    The cumulative weight that all token IDs have in redemptions. \n\n    @return The total weight.\n  */\n  function _totalRedemptionWeight(JBRedeemParamsData calldata)\n    internal\n    view\n    virtual\n    override\n    returns (uint256)\n  {\n    return store.totalRedemptionWeight(address(this));\n  }\n\n  /**\n    @notice\n    User the hook to register the first owner if it's not yet registered.\n\n    @param _from The address where the transfer is originating.\n    @param _to The address to which the transfer is being made.\n    @param _tokenId The ID of the token being transferred.\n  */\n  function _beforeTokenTransfer(\n    address _from,\n    address _to,\n    uint256 _tokenId\n  ) internal virtual override {\n    // Transferred must not be paused when not minting or burning.\n    if (_from != address(0)) {\n      // Get a reference to the tier.\n      JB721Tier memory _tier = store.tierOfTokenId(address(this), _tokenId);\n\n      // Transfers from the tier must be pausable.\n      if (_tier.transfersPausable) {\n        // Get a reference to the project's current funding cycle.\n        JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(projectId);\n\n        if (\n          _to != address(0) &&\n          JBTiered721FundingCycleMetadataResolver.transfersPaused(\n            (JBFundingCycleMetadataResolver.metadata(_fundingCycle))\n          )\n        ) revert TRANSFERS_PAUSED();\n      }\n\n      // If there's no stored first owner, and the transfer isn't originating from the zero address as expected for mints, store the first owner.\n      if (store.firstOwnerOf(address(this), _tokenId) == address(0))\n        store.recordSetFirstOwnerOf(_tokenId, _from);\n    }\n\n    super._beforeTokenTransfer(_from, _to, _tokenId);\n  }\n\n  /**\n    @notice\n    Transfer voting units after the transfer of a token.\n\n    @param _from The address where the transfer is originating.\n    @param _to The address to which the transfer is being made.\n    @param _tokenId The ID of the token being transferred.\n   */\n  function _afterTokenTransfer(\n    address _from,\n    address _to,\n    uint256 _tokenId\n  ) internal virtual override {\n    // Get a reference to the tier.\n    JB721Tier memory _tier = store.tierOfTokenId(address(this), _tokenId);\n\n    // Record the transfer.\n    store.recordTransferForTier(_tier.id, _from, _to);\n\n    // Handle any other accounting (ex. account for governance voting units)\n    _afterTokenTransferAccounting(_from, _to, _tokenId, _tier);\n\n    super._afterTokenTransfer(_from, _to, _tokenId);\n  }\n\n  /**\n    @notice \n    Custom hook to handle token/tier accounting, this way we can reuse the '_tier' instead of fetching it again.\n\n    @param _from The account to transfer voting units from.\n    @param _to The account to transfer voting units to.\n    @param _tokenId The ID of the token for which voting units are being transferred.\n    @param _tier The tier the token ID is part of.\n  */\n  function _afterTokenTransferAccounting(\n    address _from,\n    address _to,\n    uint256 _tokenId,\n    JB721Tier memory _tier\n  ) internal virtual {\n    _from; // Prevents unused var compiler and natspec complaints.\n    _to;\n    _tokenId;\n    _tier;\n  }\n}\n"
    },
    "contracts/JBTiered721DelegateDeployer.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport './interfaces/IJBTiered721DelegateDeployer.sol';\nimport './JBTiered721Delegate.sol';\nimport './JB721TieredGovernance.sol';\nimport './JB721GlobalGovernance.sol';\n\n/**\n  @notice\n  Deploys a tier delegate.\n\n  @dev\n  Adheres to -\n  IJBTiered721DelegateDeployer: General interface for the generic controller methods in this contract that interacts with funding cycles and tokens according to the protocol's rules.\n*/\ncontract JBTiered721DelegateDeployer is IJBTiered721DelegateDeployer {\n  error INVALID_GOVERNANCE_TYPE();\n\n  uint256 constant DEPLOY_BYTECODE_LENGTH = 13;\n\n  //*********************************************************************//\n  // --------------- public immutable stored properties ---------------- //\n  //*********************************************************************//\n\n  /** \n    @notice \n    The contract that supports on-chain governance across all tiers. \n  */\n  JB721GlobalGovernance public immutable globalGovernance;\n\n  /** \n    @notice \n    The contract that supports on-chain governance per-tier. \n  */\n  JB721TieredGovernance public immutable tieredGovernance;\n\n  /** \n    @notice \n    The contract that has no on-chain governance. \n  */\n  JBTiered721Delegate public immutable noGovernance;\n\n  //*********************************************************************//\n  // -------------------------- constructor ---------------------------- //\n  //*********************************************************************//\n\n  constructor(\n    JB721GlobalGovernance _globalGovernance,\n    JB721TieredGovernance _tieredGovernance,\n    JBTiered721Delegate _noGovernance\n  ) {\n    globalGovernance = _globalGovernance;\n    tieredGovernance = _tieredGovernance;\n    noGovernance = _noGovernance;\n  }\n\n  //*********************************************************************//\n  // ---------------------- external transactions ---------------------- //\n  //*********************************************************************//\n\n  /** \n    @notice\n    Deploys a delegate.\n\n    @param _projectId The ID of the project this contract's functionality applies to.\n    @param _deployTiered721DelegateData Data necessary to fulfill the transaction to deploy a delegate.\n\n    @return newDelegate The address of the newly deployed delegate.\n  */\n  function deployDelegateFor(\n    uint256 _projectId,\n    JBDeployTiered721DelegateData memory _deployTiered721DelegateData\n  ) external override returns (IJBTiered721Delegate newDelegate) {\n    // Deploy the governance variant that was requested\n    address codeToCopy;\n    if (_deployTiered721DelegateData.governanceType == JB721GovernanceType.NONE)\n      codeToCopy = address(noGovernance);\n    else if (_deployTiered721DelegateData.governanceType == JB721GovernanceType.TIERED)\n      codeToCopy = address(tieredGovernance);\n    else if (_deployTiered721DelegateData.governanceType == JB721GovernanceType.GLOBAL)\n      codeToCopy = address(globalGovernance);\n    else revert INVALID_GOVERNANCE_TYPE();\n\n    newDelegate = IJBTiered721Delegate(_clone(codeToCopy));\n    newDelegate.initialize(\n      _projectId,\n      _deployTiered721DelegateData.directory,\n      _deployTiered721DelegateData.name,\n      _deployTiered721DelegateData.symbol,\n      _deployTiered721DelegateData.fundingCycleStore,\n      _deployTiered721DelegateData.baseUri,\n      _deployTiered721DelegateData.tokenUriResolver,\n      _deployTiered721DelegateData.contractUri,\n      _deployTiered721DelegateData.pricing,\n      _deployTiered721DelegateData.store,\n      _deployTiered721DelegateData.flags\n    );\n\n    // Transfer the ownership to the specified address.\n    if (_deployTiered721DelegateData.owner != address(0))\n      Ownable(address(newDelegate)).transferOwnership(_deployTiered721DelegateData.owner);\n\n    emit DelegateDeployed(_projectId, newDelegate, _deployTiered721DelegateData.governanceType);\n\n    return newDelegate;\n  }\n\n  /**\n    @notice Clone and redeploy the bytecode of a given address\n\n    @dev Runtime bytecode needs a constructor -> we append this one\n         to the bytecode, which is a minimalistic one only returning the runtime bytecode\n\n         See https://github.com/drgorillamd/clone-deployed-contract/blob/master/readme.MD for details\n   */\n  function _clone(address _targetAddress) internal returns (address _out) {\n    assembly {\n      // Get deployed/runtime code size\n      let _codeSize := extcodesize(_targetAddress)\n\n      // Get a bit of freemem to land the bytecode, not updated as we'll leave this scope right after create(..)\n      let _freeMem := mload(0x40)\n\n      // Shift the length to the length placeholder, in the constructor (by adding zero's/mul)\n      let _mask := mul(_codeSize, 0x100000000000000000000000000000000000000000000000000000000)\n\n      // Insert the length in the correct spot (after the PUSH3 / 0x62)\n      let _initCode := or(_mask, 0x62000000600081600d8239f3fe00000000000000000000000000000000000000)\n      // --------------------------- here ^ (see the \"1\" from the mul step aligning)\n\n      // Store the deployment bytecode in free memory\n      mstore(_freeMem, _initCode)\n\n      // Copy the bytecode, after the deployer bytecode in free memory\n      extcodecopy(_targetAddress, add(_freeMem, DEPLOY_BYTECODE_LENGTH), 0, _codeSize)\n\n      // Deploy the copied bytecode (constructor + original) and return the address in 'out'\n      _out := create(0, _freeMem, add(_codeSize, DEPLOY_BYTECODE_LENGTH))\n    }\n  }\n}\n"
    },
    "contracts/abstract/ERC721.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.16;\n\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';\nimport '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';\nimport '@openzeppelin/contracts/utils/Address.sol';\nimport '@openzeppelin/contracts/utils/Context.sol';\nimport '@openzeppelin/contracts/utils/Strings.sol';\nimport '@openzeppelin/contracts/utils/introspection/ERC165.sol';\n\n/**\n * @dev Doesn't track balances.\n *\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n  using Address for address;\n  using Strings for uint256;\n\n  error ALEADY_MINTED();\n  error APPROVE_TO_CALLER();\n  error APPROVAL_TO_CURRENT_OWNER();\n  error CALLER_NOT_OWNER_OR_APPROVED();\n  error INVALID_TOKEN_ID();\n  error INCORRECT_OWNER();\n  error MINT_TO_ZERO();\n  error TRANSFER_TO_NON_IMPLEMENTER();\n  error TRANSFER_TO_ZERO_ADDRESS();\n\n  // Token name\n  string private _name;\n\n  // Token symbol\n  string private _symbol;\n\n  // Mapping from token ID to owner address\n  mapping(uint256 => address) internal _owners;\n\n  // Mapping from token ID to approved address\n  mapping(uint256 => address) private _tokenApprovals;\n\n  // Mapping from owner to operator approvals\n  mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n  /**\n   * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n   */\n  function _initialize(string memory name_, string memory symbol_) internal {\n    _name = name_;\n    _symbol = symbol_;\n  }\n\n  /**\n   * @dev See {IERC165-supportsInterface}.\n   */\n  function supportsInterface(bytes4 interfaceId)\n    public\n    view\n    virtual\n    override(ERC165, IERC165)\n    returns (bool)\n  {\n    return\n      interfaceId == type(IERC721).interfaceId ||\n      interfaceId == type(IERC721Metadata).interfaceId ||\n      super.supportsInterface(interfaceId);\n  }\n\n  /**\n    @dev Balance tracking to be overriden by childs\n  */\n  function balanceOf(address owner) external view virtual override returns (uint256 balance) {\n    owner;\n    return 0;\n  }\n\n  /**\n   * @dev See {IERC721-ownerOf}.\n   */\n  function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n    address owner = _owners[tokenId];\n    if (owner == address(0)) revert INVALID_TOKEN_ID();\n    return owner;\n  }\n\n  /**\n   * @dev See {IERC721Metadata-name}.\n   */\n  function name() public view virtual override returns (string memory) {\n    return _name;\n  }\n\n  /**\n   * @dev See {IERC721Metadata-symbol}.\n   */\n  function symbol() public view virtual override returns (string memory) {\n    return _symbol;\n  }\n\n  /**\n   * @dev See {IERC721Metadata-tokenURI}.\n   */\n  function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n    _requireMinted(tokenId);\n\n    string memory baseURI = _baseURI();\n    return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';\n  }\n\n  /**\n   * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n   * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n   * by default, can be overridden in child contracts.\n   */\n  function _baseURI() internal view virtual returns (string memory) {\n    return '';\n  }\n\n  /**\n   * @dev See {IERC721-approve}.\n   */\n  function approve(address to, uint256 tokenId) public virtual override {\n    address owner = ERC721.ownerOf(tokenId);\n\n    if (to == owner) revert APPROVAL_TO_CURRENT_OWNER();\n\n    if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender()))\n      revert CALLER_NOT_OWNER_OR_APPROVED();\n\n    _approve(to, tokenId);\n  }\n\n  /**\n   * @dev See {IERC721-getApproved}.\n   */\n  function getApproved(uint256 tokenId) public view virtual override returns (address) {\n    _requireMinted(tokenId);\n\n    return _tokenApprovals[tokenId];\n  }\n\n  /**\n   * @dev See {IERC721-setApprovalForAll}.\n   */\n  function setApprovalForAll(address operator, bool approved) public virtual override {\n    _setApprovalForAll(_msgSender(), operator, approved);\n  }\n\n  /**\n   * @dev See {IERC721-isApprovedForAll}.\n   */\n  function isApprovedForAll(address owner, address operator)\n    public\n    view\n    virtual\n    override\n    returns (bool)\n  {\n    return _operatorApprovals[owner][operator];\n  }\n\n  /**\n   * @dev See {IERC721-transferFrom}.\n   */\n  function transferFrom(\n    address from,\n    address to,\n    uint256 tokenId\n  ) public virtual override {\n    //solhint-disable-next-line max-line-length\n    if (!_isApprovedOrOwner(_msgSender(), tokenId)) revert CALLER_NOT_OWNER_OR_APPROVED();\n\n    _transfer(from, to, tokenId);\n  }\n\n  /**\n   * @dev See {IERC721-safeTransferFrom}.\n   */\n  function safeTransferFrom(\n    address from,\n    address to,\n    uint256 tokenId\n  ) public virtual override {\n    safeTransferFrom(from, to, tokenId, '');\n  }\n\n  /**\n   * @dev See {IERC721-safeTransferFrom}.\n   */\n  function safeTransferFrom(\n    address from,\n    address to,\n    uint256 tokenId,\n    bytes memory data\n  ) public virtual override {\n    if (!_isApprovedOrOwner(_msgSender(), tokenId)) revert CALLER_NOT_OWNER_OR_APPROVED();\n    _safeTransfer(from, to, tokenId, data);\n  }\n\n  /**\n   * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n   * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n   *\n   * `data` is additional data, it has no specified format and it is sent in call to `to`.\n   *\n   * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n   * implement alternative mechanisms to perform token transfer, such as signature-based.\n   *\n   * Requirements:\n   *\n   * - `from` cannot be the zero address.\n   * - `to` cannot be the zero address.\n   * - `tokenId` token must exist and be owned by `from`.\n   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n   *\n   * Emits a {Transfer} event.\n   */\n  function _safeTransfer(\n    address from,\n    address to,\n    uint256 tokenId,\n    bytes memory data\n  ) internal virtual {\n    _transfer(from, to, tokenId);\n    if (!_checkOnERC721Received(from, to, tokenId, data)) revert TRANSFER_TO_NON_IMPLEMENTER();\n  }\n\n  /**\n   * @dev Returns whether `tokenId` exists.\n   *\n   * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n   *\n   * Tokens start existing when they are minted (`_mint`),\n   * and stop existing when they are burned (`_burn`).\n   */\n  function _exists(uint256 tokenId) internal view virtual returns (bool) {\n    return _owners[tokenId] != address(0);\n  }\n\n  /**\n   * @dev Returns whether `spender` is allowed to manage `tokenId`.\n   *\n   * Requirements:\n   *\n   * - `tokenId` must exist.\n   */\n  function _isApprovedOrOwner(address spender, uint256 tokenId)\n    internal\n    view\n    virtual\n    returns (bool)\n  {\n    address owner = ERC721.ownerOf(tokenId);\n    return (spender == owner ||\n      isApprovedForAll(owner, spender) ||\n      getApproved(tokenId) == spender);\n  }\n\n  /**\n   * @dev Mints `tokenId` and transfers it to `to`.\n   *\n   * Requirements:\n   *\n   * - `tokenId` must not exist.\n   * - `to` cannot be the zero address.\n   *\n   * Emits a {Transfer} event.\n   */\n  function _mint(address to, uint256 tokenId) internal virtual {\n    if (to == address(0)) revert MINT_TO_ZERO();\n    if (_exists(tokenId)) revert ALEADY_MINTED();\n\n    _beforeTokenTransfer(address(0), to, tokenId);\n\n    _owners[tokenId] = to;\n\n    emit Transfer(address(0), to, tokenId);\n\n    _afterTokenTransfer(address(0), to, tokenId);\n  }\n\n  /**\n   * @dev Destroys `tokenId`.\n   * The approval is cleared when the token is burned.\n   *\n   * Requirements:\n   *\n   * - `tokenId` must exist.\n   *\n   * Emits a {Transfer} event.\n   */\n  function _burn(uint256 tokenId) internal virtual {\n    address owner = ERC721.ownerOf(tokenId);\n\n    _beforeTokenTransfer(owner, address(0), tokenId);\n\n    // Clear approvals\n    _approve(address(0), tokenId);\n\n    delete _owners[tokenId];\n\n    emit Transfer(owner, address(0), tokenId);\n\n    _afterTokenTransfer(owner, address(0), tokenId);\n  }\n\n  /**\n   * @dev Transfers `tokenId` from `from` to `to`.\n   *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n   *\n   * Requirements:\n   *\n   * - `to` cannot be the zero address.\n   * - `tokenId` token must be owned by `from`.\n   *\n   * Emits a {Transfer} event.\n   */\n  function _transfer(\n    address from,\n    address to,\n    uint256 tokenId\n  ) internal virtual {\n    if (ERC721.ownerOf(tokenId) != from) revert INCORRECT_OWNER();\n    if (to == address(0)) revert TRANSFER_TO_ZERO_ADDRESS();\n\n    _beforeTokenTransfer(from, to, tokenId);\n\n    // Clear approvals from the previous owner\n    _approve(address(0), tokenId);\n\n    _owners[tokenId] = to;\n\n    emit Transfer(from, to, tokenId);\n\n    _afterTokenTransfer(from, to, tokenId);\n  }\n\n  /**\n   * @dev Approve `to` to operate on `tokenId`\n   *\n   * Emits an {Approval} event.\n   */\n  function _approve(address to, uint256 tokenId) internal virtual {\n    _tokenApprovals[tokenId] = to;\n    emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n  }\n\n  /**\n   * @dev Approve `operator` to operate on all of `owner` tokens\n   *\n   * Emits an {ApprovalForAll} event.\n   */\n  function _setApprovalForAll(\n    address owner,\n    address operator,\n    bool approved\n  ) internal virtual {\n    if (owner == operator) revert APPROVE_TO_CALLER();\n    _operatorApprovals[owner][operator] = approved;\n    emit ApprovalForAll(owner, operator, approved);\n  }\n\n  /**\n   * @dev Reverts if the `tokenId` has not been minted yet.\n   */\n  function _requireMinted(uint256 tokenId) internal view virtual {\n    if (!_exists(tokenId)) revert INVALID_TOKEN_ID();\n  }\n\n  /**\n   * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n   * The call is not executed if the target address is not a contract.\n   *\n   * @param from address representing the previous owner of the given token ID\n   * @param to target address that will receive the tokens\n   * @param tokenId uint256 ID of the token to be transferred\n   * @param data bytes optional data to send along with the call\n   * @return bool whether the call correctly returned the expected magic value\n   */\n  function _checkOnERC721Received(\n    address from,\n    address to,\n    uint256 tokenId,\n    bytes memory data\n  ) private returns (bool) {\n    if (to.isContract()) {\n      try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (\n        bytes4 retval\n      ) {\n        return retval == IERC721Receiver.onERC721Received.selector;\n      } catch (bytes memory reason) {\n        if (reason.length == 0) {\n          revert TRANSFER_TO_NON_IMPLEMENTER();\n        } else {\n          /// @solidity memory-safe-assembly\n          assembly {\n            revert(add(32, reason), mload(reason))\n          }\n        }\n      }\n    } else {\n      return true;\n    }\n  }\n\n  /**\n   * @dev Hook that is called before any token transfer. This includes minting\n   * and burning.\n   *\n   * Calling conditions:\n   *\n   * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n   * transferred to `to`.\n   * - When `from` is zero, `tokenId` will be minted for `to`.\n   * - When `to` is zero, ``from``'s `tokenId` will be burned.\n   * - `from` and `to` are never both zero.\n   *\n   * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n   */\n  function _beforeTokenTransfer(\n    address from,\n    address to,\n    uint256 tokenId\n  ) internal virtual {}\n\n  /**\n   * @dev Hook that is called after any transfer of tokens. This includes\n   * minting and burning.\n   *\n   * Calling conditions:\n   *\n   * - when `from` and `to` are both non-zero.\n   * - `from` and `to` are never both zero.\n   *\n   * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n   */\n  function _afterTokenTransfer(\n    address from,\n    address to,\n    uint256 tokenId\n  ) internal virtual {}\n}\n"
    },
    "contracts/abstract/JB721Delegate.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBFundingCycleDataSource.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBPayDelegate.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/libraries/JBConstants.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/structs/JBPayParamsData.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/structs/JBPayDelegateAllocation.sol';\nimport '@paulrberg/contracts/math/PRBMath.sol';\nimport '../interfaces/IJB721Delegate.sol';\nimport './ERC721.sol';\n\n/**\n  @title \n  JB721Delegate\n\n  @notice \n  Delegate that offers project contributors NFTs upon payment and the ability to redeem NFTs for treasury assets.\n\n  @dev\n  Adheres to -\n  IJB721Delegate: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.\n  IJBFundingCycleDataSource: Allows this contract to be attached to a funding cycle to have its methods called during regular protocol operations.\n  IJBPayDelegate: Allows this contract to receive callbacks when a project receives a payment.\n  IJBRedemptionDelegate: Allows this contract to receive callbacks when a token holder redeems.\n\n  @dev\n  Inherits from -\n  ERC721: A standard definition for non-fungible tokens (NFTs).\n*/\nabstract contract JB721Delegate is\n  IJB721Delegate,\n  IJBFundingCycleDataSource,\n  IJBPayDelegate,\n  IJBRedemptionDelegate,\n  ERC721\n{\n  //*********************************************************************//\n  // --------------------------- custom errors ------------------------- //\n  //*********************************************************************//\n\n  error INVALID_PAYMENT_EVENT();\n  error INVALID_REDEMPTION_EVENT();\n  error UNAUTHORIZED();\n  error UNEXPECTED_TOKEN_REDEEMED();\n  error INVALID_REDEMPTION_METADATA();\n\n  //*********************************************************************//\n  // --------------- public immutable stored properties ---------------- //\n  //*********************************************************************//\n\n  /**\n    @notice\n    The ID of the project this contract's functionality applies to.\n  */\n  uint256 public override projectId;\n\n  /**\n    @notice\n    The directory of terminals and controllers for projects.\n  */\n  IJBDirectory public override directory;\n\n  //*********************************************************************//\n  // ------------------------- external views -------------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice \n    Part of IJBFundingCycleDataSource, this function gets called when the project receives a payment. It will set itself as the delegate to get a callback from the terminal.\n\n    @param _data The Juicebox standard project payment data.\n\n    @return weight The weight that tokens should get minted in accordance with.\n    @return memo The memo that should be forwarded to the event.\n    @return delegateAllocations The amount to send to delegates instead of adding to the local balance.\n  */\n  function payParams(JBPayParamsData calldata _data)\n    public\n    view\n    virtual\n    override\n    returns (\n      uint256 weight,\n      string memory memo,\n      JBPayDelegateAllocation[] memory delegateAllocations\n    )\n  {\n    // Forward the received weight and memo, and use this contract as a pay delegate.\n    weight = _data.weight;\n    memo = _data.memo;\n    delegateAllocations = new JBPayDelegateAllocation[](1);\n    delegateAllocations[0] = JBPayDelegateAllocation(this, 0);\n  }\n\n  /**\n    @notice \n    Part of IJBFundingCycleDataSource, this function gets called when a project's token holders redeem.\n\n    @param _data The Juicebox standard project redemption data.\n\n    @return reclaimAmount The amount that should be reclaimed from the treasury.\n    @return memo The memo that should be forwarded to the event.\n    @return delegateAllocations The amount to send to delegates instead of adding to the beneficiary.\n  */\n  function redeemParams(JBRedeemParamsData calldata _data)\n    public\n    view\n    virtual\n    override\n    returns (\n      uint256 reclaimAmount,\n      string memory memo,\n      JBRedemptionDelegateAllocation[] memory delegateAllocations\n    )\n  {\n    // Make sure fungible project tokens aren't being redeemed too.\n    if (_data.tokenCount > 0) revert UNEXPECTED_TOKEN_REDEEMED();\n\n    // Check the 4 bytes interfaceId and handle the case where the metadata was not intended for this contract\n    // Skip 32 bytes reserved for generic extension parameters.\n    if (\n      _data.metadata.length < 36 ||\n      bytes4(_data.metadata[32:36]) != type(IJB721Delegate).interfaceId\n    ) {\n      revert INVALID_REDEMPTION_METADATA();\n    }\n\n    // Set the only delegate allocation to be a callback to this contract.\n    delegateAllocations = new JBRedemptionDelegateAllocation[](1);\n    delegateAllocations[0] = JBRedemptionDelegateAllocation(this, 0);\n\n    // Decode the metadata\n    (, , uint256[] memory _decodedTokenIds) = abi.decode(\n      _data.metadata,\n      (bytes32, bytes4, uint256[])\n    );\n\n    // Get a reference to the redemption rate of the provided tokens.\n    uint256 _redemptionWeight = _redemptionWeightOf(_decodedTokenIds, _data);\n\n    // Get a reference to the total redemption weight.\n    uint256 _total = _totalRedemptionWeight(_data);\n\n    // Get a reference to the linear proportion.\n    uint256 _base = PRBMath.mulDiv(_data.overflow, _redemptionWeight, _total);\n\n    // These conditions are all part of the same curve. Edge conditions are separated because fewer operation are necessary.\n    if (_data.redemptionRate == JBConstants.MAX_REDEMPTION_RATE)\n      return (_base, _data.memo, delegateAllocations);\n\n    // Return the weighted overflow, and this contract as the delegate so that tokens can be deleted.\n    return (\n      PRBMath.mulDiv(\n        _base,\n        _data.redemptionRate +\n          PRBMath.mulDiv(\n            _redemptionWeight,\n            JBConstants.MAX_REDEMPTION_RATE - _data.redemptionRate,\n            _total\n          ),\n        JBConstants.MAX_REDEMPTION_RATE\n      ),\n      _data.memo,\n      delegateAllocations\n    );\n  }\n\n  //*********************************************************************//\n  // -------------------------- public views --------------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice\n    Indicates if this contract adheres to the specified interface.\n\n    @dev\n    See {IERC165-supportsInterface}.\n\n    @param _interfaceId The ID of the interface to check for adherence to.\n  */\n  function supportsInterface(bytes4 _interfaceId)\n    public\n    view\n    virtual\n    override(ERC721, IERC165)\n    returns (bool)\n  {\n    return\n      _interfaceId == type(IJB721Delegate).interfaceId ||\n      _interfaceId == type(IJBFundingCycleDataSource).interfaceId ||\n      _interfaceId == type(IJBPayDelegate).interfaceId ||\n      _interfaceId == type(IJBRedemptionDelegate).interfaceId ||\n      super.supportsInterface(_interfaceId);\n  }\n\n  //*********************************************************************//\n  // -------------------------- constructor ---------------------------- //\n  //*********************************************************************//\n\n  /**\n    @param _projectId The ID of the project this contract's functionality applies to.\n    @param _directory The directory of terminals and controllers for projects.\n    @param _name The name of the token.\n    @param _symbol The symbol that the token should be represented by.\n  */\n  function _initialize(\n    uint256 _projectId,\n    IJBDirectory _directory,\n    string memory _name,\n    string memory _symbol\n  ) internal {\n    ERC721._initialize(_name, _symbol);\n\n    projectId = _projectId;\n    directory = _directory;\n  }\n\n  //*********************************************************************//\n  // ---------------------- external transactions ---------------------- //\n  //*********************************************************************//\n\n  /**\n    @notice \n    Part of IJBPayDelegate, this function gets called when the project receives a payment. It will mint an NFT to the contributor (_data.beneficiary) if conditions are met.\n\n    @dev \n    This function will revert if the contract calling is not one of the project's terminals. \n\n    @param _data The Juicebox standard project payment data.\n  */\n  function didPay(JBDidPayData calldata _data) external payable virtual override {\n    uint256 _projectId = projectId;\n\n    // Make sure the caller is a terminal of the project, and the call is being made on behalf of an interaction with the correct project.\n    if (\n      msg.value != 0 ||\n      !directory.isTerminalOf(_projectId, IJBPaymentTerminal(msg.sender)) ||\n      _data.projectId != _projectId\n    ) revert INVALID_PAYMENT_EVENT();\n\n    // Process the payment.\n    _processPayment(_data);\n  }\n\n  /**\n    @notice\n    Part of IJBRedeemDelegate, this function gets called when the token holder redeems. It will burn the specified NFTs to reclaim from the treasury to the _data.beneficiary.\n\n    @dev\n    This function will revert if the contract calling is not one of the project's terminals.\n\n    @param _data The Juicebox standard project redemption data.\n  */\n  function didRedeem(JBDidRedeemData calldata _data) external payable virtual override {\n    // Make sure the caller is a terminal of the project, and the call is being made on behalf of an interaction with the correct project.\n    if (\n      msg.value != 0 ||\n      !directory.isTerminalOf(projectId, IJBPaymentTerminal(msg.sender)) ||\n      _data.projectId != projectId\n    ) revert INVALID_REDEMPTION_EVENT();\n\n    // Check the 4 bytes interfaceId and handle the case where the metadata was not intended for this contract\n    // Skip 32 bytes reserved for generic extension parameters.\n    if (\n      _data.metadata.length < 36 ||\n      bytes4(_data.metadata[32:36]) != type(IJB721Delegate).interfaceId\n    ) revert INVALID_REDEMPTION_METADATA();\n\n    // Decode the metadata.\n    (, , uint256[] memory _decodedTokenIds) = abi.decode(\n      _data.metadata,\n      (bytes32, bytes4, uint256[])\n    );\n\n    // Get a reference to the number of token IDs being checked.\n    uint256 _numberOfTokenIds = _decodedTokenIds.length;\n\n    // Keep a reference to the token ID being iterated on.\n    uint256 _tokenId;\n\n    // Iterate through all tokens, burning them if the owner is correct.\n    for (uint256 _i; _i < _numberOfTokenIds; ) {\n      // Set the token's ID.\n      _tokenId = _decodedTokenIds[_i];\n\n      // Make sure the token's owner is correct.\n      if (_owners[_tokenId] != _data.holder) revert UNAUTHORIZED();\n\n      // Burn the token.\n      _burn(_tokenId);\n\n      unchecked {\n        ++_i;\n      }\n    }\n\n    // Call the hook.\n    _didBurn(_decodedTokenIds);\n  }\n\n  //*********************************************************************//\n  // ---------------------- internal transactions ---------------------- //\n  //*********************************************************************//\n\n  /** \n    @notice\n    Process a received payment.\n\n    @param _data The Juicebox standard project payment data.\n  */\n  function _processPayment(JBDidPayData calldata _data) internal virtual {\n    _data; // Prevents unused var compiler and natspec complaints.\n  }\n\n  /** \n    @notice\n    A function that will run when tokens are burned via redemption.\n\n    @param _tokenIds The IDs of the tokens that were burned.\n  */\n  function _didBurn(uint256[] memory _tokenIds) internal virtual {\n    _tokenIds;\n  }\n\n  /** \n    @notice\n    The cumulative weight the given token IDs have in redemptions compared to the `totalRedemptionWeight`. \n\n    @param _tokenIds The IDs of the tokens to get the cumulative redemption weight of.\n    @param _data The Juicebox standard project redemption data.\n\n    @return The weight.\n  */\n  function _redemptionWeightOf(uint256[] memory _tokenIds, JBRedeemParamsData calldata _data)\n    internal\n    view\n    virtual\n    returns (uint256)\n  {\n    _tokenIds; // Prevents unused var compiler and natspec complaints.\n    _data; // Prevents unused var compiler and natspec complaints.\n    return 0;\n  }\n\n  /** \n    @notice\n    The cumulative weight that all token IDs have in redemptions. \n\n    @param _data The Juicebox standard project redemption data.\n\n    @return The total weight.\n  */\n  function _totalRedemptionWeight(JBRedeemParamsData calldata _data)\n    internal\n    view\n    virtual\n    returns (uint256)\n  {\n    _data; // Prevents unused var compiler and natspec complaints.\n    return 0;\n  }\n}\n"
    },
    "contracts/abstract/Votes.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (governance/utils/Votes.sol)\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/Checkpoints.sol';\n\n/**\n * @dev This is a base abstract contract that tracks voting units, which are a measure of voting power that can be\n * transferred, and provides a system of vote delegation, where an account can delegate its voting units to a sort of\n * \"representative\" that will pool delegated voting units from different accounts and can then use it to vote in\n * decisions. In fact, voting units _must_ be delegated in order to count as actual votes, and an account has to\n * delegate those votes to itself if it wishes to participate in decisions and does not have a trusted representative.\n *\n * This contract is often combined with a token contract such that voting units correspond to token units. For an\n * example, see {ERC721Votes}.\n *\n * The full history of delegate votes is tracked on-chain so that governance protocols can consider votes as distributed\n * at a particular block number to protect against flash loans and double voting. The opt-in delegate system makes the\n * cost of this history tracking optional.\n *\n * When using this module the derived contract must implement {_getVotingUnits} (for example, make it return\n * {ERC721-balanceOf}), and can use {_transferVotingUnits} to track a change in the distribution of those units (in the\n * previous example, it would be included in {ERC721-_beforeTokenTransfer}).\n *\n * _Available since v4.5._\n */\nabstract contract Votes {\n  using Checkpoints for Checkpoints.History;\n\n  error SIGNATURE_EXPIRED();\n  error BLOCK_NOT_YET_MINED();\n  error INVALID();\n\n  /**\n   * @dev Emitted when an account changes their delegate.\n   */\n  event DelegateChanged(\n    address indexed delegator,\n    address indexed fromDelegate,\n    address indexed toDelegate\n  );\n\n  /**\n   * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n   */\n  event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n  mapping(address => address) private _delegation;\n  mapping(address => Checkpoints.History) private _delegateCheckpoints;\n  Checkpoints.History private _totalCheckpoints;\n\n  /**\n   * @dev Returns the current amount of votes that `account` has.\n   */\n  function getVotes(address account) public view virtual returns (uint256) {\n    return _delegateCheckpoints[account].latest();\n  }\n\n  /**\n   * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n   *\n   * Requirements:\n   *\n   * - `blockNumber` must have been already mined\n   */\n  function getPastVotes(address account, uint256 blockNumber)\n    public\n    view\n    virtual\n    returns (uint256)\n  {\n    return _delegateCheckpoints[account].getAtBlock(blockNumber);\n  }\n\n  /**\n   * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n   *\n   * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n   * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n   * vote.\n   *\n   * Requirements:\n   *\n   * - `blockNumber` must have been already mined\n   */\n  function getPastTotalSupply(uint256 blockNumber) public view virtual returns (uint256) {\n    if (blockNumber >= block.number) revert BLOCK_NOT_YET_MINED();\n    return _totalCheckpoints.getAtBlock(blockNumber);\n  }\n\n  /**\n   * @dev Returns the current total supply of votes.\n   */\n  function _getTotalSupply() internal view virtual returns (uint256) {\n    return _totalCheckpoints.latest();\n  }\n\n  /**\n   * @dev Returns the delegate that `account` has chosen.\n   */\n  function delegates(address account) public view virtual returns (address) {\n    return _delegation[account];\n  }\n\n  /**\n   * @dev Delegates votes from the sender to `delegatee`.\n   */\n  function delegate(address delegatee) public virtual {\n    _delegate(msg.sender, delegatee);\n  }\n\n  /**\n   * @dev Delegate all of `account`'s voting units to `delegatee`.\n   *\n   * Emits events {DelegateChanged} and {DelegateVotesChanged}.\n   */\n  function _delegate(address account, address delegatee) internal virtual {\n    address oldDelegate = delegates(account);\n    _delegation[account] = delegatee;\n\n    emit DelegateChanged(account, oldDelegate, delegatee);\n    _moveDelegateVotes(oldDelegate, delegatee, _getVotingUnits(account));\n  }\n\n  /**\n   * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to`\n   * should be zero. Total supply of voting units will be adjusted with mints and burns.\n   */\n  function _transferVotingUnits(\n    address from,\n    address to,\n    uint256 amount\n  ) internal virtual {\n    if (from == address(0)) {\n      _totalCheckpoints.push(_add, amount);\n    }\n    if (to == address(0)) {\n      _totalCheckpoints.push(_subtract, amount);\n    }\n    _moveDelegateVotes(delegates(from), delegates(to), amount);\n  }\n\n  /**\n   * @dev Moves delegated votes from one delegate to another.\n   */\n  function _moveDelegateVotes(\n    address from,\n    address to,\n    uint256 amount\n  ) private {\n    if (from != to && amount > 0) {\n      if (from != address(0)) {\n        (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount);\n        emit DelegateVotesChanged(from, oldValue, newValue);\n      }\n      if (to != address(0)) {\n        (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_add, amount);\n        emit DelegateVotesChanged(to, oldValue, newValue);\n      }\n    }\n  }\n\n  function _add(uint256 a, uint256 b) internal pure returns (uint256) {\n    return a + b;\n  }\n\n  function _subtract(uint256 a, uint256 b) internal pure returns (uint256) {\n    return a - b;\n  }\n\n  /**\n   * @dev Must return the voting units held by an account.\n   */\n  function _getVotingUnits(address) internal view virtual returns (uint256);\n}\n"
    },
    "contracts/enums/JB721GovernanceType.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum JB721GovernanceType {\n  NONE,\n  TIERED,\n  GLOBAL\n}\n"
    },
    "contracts/interfaces/IJB721Delegate.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBDirectory.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBTokenUriResolver.sol';\n\ninterface IJB721Delegate {\n  event SetBaseUri(string indexed baseUri, address caller);\n\n  event SetContractUri(string indexed contractUri, address caller);\n\n  event SetTokenUriResolver(IJBTokenUriResolver indexed newResolver, address caller);\n\n  function projectId() external view returns (uint256);\n\n  function directory() external view returns (IJBDirectory);\n\n  function setBaseUri(string memory _baseUri) external;\n\n  function setContractUri(string calldata _contractMetadataUri) external;\n\n  function setTokenUriResolver(IJBTokenUriResolver _tokenUriResolver) external;\n}\n"
    },
    "contracts/interfaces/IJB721TieredGovernance.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './../structs/JBTiered721SetTierDelegatesData.sol';\nimport './IJBTiered721Delegate.sol';\n\ninterface IJB721TieredGovernance is IJBTiered721Delegate {\n  event TierDelegateChanged(\n    address indexed delegator,\n    address indexed fromDelegate,\n    address indexed toDelegate,\n    uint256 tierId,\n    address caller\n  );\n\n  event TierDelegateVotesChanged(\n    address indexed delegate,\n    uint256 indexed tierId,\n    uint256 previousBalance,\n    uint256 newBalance,\n    address callre\n  );\n\n  event DelegateChanged(\n    address indexed delegator,\n    address indexed fromDelegate,\n    address indexed toDelegate\n  );\n\n  function getTierDelegate(address _account, uint256 _tier) external view returns (address);\n\n  function getTierVotes(address _account, uint256 _tier) external view returns (uint256);\n\n  function getPastTierVotes(\n    address _account,\n    uint256 _tier,\n    uint256 _blockNumber\n  ) external view returns (uint256);\n\n  function getTierTotalVotes(uint256 _tier) external view returns (uint256);\n\n  function getPastTierTotalVotes(uint256 _tier, uint256 _blockNumber)\n    external\n    view\n    returns (uint256);\n\n  function setTierDelegate(address _delegatee, uint256 _tierId) external;\n\n  function setTierDelegates(JBTiered721SetTierDelegatesData[] memory _setTierDelegatesData)\n    external;\n}\n"
    },
    "contracts/interfaces/IJBTiered721Delegate.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBDirectory.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBFundingCycleStore.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBPrices.sol';\nimport './../structs/JB721PricingParams.sol';\nimport './../structs/JB721TierParams.sol';\nimport './../structs/JBTiered721MintReservesForTiersData.sol';\nimport './../structs/JBTiered721MintForTiersData.sol';\nimport './IJB721Delegate.sol';\nimport './IJBTiered721DelegateStore.sol';\n\ninterface IJBTiered721Delegate is IJB721Delegate {\n  event Mint(\n    uint256 indexed tokenId,\n    uint256 indexed tierId,\n    address indexed beneficiary,\n    uint256 totalAmountContributed,\n    address caller\n  );\n\n  event MintReservedToken(\n    uint256 indexed tokenId,\n    uint256 indexed tierId,\n    address indexed beneficiary,\n    address caller\n  );\n\n  event AddTier(uint256 indexed tierId, JB721TierParams data, address caller);\n\n  event RemoveTier(uint256 indexed tierId, address caller);\n\n  event SetDefaultReservedTokenBeneficiary(address indexed beneficiary, address caller);\n\n  function codeOrigin() external view returns (address);\n\n  function store() external view returns (IJBTiered721DelegateStore);\n\n  function fundingCycleStore() external view returns (IJBFundingCycleStore);\n\n  function prices() external view returns (IJBPrices);\n\n  function pricingCurrency() external view returns (uint256);\n\n  function pricingDecimals() external view returns (uint256);\n\n  function contractURI() external view returns (string memory);\n\n  function creditsOf(address _address) external view returns (uint256);\n\n  function firstOwnerOf(uint256 _tokenId) external view returns (address);\n\n  function adjustTiers(JB721TierParams[] memory _tierDataToAdd, uint256[] memory _tierIdsToRemove)\n    external;\n\n  function mintReservesFor(JBTiered721MintReservesForTiersData[] memory _mintReservesForTiersData)\n    external;\n\n  function mintReservesFor(uint256 _tierId, uint256 _count) external;\n\n  function mintFor(JBTiered721MintForTiersData[] memory _mintForTiersData) external;\n\n  function mintFor(uint16[] calldata _tierIds, address _beneficiary)\n    external\n    returns (uint256[] memory tokenIds);\n\n  function setDefaultReservedTokenBeneficiary(address _beneficiary) external;\n\n  function initialize(\n    uint256 _projectId,\n    IJBDirectory _directory,\n    string memory _name,\n    string memory _symbol,\n    IJBFundingCycleStore _fundingCycleStore,\n    string memory _baseUri,\n    IJBTokenUriResolver _tokenUriResolver,\n    string memory _contractUri,\n    JB721PricingParams memory _pricing,\n    IJBTiered721DelegateStore _store,\n    JBTiered721Flags memory _flags\n  ) external;\n}\n"
    },
    "contracts/interfaces/IJBTiered721DelegateDeployer.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '../enums/JB721GovernanceType.sol';\nimport '../structs/JBDeployTiered721DelegateData.sol';\nimport './IJBTiered721Delegate.sol';\n\ninterface IJBTiered721DelegateDeployer {\n  event DelegateDeployed(\n    uint256 indexed projectId,\n    IJBTiered721Delegate newDelegate,\n    JB721GovernanceType governanceType\n  );\n\n  function deployDelegateFor(\n    uint256 _projectId,\n    JBDeployTiered721DelegateData memory _deployTieredNFTRewardDelegateData\n  ) external returns (IJBTiered721Delegate delegate);\n}\n"
    },
    "contracts/interfaces/IJBTiered721DelegateStore.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBTokenUriResolver.sol';\nimport './../structs/JB721TierParams.sol';\nimport './../structs/JB721Tier.sol';\nimport './../structs/JBTiered721Flags.sol';\n\ninterface IJBTiered721DelegateStore {\n  event CleanTiers(address indexed nft, address caller);\n\n  function totalSupply(address _nft) external view returns (uint256);\n\n  function balanceOf(address _nft, address _owner) external view returns (uint256);\n\n  function maxTierIdOf(address _nft) external view returns (uint256);\n\n  function tiers(\n    address _nft,\n    uint256 _startingSortIndex,\n    uint256 _size\n  ) external view returns (JB721Tier[] memory tiers);\n\n  function tier(address _nft, uint256 _id) external view returns (JB721Tier memory tier);\n\n  function tierBalanceOf(\n    address _nft,\n    address _owner,\n    uint256 _tier\n  ) external view returns (uint256);\n\n  function tierOfTokenId(address _nft, uint256 _tokenId)\n    external\n    view\n    returns (JB721Tier memory tier);\n\n  function tierIdOfToken(uint256 _tokenId) external pure returns (uint256);\n\n  function encodedIPFSUriOf(address _nft, uint256 _tierId) external view returns (bytes32);\n\n  function firstOwnerOf(address _nft, uint256 _tokenId) external view returns (address);\n\n  function redemptionWeightOf(address _nft, uint256[] memory _tokenIds)\n    external\n    view\n    returns (uint256 weight);\n\n  function totalRedemptionWeight(address _nft) external view returns (uint256 weight);\n\n  function numberOfReservedTokensOutstandingFor(address _nft, uint256 _tierId)\n    external\n    view\n    returns (uint256);\n\n  function numberOfReservesMintedFor(address _nft, uint256 _tierId) external view returns (uint256);\n\n  function numberOfBurnedFor(address _nft, uint256 _tierId) external view returns (uint256);\n\n  function isTierRemoved(address _nft, uint256 _tierId) external view returns (bool);\n\n  function flagsOf(address _nft) external view returns (JBTiered721Flags memory);\n\n  function votingUnitsOf(address _nft, address _account) external view returns (uint256 units);\n\n  function tierVotingUnitsOf(\n    address _nft,\n    address _account,\n    uint256 _tierId\n  ) external view returns (uint256 units);\n\n  function defaultReservedTokenBeneficiaryOf(address _nft) external view returns (address);\n\n  function reservedTokenBeneficiaryOf(address _nft, uint256 _tierId)\n    external\n    view\n    returns (address);\n\n  function baseUriOf(address _nft) external view returns (string memory);\n\n  function contractUriOf(address _nft) external view returns (string memory);\n\n  function tokenUriResolverOf(address _nft) external view returns (IJBTokenUriResolver);\n\n  function encodedTierIPFSUriOf(address _nft, uint256 _tokenId) external view returns (bytes32);\n\n  function recordAddTiers(JB721TierParams[] memory _tierData)\n    external\n    returns (uint256[] memory tierIds);\n\n  function recordMintReservesFor(uint256 _tierId, uint256 _count)\n    external\n    returns (uint256[] memory tokenIds);\n\n  function recordMintBestAvailableTier(uint256 _amount)\n    external\n    returns (\n      uint256 tokenId,\n      uint256 tierId,\n      uint256 leftoverAmount\n    );\n\n  function recordBurn(uint256[] memory _tokenIds) external;\n\n  function recordSetDefaultReservedTokenBeneficiary(address _beneficiary) external;\n\n  function recordMint(\n    uint256 _amount,\n    uint16[] calldata _tierIds,\n    bool _isManualMint\n  ) external returns (uint256[] memory tokenIds, uint256 leftoverAmount);\n\n  function recordTransferForTier(\n    uint256 _tierId,\n    address _from,\n    address _to\n  ) external;\n\n  function recordRemoveTierIds(uint256[] memory _tierIds) external;\n\n  function recordSetFirstOwnerOf(uint256 _tokenId, address _owner) external;\n\n  function recordSetBaseUri(string memory _uri) external;\n\n  function recordSetContractUri(string memory _uri) external;\n\n  function recordSetTokenUriResolver(IJBTokenUriResolver _resolver) external;\n\n  function recordFlags(JBTiered721Flags calldata _flag) external;\n\n  function cleanTiers(address _nft) external;\n}\n"
    },
    "contracts/libraries/JBIpfsDecoder.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\n/**\n  \n  @notice\n  Utilities to decode an IPFS hash.\n\n  @dev\n  This is fairly gas intensive, due to multiple nested loops, onchain \n  IPFS hash decoding is therefore not advised (storing them as a string,\n  in that use-case, *might* be more efficient).\n\n*/\nlibrary JBIpfsDecoder {\n  //*********************************************************************//\n  // ------------------- internal constant properties ------------------ //\n  //*********************************************************************//\n\n  /**\n    @notice\n    Just a kind reminder to our readers\n\n    @dev\n    Used in base58ToString\n  */\n  bytes internal constant _ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n\n  function decode(string memory _baseUri, bytes32 _hexString)\n    internal\n    pure\n    returns (string memory)\n  {\n    // Concatenate the hex string with the fixed IPFS hash part (0x12 and 0x20)\n    bytes memory completeHexString = abi.encodePacked(bytes2(0x1220), _hexString);\n\n    // Convert the hex string to a hash\n    string memory ipfsHash = _toBase58(completeHexString);\n\n    // Concatenate with the base URI\n    return string(abi.encodePacked(_baseUri, ipfsHash));\n  }\n\n  /**\n    @notice\n    Convert a hex string to base58\n\n    @notice \n    Written by Martin Ludfall - Licence: MIT\n  */\n  function _toBase58(bytes memory _source) private pure returns (string memory) {\n    if (_source.length == 0) return new string(0);\n\n    uint8[] memory digits = new uint8[](46); // hash size with the prefix\n\n    digits[0] = 0;\n\n    uint8 digitlength = 1;\n    uint256 _sourceLength = _source.length;\n\n    for (uint256 i; i < _sourceLength; ) {\n      uint256 carry = uint8(_source[i]);\n\n      for (uint256 j; j < digitlength; ) {\n        carry += uint256(digits[j]) << 8; // mul 256\n        digits[j] = uint8(carry % 58);\n        carry = carry / 58;\n\n        unchecked {\n          ++j;\n        }\n      }\n\n      while (carry > 0) {\n        digits[digitlength] = uint8(carry % 58);\n        unchecked {\n          ++digitlength;\n        }\n        carry = carry / 58;\n      }\n\n      unchecked {\n        ++i;\n      }\n    }\n    return string(_toAlphabet(_reverse(_truncate(digits, digitlength))));\n  }\n\n  function _truncate(uint8[] memory _array, uint8 _length) private pure returns (uint8[] memory) {\n    uint8[] memory output = new uint8[](_length);\n    for (uint256 i; i < _length; ) {\n      output[i] = _array[i];\n\n      unchecked {\n        ++i;\n      }\n    }\n    return output;\n  }\n\n  function _reverse(uint8[] memory _input) private pure returns (uint8[] memory) {\n    uint256 _inputLength = _input.length;\n    uint8[] memory output = new uint8[](_inputLength);\n    for (uint256 i; i < _inputLength; ) {\n      unchecked {\n        output[i] = _input[_input.length - 1 - i];\n        ++i;\n      }\n    }\n    return output;\n  }\n\n  function _toAlphabet(uint8[] memory _indices) private pure returns (bytes memory) {\n    uint256 _indicesLength = _indices.length;\n    bytes memory output = new bytes(_indicesLength);\n    for (uint256 i; i < _indicesLength; ) {\n      output[i] = _ALPHABET[_indices[i]];\n\n      unchecked {\n        ++i;\n      }\n    }\n    return output;\n  }\n}\n"
    },
    "contracts/libraries/JBTiered721FundingCycleMetadataResolver.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport './../structs/JBTiered721FundingCycleMetadata.sol';\n\nlibrary JBTiered721FundingCycleMetadataResolver {\n  function transfersPaused(uint256 _data) internal pure returns (bool) {\n    return (_data & 1) == 1;\n  }\n\n  function mintingReservesPaused(uint256 _data) internal pure returns (bool) {\n    return ((_data >> 1) & 1) == 1;\n  }\n\n  /**\n    @notice\n    Pack the tiered 721 funding cycle metadata.\n\n    @param _metadata The metadata to validate and pack.\n\n    @return packed The packed uint256 of all tiered 721 metadata params.\n  */\n  function packFundingCycleGlobalMetadata(JBTiered721FundingCycleMetadata memory _metadata)\n    internal\n    pure\n    returns (uint256 packed)\n  {\n    // pause transfers in bit 0.\n    if (_metadata.pauseTransfers) packed |= 1;\n    // pause mint reserves in bit 2.\n    if (_metadata.pauseMintingReserves) packed |= 1 << 1;\n  }\n\n  /**\n    @notice\n    Expand the tiered 721 funding cycle metadata.\n\n    @param _packedMetadata The packed metadata to expand.\n\n    @return metadata The tiered 721 metadata object.\n  */\n  function expandMetadata(uint8 _packedMetadata)\n    internal\n    pure\n    returns (JBTiered721FundingCycleMetadata memory metadata)\n  {\n    return\n      JBTiered721FundingCycleMetadata(\n        transfersPaused(_packedMetadata),\n        mintingReservesPaused(_packedMetadata)\n      );\n  }\n}\n"
    },
    "contracts/structs/JB721PricingParams.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBPrices.sol';\nimport './JB721TierParams.sol';\n\n/**\n  @member tiers The tiers to set.\n  @member currency The currency that the tier contribution floors are denoted in.\n  @member decimals The number of decimals included in the tier contribution floor fixed point numbers.\n  @member prices A contract that exposes price feeds that can be used to resolved the value of a contributions that are sent in different currencies. Set to the zero address if payments must be made in `currency`.\n*/\nstruct JB721PricingParams {\n  JB721TierParams[] tiers;\n  uint256 currency;\n  uint256 decimals;\n  IJBPrices prices;\n}\n"
    },
    "contracts/structs/JB721Tier.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\n/**\n  @member id The tier's ID.\n  @member contributionFloor The minimum contribution to qualify for this tier.\n  @member lockedUntil The time up to which this tier cannot be removed or paused.\n  @member remainingQuantity Remaining number of tokens in this tier. Together with idCeiling this enables for consecutive, increasing token ids to be issued to contributors.\n  @member initialQuantity The initial `remainingAllowance` value when the tier was set.\n  @member votingUnits The amount of voting significance to give this tier compared to others.\n  @member reservedRate The number of minted tokens needed in the tier to allow for minting another reserved token.\n  @member reservedRateBeneficiary The beneificary of the reserved tokens for this tier.\n  @member encodedIPFSUri The URI to use for each token within the tier.\n  @member allowManualMint A flag indicating if the contract's owner can mint from this tier on demand.\n  @member transfersPausable A flag indicating if transfers from this tier can be pausable. \n*/\nstruct JB721Tier {\n  uint256 id;\n  uint256 contributionFloor;\n  uint256 lockedUntil;\n  uint256 remainingQuantity;\n  uint256 initialQuantity;\n  uint256 votingUnits;\n  uint256 reservedRate;\n  address reservedTokenBeneficiary;\n  bytes32 encodedIPFSUri;\n  bool allowManualMint;\n  bool transfersPausable;\n}\n"
    },
    "contracts/structs/JB721TierParams.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n  @member contributionFloor The minimum contribution to qualify for this tier.\n  @member lockedUntil The time up to which this tier cannot be removed or paused.\n  @member initialQuantity The initial `remainingAllowance` value when the tier was set.\n  @member votingUnits The amount of voting significance to give this tier compared to others.\n  @memver reservedRate The number of minted tokens needed in the tier to allow for minting another reserved token.\n  @member reservedRateBeneficiary The beneificary of the reserved tokens for this tier.\n  @member encodedIPFSUri The URI to use for each token within the tier.\n  @member allowManualMint A flag indicating if the contract's owner can mint from this tier on demand.\n  @member shouldUseBeneficiaryAsDefault A flag indicating if the `reservedTokenBeneficiary` should be stored as the default beneficiary for all tiers.\n  @member transfersPausable A flag indicating if transfers from this tier can be pausable. \n*/\nstruct JB721TierParams {\n  uint80 contributionFloor;\n  uint48 lockedUntil;\n  uint40 initialQuantity;\n  uint16 votingUnits;\n  uint16 reservedRate;\n  address reservedTokenBeneficiary;\n  bytes32 encodedIPFSUri;\n  bool allowManualMint;\n  bool shouldUseBeneficiaryAsDefault;\n  bool transfersPausable;\n}\n"
    },
    "contracts/structs/JBDeployTiered721DelegateData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBDirectory.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBFundingCycleStore.sol';\nimport '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBTokenUriResolver.sol';\nimport './../enums/JB721GovernanceType.sol';\nimport './../interfaces/IJBTiered721DelegateStore.sol';\nimport './JB721PricingParams.sol';\nimport './JBTiered721Flags.sol';\n\n/**\n  @member directory The directory of terminals and controllers for projects.\n  @member name The name of the token.\n  @member symbol The symbol that the token should be represented by.\n  @member fundingCycleStore A contract storing all funding cycle configurations.\n  @member baseUri A URI to use as a base for full token URIs.\n  @member tokenUriResolver A contract responsible for resolving the token URI for each token ID.\n  @member contractUri A URI where contract metadata can be found. \n  @member owner The address that should own this contract.\n  @member pricing The tier pricing according to which token distribution will be made. \n  @member reservedTokenBeneficiary The address receiving the reserved token\n  @member store The store contract to use.\n  @member flags A set of flags that help define how this contract works.\n  @member governanceType The type of governance to allow the NFTs to be used for.\n*/\nstruct JBDeployTiered721DelegateData {\n  IJBDirectory directory;\n  string name;\n  string symbol;\n  IJBFundingCycleStore fundingCycleStore;\n  string baseUri;\n  IJBTokenUriResolver tokenUriResolver;\n  string contractUri;\n  address owner;\n  JB721PricingParams pricing;\n  address reservedTokenBeneficiary;\n  IJBTiered721DelegateStore store;\n  JBTiered721Flags flags;\n  JB721GovernanceType governanceType;\n}\n"
    },
    "contracts/structs/JBTiered721Flags.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/** \n  @member lockReservedTokenChanges A flag indicating if reserved tokens can change over time by adding new tiers with a reserved rate.\n  @member lockVotingUnitChanges A flag indicating if voting unit expectations can change over time by adding new tiers with voting units.\n  @member lockManualMintingChanges A flag indicating if manual minting expectations can change over time by adding new tiers with manual minting.\n*/\nstruct JBTiered721Flags {\n  bool lockReservedTokenChanges;\n  bool lockVotingUnitChanges;\n  bool lockManualMintingChanges;\n}\n"
    },
    "contracts/structs/JBTiered721FundingCycleMetadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/** \n  @member pauseTransfers A flag indicating if the token transfer functionality should be paused during the funding cycle.\n  @member pauseMintingReserves A flag indicating if voting unit expectations can change over time by adding new tiers with voting units.\n*/\nstruct JBTiered721FundingCycleMetadata {\n  bool pauseTransfers;\n  bool pauseMintingReserves;\n}\n"
    },
    "contracts/structs/JBTiered721MintForTiersData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/** \n  @member tierIds The IDs of the tier to mint within.\n  @member beneficiary The beneficiary to mint for. \n*/\nstruct JBTiered721MintForTiersData {\n  uint16[] tierIds;\n  address beneficiary;\n}\n"
    },
    "contracts/structs/JBTiered721MintReservesForTiersData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/** \n  @member tierId The ID of the tier to mint within.\n  @member count The number of reserved tokens to mint. \n*/\nstruct JBTiered721MintReservesForTiersData {\n  uint256 tierId;\n  uint256 count;\n}\n"
    },
    "contracts/structs/JBTiered721SetTierDelegatesData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/** \n  @member delegatee The account to delegate tier voting units to.\n  @member tierId The ID of the tier to delegate voting units for.\n*/\nstruct JBTiered721SetTierDelegatesData {\n  address delegatee;\n  uint256 tierId;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/enums/JBBallotState.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum JBBallotState {\n  Active,\n  Approved,\n  Failed\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBDirectory.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './IJBFundingCycleStore.sol';\nimport './IJBPaymentTerminal.sol';\nimport './IJBProjects.sol';\n\ninterface IJBDirectory {\n  event SetController(uint256 indexed projectId, address indexed controller, address caller);\n\n  event AddTerminal(uint256 indexed projectId, IJBPaymentTerminal indexed terminal, address caller);\n\n  event SetTerminals(uint256 indexed projectId, IJBPaymentTerminal[] terminals, address caller);\n\n  event SetPrimaryTerminal(\n    uint256 indexed projectId,\n    address indexed token,\n    IJBPaymentTerminal indexed terminal,\n    address caller\n  );\n\n  event SetIsAllowedToSetFirstController(address indexed addr, bool indexed flag, address caller);\n\n  function projects() external view returns (IJBProjects);\n\n  function fundingCycleStore() external view returns (IJBFundingCycleStore);\n\n  function controllerOf(uint256 _projectId) external view returns (address);\n\n  function isAllowedToSetFirstController(address _address) external view returns (bool);\n\n  function terminalsOf(uint256 _projectId) external view returns (IJBPaymentTerminal[] memory);\n\n  function isTerminalOf(uint256 _projectId, IJBPaymentTerminal _terminal)\n    external\n    view\n    returns (bool);\n\n  function primaryTerminalOf(uint256 _projectId, address _token)\n    external\n    view\n    returns (IJBPaymentTerminal);\n\n  function setControllerOf(uint256 _projectId, address _controller) external;\n\n  function setTerminalsOf(uint256 _projectId, IJBPaymentTerminal[] calldata _terminals) external;\n\n  function setPrimaryTerminalOf(\n    uint256 _projectId,\n    address _token,\n    IJBPaymentTerminal _terminal\n  ) external;\n\n  function setIsAllowedToSetFirstController(address _address, bool _flag) external;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBFundingCycleBallot.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\nimport './../enums/JBBallotState.sol';\n\ninterface IJBFundingCycleBallot is IERC165 {\n  function duration() external view returns (uint256);\n\n  function stateOf(\n    uint256 _projectId,\n    uint256 _configuration,\n    uint256 _start\n  ) external view returns (JBBallotState);\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBFundingCycleDataSource.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\nimport './../structs/JBPayDelegateAllocation.sol';\nimport './../structs/JBPayParamsData.sol';\nimport './../structs/JBRedeemParamsData.sol';\nimport './../structs/JBRedemptionDelegateAllocation.sol';\n\n/**\n  @title\n  Datasource\n\n  @notice\n  The datasource is called by JBPaymentTerminal on pay and redemption, and provide an extra layer of logic to use \n  a custom weight, a custom memo and/or a pay/redeem delegate\n\n  @dev\n  Adheres to:\n  IERC165 for adequate interface integration\n*/\ninterface IJBFundingCycleDataSource is IERC165 {\n  /**\n    @notice\n    The datasource implementation for JBPaymentTerminal.pay(..)\n\n    @param _data the data passed to the data source in terminal.pay(..), as a JBPayParamsData struct:\n                  IJBPaymentTerminal terminal;\n                  address payer;\n                  JBTokenAmount amount;\n                  uint256 projectId;\n                  uint256 currentFundingCycleConfiguration;\n                  address beneficiary;\n                  uint256 weight;\n                  uint256 reservedRate;\n                  string memo;\n                  bytes metadata;\n\n    @return weight the weight to use to override the funding cycle weight\n    @return memo the memo to override the pay(..) memo\n    @return delegateAllocations The amount to send to delegates instead of adding to the local balance.\n  */\n  function payParams(JBPayParamsData calldata _data)\n    external\n    returns (\n      uint256 weight,\n      string memory memo,\n      JBPayDelegateAllocation[] memory delegateAllocations\n    );\n\n  /**\n    @notice\n    The datasource implementation for JBPaymentTerminal.redeemTokensOf(..)\n\n    @param _data the data passed to the data source in terminal.redeemTokensOf(..), as a JBRedeemParamsData struct:\n                    IJBPaymentTerminal terminal;\n                    address holder;\n                    uint256 projectId;\n                    uint256 currentFundingCycleConfiguration;\n                    uint256 tokenCount;\n                    uint256 totalSupply;\n                    uint256 overflow;\n                    JBTokenAmount reclaimAmount;\n                    bool useTotalOverflow;\n                    uint256 redemptionRate;\n                    uint256 ballotRedemptionRate;\n                    string memo;\n                    bytes metadata;\n\n    @return reclaimAmount The amount to claim, overriding the terminal logic.\n    @return memo The memo to override the redeemTokensOf(..) memo.\n    @return delegateAllocations The amount to send to delegates instead of adding to the beneficiary.\n  */\n  function redeemParams(JBRedeemParamsData calldata _data)\n    external\n    returns (\n      uint256 reclaimAmount,\n      string memory memo,\n      JBRedemptionDelegateAllocation[] memory delegateAllocations\n    );\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBFundingCycleStore.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './../enums/JBBallotState.sol';\nimport './../structs/JBFundingCycle.sol';\nimport './../structs/JBFundingCycleData.sol';\n\ninterface IJBFundingCycleStore {\n  event Configure(\n    uint256 indexed configuration,\n    uint256 indexed projectId,\n    JBFundingCycleData data,\n    uint256 metadata,\n    uint256 mustStartAtOrAfter,\n    address caller\n  );\n\n  event Init(uint256 indexed configuration, uint256 indexed projectId, uint256 indexed basedOn);\n\n  function latestConfigurationOf(uint256 _projectId) external view returns (uint256);\n\n  function get(uint256 _projectId, uint256 _configuration)\n    external\n    view\n    returns (JBFundingCycle memory);\n\n  function latestConfiguredOf(uint256 _projectId)\n    external\n    view\n    returns (JBFundingCycle memory fundingCycle, JBBallotState ballotState);\n\n  function queuedOf(uint256 _projectId) external view returns (JBFundingCycle memory fundingCycle);\n\n  function currentOf(uint256 _projectId) external view returns (JBFundingCycle memory fundingCycle);\n\n  function currentBallotStateOf(uint256 _projectId) external view returns (JBBallotState);\n\n  function configureFor(\n    uint256 _projectId,\n    JBFundingCycleData calldata _data,\n    uint256 _metadata,\n    uint256 _mustStartAtOrAfter\n  ) external returns (JBFundingCycle memory fundingCycle);\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBPayDelegate.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\nimport './../structs/JBDidPayData.sol';\n\n/**\n  @title\n  Pay delegate\n\n  @notice\n  Delegate called after JBTerminal.pay(..) logic completion (if passed by the funding cycle datasource)\n\n  @dev\n  Adheres to:\n  IERC165 for adequate interface integration\n*/\ninterface IJBPayDelegate is IERC165 {\n  /**\n    @notice\n    This function is called by JBPaymentTerminal.pay(..), after the execution of its logic\n\n    @dev\n    Critical business logic should be protected by an appropriate access control\n    \n    @param _data the data passed by the terminal, as a JBDidPayData struct:\n                  address payer;\n                  uint256 projectId;\n                  uint256 currentFundingCycleConfiguration;\n                  JBTokenAmount amount;\n                  JBTokenAmount forwardedAmount;\n                  uint256 projectTokenCount;\n                  address beneficiary;\n                  bool preferClaimedTokens;\n                  string memo;\n                  bytes metadata;\n  */\n  function didPay(JBDidPayData calldata _data) external payable;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBPaymentTerminal.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\n\ninterface IJBPaymentTerminal is IERC165 {\n  function acceptsToken(address _token, uint256 _projectId) external view returns (bool);\n\n  function currencyForToken(address _token) external view returns (uint256);\n\n  function decimalsForToken(address _token) external view returns (uint256);\n\n  // Return value must be a fixed point number with 18 decimals.\n  function currentEthOverflowOf(uint256 _projectId) external view returns (uint256);\n\n  function pay(\n    uint256 _projectId,\n    uint256 _amount,\n    address _token,\n    address _beneficiary,\n    uint256 _minReturnedTokens,\n    bool _preferClaimedTokens,\n    string calldata _memo,\n    bytes calldata _metadata\n  ) external payable returns (uint256 beneficiaryTokenCount);\n\n  function addToBalanceOf(\n    uint256 _projectId,\n    uint256 _amount,\n    address _token,\n    string calldata _memo,\n    bytes calldata _metadata\n  ) external payable;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBPriceFeed.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IJBPriceFeed {\n  function currentPrice(uint256 _targetDecimals) external view returns (uint256);\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBPrices.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './IJBPriceFeed.sol';\n\ninterface IJBPrices {\n  event AddFeed(uint256 indexed currency, uint256 indexed base, IJBPriceFeed feed);\n\n  function feedFor(uint256 _currency, uint256 _base) external view returns (IJBPriceFeed);\n\n  function priceFor(\n    uint256 _currency,\n    uint256 _base,\n    uint256 _decimals\n  ) external view returns (uint256);\n\n  function addFeedFor(\n    uint256 _currency,\n    uint256 _base,\n    IJBPriceFeed _priceFeed\n  ) external;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBProjects.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport './../structs/JBProjectMetadata.sol';\nimport './IJBTokenUriResolver.sol';\n\ninterface IJBProjects is IERC721 {\n  event Create(\n    uint256 indexed projectId,\n    address indexed owner,\n    JBProjectMetadata metadata,\n    address caller\n  );\n\n  event SetMetadata(uint256 indexed projectId, JBProjectMetadata metadata, address caller);\n\n  event SetTokenUriResolver(IJBTokenUriResolver indexed resolver, address caller);\n\n  function count() external view returns (uint256);\n\n  function metadataContentOf(uint256 _projectId, uint256 _domain)\n    external\n    view\n    returns (string memory);\n\n  function tokenUriResolver() external view returns (IJBTokenUriResolver);\n\n  function createFor(address _owner, JBProjectMetadata calldata _metadata)\n    external\n    returns (uint256 projectId);\n\n  function setMetadataOf(uint256 _projectId, JBProjectMetadata calldata _metadata) external;\n\n  function setTokenUriResolver(IJBTokenUriResolver _newResolver) external;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBRedemptionDelegate.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\nimport './../structs/JBDidRedeemData.sol';\n\n/**\n  @title\n  Redemption delegate\n\n  @notice\n  Delegate called after JBTerminal.redeemTokensOf(..) logic completion (if passed by the funding cycle datasource)\n\n  @dev\n  Adheres to:\n  IERC165 for adequate interface integration\n*/\ninterface IJBRedemptionDelegate is IERC165 {\n  /**\n    @notice\n    This function is called by JBPaymentTerminal.redeemTokensOf(..), after the execution of its logic\n\n    @dev\n    Critical business logic should be protected by an appropriate access control\n    \n    @param _data the data passed by the terminal, as a JBDidRedeemData struct:\n                address holder;\n                uint256 projectId;\n                uint256 currentFundingCycleConfiguration;\n                uint256 projectTokenCount;\n                JBTokenAmount reclaimedAmount;\n                JBTokenAmount forwardedAmount;\n                address payable beneficiary;\n                string memo;\n                bytes metadata;\n  */\n  function didRedeem(JBDidRedeemData calldata _data) external payable;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBTokenUriResolver.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IJBTokenUriResolver {\n  function getUri(uint256 _projectId) external view returns (string memory tokenUri);\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/libraries/JBConstants.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n  @notice\n  Global constants used across Juicebox contracts.\n*/\nlibrary JBConstants {\n  uint256 public constant MAX_RESERVED_RATE = 10_000;\n  uint256 public constant MAX_REDEMPTION_RATE = 10_000;\n  uint256 public constant MAX_DISCOUNT_RATE = 1_000_000_000;\n  uint256 public constant SPLITS_TOTAL_PERCENT = 1_000_000_000;\n  uint256 public constant MAX_FEE = 1_000_000_000;\n  uint256 public constant MAX_FEE_DISCOUNT = 1_000_000_000;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/libraries/JBFundingCycleMetadataResolver.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport './../structs/JBFundingCycle.sol';\nimport './../structs/JBFundingCycleMetadata.sol';\nimport './../structs/JBGlobalFundingCycleMetadata.sol';\nimport './JBConstants.sol';\nimport './JBGlobalFundingCycleMetadataResolver.sol';\n\nlibrary JBFundingCycleMetadataResolver {\n  function global(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (JBGlobalFundingCycleMetadata memory)\n  {\n    return JBGlobalFundingCycleMetadataResolver.expandMetadata(uint8(_fundingCycle.metadata >> 8));\n  }\n\n  function reservedRate(JBFundingCycle memory _fundingCycle) internal pure returns (uint256) {\n    return uint256(uint16(_fundingCycle.metadata >> 24));\n  }\n\n  function redemptionRate(JBFundingCycle memory _fundingCycle) internal pure returns (uint256) {\n    // Redemption rate is a number 0-10000. It's inverse was stored so the most common case of 100% results in no storage needs.\n    return JBConstants.MAX_REDEMPTION_RATE - uint256(uint16(_fundingCycle.metadata >> 40));\n  }\n\n  function ballotRedemptionRate(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (uint256)\n  {\n    // Redemption rate is a number 0-10000. It's inverse was stored so the most common case of 100% results in no storage needs.\n    return JBConstants.MAX_REDEMPTION_RATE - uint256(uint16(_fundingCycle.metadata >> 56));\n  }\n\n  function payPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {\n    return ((_fundingCycle.metadata >> 72) & 1) == 1;\n  }\n\n  function distributionsPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {\n    return ((_fundingCycle.metadata >> 73) & 1) == 1;\n  }\n\n  function redeemPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {\n    return ((_fundingCycle.metadata >> 74) & 1) == 1;\n  }\n\n  function burnPaused(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {\n    return ((_fundingCycle.metadata >> 75) & 1) == 1;\n  }\n\n  function mintingAllowed(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {\n    return ((_fundingCycle.metadata >> 76) & 1) == 1;\n  }\n\n  function terminalMigrationAllowed(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (bool)\n  {\n    return ((_fundingCycle.metadata >> 77) & 1) == 1;\n  }\n\n  function controllerMigrationAllowed(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (bool)\n  {\n    return ((_fundingCycle.metadata >> 78) & 1) == 1;\n  }\n\n  function shouldHoldFees(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {\n    return ((_fundingCycle.metadata >> 79) & 1) == 1;\n  }\n\n  function preferClaimedTokenOverride(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (bool)\n  {\n    return ((_fundingCycle.metadata >> 80) & 1) == 1;\n  }\n\n  function useTotalOverflowForRedemptions(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (bool)\n  {\n    return ((_fundingCycle.metadata >> 81) & 1) == 1;\n  }\n\n  function useDataSourceForPay(JBFundingCycle memory _fundingCycle) internal pure returns (bool) {\n    return (_fundingCycle.metadata >> 82) & 1 == 1;\n  }\n\n  function useDataSourceForRedeem(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (bool)\n  {\n    return (_fundingCycle.metadata >> 83) & 1 == 1;\n  }\n\n  function dataSource(JBFundingCycle memory _fundingCycle) internal pure returns (address) {\n    return address(uint160(_fundingCycle.metadata >> 84));\n  }\n\n  function metadata(JBFundingCycle memory _fundingCycle) internal pure returns (uint256) {\n    return uint256(uint8(_fundingCycle.metadata >> 244));\n  }\n\n  /**\n    @notice\n    Pack the funding cycle metadata.\n\n    @param _metadata The metadata to validate and pack.\n\n    @return packed The packed uint256 of all metadata params. The first 8 bits specify the version.\n  */\n  function packFundingCycleMetadata(JBFundingCycleMetadata memory _metadata)\n    internal\n    pure\n    returns (uint256 packed)\n  {\n    // version 1 in the bits 0-7 (8 bits).\n    packed = 1;\n    // global metadta in bits 8-23 (16 bits).\n    packed |=\n      JBGlobalFundingCycleMetadataResolver.packFundingCycleGlobalMetadata(_metadata.global) <<\n      8;\n    // reserved rate in bits 24-39 (16 bits).\n    packed |= _metadata.reservedRate << 24;\n    // redemption rate in bits 40-55 (16 bits).\n    // redemption rate is a number 0-10000. Store the reverse so the most common case of 100% results in no storage needs.\n    packed |= (JBConstants.MAX_REDEMPTION_RATE - _metadata.redemptionRate) << 40;\n    // ballot redemption rate rate in bits 56-71 (16 bits).\n    // ballot redemption rate is a number 0-10000. Store the reverse so the most common case of 100% results in no storage needs.\n    packed |= (JBConstants.MAX_REDEMPTION_RATE - _metadata.ballotRedemptionRate) << 56;\n    // pause pay in bit 72.\n    if (_metadata.pausePay) packed |= 1 << 72;\n    // pause tap in bit 73.\n    if (_metadata.pauseDistributions) packed |= 1 << 73;\n    // pause redeem in bit 74.\n    if (_metadata.pauseRedeem) packed |= 1 << 74;\n    // pause burn in bit 75.\n    if (_metadata.pauseBurn) packed |= 1 << 75;\n    // allow minting in bit 76.\n    if (_metadata.allowMinting) packed |= 1 << 76;\n    // allow terminal migration in bit 77.\n    if (_metadata.allowTerminalMigration) packed |= 1 << 77;\n    // allow controller migration in bit 78.\n    if (_metadata.allowControllerMigration) packed |= 1 << 78;\n    // hold fees in bit 79.\n    if (_metadata.holdFees) packed |= 1 << 79;\n    // prefer claimed token override in bit 80.\n    if (_metadata.preferClaimedTokenOverride) packed |= 1 << 80;\n    // useTotalOverflowForRedemptions in bit 81.\n    if (_metadata.useTotalOverflowForRedemptions) packed |= 1 << 81;\n    // use pay data source in bit 82.\n    if (_metadata.useDataSourceForPay) packed |= 1 << 82;\n    // use redeem data source in bit 83.\n    if (_metadata.useDataSourceForRedeem) packed |= 1 << 83;\n    // data source address in bits 84-243.\n    packed |= uint256(uint160(address(_metadata.dataSource))) << 84;\n    // metadata in bits 244-252 (8 bits).\n    packed |= _metadata.metadata << 244;\n  }\n\n  /**\n    @notice\n    Expand the funding cycle metadata.\n\n    @param _fundingCycle The funding cycle having its metadata expanded.\n\n    @return metadata The metadata object.\n  */\n  function expandMetadata(JBFundingCycle memory _fundingCycle)\n    internal\n    pure\n    returns (JBFundingCycleMetadata memory)\n  {\n    return\n      JBFundingCycleMetadata(\n        global(_fundingCycle),\n        reservedRate(_fundingCycle),\n        redemptionRate(_fundingCycle),\n        ballotRedemptionRate(_fundingCycle),\n        payPaused(_fundingCycle),\n        distributionsPaused(_fundingCycle),\n        redeemPaused(_fundingCycle),\n        burnPaused(_fundingCycle),\n        mintingAllowed(_fundingCycle),\n        terminalMigrationAllowed(_fundingCycle),\n        controllerMigrationAllowed(_fundingCycle),\n        shouldHoldFees(_fundingCycle),\n        preferClaimedTokenOverride(_fundingCycle),\n        useTotalOverflowForRedemptions(_fundingCycle),\n        useDataSourceForPay(_fundingCycle),\n        useDataSourceForRedeem(_fundingCycle),\n        dataSource(_fundingCycle),\n        metadata(_fundingCycle)\n      );\n  }\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/libraries/JBGlobalFundingCycleMetadataResolver.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport './../structs/JBFundingCycleMetadata.sol';\n\nlibrary JBGlobalFundingCycleMetadataResolver {\n  function setTerminalsAllowed(uint8 _data) internal pure returns (bool) {\n    return (_data & 1) == 1;\n  }\n\n  function setControllerAllowed(uint8 _data) internal pure returns (bool) {\n    return ((_data >> 1) & 1) == 1;\n  }\n\n  function transfersPaused(uint8 _data) internal pure returns (bool) {\n    return ((_data >> 2) & 1) == 1;\n  }\n\n  /**\n    @notice\n    Pack the global funding cycle metadata.\n\n    @param _metadata The metadata to validate and pack.\n\n    @return packed The packed uint256 of all global metadata params. The first 8 bits specify the version.\n  */\n  function packFundingCycleGlobalMetadata(JBGlobalFundingCycleMetadata memory _metadata)\n    internal\n    pure\n    returns (uint256 packed)\n  {\n    // allow set terminals in bit 0.\n    if (_metadata.allowSetTerminals) packed |= 1;\n    // allow set controller in bit 1.\n    if (_metadata.allowSetController) packed |= 1 << 1;\n    // pause transfers in bit 2.\n    if (_metadata.pauseTransfers) packed |= 1 << 2;\n  }\n\n  /**\n    @notice\n    Expand the global funding cycle metadata.\n\n    @param _packedMetadata The packed metadata to expand.\n\n    @return metadata The global metadata object.\n  */\n  function expandMetadata(uint8 _packedMetadata)\n    internal\n    pure\n    returns (JBGlobalFundingCycleMetadata memory metadata)\n  {\n    return\n      JBGlobalFundingCycleMetadata(\n        setTerminalsAllowed(_packedMetadata),\n        setControllerAllowed(_packedMetadata),\n        transfersPaused(_packedMetadata)\n      );\n  }\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBDidPayData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './JBTokenAmount.sol';\n\n/** \n  @member payer The address from which the payment originated.\n  @member projectId The ID of the project for which the payment was made.\n  @member currentFundingCycleConfiguration The configuration of the funding cycle during which the payment is being made.\n  @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.\n  @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.\n  @member projectTokenCount The number of project tokens minted for the beneficiary.\n  @member beneficiary The address to which the tokens were minted.\n  @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.\n  @member memo The memo that is being emitted alongside the payment.\n  @member metadata Extra data to send to the delegate.\n*/\nstruct JBDidPayData {\n  address payer;\n  uint256 projectId;\n  uint256 currentFundingCycleConfiguration;\n  JBTokenAmount amount;\n  JBTokenAmount forwardedAmount;\n  uint256 projectTokenCount;\n  address beneficiary;\n  bool preferClaimedTokens;\n  string memo;\n  bytes metadata;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBDidRedeemData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './JBTokenAmount.sol';\n\n/** \n  @member holder The holder of the tokens being redeemed.\n  @member projectId The ID of the project with which the redeemed tokens are associated.\n  @member currentFundingCycleConfiguration The configuration of the funding cycle during which the redemption is being made.\n  @member projectTokenCount The number of project tokens being redeemed.\n  @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.\n  @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.\n  @member beneficiary The address to which the reclaimed amount will be sent.\n  @member memo The memo that is being emitted alongside the redemption.\n  @member metadata Extra data to send to the delegate.\n*/\nstruct JBDidRedeemData {\n  address holder;\n  uint256 projectId;\n  uint256 currentFundingCycleConfiguration;\n  uint256 projectTokenCount;\n  JBTokenAmount reclaimedAmount;\n  JBTokenAmount forwardedAmount;\n  address payable beneficiary;\n  string memo;\n  bytes metadata;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBFundingCycle.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './../interfaces/IJBFundingCycleBallot.sol';\n\n/** \n  @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.\n  @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.\n  @member basedOn The `configuration` of the funding cycle that was active when this cycle was created.\n  @member start The timestamp marking the moment from which the funding cycle is considered active. It is a unix timestamp measured in seconds.\n  @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`.\n  @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.\n  @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`.\n  @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.\n  @member metadata Extra data that can be associated with a funding cycle.\n*/\nstruct JBFundingCycle {\n  uint256 number;\n  uint256 configuration;\n  uint256 basedOn;\n  uint256 start;\n  uint256 duration;\n  uint256 weight;\n  uint256 discountRate;\n  IJBFundingCycleBallot ballot;\n  uint256 metadata;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBFundingCycleData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './../interfaces/IJBFundingCycleBallot.sol';\n\n/** \n  @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`.\n  @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.\n  @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`.\n  @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.\n*/\nstruct JBFundingCycleData {\n  uint256 duration;\n  uint256 weight;\n  uint256 discountRate;\n  IJBFundingCycleBallot ballot;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBFundingCycleMetadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './JBGlobalFundingCycleMetadata.sol';\n\n/** \n  @member global Data used globally in non-migratable ecosystem contracts.\n  @member reservedRate The reserved rate of the funding cycle. This number is a percentage calculated out of `JBConstants.MAX_RESERVED_RATE`.\n  @member redemptionRate The redemption rate of the funding cycle. This number is a percentage calculated out of `JBConstants.MAX_REDEMPTION_RATE`.\n  @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`.\n  @member pausePay A flag indicating if the pay functionality should be paused during the funding cycle.\n  @member pauseDistributions A flag indicating if the distribute functionality should be paused during the funding cycle.\n  @member pauseRedeem A flag indicating if the redeem functionality should be paused during the funding cycle.\n  @member pauseBurn A flag indicating if the burn functionality should be paused during the funding cycle.\n  @member allowMinting A flag indicating if minting tokens should be allowed during this funding cycle.\n  @member allowTerminalMigration A flag indicating if migrating terminals should be allowed during this funding cycle.\n  @member allowControllerMigration A flag indicating if migrating controllers should be allowed during this funding cycle.\n  @member holdFees A flag indicating if fees should be held during this funding cycle.\n  @member preferClaimedTokenOverride A flag indicating if claimed tokens should always be prefered to unclaimed tokens when minting.\n  @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.\n  @member useDataSourceForPay A flag indicating if the data source should be used for pay transactions during this funding cycle.\n  @member useDataSourceForRedeem A flag indicating if the data source should be used for redeem transactions during this funding cycle.\n  @member dataSource The data source to use during this funding cycle.\n  @member metadata Metadata of the metadata, up to uint8 in size.\n*/\nstruct JBFundingCycleMetadata {\n  JBGlobalFundingCycleMetadata global;\n  uint256 reservedRate;\n  uint256 redemptionRate;\n  uint256 ballotRedemptionRate;\n  bool pausePay;\n  bool pauseDistributions;\n  bool pauseRedeem;\n  bool pauseBurn;\n  bool allowMinting;\n  bool allowTerminalMigration;\n  bool allowControllerMigration;\n  bool holdFees;\n  bool preferClaimedTokenOverride;\n  bool useTotalOverflowForRedemptions;\n  bool useDataSourceForPay;\n  bool useDataSourceForRedeem;\n  address dataSource;\n  uint256 metadata;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBGlobalFundingCycleMetadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/** \n  @member allowSetTerminals A flag indicating if setting terminals should be allowed during this funding cycle.\n  @member allowSetController A flag indicating if setting a new controller should be allowed during this funding cycle.\n  @member pauseTransfers A flag indicating if the project token transfer functionality should be paused during the funding cycle.\n*/\nstruct JBGlobalFundingCycleMetadata {\n  bool allowSetTerminals;\n  bool allowSetController;\n  bool pauseTransfers;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBPayDelegateAllocation.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '../interfaces/IJBPayDelegate.sol';\n\n/** \n @member delegate A delegate contract to use for subsequent calls.\n @member amount The amount to send to the delegate.\n*/\nstruct JBPayDelegateAllocation {\n  IJBPayDelegate delegate;\n  uint256 amount;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBPayParamsData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './../interfaces/IJBPaymentTerminal.sol';\nimport './JBTokenAmount.sol';\n\n/** \n  @member terminal The terminal that is facilitating the payment.\n  @member payer The address from which the payment originated.\n  @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.\n  @member projectId The ID of the project being paid.\n  @member currentFundingCycleConfiguration The configuration of the funding cycle during which the payment is being made.\n  @member beneficiary The specified address that should be the beneficiary of anything that results from the payment.\n  @member weight The weight of the funding cycle during which the payment is being made.\n  @member reservedRate The reserved rate of the funding cycle during which the payment is being made.\n  @member memo The memo that was sent alongside the payment.\n  @member metadata Extra data provided by the payer.\n*/\nstruct JBPayParamsData {\n  IJBPaymentTerminal terminal;\n  address payer;\n  JBTokenAmount amount;\n  uint256 projectId;\n  uint256 currentFundingCycleConfiguration;\n  address beneficiary;\n  uint256 weight;\n  uint256 reservedRate;\n  string memo;\n  bytes metadata;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBProjectMetadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/** \n  @member content The metadata content.\n  @member domain The domain within which the metadata applies.\n*/\nstruct JBProjectMetadata {\n  string content;\n  uint256 domain;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBRedeemParamsData.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport './../interfaces/IJBPaymentTerminal.sol';\nimport './JBTokenAmount.sol';\n\n/** \n  @member terminal The terminal that is facilitating the redemption.\n  @member holder The holder of the tokens being redeemed.\n  @member projectId The ID of the project whos tokens are being redeemed.\n  @member currentFundingCycleConfiguration The configuration of the funding cycle during which the redemption is being made.\n  @member tokenCount The proposed number of tokens being redeemed, as a fixed point number with 18 decimals.\n  @member totalSupply The total supply of tokens used in the calculation, as a fixed point number with 18 decimals.\n  @member overflow The amount of overflow used in the reclaim amount calculation.\n  @member reclaimAmount The amount that should be reclaimed by the redeemer using the protocol's standard bonding curve redemption formula. Includes the token being reclaimed, the reclaim value, the number of decimals included, and the currency of the reclaim amount.\n  @member useTotalOverflow If overflow across all of a project's terminals is being used when making redemptions.\n  @member redemptionRate The redemption rate of the funding cycle during which the redemption is being made.\n  @member memo The proposed memo that is being emitted alongside the redemption.\n  @member metadata Extra data provided by the redeemer.\n*/\nstruct JBRedeemParamsData {\n  IJBPaymentTerminal terminal;\n  address holder;\n  uint256 projectId;\n  uint256 currentFundingCycleConfiguration;\n  uint256 tokenCount;\n  uint256 totalSupply;\n  uint256 overflow;\n  JBTokenAmount reclaimAmount;\n  bool useTotalOverflow;\n  uint256 redemptionRate;\n  string memo;\n  bytes metadata;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBRedemptionDelegateAllocation.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '../interfaces/IJBRedemptionDelegate.sol';\n\n/** \n @member delegate A delegate contract to use for subsequent calls.\n @member amount The amount to send to the delegate.\n*/\nstruct JBRedemptionDelegateAllocation {\n  IJBRedemptionDelegate delegate;\n  uint256 amount;\n}\n"
    },
    "node_modules/@jbx-protocol/juice-contracts-v3/contracts/structs/JBTokenAmount.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/* \n  @member token The token the payment was made in.\n  @member value The amount of tokens that was paid, as a fixed point number.\n  @member decimals The number of decimals included in the value fixed point number.\n  @member currency The expected currency of the value.\n**/\nstruct JBTokenAmount {\n  address token;\n  uint256 value;\n  uint256 decimals;\n  uint256 currency;\n}\n"
    },
    "node_modules/@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool _approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
    },
    "node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
    },
    "node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n    /**\n     * @dev Returns the token collection name.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the token collection symbol.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n     */\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/Checkpoints.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Checkpoints.sol)\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SafeCast.sol\";\n\n/**\n * @dev This library defines the `History` struct, for checkpointing values as they change at different points in\n * time, and later looking up past values by block number. See {Votes} as an example.\n *\n * To create a history of checkpoints define a variable type `Checkpoints.History` in your contract, and store a new\n * checkpoint for the current transaction block using the {push} function.\n *\n * _Available since v4.5._\n */\nlibrary Checkpoints {\n    struct Checkpoint {\n        uint32 _blockNumber;\n        uint224 _value;\n    }\n\n    struct History {\n        Checkpoint[] _checkpoints;\n    }\n\n    /**\n     * @dev Returns the value in the latest checkpoint, or zero if there are no checkpoints.\n     */\n    function latest(History storage self) internal view returns (uint256) {\n        uint256 pos = self._checkpoints.length;\n        return pos == 0 ? 0 : self._checkpoints[pos - 1]._value;\n    }\n\n    /**\n     * @dev Returns the value at a given block number. If a checkpoint is not available at that block, the closest one\n     * before it is returned, or zero otherwise.\n     */\n    function getAtBlock(History storage self, uint256 blockNumber) internal view returns (uint256) {\n        require(blockNumber < block.number, \"Checkpoints: block not yet mined\");\n\n        uint256 high = self._checkpoints.length;\n        uint256 low = 0;\n        while (low < high) {\n            uint256 mid = Math.average(low, high);\n            if (self._checkpoints[mid]._blockNumber > blockNumber) {\n                high = mid;\n            } else {\n                low = mid + 1;\n            }\n        }\n        return high == 0 ? 0 : self._checkpoints[high - 1]._value;\n    }\n\n    /**\n     * @dev Pushes a value onto a History so that it is stored as the checkpoint for the current block.\n     *\n     * Returns previous value and new value.\n     */\n    function push(History storage self, uint256 value) internal returns (uint256, uint256) {\n        uint256 pos = self._checkpoints.length;\n        uint256 old = latest(self);\n        if (pos > 0 && self._checkpoints[pos - 1]._blockNumber == block.number) {\n            self._checkpoints[pos - 1]._value = SafeCast.toUint224(value);\n        } else {\n            self._checkpoints.push(\n                Checkpoint({_blockNumber: SafeCast.toUint32(block.number), _value: SafeCast.toUint224(value)})\n            );\n        }\n        return (old, value);\n    }\n\n    /**\n     * @dev Pushes a value onto a History, by updating the latest value using binary operation `op`. The new value will\n     * be set to `op(latest, delta)`.\n     *\n     * Returns previous value and new value.\n     */\n    function push(\n        History storage self,\n        function(uint256, uint256) view returns (uint256) op,\n        uint256 delta\n    ) internal returns (uint256, uint256) {\n        return push(self, op(latest(self), delta));\n    }\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/Strings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/math/Math.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1);\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`.\n        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n        // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1;\n        uint256 x = a;\n        if (x >> 128 > 0) {\n            x >>= 128;\n            result <<= 64;\n        }\n        if (x >> 64 > 0) {\n            x >>= 64;\n            result <<= 32;\n        }\n        if (x >> 32 > 0) {\n            x >>= 32;\n            result <<= 16;\n        }\n        if (x >> 16 > 0) {\n            x >>= 16;\n            result <<= 8;\n        }\n        if (x >> 8 > 0) {\n            x >>= 8;\n            result <<= 4;\n        }\n        if (x >> 4 > 0) {\n            x >>= 4;\n            result <<= 2;\n        }\n        if (x >> 2 > 0) {\n            result <<= 1;\n        }\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = sqrt(a);\n        if (rounding == Rounding.Up && result * result < a) {\n            result += 1;\n        }\n        return result;\n    }\n}\n"
    },
    "node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     *\n     * _Available since v3.0._\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        require(value >= 0, \"SafeCast: value must be positive\");\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt248(int256 value) internal pure returns (int248) {\n        require(value >= type(int248).min && value <= type(int248).max, \"SafeCast: value doesn't fit in 248 bits\");\n        return int248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt240(int256 value) internal pure returns (int240) {\n        require(value >= type(int240).min && value <= type(int240).max, \"SafeCast: value doesn't fit in 240 bits\");\n        return int240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt232(int256 value) internal pure returns (int232) {\n        require(value >= type(int232).min && value <= type(int232).max, \"SafeCast: value doesn't fit in 232 bits\");\n        return int232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt224(int256 value) internal pure returns (int224) {\n        require(value >= type(int224).min && value <= type(int224).max, \"SafeCast: value doesn't fit in 224 bits\");\n        return int224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt216(int256 value) internal pure returns (int216) {\n        require(value >= type(int216).min && value <= type(int216).max, \"SafeCast: value doesn't fit in 216 bits\");\n        return int216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt208(int256 value) internal pure returns (int208) {\n        require(value >= type(int208).min && value <= type(int208).max, \"SafeCast: value doesn't fit in 208 bits\");\n        return int208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt200(int256 value) internal pure returns (int200) {\n        require(value >= type(int200).min && value <= type(int200).max, \"SafeCast: value doesn't fit in 200 bits\");\n        return int200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt192(int256 value) internal pure returns (int192) {\n        require(value >= type(int192).min && value <= type(int192).max, \"SafeCast: value doesn't fit in 192 bits\");\n        return int192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt184(int256 value) internal pure returns (int184) {\n        require(value >= type(int184).min && value <= type(int184).max, \"SafeCast: value doesn't fit in 184 bits\");\n        return int184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt176(int256 value) internal pure returns (int176) {\n        require(value >= type(int176).min && value <= type(int176).max, \"SafeCast: value doesn't fit in 176 bits\");\n        return int176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt168(int256 value) internal pure returns (int168) {\n        require(value >= type(int168).min && value <= type(int168).max, \"SafeCast: value doesn't fit in 168 bits\");\n        return int168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt160(int256 value) internal pure returns (int160) {\n        require(value >= type(int160).min && value <= type(int160).max, \"SafeCast: value doesn't fit in 160 bits\");\n        return int160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt152(int256 value) internal pure returns (int152) {\n        require(value >= type(int152).min && value <= type(int152).max, \"SafeCast: value doesn't fit in 152 bits\");\n        return int152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt144(int256 value) internal pure returns (int144) {\n        require(value >= type(int144).min && value <= type(int144).max, \"SafeCast: value doesn't fit in 144 bits\");\n        return int144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt136(int256 value) internal pure returns (int136) {\n        require(value >= type(int136).min && value <= type(int136).max, \"SafeCast: value doesn't fit in 136 bits\");\n        return int136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt128(int256 value) internal pure returns (int128) {\n        require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return int128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt120(int256 value) internal pure returns (int120) {\n        require(value >= type(int120).min && value <= type(int120).max, \"SafeCast: value doesn't fit in 120 bits\");\n        return int120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt112(int256 value) internal pure returns (int112) {\n        require(value >= type(int112).min && value <= type(int112).max, \"SafeCast: value doesn't fit in 112 bits\");\n        return int112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt104(int256 value) internal pure returns (int104) {\n        require(value >= type(int104).min && value <= type(int104).max, \"SafeCast: value doesn't fit in 104 bits\");\n        return int104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt96(int256 value) internal pure returns (int96) {\n        require(value >= type(int96).min && value <= type(int96).max, \"SafeCast: value doesn't fit in 96 bits\");\n        return int96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt88(int256 value) internal pure returns (int88) {\n        require(value >= type(int88).min && value <= type(int88).max, \"SafeCast: value doesn't fit in 88 bits\");\n        return int88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt80(int256 value) internal pure returns (int80) {\n        require(value >= type(int80).min && value <= type(int80).max, \"SafeCast: value doesn't fit in 80 bits\");\n        return int80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt72(int256 value) internal pure returns (int72) {\n        require(value >= type(int72).min && value <= type(int72).max, \"SafeCast: value doesn't fit in 72 bits\");\n        return int72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt64(int256 value) internal pure returns (int64) {\n        require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return int64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt56(int256 value) internal pure returns (int56) {\n        require(value >= type(int56).min && value <= type(int56).max, \"SafeCast: value doesn't fit in 56 bits\");\n        return int56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt48(int256 value) internal pure returns (int48) {\n        require(value >= type(int48).min && value <= type(int48).max, \"SafeCast: value doesn't fit in 48 bits\");\n        return int48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt40(int256 value) internal pure returns (int40) {\n        require(value >= type(int40).min && value <= type(int40).max, \"SafeCast: value doesn't fit in 40 bits\");\n        return int40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt32(int256 value) internal pure returns (int32) {\n        require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return int32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt24(int256 value) internal pure returns (int24) {\n        require(value >= type(int24).min && value <= type(int24).max, \"SafeCast: value doesn't fit in 24 bits\");\n        return int24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt16(int256 value) internal pure returns (int16) {\n        require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return int16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt8(int256 value) internal pure returns (int8) {\n        require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return int8(value);\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     *\n     * _Available since v3.0._\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n        return int256(value);\n    }\n}\n"
    },
    "node_modules/@paulrberg/contracts/math/PRBMath.sol": {
      "content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.4;\n\nimport \"prb-math/contracts/PRBMath.sol\";\n"
    },
    "node_modules/prb-math/contracts/PRBMath.sol": {
      "content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.4;\n\n/// @notice Emitted when the result overflows uint256.\nerror PRBMath__MulDivFixedPointOverflow(uint256 prod1);\n\n/// @notice Emitted when the result overflows uint256.\nerror PRBMath__MulDivOverflow(uint256 prod1, uint256 denominator);\n\n/// @notice Emitted when one of the inputs is type(int256).min.\nerror PRBMath__MulDivSignedInputTooSmall();\n\n/// @notice Emitted when the intermediary absolute result overflows int256.\nerror PRBMath__MulDivSignedOverflow(uint256 rAbs);\n\n/// @notice Emitted when the input is MIN_SD59x18.\nerror PRBMathSD59x18__AbsInputTooSmall();\n\n/// @notice Emitted when ceiling a number overflows SD59x18.\nerror PRBMathSD59x18__CeilOverflow(int256 x);\n\n/// @notice Emitted when one of the inputs is MIN_SD59x18.\nerror PRBMathSD59x18__DivInputTooSmall();\n\n/// @notice Emitted when one of the intermediary unsigned results overflows SD59x18.\nerror PRBMathSD59x18__DivOverflow(uint256 rAbs);\n\n/// @notice Emitted when the input is greater than 133.084258667509499441.\nerror PRBMathSD59x18__ExpInputTooBig(int256 x);\n\n/// @notice Emitted when the input is greater than 192.\nerror PRBMathSD59x18__Exp2InputTooBig(int256 x);\n\n/// @notice Emitted when flooring a number underflows SD59x18.\nerror PRBMathSD59x18__FloorUnderflow(int256 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMathSD59x18__FromIntOverflow(int256 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMathSD59x18__FromIntUnderflow(int256 x);\n\n/// @notice Emitted when the product of the inputs is negative.\nerror PRBMathSD59x18__GmNegativeProduct(int256 x, int256 y);\n\n/// @notice Emitted when multiplying the inputs overflows SD59x18.\nerror PRBMathSD59x18__GmOverflow(int256 x, int256 y);\n\n/// @notice Emitted when the input is less than or equal to zero.\nerror PRBMathSD59x18__LogInputTooSmall(int256 x);\n\n/// @notice Emitted when one of the inputs is MIN_SD59x18.\nerror PRBMathSD59x18__MulInputTooSmall();\n\n/// @notice Emitted when the intermediary absolute result overflows SD59x18.\nerror PRBMathSD59x18__MulOverflow(uint256 rAbs);\n\n/// @notice Emitted when the intermediary absolute result overflows SD59x18.\nerror PRBMathSD59x18__PowuOverflow(uint256 rAbs);\n\n/// @notice Emitted when the input is negative.\nerror PRBMathSD59x18__SqrtNegativeInput(int256 x);\n\n/// @notice Emitted when the calculating the square root overflows SD59x18.\nerror PRBMathSD59x18__SqrtOverflow(int256 x);\n\n/// @notice Emitted when addition overflows UD60x18.\nerror PRBMathUD60x18__AddOverflow(uint256 x, uint256 y);\n\n/// @notice Emitted when ceiling a number overflows UD60x18.\nerror PRBMathUD60x18__CeilOverflow(uint256 x);\n\n/// @notice Emitted when the input is greater than 133.084258667509499441.\nerror PRBMathUD60x18__ExpInputTooBig(uint256 x);\n\n/// @notice Emitted when the input is greater than 192.\nerror PRBMathUD60x18__Exp2InputTooBig(uint256 x);\n\n/// @notice Emitted when converting a basic integer to the fixed-point format format overflows UD60x18.\nerror PRBMathUD60x18__FromUintOverflow(uint256 x);\n\n/// @notice Emitted when multiplying the inputs overflows UD60x18.\nerror PRBMathUD60x18__GmOverflow(uint256 x, uint256 y);\n\n/// @notice Emitted when the input is less than 1.\nerror PRBMathUD60x18__LogInputTooSmall(uint256 x);\n\n/// @notice Emitted when the calculating the square root overflows UD60x18.\nerror PRBMathUD60x18__SqrtOverflow(uint256 x);\n\n/// @notice Emitted when subtraction underflows UD60x18.\nerror PRBMathUD60x18__SubUnderflow(uint256 x, uint256 y);\n\n/// @dev Common mathematical functions used in both PRBMathSD59x18 and PRBMathUD60x18. Note that this shared library\n/// does not always assume the signed 59.18-decimal fixed-point or the unsigned 60.18-decimal fixed-point\n/// representation. When it does not, it is explicitly mentioned in the NatSpec documentation.\nlibrary PRBMath {\n    /// STRUCTS ///\n\n    struct SD59x18 {\n        int256 value;\n    }\n\n    struct UD60x18 {\n        uint256 value;\n    }\n\n    /// STORAGE ///\n\n    /// @dev How many trailing decimals can be represented.\n    uint256 internal constant SCALE = 1e18;\n\n    /// @dev Largest power of two divisor of SCALE.\n    uint256 internal constant SCALE_LPOTD = 262144;\n\n    /// @dev SCALE inverted mod 2^256.\n    uint256 internal constant SCALE_INVERSE =\n        78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n    /// FUNCTIONS ///\n\n    /// @notice Calculates the binary exponent of x using the binary fraction method.\n    /// @dev Has to use 192.64-bit fixed-point numbers.\n    /// See https://ethereum.stackexchange.com/a/96594/24693.\n    /// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n    /// @return result The result as an unsigned 60.18-decimal fixed-point number.\n    function exp2(uint256 x) internal pure returns (uint256 result) {\n        unchecked {\n            // Start from 0.5 in the 192.64-bit fixed-point format.\n            result = 0x800000000000000000000000000000000000000000000000;\n\n            // Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows\n            // because the initial result is 2^191 and all magic factors are less than 2^65.\n            if (x & 0x8000000000000000 > 0) {\n                result = (result * 0x16A09E667F3BCC909) >> 64;\n            }\n            if (x & 0x4000000000000000 > 0) {\n                result = (result * 0x1306FE0A31B7152DF) >> 64;\n            }\n            if (x & 0x2000000000000000 > 0) {\n                result = (result * 0x1172B83C7D517ADCE) >> 64;\n            }\n            if (x & 0x1000000000000000 > 0) {\n                result = (result * 0x10B5586CF9890F62A) >> 64;\n            }\n            if (x & 0x800000000000000 > 0) {\n                result = (result * 0x1059B0D31585743AE) >> 64;\n            }\n            if (x & 0x400000000000000 > 0) {\n                result = (result * 0x102C9A3E778060EE7) >> 64;\n            }\n            if (x & 0x200000000000000 > 0) {\n                result = (result * 0x10163DA9FB33356D8) >> 64;\n            }\n            if (x & 0x100000000000000 > 0) {\n                result = (result * 0x100B1AFA5ABCBED61) >> 64;\n            }\n            if (x & 0x80000000000000 > 0) {\n                result = (result * 0x10058C86DA1C09EA2) >> 64;\n            }\n            if (x & 0x40000000000000 > 0) {\n                result = (result * 0x1002C605E2E8CEC50) >> 64;\n            }\n            if (x & 0x20000000000000 > 0) {\n                result = (result * 0x100162F3904051FA1) >> 64;\n            }\n            if (x & 0x10000000000000 > 0) {\n                result = (result * 0x1000B175EFFDC76BA) >> 64;\n            }\n            if (x & 0x8000000000000 > 0) {\n                result = (result * 0x100058BA01FB9F96D) >> 64;\n            }\n            if (x & 0x4000000000000 > 0) {\n                result = (result * 0x10002C5CC37DA9492) >> 64;\n            }\n            if (x & 0x2000000000000 > 0) {\n                result = (result * 0x1000162E525EE0547) >> 64;\n            }\n            if (x & 0x1000000000000 > 0) {\n                result = (result * 0x10000B17255775C04) >> 64;\n            }\n            if (x & 0x800000000000 > 0) {\n                result = (result * 0x1000058B91B5BC9AE) >> 64;\n            }\n            if (x & 0x400000000000 > 0) {\n                result = (result * 0x100002C5C89D5EC6D) >> 64;\n            }\n            if (x & 0x200000000000 > 0) {\n                result = (result * 0x10000162E43F4F831) >> 64;\n            }\n            if (x & 0x100000000000 > 0) {\n                result = (result * 0x100000B1721BCFC9A) >> 64;\n            }\n            if (x & 0x80000000000 > 0) {\n                result = (result * 0x10000058B90CF1E6E) >> 64;\n            }\n            if (x & 0x40000000000 > 0) {\n                result = (result * 0x1000002C5C863B73F) >> 64;\n            }\n            if (x & 0x20000000000 > 0) {\n                result = (result * 0x100000162E430E5A2) >> 64;\n            }\n            if (x & 0x10000000000 > 0) {\n                result = (result * 0x1000000B172183551) >> 64;\n            }\n            if (x & 0x8000000000 > 0) {\n                result = (result * 0x100000058B90C0B49) >> 64;\n            }\n            if (x & 0x4000000000 > 0) {\n                result = (result * 0x10000002C5C8601CC) >> 64;\n            }\n            if (x & 0x2000000000 > 0) {\n                result = (result * 0x1000000162E42FFF0) >> 64;\n            }\n            if (x & 0x1000000000 > 0) {\n                result = (result * 0x10000000B17217FBB) >> 64;\n            }\n            if (x & 0x800000000 > 0) {\n                result = (result * 0x1000000058B90BFCE) >> 64;\n            }\n            if (x & 0x400000000 > 0) {\n                result = (result * 0x100000002C5C85FE3) >> 64;\n            }\n            if (x & 0x200000000 > 0) {\n                result = (result * 0x10000000162E42FF1) >> 64;\n            }\n            if (x & 0x100000000 > 0) {\n                result = (result * 0x100000000B17217F8) >> 64;\n            }\n            if (x & 0x80000000 > 0) {\n                result = (result * 0x10000000058B90BFC) >> 64;\n            }\n            if (x & 0x40000000 > 0) {\n                result = (result * 0x1000000002C5C85FE) >> 64;\n            }\n            if (x & 0x20000000 > 0) {\n                result = (result * 0x100000000162E42FF) >> 64;\n            }\n            if (x & 0x10000000 > 0) {\n                result = (result * 0x1000000000B17217F) >> 64;\n            }\n            if (x & 0x8000000 > 0) {\n                result = (result * 0x100000000058B90C0) >> 64;\n            }\n            if (x & 0x4000000 > 0) {\n                result = (result * 0x10000000002C5C860) >> 64;\n            }\n            if (x & 0x2000000 > 0) {\n                result = (result * 0x1000000000162E430) >> 64;\n            }\n            if (x & 0x1000000 > 0) {\n                result = (result * 0x10000000000B17218) >> 64;\n            }\n            if (x & 0x800000 > 0) {\n                result = (result * 0x1000000000058B90C) >> 64;\n            }\n            if (x & 0x400000 > 0) {\n                result = (result * 0x100000000002C5C86) >> 64;\n            }\n            if (x & 0x200000 > 0) {\n                result = (result * 0x10000000000162E43) >> 64;\n            }\n            if (x & 0x100000 > 0) {\n                result = (result * 0x100000000000B1721) >> 64;\n            }\n            if (x & 0x80000 > 0) {\n                result = (result * 0x10000000000058B91) >> 64;\n            }\n            if (x & 0x40000 > 0) {\n                result = (result * 0x1000000000002C5C8) >> 64;\n            }\n            if (x & 0x20000 > 0) {\n                result = (result * 0x100000000000162E4) >> 64;\n            }\n            if (x & 0x10000 > 0) {\n                result = (result * 0x1000000000000B172) >> 64;\n            }\n            if (x & 0x8000 > 0) {\n                result = (result * 0x100000000000058B9) >> 64;\n            }\n            if (x & 0x4000 > 0) {\n                result = (result * 0x10000000000002C5D) >> 64;\n            }\n            if (x & 0x2000 > 0) {\n                result = (result * 0x1000000000000162E) >> 64;\n            }\n            if (x & 0x1000 > 0) {\n                result = (result * 0x10000000000000B17) >> 64;\n            }\n            if (x & 0x800 > 0) {\n                result = (result * 0x1000000000000058C) >> 64;\n            }\n            if (x & 0x400 > 0) {\n                result = (result * 0x100000000000002C6) >> 64;\n            }\n            if (x & 0x200 > 0) {\n                result = (result * 0x10000000000000163) >> 64;\n            }\n            if (x & 0x100 > 0) {\n                result = (result * 0x100000000000000B1) >> 64;\n            }\n            if (x & 0x80 > 0) {\n                result = (result * 0x10000000000000059) >> 64;\n            }\n            if (x & 0x40 > 0) {\n                result = (result * 0x1000000000000002C) >> 64;\n            }\n            if (x & 0x20 > 0) {\n                result = (result * 0x10000000000000016) >> 64;\n            }\n            if (x & 0x10 > 0) {\n                result = (result * 0x1000000000000000B) >> 64;\n            }\n            if (x & 0x8 > 0) {\n                result = (result * 0x10000000000000006) >> 64;\n            }\n            if (x & 0x4 > 0) {\n                result = (result * 0x10000000000000003) >> 64;\n            }\n            if (x & 0x2 > 0) {\n                result = (result * 0x10000000000000001) >> 64;\n            }\n            if (x & 0x1 > 0) {\n                result = (result * 0x10000000000000001) >> 64;\n            }\n\n            // We're doing two things at the same time:\n            //\n            //   1. Multiply the result by 2^n + 1, where \"2^n\" is the integer part and the one is added to account for\n            //      the fact that we initially set the result to 0.5. This is accomplished by subtracting from 191\n            //      rather than 192.\n            //   2. Convert the result to the unsigned 60.18-decimal fixed-point format.\n            //\n            // This works because 2^(191-ip) = 2^ip / 2^191, where \"ip\" is the integer part \"2^n\".\n            result *= SCALE;\n            result >>= (191 - (x >> 64));\n        }\n    }\n\n    /// @notice Finds the zero-based index of the first one in the binary representation of x.\n    /// @dev See the note on msb in the \"Find First Set\" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set\n    /// @param x The uint256 number for which to find the index of the most significant bit.\n    /// @return msb The index of the most significant bit as an uint256.\n    function mostSignificantBit(uint256 x) internal pure returns (uint256 msb) {\n        if (x >= 2**128) {\n            x >>= 128;\n            msb += 128;\n        }\n        if (x >= 2**64) {\n            x >>= 64;\n            msb += 64;\n        }\n        if (x >= 2**32) {\n            x >>= 32;\n            msb += 32;\n        }\n        if (x >= 2**16) {\n            x >>= 16;\n            msb += 16;\n        }\n        if (x >= 2**8) {\n            x >>= 8;\n            msb += 8;\n        }\n        if (x >= 2**4) {\n            x >>= 4;\n            msb += 4;\n        }\n        if (x >= 2**2) {\n            x >>= 2;\n            msb += 2;\n        }\n        if (x >= 2**1) {\n            // No need to shift x any more.\n            msb += 1;\n        }\n    }\n\n    /// @notice Calculates floor(x*y÷denominator) with full precision.\n    ///\n    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n    ///\n    /// Requirements:\n    /// - The denominator cannot be zero.\n    /// - The result must fit within uint256.\n    ///\n    /// Caveats:\n    /// - This function does not work with fixed-point numbers.\n    ///\n    /// @param x The multiplicand as an uint256.\n    /// @param y The multiplier as an uint256.\n    /// @param denominator The divisor as an uint256.\n    /// @return result The result as an uint256.\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n        // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n        // variables such that product = prod1 * 2^256 + prod0.\n        uint256 prod0; // Least significant 256 bits of the product\n        uint256 prod1; // Most significant 256 bits of the product\n        assembly {\n            let mm := mulmod(x, y, not(0))\n            prod0 := mul(x, y)\n            prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n        }\n\n        // Handle non-overflow cases, 256 by 256 division.\n        if (prod1 == 0) {\n            unchecked {\n                result = prod0 / denominator;\n            }\n            return result;\n        }\n\n        // Make sure the result is less than 2^256. Also prevents denominator == 0.\n        if (prod1 >= denominator) {\n            revert PRBMath__MulDivOverflow(prod1, denominator);\n        }\n\n        ///////////////////////////////////////////////\n        // 512 by 256 division.\n        ///////////////////////////////////////////////\n\n        // Make division exact by subtracting the remainder from [prod1 prod0].\n        uint256 remainder;\n        assembly {\n            // Compute remainder using mulmod.\n            remainder := mulmod(x, y, denominator)\n\n            // Subtract 256 bit number from 512 bit number.\n            prod1 := sub(prod1, gt(remainder, prod0))\n            prod0 := sub(prod0, remainder)\n        }\n\n        // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n        // See https://cs.stackexchange.com/q/138556/92363.\n        unchecked {\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 lpotdod = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by lpotdod.\n                denominator := div(denominator, lpotdod)\n\n                // Divide [prod1 prod0] by lpotdod.\n                prod0 := div(prod0, lpotdod)\n\n                // Flip lpotdod such that it is 2^256 / lpotdod. If lpotdod is zero, then it becomes one.\n                lpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * lpotdod;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /// @notice Calculates floor(x*y÷1e18) with full precision.\n    ///\n    /// @dev Variant of \"mulDiv\" with constant folding, i.e. in which the denominator is always 1e18. Before returning the\n    /// final result, we add 1 if (x * y) % SCALE >= HALF_SCALE. Without this, 6.6e-19 would be truncated to 0 instead of\n    /// being rounded to 1e-18.  See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717.\n    ///\n    /// Requirements:\n    /// - The result must fit within uint256.\n    ///\n    /// Caveats:\n    /// - The body is purposely left uncommented; see the NatSpec comments in \"PRBMath.mulDiv\" to understand how this works.\n    /// - It is assumed that the result can never be type(uint256).max when x and y solve the following two equations:\n    ///     1. x * y = type(uint256).max * SCALE\n    ///     2. (x * y) % SCALE >= SCALE / 2\n    ///\n    /// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n    /// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n    /// @return result The result as an unsigned 60.18-decimal fixed-point number.\n    function mulDivFixedPoint(uint256 x, uint256 y) internal pure returns (uint256 result) {\n        uint256 prod0;\n        uint256 prod1;\n        assembly {\n            let mm := mulmod(x, y, not(0))\n            prod0 := mul(x, y)\n            prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n        }\n\n        if (prod1 >= SCALE) {\n            revert PRBMath__MulDivFixedPointOverflow(prod1);\n        }\n\n        uint256 remainder;\n        uint256 roundUpUnit;\n        assembly {\n            remainder := mulmod(x, y, SCALE)\n            roundUpUnit := gt(remainder, 499999999999999999)\n        }\n\n        if (prod1 == 0) {\n            unchecked {\n                result = (prod0 / SCALE) + roundUpUnit;\n                return result;\n            }\n        }\n\n        assembly {\n            result := add(\n                mul(\n                    or(\n                        div(sub(prod0, remainder), SCALE_LPOTD),\n                        mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, SCALE_LPOTD), SCALE_LPOTD), 1))\n                    ),\n                    SCALE_INVERSE\n                ),\n                roundUpUnit\n            )\n        }\n    }\n\n    /// @notice Calculates floor(x*y÷denominator) with full precision.\n    ///\n    /// @dev An extension of \"mulDiv\" for signed numbers. Works by computing the signs and the absolute values separately.\n    ///\n    /// Requirements:\n    /// - None of the inputs can be type(int256).min.\n    /// - The result must fit within int256.\n    ///\n    /// @param x The multiplicand as an int256.\n    /// @param y The multiplier as an int256.\n    /// @param denominator The divisor as an int256.\n    /// @return result The result as an int256.\n    function mulDivSigned(\n        int256 x,\n        int256 y,\n        int256 denominator\n    ) internal pure returns (int256 result) {\n        if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n            revert PRBMath__MulDivSignedInputTooSmall();\n        }\n\n        // Get hold of the absolute values of x, y and the denominator.\n        uint256 ax;\n        uint256 ay;\n        uint256 ad;\n        unchecked {\n            ax = x < 0 ? uint256(-x) : uint256(x);\n            ay = y < 0 ? uint256(-y) : uint256(y);\n            ad = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n        }\n\n        // Compute the absolute value of (x*y)÷denominator. The result must fit within int256.\n        uint256 rAbs = mulDiv(ax, ay, ad);\n        if (rAbs > uint256(type(int256).max)) {\n            revert PRBMath__MulDivSignedOverflow(rAbs);\n        }\n\n        // Get the signs of x, y and the denominator.\n        uint256 sx;\n        uint256 sy;\n        uint256 sd;\n        assembly {\n            sx := sgt(x, sub(0, 1))\n            sy := sgt(y, sub(0, 1))\n            sd := sgt(denominator, sub(0, 1))\n        }\n\n        // XOR over sx, sy and sd. This is checking whether there are one or three negative signs in the inputs.\n        // If yes, the result should be negative.\n        result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs);\n    }\n\n    /// @notice Calculates the square root of x, rounding down.\n    /// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n    ///\n    /// Caveats:\n    /// - This function does not work with fixed-point numbers.\n    ///\n    /// @param x The uint256 number for which to calculate the square root.\n    /// @return result The result as an uint256.\n    function sqrt(uint256 x) internal pure returns (uint256 result) {\n        if (x == 0) {\n            return 0;\n        }\n\n        // Set the initial guess to the least power of two that is greater than or equal to sqrt(x).\n        uint256 xAux = uint256(x);\n        result = 1;\n        if (xAux >= 0x100000000000000000000000000000000) {\n            xAux >>= 128;\n            result <<= 64;\n        }\n        if (xAux >= 0x10000000000000000) {\n            xAux >>= 64;\n            result <<= 32;\n        }\n        if (xAux >= 0x100000000) {\n            xAux >>= 32;\n            result <<= 16;\n        }\n        if (xAux >= 0x10000) {\n            xAux >>= 16;\n            result <<= 8;\n        }\n        if (xAux >= 0x100) {\n            xAux >>= 8;\n            result <<= 4;\n        }\n        if (xAux >= 0x10) {\n            xAux >>= 4;\n            result <<= 2;\n        }\n        if (xAux >= 0x8) {\n            result <<= 1;\n        }\n\n        // The operations can never overflow because the result is max 2^127 when it enters this block.\n        unchecked {\n            result = (result + x / result) >> 1;\n            result = (result + x / result) >> 1;\n            result = (result + x / result) >> 1;\n            result = (result + x / result) >> 1;\n            result = (result + x / result) >> 1;\n            result = (result + x / result) >> 1;\n            result = (result + x / result) >> 1; // Seven iterations should be enough\n            uint256 roundedDownResult = x / result;\n            return result >= roundedDownResult ? roundedDownResult : result;\n        }\n    }\n}\n"
    }
  },
  "settings": {
    "remappings": [
      "@jbx-protocol/=node_modules/@jbx-protocol/",
      "@openzeppelin/=node_modules/@openzeppelin/",
      "@paulrberg/=node_modules/@paulrberg/",
      "ds-test/=lib/forge-std/lib/ds-test/src/",
      "forge-std/=lib/forge-std/src/",
      "prb-math/=node_modules/prb-math/"
    ],
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "metadata": {
      "bytecodeHash": "ipfs"
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "london",
    "libraries": {}
  }
}