@bananapus/core-v6 0.0.49 → 0.0.52
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/CHANGELOG.md +37 -0
- package/foundry.toml +1 -0
- package/package.json +1 -1
- package/src/JBMultiTerminal.sol +530 -304
- package/src/interfaces/IJBCashOutTerminal.sol +68 -0
- package/src/interfaces/IJBFeeTerminal.sol +0 -3
- package/src/libraries/JBCashOutHookSpecsLib.sol +181 -0
- package/src/libraries/JBConstants.sol +6 -0
- package/src/libraries/JBFees.sol +25 -0
- package/src/libraries/JBHeldFeesLib.sol +288 -0
- package/src/libraries/JBRulesetMetadataResolver.sol +20 -12
- package/src/structs/JBRulesetMetadata.sol +4 -1
- package/test/helpers/JBTest.sol +6 -3
|
@@ -71,20 +71,25 @@ library JBRulesetMetadataResolver {
|
|
|
71
71
|
return ((ruleset.metadata >> 79) & 1) == 1;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
function pauseCrossProjectFeeFreeInflows(JBRuleset memory ruleset) internal pure returns (bool) {
|
|
75
|
+
return ((ruleset.metadata >> 80) & 1) == 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
74
78
|
function useDataHookForPay(JBRuleset memory ruleset) internal pure returns (bool) {
|
|
75
|
-
return (ruleset.metadata >>
|
|
79
|
+
return (ruleset.metadata >> 81) & 1 == 1;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
function useDataHookForCashOut(JBRuleset memory ruleset) internal pure returns (bool) {
|
|
79
|
-
return (ruleset.metadata >>
|
|
83
|
+
return (ruleset.metadata >> 82) & 1 == 1;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
function dataHook(JBRuleset memory ruleset) internal pure returns (address) {
|
|
83
|
-
return address(uint160(ruleset.metadata >>
|
|
87
|
+
return address(uint160(ruleset.metadata >> 83));
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
function metadata(JBRuleset memory ruleset) internal pure returns (uint16) {
|
|
87
|
-
|
|
91
|
+
// 13-bit field at bits 243-255.
|
|
92
|
+
return uint16(ruleset.metadata >> 243);
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
/// @notice Pack the funding cycle metadata.
|
|
@@ -125,14 +130,16 @@ library JBRulesetMetadataResolver {
|
|
|
125
130
|
if (rulesetMetadata.holdFees) packed |= 1 << 78;
|
|
126
131
|
// scopeCashOutsToLocalBalances in bit 79.
|
|
127
132
|
if (rulesetMetadata.scopeCashOutsToLocalBalances) packed |= 1 << 79;
|
|
128
|
-
//
|
|
129
|
-
if (rulesetMetadata.
|
|
130
|
-
// use
|
|
131
|
-
if (rulesetMetadata.
|
|
132
|
-
// data source
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
packed |=
|
|
133
|
+
// pause cross-project fee-free inflows in bit 80.
|
|
134
|
+
if (rulesetMetadata.pauseCrossProjectFeeFreeInflows) packed |= 1 << 80;
|
|
135
|
+
// use pay data source in bit 81.
|
|
136
|
+
if (rulesetMetadata.useDataHookForPay) packed |= 1 << 81;
|
|
137
|
+
// use cash out data source in bit 82.
|
|
138
|
+
if (rulesetMetadata.useDataHookForCashOut) packed |= 1 << 82;
|
|
139
|
+
// data source address in bits 83-242.
|
|
140
|
+
packed |= uint256(uint160(address(rulesetMetadata.dataHook))) << 83;
|
|
141
|
+
// metadata in bits 243-255 (13 bits).
|
|
142
|
+
packed |= (uint256(rulesetMetadata.metadata) & 0x1FFF) << 243;
|
|
136
143
|
}
|
|
137
144
|
|
|
138
145
|
/// @notice Expand the funding cycle metadata.
|
|
@@ -155,6 +162,7 @@ library JBRulesetMetadataResolver {
|
|
|
155
162
|
ownerMustSendPayouts: ownerMustSendPayouts(ruleset),
|
|
156
163
|
holdFees: holdFees(ruleset),
|
|
157
164
|
scopeCashOutsToLocalBalances: scopeCashOutsToLocalBalances(ruleset),
|
|
165
|
+
pauseCrossProjectFeeFreeInflows: pauseCrossProjectFeeFreeInflows(ruleset),
|
|
158
166
|
useDataHookForPay: useDataHookForPay(ruleset),
|
|
159
167
|
useDataHookForCashOut: useDataHookForCashOut(ruleset),
|
|
160
168
|
dataHook: dataHook(ruleset),
|
|
@@ -23,10 +23,12 @@ pragma solidity ^0.8.0;
|
|
|
23
23
|
/// @custom:member holdFees If `true`, fees are accumulated but not processed until a future ruleset (or manually).
|
|
24
24
|
/// @custom:member scopeCashOutsToLocalBalances If `true`, omnichain cash-out calculations use only the local chain's
|
|
25
25
|
/// balances (not cross-chain aggregates).
|
|
26
|
+
/// @custom:member pauseCrossProjectFeeFreeInflows If `true`, the project cannot be targeted by
|
|
27
|
+
/// `payAfterCashOutTokensOf` calls during this ruleset.
|
|
26
28
|
/// @custom:member useDataHookForPay If `true`, the data hook is called before recording payments.
|
|
27
29
|
/// @custom:member useDataHookForCashOut If `true`, the data hook is called before recording cash outs.
|
|
28
30
|
/// @custom:member dataHook Contract called before pay/cash-out to potentially override token counts or add hooks.
|
|
29
|
-
/// @custom:member metadata
|
|
31
|
+
/// @custom:member metadata 13 bits of application-specific metadata (upper 3 bits of the uint16 are ignored).
|
|
30
32
|
struct JBRulesetMetadata {
|
|
31
33
|
uint16 reservedPercent;
|
|
32
34
|
uint16 cashOutTaxRate;
|
|
@@ -43,6 +45,7 @@ struct JBRulesetMetadata {
|
|
|
43
45
|
bool ownerMustSendPayouts;
|
|
44
46
|
bool holdFees;
|
|
45
47
|
bool scopeCashOutsToLocalBalances;
|
|
48
|
+
bool pauseCrossProjectFeeFreeInflows;
|
|
46
49
|
bool useDataHookForPay;
|
|
47
50
|
bool useDataHookForCashOut;
|
|
48
51
|
address dataHook;
|
package/test/helpers/JBTest.sol
CHANGED
|
@@ -68,7 +68,8 @@ contract JBTest is Test {
|
|
|
68
68
|
useDataHookForPay: false,
|
|
69
69
|
useDataHookForCashOut: false,
|
|
70
70
|
dataHook: address(0),
|
|
71
|
-
metadata: 0
|
|
71
|
+
metadata: 0,
|
|
72
|
+
pauseCrossProjectFeeFreeInflows: false
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
uint256 packed = _rulesMetadata.packRulesetMetadata();
|
|
@@ -106,7 +107,8 @@ contract JBTest is Test {
|
|
|
106
107
|
useDataHookForPay: false,
|
|
107
108
|
useDataHookForCashOut: false,
|
|
108
109
|
dataHook: address(0),
|
|
109
|
-
metadata: 0
|
|
110
|
+
metadata: 0,
|
|
111
|
+
pauseCrossProjectFeeFreeInflows: false
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
|
|
@@ -130,7 +132,8 @@ contract JBTest is Test {
|
|
|
130
132
|
useDataHookForPay: false,
|
|
131
133
|
useDataHookForCashOut: false,
|
|
132
134
|
dataHook: address(0),
|
|
133
|
-
metadata: 0
|
|
135
|
+
metadata: 0,
|
|
136
|
+
pauseCrossProjectFeeFreeInflows: false
|
|
134
137
|
});
|
|
135
138
|
|
|
136
139
|
uint256 packed = _rulesMetadata.packRulesetMetadata();
|