@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.
- package/.gas-snapshot +152 -0
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/SKILLS.md +140 -0
- package/docs/book.css +13 -0
- package/docs/book.toml +12 -0
- package/docs/solidity.min.js +74 -0
- package/docs/src/README.md +253 -0
- package/docs/src/SUMMARY.md +38 -0
- package/docs/src/src/JB721TiersHook.sol/contract.JB721TiersHook.md +645 -0
- package/docs/src/src/JB721TiersHookDeployer.sol/contract.JB721TiersHookDeployer.md +99 -0
- package/docs/src/src/JB721TiersHookProjectDeployer.sol/contract.JB721TiersHookProjectDeployer.md +288 -0
- package/docs/src/src/JB721TiersHookStore.sol/contract.JB721TiersHookStore.md +1096 -0
- package/docs/src/src/README.md +11 -0
- package/docs/src/src/abstract/ERC721.sol/abstract.ERC721.md +430 -0
- package/docs/src/src/abstract/JB721Hook.sol/abstract.JB721Hook.md +309 -0
- package/docs/src/src/abstract/README.md +5 -0
- package/docs/src/src/interfaces/IJB721Hook.sol/interface.IJB721Hook.md +29 -0
- package/docs/src/src/interfaces/IJB721TiersHook.sol/interface.IJB721TiersHook.md +203 -0
- package/docs/src/src/interfaces/IJB721TiersHookDeployer.sol/interface.IJB721TiersHookDeployer.md +25 -0
- package/docs/src/src/interfaces/IJB721TiersHookProjectDeployer.sol/interface.IJB721TiersHookProjectDeployer.md +64 -0
- package/docs/src/src/interfaces/IJB721TiersHookStore.sol/interface.IJB721TiersHookStore.md +265 -0
- package/docs/src/src/interfaces/IJB721TokenUriResolver.sol/interface.IJB721TokenUriResolver.md +12 -0
- package/docs/src/src/interfaces/README.md +9 -0
- package/docs/src/src/libraries/JB721Constants.sol/library.JB721Constants.md +14 -0
- package/docs/src/src/libraries/JB721TiersRulesetMetadataResolver.sol/library.JB721TiersRulesetMetadataResolver.md +68 -0
- package/docs/src/src/libraries/JBBitmap.sol/library.JBBitmap.md +82 -0
- package/docs/src/src/libraries/JBIpfsDecoder.sol/library.JBIpfsDecoder.md +61 -0
- package/docs/src/src/libraries/README.md +7 -0
- package/docs/src/src/structs/JB721InitTiersConfig.sol/struct.JB721InitTiersConfig.md +27 -0
- package/docs/src/src/structs/JB721Tier.sol/struct.JB721Tier.md +59 -0
- package/docs/src/src/structs/JB721TierConfig.sol/struct.JB721TierConfig.md +60 -0
- package/docs/src/src/structs/JB721TiersHookFlags.sol/struct.JB721TiersHookFlags.md +26 -0
- package/docs/src/src/structs/JB721TiersMintReservesConfig.sol/struct.JB721TiersMintReservesConfig.md +16 -0
- package/docs/src/src/structs/JB721TiersRulesetMetadata.sol/struct.JB721TiersRulesetMetadata.md +20 -0
- package/docs/src/src/structs/JB721TiersSetDiscountPercentConfig.sol/struct.JB721TiersSetDiscountPercentConfig.md +16 -0
- package/docs/src/src/structs/JBBitmapWord.sol/struct.JBBitmapWord.md +19 -0
- package/docs/src/src/structs/JBDeploy721TiersHookConfig.sol/struct.JBDeploy721TiersHookConfig.md +34 -0
- package/docs/src/src/structs/JBLaunchProjectConfig.sol/struct.JBLaunchProjectConfig.md +23 -0
- package/docs/src/src/structs/JBLaunchRulesetsConfig.sol/struct.JBLaunchRulesetsConfig.md +22 -0
- package/docs/src/src/structs/JBPayDataHookRulesetConfig.sol/struct.JBPayDataHookRulesetConfig.md +51 -0
- package/docs/src/src/structs/JBPayDataHookRulesetMetadata.sol/struct.JBPayDataHookRulesetMetadata.md +66 -0
- package/docs/src/src/structs/JBQueueRulesetsConfig.sol/struct.JBQueueRulesetsConfig.md +21 -0
- package/docs/src/src/structs/JBStored721Tier.sol/struct.JBStored721Tier.md +42 -0
- package/docs/src/src/structs/README.md +18 -0
- package/foundry.lock +11 -0
- package/foundry.toml +22 -0
- package/package.json +31 -0
- package/remappings.txt +1 -0
- package/script/Deploy.s.sol +140 -0
- package/script/helpers/Hook721DeploymentLib.sol +81 -0
- package/slither-ci.config.json +10 -0
- package/sphinx.lock +476 -0
- package/src/JB721TiersHook.sol +765 -0
- package/src/JB721TiersHookDeployer.sol +114 -0
- package/src/JB721TiersHookProjectDeployer.sol +413 -0
- package/src/JB721TiersHookStore.sol +1195 -0
- package/src/abstract/ERC721.sol +484 -0
- package/src/abstract/JB721Hook.sol +279 -0
- package/src/interfaces/IJB721Hook.sol +21 -0
- package/src/interfaces/IJB721TiersHook.sol +135 -0
- package/src/interfaces/IJB721TiersHookDeployer.sol +22 -0
- package/src/interfaces/IJB721TiersHookProjectDeployer.sol +76 -0
- package/src/interfaces/IJB721TiersHookStore.sol +220 -0
- package/src/interfaces/IJB721TokenUriResolver.sol +10 -0
- package/src/libraries/JB721Constants.sol +7 -0
- package/src/libraries/JB721TiersRulesetMetadataResolver.sol +44 -0
- package/src/libraries/JBBitmap.sol +57 -0
- package/src/libraries/JBIpfsDecoder.sol +95 -0
- package/src/structs/JB721InitTiersConfig.sol +20 -0
- package/src/structs/JB721Tier.sol +39 -0
- package/src/structs/JB721TierConfig.sol +40 -0
- package/src/structs/JB721TiersHookFlags.sol +17 -0
- package/src/structs/JB721TiersMintReservesConfig.sol +9 -0
- package/src/structs/JB721TiersRulesetMetadata.sol +12 -0
- package/src/structs/JB721TiersSetDiscountPercentConfig.sol +9 -0
- package/src/structs/JBBitmapWord.sol +11 -0
- package/src/structs/JBDeploy721TiersHookConfig.sol +25 -0
- package/src/structs/JBLaunchProjectConfig.sol +18 -0
- package/src/structs/JBLaunchRulesetsConfig.sol +17 -0
- package/src/structs/JBPayDataHookRulesetConfig.sol +44 -0
- package/src/structs/JBPayDataHookRulesetMetadata.sol +46 -0
- package/src/structs/JBQueueRulesetsConfig.sol +13 -0
- package/src/structs/JBStored721Tier.sol +24 -0
- package/test/721HookAttacks.t.sol +396 -0
- package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +944 -0
- package/test/invariants/TierLifecycleInvariant.t.sol +187 -0
- package/test/invariants/TieredHookStoreInvariant.t.sol +81 -0
- package/test/invariants/handlers/TierLifecycleHandler.sol +262 -0
- package/test/invariants/handlers/TierStoreHandler.sol +155 -0
- package/test/unit/JB721TiersRulesetMetadataResolver.t.sol +141 -0
- package/test/unit/JBBitmap.t.sol +169 -0
- package/test/unit/JBIpfsDecoder.t.sol +131 -0
- package/test/unit/M6_TierSupplyCheck.t.sol +220 -0
- package/test/unit/adjustTier_Unit.t.sol +1740 -0
- package/test/unit/deployer_Unit.t.sol +103 -0
- package/test/unit/getters_constructor_Unit.t.sol +548 -0
- package/test/unit/mintFor_mintReservesFor_Unit.t.sol +443 -0
- package/test/unit/pay_Unit.t.sol +1537 -0
- package/test/unit/redeem_Unit.t.sol +459 -0
package/docs/src/src/structs/JB721TiersMintReservesConfig.sol/struct.JB721TiersMintReservesConfig.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# JB721TiersMintReservesConfig
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JB721TiersMintReservesConfig.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: tierId The ID of the tier to mint from.
|
|
6
|
+
|
|
7
|
+
- member: count The number of NFTs to mint from that tier.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
```solidity
|
|
11
|
+
struct JB721TiersMintReservesConfig {
|
|
12
|
+
uint32 tierId;
|
|
13
|
+
uint16 count;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
package/docs/src/src/structs/JB721TiersRulesetMetadata.sol/struct.JB721TiersRulesetMetadata.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# JB721TiersRulesetMetadata
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JB721TiersRulesetMetadata.sol)
|
|
3
|
+
|
|
4
|
+
`JB721TiersHook` options which are packed and stored in the corresponding `JBRulesetMetadata.metadata` on a
|
|
5
|
+
per-ruleset basis.
|
|
6
|
+
|
|
7
|
+
**Notes:**
|
|
8
|
+
- member: pauseTransfers A boolean indicating whether NFT transfers are paused during this ruleset.
|
|
9
|
+
|
|
10
|
+
- member: pauseMintPendingReserves A boolean indicating whether pending/outstanding NFT reserves can be minted
|
|
11
|
+
during this ruleset.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
```solidity
|
|
15
|
+
struct JB721TiersRulesetMetadata {
|
|
16
|
+
bool pauseTransfers;
|
|
17
|
+
bool pauseMintPendingReserves;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# JB721TiersSetDiscountPercentConfig
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JB721TiersSetDiscountPercentConfig.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: tierId The ID of the tier to set the discount percent for.
|
|
6
|
+
|
|
7
|
+
- member: discountPercent The discount percent to set for the tier.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
```solidity
|
|
11
|
+
struct JB721TiersSetDiscountPercentConfig {
|
|
12
|
+
uint32 tierId;
|
|
13
|
+
uint16 discountPercent;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# JBBitmapWord
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBBitmapWord.sol)
|
|
3
|
+
|
|
4
|
+
*A "word" is a 256-bit integer that stores the status of 256 bits (true/false values). Each row of the
|
|
5
|
+
`JBBitmap` matrix is a "word".*
|
|
6
|
+
|
|
7
|
+
**Notes:**
|
|
8
|
+
- member: The information stored at the index.
|
|
9
|
+
|
|
10
|
+
- member: The index.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
```solidity
|
|
14
|
+
struct JBBitmapWord {
|
|
15
|
+
uint256 currentWord;
|
|
16
|
+
uint256 currentDepth;
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
package/docs/src/src/structs/JBDeploy721TiersHookConfig.sol/struct.JBDeploy721TiersHookConfig.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# JBDeploy721TiersHookConfig
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBDeploy721TiersHookConfig.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: name The NFT collection's name.
|
|
6
|
+
|
|
7
|
+
- member: symbol The NFT collection's symbol.
|
|
8
|
+
|
|
9
|
+
- member: baseUri The URI to use as a base for full NFT URIs.
|
|
10
|
+
|
|
11
|
+
- member: tokenUriResolver The contract responsible for resolving the URI for each NFT.
|
|
12
|
+
|
|
13
|
+
- member: contractUri The URI where this contract's metadata can be found.
|
|
14
|
+
|
|
15
|
+
- member: tiersConfig The NFT tiers and pricing config to launch the hook with.
|
|
16
|
+
|
|
17
|
+
- member: reserveBeneficiary The default reserved beneficiary for all tiers.
|
|
18
|
+
|
|
19
|
+
- member: flags A set of boolean options to configure the hook with.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
```solidity
|
|
23
|
+
struct JBDeploy721TiersHookConfig {
|
|
24
|
+
string name;
|
|
25
|
+
string symbol;
|
|
26
|
+
string baseUri;
|
|
27
|
+
IJB721TokenUriResolver tokenUriResolver;
|
|
28
|
+
string contractUri;
|
|
29
|
+
JB721InitTiersConfig tiersConfig;
|
|
30
|
+
address reserveBeneficiary;
|
|
31
|
+
JB721TiersHookFlags flags;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# JBLaunchProjectConfig
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBLaunchProjectConfig.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: projectUri Metadata URI to associate with the project. This can be updated any time by the owner of
|
|
6
|
+
the project.
|
|
7
|
+
|
|
8
|
+
- member: rulesetConfigurations The ruleset configurations to queue.
|
|
9
|
+
|
|
10
|
+
- member: terminalConfigurations The terminal configurations to add for the project.
|
|
11
|
+
|
|
12
|
+
- member: memo A memo to pass along to the emitted event.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
```solidity
|
|
16
|
+
struct JBLaunchProjectConfig {
|
|
17
|
+
string projectUri;
|
|
18
|
+
JBPayDataHookRulesetConfig[] rulesetConfigurations;
|
|
19
|
+
JBTerminalConfig[] terminalConfigurations;
|
|
20
|
+
string memo;
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# JBLaunchRulesetsConfig
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBLaunchRulesetsConfig.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: projectId The ID of the project to launch rulesets for.
|
|
6
|
+
|
|
7
|
+
- member: rulesetConfigurations The ruleset configurations to queue.
|
|
8
|
+
|
|
9
|
+
- member: terminalConfigurations The terminal configurations to add for the project.
|
|
10
|
+
|
|
11
|
+
- member: memo A memo to pass along to the emitted event.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
```solidity
|
|
15
|
+
struct JBLaunchRulesetsConfig {
|
|
16
|
+
uint56 projectId;
|
|
17
|
+
JBPayDataHookRulesetConfig[] rulesetConfigurations;
|
|
18
|
+
JBTerminalConfig[] terminalConfigurations;
|
|
19
|
+
string memo;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
package/docs/src/src/structs/JBPayDataHookRulesetConfig.sol/struct.JBPayDataHookRulesetConfig.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# JBPayDataHookRulesetConfig
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBPayDataHookRulesetConfig.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: mustStartAtOrAfter The earliest time the ruleset can start.
|
|
6
|
+
|
|
7
|
+
- member: duration The number of seconds the ruleset lasts for, after which a new ruleset will start. A
|
|
8
|
+
duration of 0 means that the ruleset will stay active until the project owner explicitly issues a reconfiguration,
|
|
9
|
+
at which point a new ruleset will immediately start with the updated properties. If the duration is greater than 0,
|
|
10
|
+
a project owner cannot make changes to a ruleset's parameters while it is active – any proposed changes will apply
|
|
11
|
+
to the subsequent ruleset. If no changes are proposed, a ruleset rolls over to another one with the same properties
|
|
12
|
+
but new `start` timestamp and a decayed `weight`.
|
|
13
|
+
|
|
14
|
+
- member: weight A fixed point number with 18 decimals that contracts can use to base arbitrary calculations
|
|
15
|
+
on. For example, payment terminals can use this to determine how many tokens should be minted when a payment is
|
|
16
|
+
received.
|
|
17
|
+
|
|
18
|
+
- member: weightCutPercent A percent by how much the `weight` of the subsequent ruleset should be reduced, if
|
|
19
|
+
the
|
|
20
|
+
project owner hasn't queued the subsequent ruleset with an explicit `weight`. If it's 0, each ruleset will have
|
|
21
|
+
equal weight. If the number is 90%, the next ruleset will have a 10% smaller weight. This weight is out of
|
|
22
|
+
`JBConstants.MAX_WEIGHT_CUT_PERCENT`.
|
|
23
|
+
|
|
24
|
+
- member: approvalHook An address of a contract that says whether a proposed ruleset should be accepted or
|
|
25
|
+
rejected. It
|
|
26
|
+
can be used to create rules around how a project owner can change ruleset parameters over time.
|
|
27
|
+
|
|
28
|
+
- member: metadata Metadata specifying the controller-specific parameters that a ruleset can have. These
|
|
29
|
+
properties cannot change until the next ruleset starts.
|
|
30
|
+
|
|
31
|
+
- member: splitGroups An array of splits to use for any number of groups while the ruleset is active.
|
|
32
|
+
|
|
33
|
+
- member: fundAccessLimitGroups An array of structs which dictate the amount of funds a project can access from
|
|
34
|
+
its balance in each payment terminal while the ruleset is active. Amounts are fixed point numbers using the same
|
|
35
|
+
number of decimals as the corresponding terminal. The `payoutLimit` and `surplusAllowance` parameters must fit in
|
|
36
|
+
a `uint232`.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
```solidity
|
|
40
|
+
struct JBPayDataHookRulesetConfig {
|
|
41
|
+
uint48 mustStartAtOrAfter;
|
|
42
|
+
uint32 duration;
|
|
43
|
+
uint112 weight;
|
|
44
|
+
uint32 weightCutPercent;
|
|
45
|
+
IJBRulesetApprovalHook approvalHook;
|
|
46
|
+
JBPayDataHookRulesetMetadata metadata;
|
|
47
|
+
JBSplitGroup[] splitGroups;
|
|
48
|
+
JBFundAccessLimitGroup[] fundAccessLimitGroups;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
package/docs/src/src/structs/JBPayDataHookRulesetMetadata.sol/struct.JBPayDataHookRulesetMetadata.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# JBPayDataHookRulesetMetadata
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBPayDataHookRulesetMetadata.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: reservedPercent The reserved percent of the ruleset. This number is a percentage calculated out of
|
|
6
|
+
`JBConstants.MAX_RESERVED_PERCENT`.
|
|
7
|
+
|
|
8
|
+
- member: cashOutTaxRate The cash out tax rate of the ruleset. This number is a percentage calculated out of
|
|
9
|
+
`JBConstants.MAX_CASH_OUT_TAX_RATE`.
|
|
10
|
+
|
|
11
|
+
- member: baseCurrency The currency on which to base the ruleset's weight.
|
|
12
|
+
|
|
13
|
+
- member: pausePay A flag indicating if the pay functionality should be paused during the ruleset.
|
|
14
|
+
|
|
15
|
+
- member: pauseCreditTransfers A flag indicating if the project token transfer functionality should be paused
|
|
16
|
+
during the funding cycle.
|
|
17
|
+
|
|
18
|
+
- member: allowOwnerMinting A flag indicating if the project owner or an operator with the `MINT_TOKENS`
|
|
19
|
+
permission from the owner should be allowed to mint project tokens on demand during this ruleset.
|
|
20
|
+
|
|
21
|
+
- member: allowTerminalMigration A flag indicating if migrating terminals should be allowed during this
|
|
22
|
+
ruleset.
|
|
23
|
+
|
|
24
|
+
- member: allowSetTerminals A flag indicating if a project's terminals can be added or removed.
|
|
25
|
+
|
|
26
|
+
- member: allowSetController A flag indicating if a project's controller can be changed.
|
|
27
|
+
|
|
28
|
+
- member: allowAddAccountingContext A flag indicating if a project can add new accounting contexts for its
|
|
29
|
+
terminals to use.
|
|
30
|
+
|
|
31
|
+
- member: allowAddPriceFeed A flag indicating if a project can add new price feeds to calculate exchange rates
|
|
32
|
+
between its tokens.
|
|
33
|
+
|
|
34
|
+
- member: holdFees A flag indicating if fees should be held during this ruleset.
|
|
35
|
+
|
|
36
|
+
- member: useTotalSurplusForCashOut A flag indicating if cash outs should use the project's balance held
|
|
37
|
+
in all terminals instead of the project's local terminal balance from which the cash out is being fulfilled.
|
|
38
|
+
|
|
39
|
+
- member: useDataHookForCashOuts A flag indicating if the data hook should be used for cash out transactions
|
|
40
|
+
during
|
|
41
|
+
this ruleset.
|
|
42
|
+
|
|
43
|
+
- member: metadata Metadata of the metadata, up to uint8 in size.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
```solidity
|
|
47
|
+
struct JBPayDataHookRulesetMetadata {
|
|
48
|
+
uint16 reservedPercent;
|
|
49
|
+
uint16 cashOutTaxRate;
|
|
50
|
+
uint32 baseCurrency;
|
|
51
|
+
bool pausePay;
|
|
52
|
+
bool pauseCreditTransfers;
|
|
53
|
+
bool allowOwnerMinting;
|
|
54
|
+
bool allowTerminalMigration;
|
|
55
|
+
bool allowSetTerminals;
|
|
56
|
+
bool allowSetController;
|
|
57
|
+
bool allowAddAccountingContext;
|
|
58
|
+
bool allowAddPriceFeed;
|
|
59
|
+
bool ownerMustSendPayouts;
|
|
60
|
+
bool holdFees;
|
|
61
|
+
bool useTotalSurplusForCashOuts;
|
|
62
|
+
bool useDataHookForCashOut;
|
|
63
|
+
uint16 metadata;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# JBQueueRulesetsConfig
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBQueueRulesetsConfig.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: projectId The ID of the project to launch rulesets for.
|
|
6
|
+
|
|
7
|
+
- member: rulesetConfigurations The ruleset configurations to queue.
|
|
8
|
+
|
|
9
|
+
- member: terminalConfigurations The terminal configurations to add for the project.
|
|
10
|
+
|
|
11
|
+
- member: memo A memo to pass along to the emitted event.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
```solidity
|
|
15
|
+
struct JBQueueRulesetsConfig {
|
|
16
|
+
uint56 projectId;
|
|
17
|
+
JBPayDataHookRulesetConfig[] rulesetConfigurations;
|
|
18
|
+
string memo;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# JBStored721Tier
|
|
2
|
+
[Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/structs/JBStored721Tier.sol)
|
|
3
|
+
|
|
4
|
+
**Notes:**
|
|
5
|
+
- member: price The price to buy an NFT in this tier, in terms of the currency in its `JBInitTiersConfig`.
|
|
6
|
+
|
|
7
|
+
- member: remainingSupply The remaining number of NFTs which can be minted from this tier.
|
|
8
|
+
|
|
9
|
+
- member: initialSupply The total number of NFTs which can be minted from this tier.
|
|
10
|
+
|
|
11
|
+
- member: votingUnits The number of votes that each NFT in this tier gets.
|
|
12
|
+
|
|
13
|
+
- member: category The category that NFTs in this tier belongs to. Used to group NFT tiers.
|
|
14
|
+
|
|
15
|
+
- member: discountPercent The discount that should be applied to the tier.
|
|
16
|
+
|
|
17
|
+
- member: reserveFrequency The frequency at which an extra NFT is minted for the `reserveBeneficiary` from this
|
|
18
|
+
tier. With a `reserveFrequency` of 5, an extra NFT will be minted for the `reserveBeneficiary` for every 5 NFTs
|
|
19
|
+
purchased.
|
|
20
|
+
|
|
21
|
+
- member: allowOwnerMint A boolean indicating whether the contract's owner can mint NFTs from this tier
|
|
22
|
+
on-demand.
|
|
23
|
+
|
|
24
|
+
- member: transfersPausable A boolean indicating whether transfers for NFTs in tier can be paused.
|
|
25
|
+
|
|
26
|
+
- member: useVotingUnits A boolean indicating whether the `votingUnits` should be used to calculate voting
|
|
27
|
+
power. If `useVotingUnits` is false, voting power is based on the tier's price.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
```solidity
|
|
31
|
+
struct JBStored721Tier {
|
|
32
|
+
uint104 price;
|
|
33
|
+
uint32 remainingSupply;
|
|
34
|
+
uint32 initialSupply;
|
|
35
|
+
uint32 votingUnits;
|
|
36
|
+
uint24 category;
|
|
37
|
+
uint8 discountPercent;
|
|
38
|
+
uint16 reserveFrequency;
|
|
39
|
+
uint8 packedBools;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# Contents
|
|
4
|
+
- [JB721InitTiersConfig](JB721InitTiersConfig.sol/struct.JB721InitTiersConfig.md)
|
|
5
|
+
- [JB721Tier](JB721Tier.sol/struct.JB721Tier.md)
|
|
6
|
+
- [JB721TierConfig](JB721TierConfig.sol/struct.JB721TierConfig.md)
|
|
7
|
+
- [JB721TiersHookFlags](JB721TiersHookFlags.sol/struct.JB721TiersHookFlags.md)
|
|
8
|
+
- [JB721TiersMintReservesConfig](JB721TiersMintReservesConfig.sol/struct.JB721TiersMintReservesConfig.md)
|
|
9
|
+
- [JB721TiersRulesetMetadata](JB721TiersRulesetMetadata.sol/struct.JB721TiersRulesetMetadata.md)
|
|
10
|
+
- [JB721TiersSetDiscountPercentConfig](JB721TiersSetDiscountPercentConfig.sol/struct.JB721TiersSetDiscountPercentConfig.md)
|
|
11
|
+
- [JBBitmapWord](JBBitmapWord.sol/struct.JBBitmapWord.md)
|
|
12
|
+
- [JBDeploy721TiersHookConfig](JBDeploy721TiersHookConfig.sol/struct.JBDeploy721TiersHookConfig.md)
|
|
13
|
+
- [JBLaunchProjectConfig](JBLaunchProjectConfig.sol/struct.JBLaunchProjectConfig.md)
|
|
14
|
+
- [JBLaunchRulesetsConfig](JBLaunchRulesetsConfig.sol/struct.JBLaunchRulesetsConfig.md)
|
|
15
|
+
- [JBPayDataHookRulesetConfig](JBPayDataHookRulesetConfig.sol/struct.JBPayDataHookRulesetConfig.md)
|
|
16
|
+
- [JBPayDataHookRulesetMetadata](JBPayDataHookRulesetMetadata.sol/struct.JBPayDataHookRulesetMetadata.md)
|
|
17
|
+
- [JBQueueRulesetsConfig](JBQueueRulesetsConfig.sol/struct.JBQueueRulesetsConfig.md)
|
|
18
|
+
- [JBStored721Tier](JBStored721Tier.sol/struct.JBStored721Tier.md)
|
package/foundry.lock
ADDED
package/foundry.toml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[profile.default]
|
|
2
|
+
solc = '0.8.23'
|
|
3
|
+
evm_version = 'paris'
|
|
4
|
+
optimizer_runs = 800
|
|
5
|
+
libs = ["node_modules", "lib"]
|
|
6
|
+
fs_permissions = [{ access = "read-write", path = "./"}]
|
|
7
|
+
|
|
8
|
+
[profile.ci_sizes]
|
|
9
|
+
optimizer_runs = 200
|
|
10
|
+
|
|
11
|
+
[fuzz]
|
|
12
|
+
runs = 4096
|
|
13
|
+
|
|
14
|
+
[invariant]
|
|
15
|
+
runs = 1024
|
|
16
|
+
depth = 100
|
|
17
|
+
fail_on_revert = false
|
|
18
|
+
|
|
19
|
+
[fmt]
|
|
20
|
+
number_underscore = "thousands"
|
|
21
|
+
multiline_func_header = "all"
|
|
22
|
+
wrap_comments = true
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bananapus/721-hook-v6",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Bananapus/nana-721-hook-v6"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20.0.0"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "forge test",
|
|
14
|
+
"coverage": "forge coverage --report lcov --report summary",
|
|
15
|
+
"deploy:mainnets": "source ./.env && npx sphinx propose ./script/Deploy.s.sol --networks mainnets",
|
|
16
|
+
"deploy:testnets": "source ./.env && npx sphinx propose ./script/Deploy.s.sol --networks testnets",
|
|
17
|
+
"artifacts": "source ./.env && npx sphinx artifacts --org-id 'ea165b21-7cdc-4d7b-be59-ecdd4c26bee4' --project-name 'nana-721-hook-v6'"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@bananapus/address-registry-v6": "^0.0.1",
|
|
21
|
+
"@bananapus/core-v6": "^0.0.1",
|
|
22
|
+
"@bananapus/ownable-v6": "^0.0.1",
|
|
23
|
+
"@bananapus/permission-ids-v6": "^0.0.1",
|
|
24
|
+
"@openzeppelin/contracts": "5.2.0",
|
|
25
|
+
"@prb/math": "^4.1.0",
|
|
26
|
+
"solady": "^0.1.8"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@sphinx-labs/plugins": "^0.33.2"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/remappings.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@sphinx-labs/contracts/=node_modules/@sphinx-labs/contracts/contracts/foundry
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.23;
|
|
3
|
+
|
|
4
|
+
import "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
5
|
+
import "@bananapus/address-registry-v6/script/helpers/AddressRegistryDeploymentLib.sol";
|
|
6
|
+
|
|
7
|
+
import {Sphinx} from "@sphinx-labs/contracts/SphinxPlugin.sol";
|
|
8
|
+
import {Script} from "forge-std/Script.sol";
|
|
9
|
+
|
|
10
|
+
import {JB721TiersHookDeployer} from "../src/JB721TiersHookDeployer.sol";
|
|
11
|
+
import {JB721TiersHookProjectDeployer} from "../src/JB721TiersHookProjectDeployer.sol";
|
|
12
|
+
import {JB721TiersHookStore} from "../src/JB721TiersHookStore.sol";
|
|
13
|
+
import {JB721TiersHook} from "../src/JB721TiersHook.sol";
|
|
14
|
+
|
|
15
|
+
contract DeployScript is Script, Sphinx {
|
|
16
|
+
/// @notice tracks the deployment of the core contracts for the chain we are deploying to.
|
|
17
|
+
CoreDeployment core;
|
|
18
|
+
/// @notice tracks the deployment of the address registry for the chain we are deploying to.
|
|
19
|
+
AddressRegistryDeployment registry;
|
|
20
|
+
|
|
21
|
+
/// @notice The address that is allowed to forward calls to the terminal and controller on a users behalf.
|
|
22
|
+
address private TRUSTED_FORWARDER;
|
|
23
|
+
|
|
24
|
+
/// @notice the salts that are used to deploy the contracts.
|
|
25
|
+
bytes32 HOOK_SALT = "JB721TiersHookV6_";
|
|
26
|
+
bytes32 HOOK_DEPLOYER_SALT = "JB721TiersHookDeployerV6_";
|
|
27
|
+
bytes32 HOOK_STORE_SALT = "JB721TiersHookStoreV6_";
|
|
28
|
+
bytes32 PROJECT_DEPLOYER_SALT = "JB721TiersHookProjectDeployerV6";
|
|
29
|
+
|
|
30
|
+
function configureSphinx() public override {
|
|
31
|
+
sphinxConfig.projectName = "nana-721-hook-v6";
|
|
32
|
+
sphinxConfig.mainnets = ["ethereum", "optimism", "base", "arbitrum"];
|
|
33
|
+
sphinxConfig.testnets = ["ethereum_sepolia", "optimism_sepolia", "base_sepolia", "arbitrum_sepolia"];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function run() public {
|
|
37
|
+
// Get the deployment addresses for the nana CORE for this chain.
|
|
38
|
+
// We want to do this outside of the `sphinx` modifier.
|
|
39
|
+
core = CoreDeploymentLib.getDeployment(
|
|
40
|
+
vm.envOr("NANA_CORE_DEPLOYMENT_PATH", string("node_modules/@bananapus/core-v6/deployments/"))
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// We use the same trusted forwarder as the core deployment.
|
|
44
|
+
TRUSTED_FORWARDER = core.permissions.trustedForwarder();
|
|
45
|
+
|
|
46
|
+
registry = AddressRegistryDeploymentLib.getDeployment(
|
|
47
|
+
vm.envOr(
|
|
48
|
+
"NANA_ADDRESS_REGISTRY_DEPLOYMENT_PATH",
|
|
49
|
+
string("node_modules/@bananapus/address-registry-v6/deployments/")
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
// Perform the deployment transactions.
|
|
53
|
+
deploy();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// @notice each contract here will be deployed it if needs to be (re)deployed.
|
|
57
|
+
/// It will deploy if the contracts bytecode changes or if any constructor arguments change.
|
|
58
|
+
/// Since all the contract dependencies are passed in using the constructor args,
|
|
59
|
+
// this makes it so that if any dependency contract (address) changes the contract will be redeployed.
|
|
60
|
+
function deploy() public sphinx {
|
|
61
|
+
JB721TiersHookStore store;
|
|
62
|
+
{
|
|
63
|
+
// Perform the check for the store.
|
|
64
|
+
(address _store, bool _storeIsDeployed) =
|
|
65
|
+
_isDeployed(HOOK_STORE_SALT, type(JB721TiersHookStore).creationCode, "");
|
|
66
|
+
|
|
67
|
+
// Deploy it if it has not been deployed yet.
|
|
68
|
+
store = !_storeIsDeployed ? new JB721TiersHookStore{salt: HOOK_STORE_SALT}() : JB721TiersHookStore(_store);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
JB721TiersHook hook;
|
|
72
|
+
{
|
|
73
|
+
// Perform the check for the registry.
|
|
74
|
+
(address _hook, bool _hookIsDeployed) = _isDeployed(
|
|
75
|
+
HOOK_SALT,
|
|
76
|
+
type(JB721TiersHook).creationCode,
|
|
77
|
+
abi.encode(core.directory, core.permissions, core.rulesets, store, TRUSTED_FORWARDER)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// Deploy it if it has not been deployed yet.
|
|
81
|
+
hook = !_hookIsDeployed
|
|
82
|
+
? new JB721TiersHook{salt: HOOK_SALT}(
|
|
83
|
+
core.directory, core.permissions, core.rulesets, store, TRUSTED_FORWARDER
|
|
84
|
+
)
|
|
85
|
+
: JB721TiersHook(_hook);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
JB721TiersHookDeployer hookDeployer;
|
|
89
|
+
{
|
|
90
|
+
// Perform the check for the registry.
|
|
91
|
+
(address _hookDeployer, bool _hookDeployerIsDeployed) = _isDeployed(
|
|
92
|
+
HOOK_DEPLOYER_SALT,
|
|
93
|
+
type(JB721TiersHookDeployer).creationCode,
|
|
94
|
+
abi.encode(hook, store, registry.registry, TRUSTED_FORWARDER)
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
hookDeployer = !_hookDeployerIsDeployed
|
|
98
|
+
? new JB721TiersHookDeployer{salt: HOOK_DEPLOYER_SALT}(
|
|
99
|
+
hook, store, registry.registry, TRUSTED_FORWARDER
|
|
100
|
+
)
|
|
101
|
+
: JB721TiersHookDeployer(_hookDeployer);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
JB721TiersHookProjectDeployer projectDeployer;
|
|
105
|
+
{
|
|
106
|
+
// Perform the check for the registry.
|
|
107
|
+
(address _projectDeployer, bool _projectDeployerIsdeployed) = _isDeployed(
|
|
108
|
+
PROJECT_DEPLOYER_SALT,
|
|
109
|
+
type(JB721TiersHookProjectDeployer).creationCode,
|
|
110
|
+
abi.encode(core.directory, core.permissions, hookDeployer, TRUSTED_FORWARDER)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
projectDeployer = !_projectDeployerIsdeployed
|
|
114
|
+
? new JB721TiersHookProjectDeployer{salt: PROJECT_DEPLOYER_SALT}(
|
|
115
|
+
core.directory, core.permissions, hookDeployer, TRUSTED_FORWARDER
|
|
116
|
+
)
|
|
117
|
+
: JB721TiersHookProjectDeployer(_projectDeployer);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function _isDeployed(
|
|
122
|
+
bytes32 salt,
|
|
123
|
+
bytes memory creationCode,
|
|
124
|
+
bytes memory arguments
|
|
125
|
+
)
|
|
126
|
+
internal
|
|
127
|
+
view
|
|
128
|
+
returns (address, bool)
|
|
129
|
+
{
|
|
130
|
+
address _deployedTo = vm.computeCreate2Address({
|
|
131
|
+
salt: salt,
|
|
132
|
+
initCodeHash: keccak256(abi.encodePacked(creationCode, arguments)),
|
|
133
|
+
// Arachnid/deterministic-deployment-proxy address.
|
|
134
|
+
deployer: address(0x4e59b44847b379578588920cA78FbF26c0B4956C)
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Return if code is already present at this address.
|
|
138
|
+
return (_deployedTo, address(_deployedTo).code.length != 0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.23;
|
|
3
|
+
|
|
4
|
+
import {stdJson} from "forge-std/Script.sol";
|
|
5
|
+
import {Vm} from "forge-std/Vm.sol";
|
|
6
|
+
|
|
7
|
+
import {SphinxConstants, NetworkInfo} from "@sphinx-labs/contracts/SphinxConstants.sol";
|
|
8
|
+
|
|
9
|
+
import {IJB721TiersHookDeployer} from "../../src/interfaces/IJB721TiersHookDeployer.sol";
|
|
10
|
+
import {IJB721TiersHookProjectDeployer} from "../../src/interfaces/IJB721TiersHookProjectDeployer.sol";
|
|
11
|
+
import {IJB721TiersHookStore} from "../../src/interfaces/IJB721TiersHookStore.sol";
|
|
12
|
+
|
|
13
|
+
struct Hook721Deployment {
|
|
14
|
+
IJB721TiersHookDeployer hook_deployer;
|
|
15
|
+
IJB721TiersHookProjectDeployer project_deployer;
|
|
16
|
+
IJB721TiersHookStore store;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
library Hook721DeploymentLib {
|
|
20
|
+
// Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.
|
|
21
|
+
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
|
|
22
|
+
Vm internal constant vm = Vm(VM_ADDRESS);
|
|
23
|
+
|
|
24
|
+
function getDeployment(string memory path) internal returns (Hook721Deployment memory deployment) {
|
|
25
|
+
// get chainId for which we need to get the deployment.
|
|
26
|
+
uint256 chainId = block.chainid;
|
|
27
|
+
|
|
28
|
+
// Deploy to get the constants.
|
|
29
|
+
// TODO: get constants without deploy.
|
|
30
|
+
SphinxConstants sphinxConstants = new SphinxConstants();
|
|
31
|
+
NetworkInfo[] memory networks = sphinxConstants.getNetworkInfoArray();
|
|
32
|
+
|
|
33
|
+
for (uint256 _i; _i < networks.length; _i++) {
|
|
34
|
+
if (networks[_i].chainId == chainId) {
|
|
35
|
+
return getDeployment(path, networks[_i].name);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
revert("ChainID is not (currently) supported by Sphinx.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getDeployment(
|
|
43
|
+
string memory path,
|
|
44
|
+
string memory network_name
|
|
45
|
+
)
|
|
46
|
+
internal
|
|
47
|
+
view
|
|
48
|
+
returns (Hook721Deployment memory deployment)
|
|
49
|
+
{
|
|
50
|
+
deployment.hook_deployer = IJB721TiersHookDeployer(
|
|
51
|
+
_getDeploymentAddress(path, "nana-721-hook-v6", network_name, "JB721TiersHookDeployer")
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
deployment.project_deployer = IJB721TiersHookProjectDeployer(
|
|
55
|
+
_getDeploymentAddress(path, "nana-721-hook-v6", network_name, "JB721TiersHookProjectDeployer")
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
deployment.store =
|
|
59
|
+
IJB721TiersHookStore(_getDeploymentAddress(path, "nana-721-hook-v6", network_name, "JB721TiersHookStore"));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// @notice Get the address of a contract that was deployed by the Deploy script.
|
|
63
|
+
/// @dev Reverts if the contract was not found.
|
|
64
|
+
/// @param path The path to the deployment file.
|
|
65
|
+
/// @param contractName The name of the contract to get the address of.
|
|
66
|
+
/// @return The address of the contract.
|
|
67
|
+
function _getDeploymentAddress(
|
|
68
|
+
string memory path,
|
|
69
|
+
string memory project_name,
|
|
70
|
+
string memory network_name,
|
|
71
|
+
string memory contractName
|
|
72
|
+
)
|
|
73
|
+
internal
|
|
74
|
+
view
|
|
75
|
+
returns (address)
|
|
76
|
+
{
|
|
77
|
+
string memory deploymentJson =
|
|
78
|
+
vm.readFile(string.concat(path, project_name, "/", network_name, "/", contractName, ".json"));
|
|
79
|
+
return stdJson.readAddress(deploymentJson, ".address");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"detectors_to_exclude": "timestamp,uninitialized-local,naming-convention,solc-version,shadowing-local",
|
|
3
|
+
"exclude_informational": true,
|
|
4
|
+
"exclude_low": false,
|
|
5
|
+
"exclude_medium": false,
|
|
6
|
+
"exclude_high": false,
|
|
7
|
+
"disable_color": false,
|
|
8
|
+
"filter_paths": "(mocks/|test/|node_modules/|lib/)",
|
|
9
|
+
"legacy_ast": false
|
|
10
|
+
}
|