@bananapus/core-v6 0.0.80 → 0.0.82

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/src/JBTokens.sol CHANGED
@@ -19,16 +19,37 @@ contract JBTokens is JBControlled, IJBTokens {
19
19
  // --------------------------- custom errors ------------------------- //
20
20
  //*********************************************************************//
21
21
 
22
+ /// @notice Thrown when deploying a token with an empty name.
22
23
  error JBTokens_EmptyName(uint256 projectId);
24
+
25
+ /// @notice Thrown when deploying a token with an empty symbol.
23
26
  error JBTokens_EmptySymbol(uint256 projectId);
27
+
28
+ /// @notice Thrown when the token to set is the zero address.
24
29
  error JBTokens_EmptyToken(uint256 projectId);
30
+
31
+ /// @notice Thrown when burning more credits than the holder's credit balance.
25
32
  error JBTokens_InsufficientCredits(uint256 count, uint256 creditBalance);
33
+
34
+ /// @notice Thrown when burning more tokens than the holder's combined token and credit balance.
26
35
  error JBTokens_InsufficientTokensToBurn(uint256 count, uint256 tokenBalance);
36
+
37
+ /// @notice Thrown when minting would push the total supply past the uint208 maximum.
27
38
  error JBTokens_OverflowAlert(uint256 value, uint256 limit);
39
+
40
+ /// @notice Thrown when the project already has a token set.
28
41
  error JBTokens_ProjectAlreadyHasToken(IJBToken token);
42
+
43
+ /// @notice Thrown when the token is already in use by another project.
29
44
  error JBTokens_TokenAlreadyBeingUsed(uint256 projectId);
45
+
46
+ /// @notice Thrown when the token reports that it cannot be added to the project.
30
47
  error JBTokens_TokenCantBeAdded(uint256 projectId);
48
+
49
+ /// @notice Thrown when the project has no token set.
31
50
  error JBTokens_TokenNotFound(uint256 projectId);
51
+
52
+ /// @notice Thrown when the token does not use 18 decimals.
32
53
  error JBTokens_TokensMustHave18Decimals(uint256 decimals);
33
54
 
34
55
  //*********************************************************************//
@@ -12,6 +12,7 @@ abstract contract JBControlled is IJBControlled {
12
12
  // --------------------------- custom errors -------------------------- //
13
13
  //*********************************************************************//
14
14
 
15
+ /// @notice Thrown when the caller is not the controller of the specified project.
15
16
  error JBControlled_ControllerUnauthorized(address controller);
16
17
 
17
18
  //*********************************************************************//
@@ -14,6 +14,7 @@ abstract contract JBPermissioned is Context, IJBPermissioned {
14
14
  // --------------------------- custom errors -------------------------- //
15
15
  //*********************************************************************//
16
16
 
17
+ /// @notice Thrown when the sender lacks the required permission from the account to perform the operation.
17
18
  error JBPermissioned_Unauthorized(address account, address sender, uint256 projectId, uint256 permissionId);
18
19
 
19
20
  //*********************************************************************//
@@ -2,12 +2,12 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  /// @notice The lifecycle states a queued ruleset can be in relative to its approval hook.
5
- /// @dev `Empty` — no ruleset exists. `Upcoming` — queued but not yet eligible for approval check. `Active` —
6
- /// currently
7
- /// governing the project. `ApprovalExpected` — the deadline hasn't passed yet, expected to be approved.
8
- /// `Approved` — passed the approval hook and will take effect. `Failed` — rejected by the approval hook; the
9
- /// previous
10
- /// ruleset continues.
5
+ /// @dev `Empty` — no ruleset exists.
6
+ /// `Upcoming` — queued but not yet eligible for approval check.
7
+ /// `Active` — currently governing the project.
8
+ /// `ApprovalExpected` — the deadline hasn't passed yet, expected to be approved.
9
+ /// `Approved` — passed the approval hook and will take effect.
10
+ /// `Failed` — rejected by the approval hook; the previous ruleset continues.
11
11
  enum JBApprovalStatus {
12
12
  Empty,
13
13
  Upcoming,
@@ -84,8 +84,6 @@ interface IJBCashOutTerminal is IJBTerminal {
84
84
  /// @param minTokensReclaimed The minimum number of terminal tokens that must be reclaimed.
85
85
  /// @param beneficiary The address to send the reclaimed terminal tokens to.
86
86
  /// @param metadata Extra data to send to the data hook and cash out hooks.
87
- /// @param referralProjectId Optional project to credit with the protocol fee volume taken by this call. Pass `0`
88
- /// for no referral credit.
89
87
  /// @return reclaimAmount The number of terminal tokens reclaimed from the project's surplus.
90
88
  function cashOutTokensOf(
91
89
  address holder,
@@ -94,8 +92,7 @@ interface IJBCashOutTerminal is IJBTerminal {
94
92
  address tokenToReclaim,
95
93
  uint256 minTokensReclaimed,
96
94
  address payable beneficiary,
97
- bytes calldata metadata,
98
- uint256 referralProjectId
95
+ bytes calldata metadata
99
96
  )
100
97
  external
101
98
  returns (uint256 reclaimAmount);
@@ -31,19 +31,6 @@ interface IJBMultiTerminal is IJBTerminal, IJBFeeTerminal, IJBCashOutTerminal, I
31
31
  /// @notice The contract that manages token minting and burning.
32
32
  function TOKENS() external view returns (IJBTokens);
33
33
 
34
- /// @notice The caller-originated referrer reference for the in-flight fee-paying external call.
35
- /// @dev Encoded as `(referralChainId << 48) | referralProjectId`: bits [79:48] are the referrer's EIP-155 chain
36
- /// ID (uint32), bits [47:0] are the referrer's project ID on that chain (uint48). Allows a referrer with a
37
- /// project on chain X to be credited for activity on chain Y. A bare project ID (chain bits zero) is auto-
38
- /// resolved to the current execution chain via `block.chainid` at the entry point, so storage and indexers
39
- /// always see a fully-resolved `(chainId, projectId)` pair.
40
- /// @dev Backed by transient storage. Set by `cashOutTokensOf`, `sendPayoutsOf`, and `useAllowanceOf` (save-
41
- /// restore wrapper) so hooks invoked during that call (pay hooks, cash out hooks, split hooks) can introspect
42
- /// which referrer originated the activity. Reads `0` outside any fee-paying call.
43
- /// @dev Per-referrer cumulative fee payment amounts credited via this terminal are stored in
44
- /// `JBTerminalStore.feeVolumeByReferralOf(address terminal, uint256 referralChainId, uint256 referralProjectId)`.
45
- function currentReferralProjectId() external view returns (uint256);
46
-
47
34
  /// @notice The cumulative amount of fee-free intra-terminal payouts a project has received for a given token.
48
35
  /// @dev Incremented each time a fee-free payout lands (same terminal, no fee charged) and consumed during
49
36
  /// zero-tax cash outs to prevent a round-trip fee bypass (intra-terminal payout -> zero-tax cash out). Exposed
@@ -102,16 +102,13 @@ interface IJBPayoutTerminal is IJBTerminal {
102
102
  /// @param amount The total amount of tokens to pay out.
103
103
  /// @param currency The currency the amount is denominated in.
104
104
  /// @param minTokensPaidOut The minimum number of terminal tokens expected to be paid out.
105
- /// @param referralProjectId Optional project to credit with the protocol fee volume taken by this call. Pass `0`
106
- /// for no referral credit.
107
105
  /// @return amountPaidOut The total amount paid out.
108
106
  function sendPayoutsOf(
109
107
  uint256 projectId,
110
108
  address token,
111
109
  uint256 amount,
112
110
  uint256 currency,
113
- uint256 minTokensPaidOut,
114
- uint256 referralProjectId
111
+ uint256 minTokensPaidOut
115
112
  )
116
113
  external
117
114
  returns (uint256 amountPaidOut);
@@ -125,8 +122,6 @@ interface IJBPayoutTerminal is IJBTerminal {
125
122
  /// @param beneficiary The address to send the funds to.
126
123
  /// @param feeBeneficiary The address that will receive any project tokens minted from fees.
127
124
  /// @param memo A memo to pass along to the emitted event.
128
- /// @param referralProjectId Optional project to credit with the protocol fee volume taken by this call. Pass `0`
129
- /// for no referral credit.
130
125
  /// @return netAmountPaidOut The net amount paid out to the beneficiary after fees.
131
126
  function useAllowanceOf(
132
127
  uint256 projectId,
@@ -136,8 +131,7 @@ interface IJBPayoutTerminal is IJBTerminal {
136
131
  uint256 minTokensPaidOut,
137
132
  address payable beneficiary,
138
133
  address payable feeBeneficiary,
139
- string calldata memo,
140
- uint256 referralProjectId
134
+ string calldata memo
141
135
  )
142
136
  external
143
137
  returns (uint256 netAmountPaidOut);
@@ -15,25 +15,6 @@ import {JBTokenAmount} from "../structs/JBTokenAmount.sol";
15
15
  /// allowances, calculates token issuance per payment, and determines cash-out reclaim amounts via the bonding curve.
16
16
  /// Terminals delegate all state-changing accounting to this contract.
17
17
  interface IJBTerminalStore {
18
- /// @notice Emitted when a referrer is credited with a fee payment amount.
19
- /// @dev `referralChainId` and `referralProjectId` are emitted as separate indexed topics so off-chain consumers
20
- /// can filter directly on either dimension. The public `feeVolumeByReferralOf` getter exposes the same unpacked
21
- /// `(terminal, referralChainId, referralProjectId)` tuple.
22
- /// @param terminal The terminal that originated the fee-paying call (`msg.sender` on `recordFeeReferralCreditOf`).
23
- /// @param referralChainId The EIP-155 chain ID of the referrer's home chain.
24
- /// @param referralProjectId The referrer's bare project ID on `referralChainId` (no chain bits).
25
- /// @param amount The fee amount credited, in the terminal's accounting-context units.
26
- /// @param newTotal The new value of `totalFeeVolumeOf[terminal]` after this credit.
27
- /// @param caller The address that recorded the credit.
28
- event ReferralCredit(
29
- address indexed terminal,
30
- uint256 indexed referralChainId,
31
- uint256 indexed referralProjectId,
32
- uint256 amount,
33
- uint256 newTotal,
34
- address caller
35
- );
36
-
37
18
  /// @notice The directory of terminals and controllers for projects.
38
19
  function DIRECTORY() external view returns (IJBDirectory);
39
20
 
@@ -161,27 +142,6 @@ interface IJBTerminalStore {
161
142
  view
162
143
  returns (uint256);
163
144
 
164
- /// @notice The cumulative fee payment amount credited to a referrer (chainId, projectId) pair as a result of
165
- /// fee-paying calls that originated through a given terminal.
166
- /// @dev Written by terminals via `recordFeeReferralCreditOf` — `msg.sender` is recorded as the writing terminal,
167
- /// so a malicious caller can only pollute their own slot. Off-chain consumers should filter on known terminal
168
- /// addresses.
169
- /// @dev Nested by chain ID then project ID so consumers can read the credit for a specific
170
- /// `(chainId, projectId)` directly without re-packing the encoded form. The encoded `(chainId << 48) | projectId`
171
- /// form is used only inside the transient slot and the entry-point parameter; storage exposes the unpacked pair.
172
- /// @param terminal The terminal that originated the fee-paying call.
173
- /// @param referralChainId The EIP-155 chain ID of the referrer's home chain.
174
- /// @param referralProjectId The referrer's bare project ID on `referralChainId`.
175
- /// @return The cumulative fee amount credited.
176
- function feeVolumeByReferralOf(
177
- address terminal,
178
- uint256 referralChainId,
179
- uint256 referralProjectId
180
- )
181
- external
182
- view
183
- returns (uint256);
184
-
185
145
  /// @notice Simulates a cash out without modifying state.
186
146
  /// @param terminal The terminal to simulate the cash out from.
187
147
  /// @param holder The address cashing out.
@@ -234,13 +194,6 @@ interface IJBTerminalStore {
234
194
  view
235
195
  returns (JBRuleset memory ruleset, uint256 tokenCount, JBPayHookSpecification[] memory hookSpecifications);
236
196
 
237
- /// @notice The cumulative fee payment amount credited across all referral projects for a given terminal.
238
- /// @dev Incremented in lockstep with `feeVolumeByReferralOf` so consumers can compute pro-rata shares in a
239
- /// single SLOAD pair without enumerating referrers.
240
- /// @param terminal The terminal that originated the fee-paying calls.
241
- /// @return The cumulative total fee amount credited across all referrers for this terminal.
242
- function totalFeeVolumeOf(address terminal) external view returns (uint256);
243
-
244
197
  /// @notice Returns the amount of payout limit used by a terminal for a project in a given cycle.
245
198
  /// @param terminal The terminal to get the used payout limit of.
246
199
  /// @param projectId The ID of the project.
@@ -316,15 +269,6 @@ interface IJBTerminalStore {
316
269
  JBCashOutHookSpecification[] memory hookSpecifications
317
270
  );
318
271
 
319
- /// @notice Credit a referral project with a fee payment amount routed through `msg.sender` (the calling terminal).
320
- /// @dev Permissionless: the write is scoped to `msg.sender`'s slot, so an arbitrary caller can only pollute
321
- /// their own bucket. The amount is normalized to `JBConstants.NATIVE_TOKEN` units (18 decimals) using the fee
322
- /// project's price feeds so credits across different fee tokens (ETH, USDC, USDT, …) are summable. No-op when
323
- /// `referralProjectId == 0`, when `amount.value == 0`, or when no price feed exists for the pair.
324
- /// @param referralProjectId The referral project to credit.
325
- /// @param amount The fee amount paid by this fee-take call (raw token amount, decimals, and currency).
326
- function recordFeeReferralCreditOf(uint256 referralProjectId, JBTokenAmount calldata amount) external;
327
-
328
272
  /// @notice Records a payment to a project.
329
273
  /// @param payer The address of the payer.
330
274
  /// @param amount The amount to pay.
@@ -25,9 +25,16 @@ pragma solidity 0.8.28;
25
25
  * +-----------------------+
26
26
  */
27
27
  library JBMetadataResolver {
28
+ /// @notice Thrown when the data to add is not padded to a multiple of 32 bytes.
28
29
  error JBMetadataResolver_DataNotPadded(uint256 dataLength);
30
+
31
+ /// @notice Thrown when the IDs and datas arrays have mismatched lengths.
29
32
  error JBMetadataResolver_LengthMismatch(uint256 idsLength, uint256 datasLength);
33
+
34
+ /// @notice Thrown when the metadata offset exceeds the maximum addressable offset of 255.
30
35
  error JBMetadataResolver_MetadataTooLong(uint256 offset, uint256 maxOffset);
36
+
37
+ /// @notice Thrown when the metadata is shorter than the minimum required length.
31
38
  error JBMetadataResolver_MetadataTooShort(uint256 metadataLength, uint256 minMetadataLength);
32
39
 
33
40
  // Constants alphabetized per STYLE_GUIDE; trailing comments document derivation.
@@ -260,7 +267,7 @@ library JBMetadataResolver {
260
267
  if (parsedId == id) {
261
268
  // Are we at the end of the lookup table (either at the start of data's or next offset is 0/in the
262
269
  // padding)
263
- // If not, only return until from this offset to the begining of the next offset
270
+ // If not, only return until from this offset to the beginning of the next offset
264
271
  uint256 end = (i + NEXT_ID_OFFSET >= firstOffset * WORD_SIZE || metadata[i + NEXT_ID_OFFSET] == 0)
265
272
  ? metadata.length
266
273
  : uint256(uint8(metadata[i + NEXT_ID_OFFSET])) * WORD_SIZE;
@@ -295,6 +302,7 @@ library JBMetadataResolver {
295
302
  /// @param start The start index to slice at.
296
303
  /// @param end The end index to slice at.
297
304
  /// @param slicedBytes The sliced array.
305
+ /// @return slicedBytes The sliced array.
298
306
  function _sliceBytes(bytes memory data, uint256 start, uint256 end)
299
307
  private
300
308
  pure
@@ -44,8 +44,22 @@ interface IJBPayoutSplitGroupExecutor {
44
44
  /// @dev Extracted as an external library to reduce `JBMultiTerminal` bytecode size. Called via DELEGATECALL, so events
45
45
  /// are emitted from the terminal's address.
46
46
  library JBPayoutSplitGroupLib {
47
+ /// @notice A payout to a split reverted, so the amount was returned to the project's balance.
48
+ /// @param projectId The ID of the project whose payout reverted.
49
+ /// @param split The split that was being paid when the revert occurred.
50
+ /// @param amount The amount that was being sent to the split.
51
+ /// @param reason The reason the payout reverted.
52
+ /// @param caller The address that called the payout function.
47
53
  event PayoutReverted(uint256 indexed projectId, JBSplit split, uint256 amount, bytes reason, address caller);
48
54
 
55
+ /// @notice A payout was sent to a split.
56
+ /// @param projectId The ID of the project that the payout was made from.
57
+ /// @param rulesetId The ID of the ruleset the split belongs to.
58
+ /// @param group The group the split belongs to.
59
+ /// @param split The split that was paid.
60
+ /// @param amount The amount that was sent to the split.
61
+ /// @param netAmount The amount that the split recipient actually received, after fees.
62
+ /// @param caller The address that called the payout function.
49
63
  event SendPayoutToSplit(
50
64
  uint256 indexed projectId,
51
65
  uint256 indexed rulesetId,
@@ -8,7 +8,9 @@ import {IJBPriceFeed} from "../interfaces/IJBPriceFeed.sol";
8
8
  contract JBMatchingPriceFeed is IJBPriceFeed {
9
9
  constructor() {}
10
10
 
11
- /// @inheritdoc IJBPriceFeed
11
+ /// @notice Gets the current price (per 1 unit) from the feed.
12
+ /// @param decimals The number of decimals the return value should use.
13
+ /// @return The current unit price from the feed, as a fixed point number with the specified number of decimals.
12
14
  function currentUnitPrice(uint256 decimals) public view virtual override returns (uint256) {
13
15
  return 10 ** decimals;
14
16
  }
@@ -4,20 +4,10 @@ pragma solidity ^0.8.0;
4
4
  /// @custom:member amount The total amount the fee was taken from, as a fixed point number with the same number of
5
5
  /// decimals as the token's accounting context. `uint224` covers any realistic per-call fee basis (max
6
6
  /// ~2.7e49 ETH-equivalent at 18 decimals) and is the same width the protocol's payout/surplus-allowance limits use.
7
- /// @custom:member referralChainId The EIP-155 chain ID of the referrer's home chain, captured from the upper bits of
8
- /// the transient referral encoding at fee-take time. A value of `0` is the "current chain" sentinel — a referrer that
9
- /// only encoded a project ID without a chain prefix is credited on the chain the fee is paid on. Packing this beside
10
- /// `amount` in the same storage slot avoids growing `JBFee` to a third slot.
11
7
  /// @custom:member beneficiary The address that will receive the tokens that are minted as a result of the fee payment.
12
8
  /// @custom:member unlockTimestamp The timestamp at which the fee is unlocked and can be processed.
13
- /// @custom:member referralProjectId The referrer's project ID on `referralChainId`. Captured from the lower bits of
14
- /// `currentReferralProjectId` at fee-take time so held-fee attribution survives the 28-day hold window. The transient
15
- /// slot and terminal entry-point arguments use the packed `(referralChainId << 48) | referralProjectId` form; this
16
- /// struct stores the two halves separately for cheap storage.
17
9
  struct JBFee {
18
10
  uint224 amount;
19
- uint32 referralChainId;
20
11
  address beneficiary;
21
12
  uint48 unlockTimestamp;
22
- uint48 referralProjectId;
23
13
  }
@@ -18,8 +18,7 @@ contract MaliciousPayoutBeneficiary is IERC721Receiver, Test {
18
18
  amount: 5 * 10 ** 18,
19
19
  currency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
20
20
  token: JBConstants.NATIVE_TOKEN,
21
- minTokensPaidOut: 0,
22
- referralProjectId: 0
21
+ minTokensPaidOut: 0
23
22
  });
24
23
  assertEq(_reentrantPayout, 0);
25
24
  }
@@ -50,8 +49,7 @@ contract MaliciousAllowanceBeneficiary is IERC721Receiver, Test {
50
49
  minTokensPaidOut: 0,
51
50
  beneficiary: payable(address(this)),
52
51
  feeBeneficiary: payable(0x000000000000000000000000000000000000007B),
53
- memo: "MEMO",
54
- referralProjectId: 0
52
+ memo: "MEMO"
55
53
  });
56
54
  }
57
55