@bananapus/721-hook-v6 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.gas-snapshot +152 -0
  2. package/LICENSE +21 -0
  3. package/README.md +253 -0
  4. package/SKILLS.md +140 -0
  5. package/docs/book.css +13 -0
  6. package/docs/book.toml +12 -0
  7. package/docs/solidity.min.js +74 -0
  8. package/docs/src/README.md +253 -0
  9. package/docs/src/SUMMARY.md +38 -0
  10. package/docs/src/src/JB721TiersHook.sol/contract.JB721TiersHook.md +645 -0
  11. package/docs/src/src/JB721TiersHookDeployer.sol/contract.JB721TiersHookDeployer.md +99 -0
  12. package/docs/src/src/JB721TiersHookProjectDeployer.sol/contract.JB721TiersHookProjectDeployer.md +288 -0
  13. package/docs/src/src/JB721TiersHookStore.sol/contract.JB721TiersHookStore.md +1096 -0
  14. package/docs/src/src/README.md +11 -0
  15. package/docs/src/src/abstract/ERC721.sol/abstract.ERC721.md +430 -0
  16. package/docs/src/src/abstract/JB721Hook.sol/abstract.JB721Hook.md +309 -0
  17. package/docs/src/src/abstract/README.md +5 -0
  18. package/docs/src/src/interfaces/IJB721Hook.sol/interface.IJB721Hook.md +29 -0
  19. package/docs/src/src/interfaces/IJB721TiersHook.sol/interface.IJB721TiersHook.md +203 -0
  20. package/docs/src/src/interfaces/IJB721TiersHookDeployer.sol/interface.IJB721TiersHookDeployer.md +25 -0
  21. package/docs/src/src/interfaces/IJB721TiersHookProjectDeployer.sol/interface.IJB721TiersHookProjectDeployer.md +64 -0
  22. package/docs/src/src/interfaces/IJB721TiersHookStore.sol/interface.IJB721TiersHookStore.md +265 -0
  23. package/docs/src/src/interfaces/IJB721TokenUriResolver.sol/interface.IJB721TokenUriResolver.md +12 -0
  24. package/docs/src/src/interfaces/README.md +9 -0
  25. package/docs/src/src/libraries/JB721Constants.sol/library.JB721Constants.md +14 -0
  26. package/docs/src/src/libraries/JB721TiersRulesetMetadataResolver.sol/library.JB721TiersRulesetMetadataResolver.md +68 -0
  27. package/docs/src/src/libraries/JBBitmap.sol/library.JBBitmap.md +82 -0
  28. package/docs/src/src/libraries/JBIpfsDecoder.sol/library.JBIpfsDecoder.md +61 -0
  29. package/docs/src/src/libraries/README.md +7 -0
  30. package/docs/src/src/structs/JB721InitTiersConfig.sol/struct.JB721InitTiersConfig.md +27 -0
  31. package/docs/src/src/structs/JB721Tier.sol/struct.JB721Tier.md +59 -0
  32. package/docs/src/src/structs/JB721TierConfig.sol/struct.JB721TierConfig.md +60 -0
  33. package/docs/src/src/structs/JB721TiersHookFlags.sol/struct.JB721TiersHookFlags.md +26 -0
  34. package/docs/src/src/structs/JB721TiersMintReservesConfig.sol/struct.JB721TiersMintReservesConfig.md +16 -0
  35. package/docs/src/src/structs/JB721TiersRulesetMetadata.sol/struct.JB721TiersRulesetMetadata.md +20 -0
  36. package/docs/src/src/structs/JB721TiersSetDiscountPercentConfig.sol/struct.JB721TiersSetDiscountPercentConfig.md +16 -0
  37. package/docs/src/src/structs/JBBitmapWord.sol/struct.JBBitmapWord.md +19 -0
  38. package/docs/src/src/structs/JBDeploy721TiersHookConfig.sol/struct.JBDeploy721TiersHookConfig.md +34 -0
  39. package/docs/src/src/structs/JBLaunchProjectConfig.sol/struct.JBLaunchProjectConfig.md +23 -0
  40. package/docs/src/src/structs/JBLaunchRulesetsConfig.sol/struct.JBLaunchRulesetsConfig.md +22 -0
  41. package/docs/src/src/structs/JBPayDataHookRulesetConfig.sol/struct.JBPayDataHookRulesetConfig.md +51 -0
  42. package/docs/src/src/structs/JBPayDataHookRulesetMetadata.sol/struct.JBPayDataHookRulesetMetadata.md +66 -0
  43. package/docs/src/src/structs/JBQueueRulesetsConfig.sol/struct.JBQueueRulesetsConfig.md +21 -0
  44. package/docs/src/src/structs/JBStored721Tier.sol/struct.JBStored721Tier.md +42 -0
  45. package/docs/src/src/structs/README.md +18 -0
  46. package/foundry.lock +11 -0
  47. package/foundry.toml +22 -0
  48. package/package.json +31 -0
  49. package/remappings.txt +1 -0
  50. package/script/Deploy.s.sol +140 -0
  51. package/script/helpers/Hook721DeploymentLib.sol +81 -0
  52. package/slither-ci.config.json +10 -0
  53. package/sphinx.lock +476 -0
  54. package/src/JB721TiersHook.sol +765 -0
  55. package/src/JB721TiersHookDeployer.sol +114 -0
  56. package/src/JB721TiersHookProjectDeployer.sol +413 -0
  57. package/src/JB721TiersHookStore.sol +1195 -0
  58. package/src/abstract/ERC721.sol +484 -0
  59. package/src/abstract/JB721Hook.sol +279 -0
  60. package/src/interfaces/IJB721Hook.sol +21 -0
  61. package/src/interfaces/IJB721TiersHook.sol +135 -0
  62. package/src/interfaces/IJB721TiersHookDeployer.sol +22 -0
  63. package/src/interfaces/IJB721TiersHookProjectDeployer.sol +76 -0
  64. package/src/interfaces/IJB721TiersHookStore.sol +220 -0
  65. package/src/interfaces/IJB721TokenUriResolver.sol +10 -0
  66. package/src/libraries/JB721Constants.sol +7 -0
  67. package/src/libraries/JB721TiersRulesetMetadataResolver.sol +44 -0
  68. package/src/libraries/JBBitmap.sol +57 -0
  69. package/src/libraries/JBIpfsDecoder.sol +95 -0
  70. package/src/structs/JB721InitTiersConfig.sol +20 -0
  71. package/src/structs/JB721Tier.sol +39 -0
  72. package/src/structs/JB721TierConfig.sol +40 -0
  73. package/src/structs/JB721TiersHookFlags.sol +17 -0
  74. package/src/structs/JB721TiersMintReservesConfig.sol +9 -0
  75. package/src/structs/JB721TiersRulesetMetadata.sol +12 -0
  76. package/src/structs/JB721TiersSetDiscountPercentConfig.sol +9 -0
  77. package/src/structs/JBBitmapWord.sol +11 -0
  78. package/src/structs/JBDeploy721TiersHookConfig.sol +25 -0
  79. package/src/structs/JBLaunchProjectConfig.sol +18 -0
  80. package/src/structs/JBLaunchRulesetsConfig.sol +17 -0
  81. package/src/structs/JBPayDataHookRulesetConfig.sol +44 -0
  82. package/src/structs/JBPayDataHookRulesetMetadata.sol +46 -0
  83. package/src/structs/JBQueueRulesetsConfig.sol +13 -0
  84. package/src/structs/JBStored721Tier.sol +24 -0
  85. package/test/721HookAttacks.t.sol +396 -0
  86. package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +944 -0
  87. package/test/invariants/TierLifecycleInvariant.t.sol +187 -0
  88. package/test/invariants/TieredHookStoreInvariant.t.sol +81 -0
  89. package/test/invariants/handlers/TierLifecycleHandler.sol +262 -0
  90. package/test/invariants/handlers/TierStoreHandler.sol +155 -0
  91. package/test/unit/JB721TiersRulesetMetadataResolver.t.sol +141 -0
  92. package/test/unit/JBBitmap.t.sol +169 -0
  93. package/test/unit/JBIpfsDecoder.t.sol +131 -0
  94. package/test/unit/M6_TierSupplyCheck.t.sol +220 -0
  95. package/test/unit/adjustTier_Unit.t.sol +1740 -0
  96. package/test/unit/deployer_Unit.t.sol +103 -0
  97. package/test/unit/getters_constructor_Unit.t.sol +548 -0
  98. package/test/unit/mintFor_mintReservesFor_Unit.t.sol +443 -0
  99. package/test/unit/pay_Unit.t.sol +1537 -0
  100. package/test/unit/redeem_Unit.t.sol +459 -0
@@ -0,0 +1,1096 @@
1
+ # JB721TiersHookStore
2
+ [Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/JB721TiersHookStore.sol)
3
+
4
+ **Inherits:**
5
+ [IJB721TiersHookStore](/src/interfaces/IJB721TiersHookStore.sol/interface.IJB721TiersHookStore.md)
6
+
7
+ This contract stores and manages data for many `IJB721TiersHook`s and their NFTs.
8
+
9
+
10
+ ## State Variables
11
+ ### _ONE_BILLION
12
+ Just a kind reminder to our readers.
13
+
14
+ *Used in 721 token ID generation.*
15
+
16
+
17
+ ```solidity
18
+ uint256 private constant _ONE_BILLION = 1_000_000_000;
19
+ ```
20
+
21
+
22
+ ### defaultReserveBeneficiaryOf
23
+ Returns the default reserve beneficiary for the provided 721 contract.
24
+
25
+ *If a tier has a reserve beneficiary set, it will override this value.*
26
+
27
+
28
+ ```solidity
29
+ mapping(address hook => address) public override defaultReserveBeneficiaryOf;
30
+ ```
31
+
32
+
33
+ ### encodedIPFSUriOf
34
+ Returns the encoded IPFS URI for the provided tier ID of the provided 721 contract.
35
+
36
+ *Token URIs managed by this contract are stored in 32 bytes, based on stripped down IPFS hashes.*
37
+
38
+ **Note:**
39
+ returns: The encoded IPFS URI.
40
+
41
+
42
+ ```solidity
43
+ mapping(address hook => mapping(uint256 tierId => bytes32)) public override encodedIPFSUriOf;
44
+ ```
45
+
46
+
47
+ ### maxTierIdOf
48
+ Returns the largest tier ID currently used on the provided 721 contract.
49
+
50
+ *This may not include the last tier ID if it has been removed.*
51
+
52
+
53
+ ```solidity
54
+ mapping(address hook => uint256) public override maxTierIdOf;
55
+ ```
56
+
57
+
58
+ ### numberOfBurnedFor
59
+ Returns the number of NFTs which have been burned from the provided tier ID of the provided 721
60
+ contract.
61
+
62
+
63
+ ```solidity
64
+ mapping(address hook => mapping(uint256 tierId => uint256)) public override numberOfBurnedFor;
65
+ ```
66
+
67
+
68
+ ### numberOfReservesMintedFor
69
+ Returns the number of reserve NFTs which have been minted from the provided tier ID of the provided 721
70
+ contract.
71
+
72
+
73
+ ```solidity
74
+ mapping(address hook => mapping(uint256 tierId => uint256)) public override numberOfReservesMintedFor;
75
+ ```
76
+
77
+
78
+ ### tierBalanceOf
79
+ Returns the number of NFTs which the provided owner address owns from the provided 721 contract and tier
80
+ ID.
81
+
82
+
83
+ ```solidity
84
+ mapping(address hook => mapping(address owner => mapping(uint256 tierId => uint256))) public override tierBalanceOf;
85
+ ```
86
+
87
+
88
+ ### tokenUriResolverOf
89
+ Returns the custom token URI resolver which overrides the default token URI resolver for the provided
90
+ 721 contract.
91
+
92
+
93
+ ```solidity
94
+ mapping(address hook => IJB721TokenUriResolver) public override tokenUriResolverOf;
95
+ ```
96
+
97
+
98
+ ### _flagsOf
99
+ Returns the flags which dictate the behavior of the provided `IJB721TiersHook` contract.
100
+
101
+ **Note:**
102
+ returns: The flags.
103
+
104
+
105
+ ```solidity
106
+ mapping(address hook => JB721TiersHookFlags) internal _flagsOf;
107
+ ```
108
+
109
+
110
+ ### _lastTrackedSortedTierIdOf
111
+ Return the ID of the last sorted tier from the provided 721 contract.
112
+
113
+ *If not set, it is assumed the `maxTierIdOf` is the last sorted tier ID.*
114
+
115
+
116
+ ```solidity
117
+ mapping(address hook => uint256) internal _lastTrackedSortedTierIdOf;
118
+ ```
119
+
120
+
121
+ ### _removedTiersBitmapWordOf
122
+ Get the bitmap word at the provided depth from the provided 721 contract's tier removal bitmap.
123
+
124
+ *See `JBBitmap` for more information.*
125
+
126
+ **Note:**
127
+ returns: word The bitmap row's content.
128
+
129
+
130
+ ```solidity
131
+ mapping(address hook => mapping(uint256 depth => uint256 word)) internal _removedTiersBitmapWordOf;
132
+ ```
133
+
134
+
135
+ ### _reserveBeneficiaryOf
136
+ Returns the reserve beneficiary (if there is one) for the provided tier ID on the provided
137
+ `IJB721TiersHook` contract.
138
+
139
+ **Note:**
140
+ returns: The address of the reserved token beneficiary.
141
+
142
+
143
+ ```solidity
144
+ mapping(address hook => mapping(uint256 tierId => address)) internal _reserveBeneficiaryOf;
145
+ ```
146
+
147
+
148
+ ### _startingTierIdOfCategory
149
+ Returns the ID of the first tier in the provided category on the provided 721 contract.
150
+
151
+
152
+ ```solidity
153
+ mapping(address hook => mapping(uint256 category => uint256)) internal _startingTierIdOfCategory;
154
+ ```
155
+
156
+
157
+ ### _storedTierOf
158
+ Returns the stored tier of the provided tier ID on the provided `IJB721TiersHook` contract.
159
+
160
+ **Note:**
161
+ returns: The stored tier, as a `JBStored721Tier` struct.
162
+
163
+
164
+ ```solidity
165
+ mapping(address hook => mapping(uint256 tierId => JBStored721Tier)) internal _storedTierOf;
166
+ ```
167
+
168
+
169
+ ### _tierIdAfter
170
+ Returns the ID of the tier which comes after the provided tier ID (sorted by price).
171
+
172
+ *If empty, assume the next tier ID should come after.*
173
+
174
+ **Note:**
175
+ returns: The following tier's ID.
176
+
177
+
178
+ ```solidity
179
+ mapping(address hook => mapping(uint256 tierId => uint256)) internal _tierIdAfter;
180
+ ```
181
+
182
+
183
+ ## Functions
184
+ ### encodedTierIPFSUriOf
185
+
186
+ Resolves the encoded IPFS URI for the tier of the 721 with the provided token ID from the provided 721
187
+ contract.
188
+
189
+
190
+ ```solidity
191
+ function encodedTierIPFSUriOf(address hook, uint256 tokenId) external view override returns (bytes32);
192
+ ```
193
+ **Parameters**
194
+
195
+ |Name|Type|Description|
196
+ |----|----|-----------|
197
+ |`hook`|`address`|The 721 contract that the encoded IPFS URI belongs to.|
198
+ |`tokenId`|`uint256`|The token ID of the 721 to get the encoded tier IPFS URI of.|
199
+
200
+ **Returns**
201
+
202
+ |Name|Type|Description|
203
+ |----|----|-----------|
204
+ |`<none>`|`bytes32`|The encoded IPFS URI.|
205
+
206
+
207
+ ### flagsOf
208
+
209
+ Get the flags that dictate the behavior of the provided 721 contract.
210
+
211
+
212
+ ```solidity
213
+ function flagsOf(address hook) external view override returns (JB721TiersHookFlags memory);
214
+ ```
215
+ **Parameters**
216
+
217
+ |Name|Type|Description|
218
+ |----|----|-----------|
219
+ |`hook`|`address`|The 721 contract to get the flags of.|
220
+
221
+ **Returns**
222
+
223
+ |Name|Type|Description|
224
+ |----|----|-----------|
225
+ |`<none>`|`JB721TiersHookFlags`|The flags.|
226
+
227
+
228
+ ### isTierRemoved
229
+
230
+ Check if the provided tier has been removed from the provided 721 contract.
231
+
232
+
233
+ ```solidity
234
+ function isTierRemoved(address hook, uint256 tierId) external view override returns (bool);
235
+ ```
236
+ **Parameters**
237
+
238
+ |Name|Type|Description|
239
+ |----|----|-----------|
240
+ |`hook`|`address`|The 721 contract the tier belongs to.|
241
+ |`tierId`|`uint256`|The ID of the tier to check the removal status of.|
242
+
243
+ **Returns**
244
+
245
+ |Name|Type|Description|
246
+ |----|----|-----------|
247
+ |`<none>`|`bool`|A bool which is `true` if the tier has been removed, and `false` otherwise.|
248
+
249
+
250
+ ### numberOfPendingReservesFor
251
+
252
+ Get the number of pending reserve NFTs for the provided tier ID of the provided 721 contract.
253
+
254
+ *"Pending" means that the NFTs have been reserved, but have not been minted yet.*
255
+
256
+
257
+ ```solidity
258
+ function numberOfPendingReservesFor(address hook, uint256 tierId) external view override returns (uint256);
259
+ ```
260
+ **Parameters**
261
+
262
+ |Name|Type|Description|
263
+ |----|----|-----------|
264
+ |`hook`|`address`|The 721 contract to check for pending reserved NFTs.|
265
+ |`tierId`|`uint256`|The ID of the tier to get the number of pending reserves for.|
266
+
267
+ **Returns**
268
+
269
+ |Name|Type|Description|
270
+ |----|----|-----------|
271
+ |`<none>`|`uint256`|The number of pending reserved NFTs.|
272
+
273
+
274
+ ### tierOf
275
+
276
+ Get the tier with the provided ID from the provided 721 contract.
277
+
278
+
279
+ ```solidity
280
+ function tierOf(address hook, uint256 id, bool includeResolvedUri) public view override returns (JB721Tier memory);
281
+ ```
282
+ **Parameters**
283
+
284
+ |Name|Type|Description|
285
+ |----|----|-----------|
286
+ |`hook`|`address`|The 721 contract to get the tier from.|
287
+ |`id`|`uint256`|The ID of the tier to get.|
288
+ |`includeResolvedUri`|`bool`|If set to `true`, if the contract has a token URI resolver, its content will be resolved and included.|
289
+
290
+ **Returns**
291
+
292
+ |Name|Type|Description|
293
+ |----|----|-----------|
294
+ |`<none>`|`JB721Tier`|The tier.|
295
+
296
+
297
+ ### tierOfTokenId
298
+
299
+ Get the tier of the 721 with the provided token ID in the provided 721 contract.
300
+
301
+
302
+ ```solidity
303
+ function tierOfTokenId(
304
+ address hook,
305
+ uint256 tokenId,
306
+ bool includeResolvedUri
307
+ )
308
+ external
309
+ view
310
+ override
311
+ returns (JB721Tier memory);
312
+ ```
313
+ **Parameters**
314
+
315
+ |Name|Type|Description|
316
+ |----|----|-----------|
317
+ |`hook`|`address`|The 721 contract that the tier belongs to.|
318
+ |`tokenId`|`uint256`|The token ID of the 721 to get the tier of.|
319
+ |`includeResolvedUri`|`bool`|If set to `true`, if the contract has a token URI resolver, its content will be resolved and included.|
320
+
321
+ **Returns**
322
+
323
+ |Name|Type|Description|
324
+ |----|----|-----------|
325
+ |`<none>`|`JB721Tier`|The tier.|
326
+
327
+
328
+ ### tierVotingUnitsOf
329
+
330
+ Returns the number of voting units an addresses has within the specified tier of the specified 721
331
+ contract.
332
+
333
+ *NFTs have a tier-specific number of voting units. If the tier does not have a custom number of voting
334
+ units, the price is used.*
335
+
336
+
337
+ ```solidity
338
+ function tierVotingUnitsOf(
339
+ address hook,
340
+ address account,
341
+ uint256 tierId
342
+ )
343
+ external
344
+ view
345
+ virtual
346
+ override
347
+ returns (uint256);
348
+ ```
349
+ **Parameters**
350
+
351
+ |Name|Type|Description|
352
+ |----|----|-----------|
353
+ |`hook`|`address`|The 721 contract that the tier belongs to.|
354
+ |`account`|`address`|The address to get the voting units of within the tier.|
355
+ |`tierId`|`uint256`|The ID of the tier to get voting units within.|
356
+
357
+ **Returns**
358
+
359
+ |Name|Type|Description|
360
+ |----|----|-----------|
361
+ |`<none>`|`uint256`|The address' voting units within the tier.|
362
+
363
+
364
+ ### tiersOf
365
+
366
+ Gets an array of currently active 721 tiers for the provided 721 contract.
367
+
368
+
369
+ ```solidity
370
+ function tiersOf(
371
+ address hook,
372
+ uint256[] calldata categories,
373
+ bool includeResolvedUri,
374
+ uint256 startingId,
375
+ uint256 size
376
+ )
377
+ external
378
+ view
379
+ override
380
+ returns (JB721Tier[] memory tiers);
381
+ ```
382
+ **Parameters**
383
+
384
+ |Name|Type|Description|
385
+ |----|----|-----------|
386
+ |`hook`|`address`|The 721 contract to get the tiers of.|
387
+ |`categories`|`uint256[]`|An array tier categories to get tiers from. Send an empty array to get all categories.|
388
+ |`includeResolvedUri`|`bool`|If set to `true`, if the contract has a token URI resolver, its content will be resolved and included.|
389
+ |`startingId`|`uint256`|The ID of the first tier to get (sorted by price). Send 0 to get all active tiers.|
390
+ |`size`|`uint256`|The number of tiers to include.|
391
+
392
+ **Returns**
393
+
394
+ |Name|Type|Description|
395
+ |----|----|-----------|
396
+ |`tiers`|`JB721Tier[]`|An array of active 721 tiers.|
397
+
398
+
399
+ ### totalSupplyOf
400
+
401
+ Get the number of NFTs which have been minted from the provided 721 contract (across all tiers).
402
+
403
+
404
+ ```solidity
405
+ function totalSupplyOf(address hook) external view override returns (uint256 supply);
406
+ ```
407
+ **Parameters**
408
+
409
+ |Name|Type|Description|
410
+ |----|----|-----------|
411
+ |`hook`|`address`|The 721 contract to get a total supply of.|
412
+
413
+ **Returns**
414
+
415
+ |Name|Type|Description|
416
+ |----|----|-----------|
417
+ |`supply`|`uint256`|The total number of NFTs minted from all tiers on the contract.|
418
+
419
+
420
+ ### votingUnitsOf
421
+
422
+ Get the number of voting units the provided address has for the provided 721 contract (across all
423
+ tiers).
424
+
425
+ *NFTs have a tier-specific number of voting units. If the tier does not have a custom number of voting
426
+ units, the price is used.*
427
+
428
+
429
+ ```solidity
430
+ function votingUnitsOf(address hook, address account) external view virtual override returns (uint256 units);
431
+ ```
432
+ **Parameters**
433
+
434
+ |Name|Type|Description|
435
+ |----|----|-----------|
436
+ |`hook`|`address`|The 721 contract to get the voting units within.|
437
+ |`account`|`address`|The address to get the voting unit total of.|
438
+
439
+ **Returns**
440
+
441
+ |Name|Type|Description|
442
+ |----|----|-----------|
443
+ |`units`|`uint256`|The total voting units the address has within the 721 contract.|
444
+
445
+
446
+ ### balanceOf
447
+
448
+ Get the number of NFTs that the specified address has from the specified 721 contract (across all
449
+ tiers).
450
+
451
+
452
+ ```solidity
453
+ function balanceOf(address hook, address owner) public view override returns (uint256 balance);
454
+ ```
455
+ **Parameters**
456
+
457
+ |Name|Type|Description|
458
+ |----|----|-----------|
459
+ |`hook`|`address`|The 721 contract to get the balance within.|
460
+ |`owner`|`address`|The address to check the balance of.|
461
+
462
+ **Returns**
463
+
464
+ |Name|Type|Description|
465
+ |----|----|-----------|
466
+ |`balance`|`uint256`|The number of NFTs the owner has from the 721 contract.|
467
+
468
+
469
+ ### cashOutWeightOf
470
+
471
+ The combined cash out weight of the NFTs with the provided token IDs.
472
+
473
+ *Cash out weight is based on 721 price.*
474
+
475
+ *Divide this result by the `totalCashOutWeight` to get the portion of funds that can be reclaimed by
476
+ cashing out these NFTs.*
477
+
478
+
479
+ ```solidity
480
+ function cashOutWeightOf(address hook, uint256[] calldata tokenIds) public view override returns (uint256 weight);
481
+ ```
482
+ **Parameters**
483
+
484
+ |Name|Type|Description|
485
+ |----|----|-----------|
486
+ |`hook`|`address`|The 721 contract that the NFTs belong to.|
487
+ |`tokenIds`|`uint256[]`|The token IDs of the NFTs to get the cash out weight of.|
488
+
489
+ **Returns**
490
+
491
+ |Name|Type|Description|
492
+ |----|----|-----------|
493
+ |`weight`|`uint256`|The cash out weight.|
494
+
495
+
496
+ ### reserveBeneficiaryOf
497
+
498
+ The reserve beneficiary for the provided tier ID on the provided 721 contract.
499
+
500
+
501
+ ```solidity
502
+ function reserveBeneficiaryOf(address hook, uint256 tierId) public view override returns (address);
503
+ ```
504
+ **Parameters**
505
+
506
+ |Name|Type|Description|
507
+ |----|----|-----------|
508
+ |`hook`|`address`|The 721 contract that the tier belongs to.|
509
+ |`tierId`|`uint256`|The ID of the tier to get the reserve beneficiary of.|
510
+
511
+ **Returns**
512
+
513
+ |Name|Type|Description|
514
+ |----|----|-----------|
515
+ |`<none>`|`address`|The reserve beneficiary for the tier.|
516
+
517
+
518
+ ### tierIdOfToken
519
+
520
+ The tier ID for the 721 with the provided token ID.
521
+
522
+ *Tiers are 1-indexed from the `tiers` array, meaning the 0th element of the array is tier 1.*
523
+
524
+
525
+ ```solidity
526
+ function tierIdOfToken(uint256 tokenId) public pure override returns (uint256);
527
+ ```
528
+ **Parameters**
529
+
530
+ |Name|Type|Description|
531
+ |----|----|-----------|
532
+ |`tokenId`|`uint256`|The token ID of the 721 to get the tier ID of.|
533
+
534
+ **Returns**
535
+
536
+ |Name|Type|Description|
537
+ |----|----|-----------|
538
+ |`<none>`|`uint256`|The ID of the 721's tier.|
539
+
540
+
541
+ ### totalCashOutWeight
542
+
543
+ The combined cash out weight for all NFTs from the provided 721 contract.
544
+
545
+
546
+ ```solidity
547
+ function totalCashOutWeight(address hook) public view override returns (uint256 weight);
548
+ ```
549
+ **Parameters**
550
+
551
+ |Name|Type|Description|
552
+ |----|----|-----------|
553
+ |`hook`|`address`|The 721 contract to get the total cash out weight of.|
554
+
555
+ **Returns**
556
+
557
+ |Name|Type|Description|
558
+ |----|----|-----------|
559
+ |`weight`|`uint256`|The total cash out weight.|
560
+
561
+
562
+ ### _firstSortedTierIdOf
563
+
564
+ Get the first tier ID from an 721 contract (when sorted by price) within a provided category.
565
+
566
+
567
+ ```solidity
568
+ function _firstSortedTierIdOf(address hook, uint256 category) internal view returns (uint256 id);
569
+ ```
570
+ **Parameters**
571
+
572
+ |Name|Type|Description|
573
+ |----|----|-----------|
574
+ |`hook`|`address`|The 721 contract to get the first sorted tier ID of.|
575
+ |`category`|`uint256`|The category to get the first sorted tier ID within. Send 0 for the first ID across all tiers, which might not be in the 0th category if the 0th category does not exist.|
576
+
577
+ **Returns**
578
+
579
+ |Name|Type|Description|
580
+ |----|----|-----------|
581
+ |`id`|`uint256`|The first sorted tier ID within the provided category.|
582
+
583
+
584
+ ### _generateTokenId
585
+
586
+ Generate a token ID for an 721 given a tier ID and a token number within that tier.
587
+
588
+
589
+ ```solidity
590
+ function _generateTokenId(uint256 tierId, uint256 tokenNumber) internal pure returns (uint256);
591
+ ```
592
+ **Parameters**
593
+
594
+ |Name|Type|Description|
595
+ |----|----|-----------|
596
+ |`tierId`|`uint256`|The ID of the tier to generate a token ID for.|
597
+ |`tokenNumber`|`uint256`|The token number of the 721 within the tier.|
598
+
599
+ **Returns**
600
+
601
+ |Name|Type|Description|
602
+ |----|----|-----------|
603
+ |`<none>`|`uint256`|The token ID of the 721.|
604
+
605
+
606
+ ### _getTierFrom
607
+
608
+ Returns the tier corresponding to the stored tier provided.
609
+
610
+ *Translate `JBStored721Tier` to `JB721Tier`.*
611
+
612
+
613
+ ```solidity
614
+ function _getTierFrom(
615
+ address hook,
616
+ uint256 tierId,
617
+ JBStored721Tier memory storedTier,
618
+ bool includeResolvedUri
619
+ )
620
+ internal
621
+ view
622
+ returns (JB721Tier memory);
623
+ ```
624
+ **Parameters**
625
+
626
+ |Name|Type|Description|
627
+ |----|----|-----------|
628
+ |`hook`|`address`|The 721 contract to get the tier from.|
629
+ |`tierId`|`uint256`|The ID of the tier to get.|
630
+ |`storedTier`|`JBStored721Tier`|The stored tier to get the corresponding tier for.|
631
+ |`includeResolvedUri`|`bool`|If set to `true`, if the contract has a token URI resolver, its content will be resolved and included.|
632
+
633
+ **Returns**
634
+
635
+ |Name|Type|Description|
636
+ |----|----|-----------|
637
+ |`<none>`|`JB721Tier`|tier The tier as a `JB721Tier` struct.|
638
+
639
+
640
+ ### _isTierRemovedWithRefresh
641
+
642
+ Check whether a tier has been removed while refreshing the relevant bitmap word if needed.
643
+
644
+
645
+ ```solidity
646
+ function _isTierRemovedWithRefresh(
647
+ address hook,
648
+ uint256 tierId,
649
+ JBBitmapWord memory bitmapWord
650
+ )
651
+ internal
652
+ view
653
+ returns (bool);
654
+ ```
655
+ **Parameters**
656
+
657
+ |Name|Type|Description|
658
+ |----|----|-----------|
659
+ |`hook`|`address`|The 721 contract to check for removals on.|
660
+ |`tierId`|`uint256`|The ID of the tier to check the removal status of.|
661
+ |`bitmapWord`|`JBBitmapWord`|The bitmap word to use.|
662
+
663
+ **Returns**
664
+
665
+ |Name|Type|Description|
666
+ |----|----|-----------|
667
+ |`<none>`|`bool`|A boolean which is `true` if the tier has been removed.|
668
+
669
+
670
+ ### _lastSortedTierIdOf
671
+
672
+ The last sorted tier ID from an 721 contract (when sorted by price).
673
+
674
+
675
+ ```solidity
676
+ function _lastSortedTierIdOf(address hook) internal view returns (uint256 id);
677
+ ```
678
+ **Parameters**
679
+
680
+ |Name|Type|Description|
681
+ |----|----|-----------|
682
+ |`hook`|`address`|The 721 contract to get the last sorted tier ID of.|
683
+
684
+ **Returns**
685
+
686
+ |Name|Type|Description|
687
+ |----|----|-----------|
688
+ |`id`|`uint256`|The last sorted tier ID.|
689
+
690
+
691
+ ### _nextSortedTierIdOf
692
+
693
+ Get the tier ID which comes after the provided one when sorted by price.
694
+
695
+
696
+ ```solidity
697
+ function _nextSortedTierIdOf(address hook, uint256 id, uint256 max) internal view returns (uint256);
698
+ ```
699
+ **Parameters**
700
+
701
+ |Name|Type|Description|
702
+ |----|----|-----------|
703
+ |`hook`|`address`|The 721 contract to get the next sorted tier ID from.|
704
+ |`id`|`uint256`|The tier ID to get the next sorted tier ID relative to.|
705
+ |`max`|`uint256`|The maximum tier ID.|
706
+
707
+ **Returns**
708
+
709
+ |Name|Type|Description|
710
+ |----|----|-----------|
711
+ |`<none>`|`uint256`|The next sorted tier ID.|
712
+
713
+
714
+ ### _numberOfPendingReservesFor
715
+
716
+ Get the number of pending reserve NFTs for the specified tier ID.
717
+
718
+
719
+ ```solidity
720
+ function _numberOfPendingReservesFor(
721
+ address hook,
722
+ uint256 tierId,
723
+ JBStored721Tier memory storedTier
724
+ )
725
+ internal
726
+ view
727
+ returns (uint256);
728
+ ```
729
+ **Parameters**
730
+
731
+ |Name|Type|Description|
732
+ |----|----|-----------|
733
+ |`hook`|`address`|The 721 contract that the tier belongs to.|
734
+ |`tierId`|`uint256`|The ID of the tier to get the number of pending reserve NFTs for.|
735
+ |`storedTier`|`JBStored721Tier`|The stored tier to get the number of pending reserve NFTs for.|
736
+
737
+ **Returns**
738
+
739
+ |Name|Type|Description|
740
+ |----|----|-----------|
741
+ |`<none>`|`uint256`|numberReservedTokensOutstanding The number of pending reserve NFTs for the tier.|
742
+
743
+
744
+ ### _packBools
745
+
746
+ Pack five bools into a single uint8.
747
+
748
+
749
+ ```solidity
750
+ function _packBools(
751
+ bool allowOwnerMint,
752
+ bool transfersPausable,
753
+ bool useVotingUnits,
754
+ bool cannotBeRemoved,
755
+ bool cannotIncreaseDiscountPercent
756
+ )
757
+ internal
758
+ pure
759
+ returns (uint8 packed);
760
+ ```
761
+ **Parameters**
762
+
763
+ |Name|Type|Description|
764
+ |----|----|-----------|
765
+ |`allowOwnerMint`|`bool`|Whether or not owner minting is allowed in new tiers.|
766
+ |`transfersPausable`|`bool`|Whether or not 721 transfers can be paused.|
767
+ |`useVotingUnits`|`bool`|Whether or not custom voting unit amounts are allowed in new tiers.|
768
+ |`cannotBeRemoved`|`bool`|Whether or not attempts to remove the tier will revert.|
769
+ |`cannotIncreaseDiscountPercent`|`bool`|Whether or not attempts to increase the discount percent will revert.|
770
+
771
+ **Returns**
772
+
773
+ |Name|Type|Description|
774
+ |----|----|-----------|
775
+ |`packed`|`uint8`|The packed bools.|
776
+
777
+
778
+ ### _unpackBools
779
+
780
+ Unpack five bools from a single uint8.
781
+
782
+
783
+ ```solidity
784
+ function _unpackBools(uint8 packed)
785
+ internal
786
+ pure
787
+ returns (
788
+ bool allowOwnerMint,
789
+ bool transfersPausable,
790
+ bool useVotingUnits,
791
+ bool cannotBeRemoved,
792
+ bool cannotIncreaseDiscountPercent
793
+ );
794
+ ```
795
+ **Parameters**
796
+
797
+ |Name|Type|Description|
798
+ |----|----|-----------|
799
+ |`packed`|`uint8`|The packed bools.|
800
+
801
+
802
+ ### cleanTiers
803
+
804
+ Cleans an 721 contract's removed tiers from the tier sorting sequence.
805
+
806
+
807
+ ```solidity
808
+ function cleanTiers(address hook) external override;
809
+ ```
810
+ **Parameters**
811
+
812
+ |Name|Type|Description|
813
+ |----|----|-----------|
814
+ |`hook`|`address`|The 721 contract to clean tiers for.|
815
+
816
+
817
+ ### recordAddTiers
818
+
819
+ Record newly added tiers.
820
+
821
+
822
+ ```solidity
823
+ function recordAddTiers(JB721TierConfig[] calldata tiersToAdd) external override returns (uint256[] memory tierIds);
824
+ ```
825
+ **Parameters**
826
+
827
+ |Name|Type|Description|
828
+ |----|----|-----------|
829
+ |`tiersToAdd`|`JB721TierConfig[]`|The tiers to add.|
830
+
831
+ **Returns**
832
+
833
+ |Name|Type|Description|
834
+ |----|----|-----------|
835
+ |`tierIds`|`uint256[]`|The IDs of the tiers being added.|
836
+
837
+
838
+ ### recordBurn
839
+
840
+ Records 721 burns.
841
+
842
+
843
+ ```solidity
844
+ function recordBurn(uint256[] calldata tokenIds) external override;
845
+ ```
846
+ **Parameters**
847
+
848
+ |Name|Type|Description|
849
+ |----|----|-----------|
850
+ |`tokenIds`|`uint256[]`|The token IDs of the NFTs to burn.|
851
+
852
+
853
+ ### recordFlags
854
+
855
+ Record newly set flags.
856
+
857
+
858
+ ```solidity
859
+ function recordFlags(JB721TiersHookFlags calldata flags) external override;
860
+ ```
861
+ **Parameters**
862
+
863
+ |Name|Type|Description|
864
+ |----|----|-----------|
865
+ |`flags`|`JB721TiersHookFlags`|The flags to set.|
866
+
867
+
868
+ ### recordMint
869
+
870
+ Record 721 mints from the provided tiers.
871
+
872
+
873
+ ```solidity
874
+ function recordMint(
875
+ uint256 amount,
876
+ uint16[] calldata tierIds,
877
+ bool isOwnerMint
878
+ )
879
+ external
880
+ override
881
+ returns (uint256[] memory tokenIds, uint256 leftoverAmount);
882
+ ```
883
+ **Parameters**
884
+
885
+ |Name|Type|Description|
886
+ |----|----|-----------|
887
+ |`amount`|`uint256`|The amount being spent on NFTs. The total price must not exceed this amount.|
888
+ |`tierIds`|`uint16[]`|The IDs of the tiers to mint from.|
889
+ |`isOwnerMint`|`bool`|A flag indicating whether this function is being directly called by the 721 contract's owner.|
890
+
891
+ **Returns**
892
+
893
+ |Name|Type|Description|
894
+ |----|----|-----------|
895
+ |`tokenIds`|`uint256[]`|The token IDs of the NFTs which were minted.|
896
+ |`leftoverAmount`|`uint256`|The `amount` remaining after minting.|
897
+
898
+
899
+ ### recordMintReservesFor
900
+
901
+ Record reserve 721 minting for the provided tier ID on the provided 721 contract.
902
+
903
+
904
+ ```solidity
905
+ function recordMintReservesFor(uint256 tierId, uint256 count) external override returns (uint256[] memory tokenIds);
906
+ ```
907
+ **Parameters**
908
+
909
+ |Name|Type|Description|
910
+ |----|----|-----------|
911
+ |`tierId`|`uint256`|The ID of the tier to mint reserves from.|
912
+ |`count`|`uint256`|The number of reserve NFTs to mint.|
913
+
914
+ **Returns**
915
+
916
+ |Name|Type|Description|
917
+ |----|----|-----------|
918
+ |`tokenIds`|`uint256[]`|The token IDs of the reserve NFTs which were minted.|
919
+
920
+
921
+ ### recordRemoveTierIds
922
+
923
+ Record tiers being removed.
924
+
925
+
926
+ ```solidity
927
+ function recordRemoveTierIds(uint256[] calldata tierIds) external override;
928
+ ```
929
+ **Parameters**
930
+
931
+ |Name|Type|Description|
932
+ |----|----|-----------|
933
+ |`tierIds`|`uint256[]`|The IDs of the tiers being removed.|
934
+
935
+
936
+ ### recordSetDiscountPercentOf
937
+
938
+ Records the setting of a discount for a tier.
939
+
940
+
941
+ ```solidity
942
+ function recordSetDiscountPercentOf(uint256 tierId, uint256 discountPercent) external override;
943
+ ```
944
+ **Parameters**
945
+
946
+ |Name|Type|Description|
947
+ |----|----|-----------|
948
+ |`tierId`|`uint256`|The ID of the tier to record a discount for.|
949
+ |`discountPercent`|`uint256`|The new discount percent being applied.|
950
+
951
+
952
+ ### recordSetEncodedIPFSUriOf
953
+
954
+ Record a new encoded IPFS URI for a tier.
955
+
956
+
957
+ ```solidity
958
+ function recordSetEncodedIPFSUriOf(uint256 tierId, bytes32 encodedIPFSUri) external override;
959
+ ```
960
+ **Parameters**
961
+
962
+ |Name|Type|Description|
963
+ |----|----|-----------|
964
+ |`tierId`|`uint256`|The ID of the tier to set the encoded IPFS URI of.|
965
+ |`encodedIPFSUri`|`bytes32`|The encoded IPFS URI to set for the tier.|
966
+
967
+
968
+ ### recordSetTokenUriResolver
969
+
970
+ Record a newly set token URI resolver.
971
+
972
+
973
+ ```solidity
974
+ function recordSetTokenUriResolver(IJB721TokenUriResolver resolver) external override;
975
+ ```
976
+ **Parameters**
977
+
978
+ |Name|Type|Description|
979
+ |----|----|-----------|
980
+ |`resolver`|`IJB721TokenUriResolver`|The resolver to set.|
981
+
982
+
983
+ ### recordTransferForTier
984
+
985
+ Record an 721 transfer.
986
+
987
+
988
+ ```solidity
989
+ function recordTransferForTier(uint256 tierId, address from, address to) external override;
990
+ ```
991
+ **Parameters**
992
+
993
+ |Name|Type|Description|
994
+ |----|----|-----------|
995
+ |`tierId`|`uint256`|The ID of the tier that the 721 being transferred belongs to.|
996
+ |`from`|`address`|The address that the 721 is being transferred from.|
997
+ |`to`|`address`|The address that the 721 is being transferred to.|
998
+
999
+
1000
+ ## Errors
1001
+ ### JB721TiersHookStore_CantMintManually
1002
+
1003
+ ```solidity
1004
+ error JB721TiersHookStore_CantMintManually();
1005
+ ```
1006
+
1007
+ ### JB721TiersHookStore_CantRemoveTier
1008
+
1009
+ ```solidity
1010
+ error JB721TiersHookStore_CantRemoveTier();
1011
+ ```
1012
+
1013
+ ### JB721TiersHookStore_DiscountPercentExceedsBounds
1014
+
1015
+ ```solidity
1016
+ error JB721TiersHookStore_DiscountPercentExceedsBounds(uint256 percent, uint256 limit);
1017
+ ```
1018
+
1019
+ ### JB721TiersHookStore_DiscountPercentIncreaseNotAllowed
1020
+
1021
+ ```solidity
1022
+ error JB721TiersHookStore_DiscountPercentIncreaseNotAllowed(uint256 percent, uint256 storedPercent);
1023
+ ```
1024
+
1025
+ ### JB721TiersHookStore_InsufficientPendingReserves
1026
+
1027
+ ```solidity
1028
+ error JB721TiersHookStore_InsufficientPendingReserves(uint256 count, uint256 numberOfPendingReserves);
1029
+ ```
1030
+
1031
+ ### JB721TiersHookStore_InsufficientSupplyRemaining
1032
+
1033
+ ```solidity
1034
+ error JB721TiersHookStore_InsufficientSupplyRemaining();
1035
+ ```
1036
+
1037
+ ### JB721TiersHookStore_InvalidCategorySortOrder
1038
+
1039
+ ```solidity
1040
+ error JB721TiersHookStore_InvalidCategorySortOrder(uint256 tierCategory, uint256 previousTierCategory);
1041
+ ```
1042
+
1043
+ ### JB721TiersHookStore_InvalidQuantity
1044
+
1045
+ ```solidity
1046
+ error JB721TiersHookStore_InvalidQuantity(uint256 quantity, uint256 limit);
1047
+ ```
1048
+
1049
+ ### JB721TiersHookStore_ManualMintingNotAllowed
1050
+
1051
+ ```solidity
1052
+ error JB721TiersHookStore_ManualMintingNotAllowed();
1053
+ ```
1054
+
1055
+ ### JB721TiersHookStore_MaxTiersExceeded
1056
+
1057
+ ```solidity
1058
+ error JB721TiersHookStore_MaxTiersExceeded(uint256 numberOfTiers, uint256 limit);
1059
+ ```
1060
+
1061
+ ### JB721TiersHookStore_PriceExceedsAmount
1062
+
1063
+ ```solidity
1064
+ error JB721TiersHookStore_PriceExceedsAmount(uint256 price, uint256 leftoverAmount);
1065
+ ```
1066
+
1067
+ ### JB721TiersHookStore_ReserveFrequencyNotAllowed
1068
+
1069
+ ```solidity
1070
+ error JB721TiersHookStore_ReserveFrequencyNotAllowed();
1071
+ ```
1072
+
1073
+ ### JB721TiersHookStore_TierRemoved
1074
+
1075
+ ```solidity
1076
+ error JB721TiersHookStore_TierRemoved(uint256 tierId);
1077
+ ```
1078
+
1079
+ ### JB721TiersHookStore_UnrecognizedTier
1080
+
1081
+ ```solidity
1082
+ error JB721TiersHookStore_UnrecognizedTier();
1083
+ ```
1084
+
1085
+ ### JB721TiersHookStore_VotingUnitsNotAllowed
1086
+
1087
+ ```solidity
1088
+ error JB721TiersHookStore_VotingUnitsNotAllowed();
1089
+ ```
1090
+
1091
+ ### JB721TiersHookStore_ZeroInitialSupply
1092
+
1093
+ ```solidity
1094
+ error JB721TiersHookStore_ZeroInitialSupply();
1095
+ ```
1096
+