@bananapus/core-v6 0.0.40 → 0.0.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananapus/core-v6",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1238,7 +1238,7 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
1238
1238
 
1239
1239
  /// @notice Splits a token count into beneficiary and reserved portions.
1240
1240
  /// @param tokenCount The total token count, including reserved tokens.
1241
- /// @param reservedPercent The reserved percent to apply.
1241
+ /// @param reservedPercent The reserved percent to apply, out of `JBConstants.MAX_RESERVED_PERCENT`.
1242
1242
  /// @return beneficiaryTokenCount The number of tokens for the beneficiary.
1243
1243
  /// @return reservedTokenCount The number of tokens to reserve.
1244
1244
  function _splitTokenCount(
@@ -159,7 +159,7 @@ contract JBFundAccessLimits is JBControlled, IJBFundAccessLimits {
159
159
 
160
160
  /// @notice Look up how much a project can distribute (via `sendPayoutsOf`) from a specific terminal and token,
161
161
  /// denominated in a specific currency. Returns 0 if no limit is configured for that currency.
162
- /// @dev The fixed point return amount uses the same number of decimals as the terminal.
162
+ /// @dev The fixed point return amount uses the same number of decimals as the token's accounting context.
163
163
  /// @param projectId The project's ID.
164
164
  /// @param rulesetId The ruleset's ID.
165
165
  /// @param terminal The terminal the payout limit applies to.
@@ -203,7 +203,7 @@ contract JBFundAccessLimits is JBControlled, IJBFundAccessLimits {
203
203
 
204
204
  /// @notice Get all payout limits for a project's terminal and token during a ruleset. A project can have multiple
205
205
  /// payout limits denominated in different currencies (e.g. 10,000 USD + 5 ETH). Each is enforced independently.
206
- /// @dev The fixed point `amount`s returned use the same number of decimals as the terminal.
206
+ /// @dev The fixed point `amount`s returned use the same number of decimals as the token's accounting context.
207
207
  /// @param projectId The project's ID.
208
208
  /// @param rulesetId The ruleset's ID.
209
209
  /// @param terminal The terminal the payout limits apply to.
@@ -250,7 +250,7 @@ contract JBFundAccessLimits is JBControlled, IJBFundAccessLimits {
250
250
 
251
251
  /// @notice Look up how much a project's owner can withdraw from the surplus (via `useAllowanceOf`) from a specific
252
252
  /// terminal and token, denominated in a specific currency. Returns 0 if no allowance is configured.
253
- /// @dev The fixed point return amount uses the same number of decimals as the terminal.
253
+ /// @dev The fixed point return amount uses the same number of decimals as the token's accounting context.
254
254
  /// @param projectId The project's ID.
255
255
  /// @param rulesetId The ruleset's ID.
256
256
  /// @param terminal The terminal the surplus allowance applies to.
@@ -295,7 +295,7 @@ contract JBFundAccessLimits is JBControlled, IJBFundAccessLimits {
295
295
 
296
296
  /// @notice Get all surplus allowances for a project's terminal and token during a ruleset. Like payout limits, a
297
297
  /// project can have multiple surplus allowances in different currencies, each enforced independently.
298
- /// @dev The fixed point `amount`s returned use the same number of decimals as the terminal.
298
+ /// @dev The fixed point `amount`s returned use the same number of decimals as the token's accounting context.
299
299
  /// @param projectId The project's ID.
300
300
  /// @param rulesetId The ruleset's ID.
301
301
  /// @param terminal The terminal the surplus allowances apply to.
@@ -88,9 +88,6 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
88
88
  // ------------------------ internal constants ----------------------- //
89
89
  //*********************************************************************//
90
90
 
91
- /// @notice Denominator for forward-calculating this terminal's fee from a pre-fee amount.
92
- uint256 internal constant _FEE_AMOUNT_FROM_DENOMINATOR = JBConstants.MAX_FEE / FEE;
93
-
94
91
  /// @notice Project ID #1 receives fees. It should be the first project launched during the deployment process.
95
92
  uint256 internal constant _FEE_BENEFICIARY_PROJECT_ID = 1;
96
93
 
@@ -229,7 +226,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
229
226
  /// @dev If `shouldReturnHeldFees` is true, the added amount offsets held fees proportionally.
230
227
  /// @param projectId The ID of the project to add funds to the balance of.
231
228
  /// @param amount The amount of tokens to add to the balance, as a fixed point number with the same number of
232
- /// decimals as this terminal. If this is a native token terminal, this is ignored and `msg.value` is used instead.
229
+ /// decimals as the token's accounting context. If this is a native token terminal, this is ignored and `msg.value`
230
+ /// is used instead.
233
231
  /// @param token The token to add to the balance.
234
232
  /// @param shouldReturnHeldFees If true, return held fees proportional to the amount added.
235
233
  /// @param memo A memo to pass along to the emitted event.
@@ -266,8 +264,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
266
264
  /// decimals.
267
265
  /// @param tokenToReclaim The token to reclaim.
268
266
  /// @param minTokensReclaimed The minimum number of terminal tokens expected in return, as a fixed point number with
269
- /// the same number of decimals as this terminal. If the amount of tokens minted for the beneficiary would be less
270
- /// than this amount, the cash out is reverted.
267
+ /// the same number of decimals as the token's accounting context. If the amount of tokens minted for the
268
+ /// beneficiary would be less than this amount, the cash out is reverted.
271
269
  /// @param beneficiary The address to send the cashed out terminal tokens to, and to pass along to the ruleset's
272
270
  /// data hook and cash out hook if applicable.
273
271
  /// @param metadata Bytes to send along to the emitted event, as well as the data hook and cash out hook if
@@ -310,7 +308,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
310
308
  /// @param projectId The ID of the project the split belongs to.
311
309
  /// @param token The address of the token to pay to the split.
312
310
  /// @param amount The total amount to pay to the split, as a fixed point number with the same number of
313
- /// decimals as this terminal.
311
+ /// decimals as the token's accounting context.
314
312
  /// @return netPayoutAmount The amount sent to the split after subtracting fees.
315
313
  function executePayout(
316
314
  JBSplit calldata split,
@@ -572,14 +570,14 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
572
570
  /// beneficiary will receive.
573
571
  /// @param projectId The ID of the project to pay.
574
572
  /// @param amount The amount of tokens to send, as a fixed point number with the same number of
575
- /// decimals as this terminal. If this terminal's token is native, this is ignored and `msg.value` is used in its
576
- /// place.
573
+ /// decimals as the token's accounting context. If this terminal's token is native, this is ignored and `msg.value`
574
+ /// is used in its place.
577
575
  /// @param token The token to pay with.
578
576
  /// @param beneficiary The address to mint tokens to, and pass along to the ruleset's data hook and pay hook if
579
577
  /// applicable.
580
578
  /// @param minReturnedTokens The minimum number of project tokens expected in return for this payment, as a fixed
581
- /// point number with the same number of decimals as this terminal. If the amount of tokens minted for the
582
- /// beneficiary would be less than this amount, the payment is reverted.
579
+ /// point number with the same number of decimals as the token's accounting context. If the amount of tokens minted
580
+ /// for the beneficiary would be less than this amount, the payment is reverted.
583
581
  /// @param memo A memo to pass along to the emitted event.
584
582
  /// @param metadata Bytes to pass along to the emitted event, as well as the data hook and pay hook if applicable.
585
583
  /// @return beneficiaryTokenCount The number of tokens minted to the beneficiary, as a fixed point number with 18
@@ -703,13 +701,14 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
703
701
  /// exempt.
704
702
  /// @param projectId The ID of the project having its payouts sent.
705
703
  /// @param token The token to send.
706
- /// @param amount The total number of terminal tokens to send, as a fixed point number with same number of decimals
707
- /// as this terminal.
704
+ /// @param amount The total number of terminal tokens to send, as a fixed point number with the same number of
705
+ /// decimals as the token's accounting context.
708
706
  /// @param currency The expected currency of the payouts. Must match the currency of one of the
709
707
  /// project's current ruleset's payout limits.
710
708
  /// @param minTokensPaidOut The minimum number of terminal tokens that the `amount` should be worth (if expressed
711
- /// in terms of this terminal's currency), as a fixed point number with the same number of decimals as this
712
- /// terminal. If the amount of tokens paid out would be less than this amount, the send is reverted.
709
+ /// in terms of the token's accounting context currency), as a fixed point number with the same number of decimals
710
+ /// as the token's accounting context. If the amount of tokens paid out would be less than this amount, the send is
711
+ /// reverted.
713
712
  /// @return amountPaidOut The total amount paid out.
714
713
  function sendPayoutsOf(
715
714
  uint256 projectId,
@@ -735,7 +734,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
735
734
  /// @param projectId The ID of the project to use the surplus allowance of.
736
735
  /// @param token The token to pay out from the surplus.
737
736
  /// @param amount The amount of terminal tokens to use from the project's current surplus allowance, as a fixed
738
- /// point number with the same amount of decimals as this terminal.
737
+ /// point number with the same number of decimals as the token's accounting context.
739
738
  /// @param currency The expected currency of the amount to pay out. Must match the currency of one of the
740
739
  /// project's current ruleset's surplus allowances.
741
740
  /// @param minTokensPaidOut The minimum number of terminal tokens that should be returned from the surplus allowance
@@ -745,7 +744,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
745
744
  /// @param feeBeneficiary The address to send the tokens resulting from paying the fee.
746
745
  /// @param memo A memo to pass along to the emitted event.
747
746
  /// @return netAmountPaidOut The number of tokens that were sent to the beneficiary, as a fixed point number with
748
- /// the same amount of decimals as the terminal.
747
+ /// the same number of decimals as the token's accounting context.
749
748
  function useAllowanceOf(
750
749
  uint256 projectId,
751
750
  address token,
@@ -1408,8 +1407,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1408
1407
  /// @param cashOutCount The number of tokens to cash out.
1409
1408
  /// @param metadata Bytes to send along to the emitted event and cash out hooks as applicable.
1410
1409
  /// @param ruleset The ruleset active during this cash out as a `JBRuleset` struct.
1411
- /// @param cashOutTaxRate The cash out tax rate influencing the reclaim amount.
1412
- /// @param beneficiary The address which will receive any terminal tokens that are cashed out.
1410
+ /// @param cashOutTaxRate The cash out tax rate influencing the reclaim amount, out of
1411
+ /// `JBConstants.MAX_CASH_OUT_TAX_RATE`. @param beneficiary The address which will receive any terminal tokens that
1412
+ /// are cashed out.
1413
1413
  /// @param specifications The hook specifications to fulfill.
1414
1414
  /// @return amountEligibleForFees The amount of funds which were allocated to cash out hooks and are eligible for
1415
1415
  /// fees.
@@ -1593,8 +1593,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1593
1593
  /// @param projectId The ID of the project to pay.
1594
1594
  /// @param token The address of the token to pay the project with.
1595
1595
  /// @param amount The amount of tokens to send, as a fixed point number with the same number of
1596
- /// decimals as this terminal. If this terminal's token is the native token, `amount` is ignored and `msg.value` is
1597
- /// used in its place.
1596
+ /// decimals as the token's accounting context. If this terminal's token is the native token, `amount` is ignored
1597
+ /// and `msg.value` is used in its place.
1598
1598
  /// @param payer The address making the payment.
1599
1599
  /// @param beneficiary The address to mint tokens to, and pass along to the ruleset's data hook and pay hook if
1600
1600
  /// applicable.
@@ -1733,9 +1733,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1733
1733
  /// @param projectId The project to return held fees to.
1734
1734
  /// @param token The token that the held fees are in.
1735
1735
  /// @param amount The amount to base the calculation on, as a fixed point number with the same number of decimals
1736
- /// as this terminal.
1736
+ /// as the token's accounting context.
1737
1737
  /// @return returnedFees The amount of held fees that were returned, as a fixed point number with the same number of
1738
- /// decimals as this terminal
1738
+ /// decimals as the token's accounting context.
1739
1739
  function _returnHeldFees(uint256 projectId, address token, uint256 amount) internal returns (uint256 returnedFees) {
1740
1740
  // Keep a reference to the start index.
1741
1741
  uint256 startIndex = _nextHeldFeeIndexOf[projectId][token];
@@ -1779,9 +1779,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1779
1779
  // Move the start index forward to the held fee after the current one.
1780
1780
  newStartIndex = startIndex + i + 1;
1781
1781
  } else {
1782
- // Use the floor variant here. The minimum 1-unit fee applies when a fee is created, not while
1783
- // splitting an already-held fee entry across repayments.
1784
- feeAmount = JBFees.feeAmountResultingInFloorForFee25(leftoverAmount);
1782
+ feeAmount = JBFees.feeAmountResultingIn({amountAfterFee: leftoverAmount, feePercent: FEE});
1785
1783
 
1786
1784
  // Get fee from `leftoverAmount`.
1787
1785
  unchecked {
@@ -1812,8 +1810,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1812
1810
  /// @notice Sends payouts to a project's payout split group using the specified ruleset.
1813
1811
  /// @param projectId The ID of the project to send the payouts of.
1814
1812
  /// @param token The token to pay out.
1815
- /// @param amount The number of terminal tokens to pay out, as a fixed point number with same number of decimals as
1816
- /// this terminal.
1813
+ /// @param amount The number of terminal tokens to pay out, as a fixed point number with the same number of decimals
1814
+ /// as the token's accounting context.
1817
1815
  /// @param currency The expected currency of the amount to pay out. Must match the currency of one of the
1818
1816
  /// project's current ruleset's payout limits.
1819
1817
  /// @return amountPaidOut The total amount that was paid out.
@@ -2013,7 +2011,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
2013
2011
  /// @param owner The project's owner.
2014
2012
  /// @param token The token to pay out from the surplus.
2015
2013
  /// @param amount The amount of terminal tokens to use from the project's current surplus allowance, as a fixed
2016
- /// point number with the same amount of decimals as this terminal.
2014
+ /// point number with the same number of decimals as the token's accounting context.
2017
2015
  /// @param currency The expected currency of the amount to pay out. Must match the currency of one of the
2018
2016
  /// project's current ruleset's surplus allowances.
2019
2017
  /// @param beneficiary The address to send the funds to.
@@ -2199,12 +2197,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
2199
2197
  //*********************************************************************//
2200
2198
 
2201
2199
  /// @notice The terminal fee charged from a pre-fee `amount`.
2202
- /// @dev Returns at least 1 for nonzero feeable amounts so dust payouts cannot bypass protocol fees.
2203
2200
  /// @param amount The amount before the fee is applied.
2204
- /// @return feeAmount The fee amount.
2205
- function _feeAmountFrom(uint256 amount) private pure returns (uint256 feeAmount) {
2206
- feeAmount = amount / _FEE_AMOUNT_FROM_DENOMINATOR;
2207
-
2208
- return feeAmount == 0 && amount != 0 ? 1 : feeAmount;
2201
+ /// @return The fee amount.
2202
+ function _feeAmountFrom(uint256 amount) private pure returns (uint256) {
2203
+ return JBFees.feeAmountFrom({amountBeforeFee: amount, feePercent: FEE});
2209
2204
  }
2210
2205
  }
@@ -96,8 +96,9 @@ contract JBRulesets is JBControlled, IJBRulesets {
96
96
  /// replaced). When a duration ends without a queued replacement, the ruleset rolls over with decayed weight.
97
97
  /// @param weight Tokens minted per unit paid (18 decimals). Terminals divide payment amount by weight to determine
98
98
  /// issuance. A value of 1 means "inherit decayed weight from previous ruleset".
99
- /// @param weightCutPercent How much to reduce weight each auto-cycle (out of 1,000,000,000). Only applies when no
100
- /// explicit replacement is queued. 0 = no decay. 100,000,000 = 10% cut per cycle.
99
+ /// @param weightCutPercent How much to reduce weight each auto-cycle, out of
100
+ /// `JBConstants.MAX_WEIGHT_CUT_PERCENT`. Only applies when no explicit replacement is queued. 0 = no decay.
101
+ /// 100,000,000 = 10% cut per cycle.
101
102
  /// @param approvalHook A contract that gates whether the *next* queued ruleset can take effect (e.g. `JBDeadline`
102
103
  /// for minimum notice periods). Set to address(0) for no approval gate.
103
104
  /// @param metadata Packed 256-bit field decoded by `JBRulesetMetadataResolver`. Not used by `JBRulesets` itself.
@@ -614,7 +615,8 @@ contract JBRulesets is JBControlled, IJBRulesets {
614
615
  /// @param baseRulesetStart The start time of the base ruleset.
615
616
  /// @param baseRulesetDuration The duration of the base ruleset.
616
617
  /// @param baseRulesetWeight The weight of the base ruleset.
617
- /// @param baseRulesetWeightCutPercent The weight cut percent of the base ruleset.
618
+ /// @param baseRulesetWeightCutPercent The weight cut percent of the base ruleset, out of
619
+ /// `JBConstants.MAX_WEIGHT_CUT_PERCENT`.
618
620
  /// @param baseRulesetCacheId The ID of the ruleset to base the calculation on (the previous ruleset).
619
621
  /// @param start The start time of the ruleset to derive a weight for.
620
622
  /// @return weight The derived weight, as a fixed point number with 18 decimals.
@@ -16,7 +16,7 @@ interface IJBCashOutTerminal is IJBTerminal {
16
16
  /// @param holder The address whose tokens were cashed out.
17
17
  /// @param beneficiary The address that received the reclaimed funds.
18
18
  /// @param cashOutCount The number of tokens cashed out.
19
- /// @param cashOutTaxRate The cash out tax rate applied.
19
+ /// @param cashOutTaxRate The cash out tax rate applied, out of `JBConstants.MAX_CASH_OUT_TAX_RATE`.
20
20
  /// @param reclaimAmount The amount of funds reclaimed.
21
21
  /// @param metadata Extra metadata associated with the cash out.
22
22
  /// @param caller The address that called the cash out function.
@@ -69,7 +69,7 @@ interface IJBController is IERC165, IJBProjectUriRegistry, IJBDirectoryAccessCon
69
69
  /// @param tokenCount The total number of tokens minted, including reserved tokens.
70
70
  /// @param beneficiaryTokenCount The number of tokens minted for the beneficiary.
71
71
  /// @param memo A memo associated with the mint.
72
- /// @param reservedPercent The reserved percent applied to the mint.
72
+ /// @param reservedPercent The reserved percent applied to the mint, out of `JBConstants.MAX_RESERVED_PERCENT`.
73
73
  /// @param caller The address that called the mint function.
74
74
  event MintTokens(
75
75
  address indexed beneficiary,
@@ -22,7 +22,8 @@ interface IJBRulesets {
22
22
  /// @param projectId The ID of the project the ruleset was queued for.
23
23
  /// @param duration The duration of the ruleset in seconds.
24
24
  /// @param weight The weight of the ruleset.
25
- /// @param weightCutPercent The percent by which the weight decreases each cycle.
25
+ /// @param weightCutPercent The percent by which the weight decreases each cycle, out of
26
+ /// `JBConstants.MAX_WEIGHT_CUT_PERCENT`.
26
27
  /// @param approvalHook The approval hook for the ruleset.
27
28
  /// @param metadata The packed ruleset metadata.
28
29
  /// @param mustStartAtOrAfter The earliest time the ruleset can start.
@@ -89,7 +90,8 @@ interface IJBRulesets {
89
90
  /// @param baseRulesetStart The start time of the base ruleset.
90
91
  /// @param baseRulesetDuration The duration of the base ruleset.
91
92
  /// @param baseRulesetWeight The weight of the base ruleset.
92
- /// @param baseRulesetWeightCutPercent The weight cut percent of the base ruleset.
93
+ /// @param baseRulesetWeightCutPercent The weight cut percent of the base ruleset, out of
94
+ /// `JBConstants.MAX_WEIGHT_CUT_PERCENT`.
93
95
  /// @param baseRulesetCacheId The cache ID of the base ruleset.
94
96
  /// @param start The start time to derive the weight for.
95
97
  /// @return weight The derived weight.
@@ -150,7 +152,8 @@ interface IJBRulesets {
150
152
  /// @param projectId The ID of the project to queue the ruleset for.
151
153
  /// @param duration The duration of the ruleset in seconds.
152
154
  /// @param weight The weight of the ruleset.
153
- /// @param weightCutPercent The percent by which the weight decreases each cycle.
155
+ /// @param weightCutPercent The percent by which the weight decreases each cycle, out of
156
+ /// `JBConstants.MAX_WEIGHT_CUT_PERCENT`.
154
157
  /// @param approvalHook The approval hook for the ruleset.
155
158
  /// @param metadata The packed ruleset metadata.
156
159
  /// @param mustStartAtOrAfter The earliest time the ruleset can start.
@@ -20,7 +20,7 @@ library JBCashOuts {
20
20
  /// @param surplus The total amount of surplus terminal tokens.
21
21
  /// @param cashOutCount The number of tokens to cash out, as a fixed point number with 18 decimals.
22
22
  /// @param totalSupply The total token supply, as a fixed point number with 18 decimals.
23
- /// @param cashOutTaxRate The current ruleset's cash out tax rate.
23
+ /// @param cashOutTaxRate The current ruleset's cash out tax rate, out of `JBConstants.MAX_CASH_OUT_TAX_RATE`.
24
24
  /// @return reclaimableSurplus The amount of surplus tokens that can be reclaimed.
25
25
  function cashOutFrom(
26
26
  uint256 surplus,
@@ -64,7 +64,7 @@ library JBCashOuts {
64
64
  /// @param surplus The total amount of surplus terminal tokens.
65
65
  /// @param desiredOutput The minimum amount of surplus tokens the caller wants to receive.
66
66
  /// @param totalSupply The total token supply, as a fixed point number with 18 decimals.
67
- /// @param cashOutTaxRate The current ruleset's cash out tax rate.
67
+ /// @param cashOutTaxRate The current ruleset's cash out tax rate, out of `JBConstants.MAX_CASH_OUT_TAX_RATE`.
68
68
  /// @return count The minimum number of tokens to cash out.
69
69
  function minCashOutCountFor(
70
70
  uint256 surplus,
@@ -5,68 +5,26 @@ import {mulDiv} from "@prb/math/src/Common.sol";
5
5
 
6
6
  import {JBConstants} from "./../libraries/JBConstants.sol";
7
7
 
8
- /// @notice Utility functions for calculating the protocol fee (2.5%) in both directions: forward (fee from a pre-fee
9
- /// amount) and backward (the pre-fee amount that would yield a given post-fee amount). Used by `JBMultiTerminal`
10
- /// during payouts, surplus allowance usage, and cash outs.
11
- /// @dev Fee dust protection: if a nonzero amount with a nonzero fee would otherwise round to 0, returns 1 wei to
12
- /// prevent fee bypass via many tiny transfers.
8
+ /// @notice Fee calculations.
13
9
  library JBFees {
14
- /// @notice Returns the fee that would be taken from `amountBeforeFee`.
15
- /// @dev Use this to forward-calculate the fee from a known pre-fee amount.
16
- /// @dev If a nonzero amount and nonzero fee would otherwise produce a zero fee, returns 1 so feeable dust payouts
17
- /// cannot bypass protocol fees by splitting across tiny transfers.
18
- /// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
19
- /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
20
- /// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
21
- function feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
22
- uint256 feeAmount = feeAmountFromFloor({amountBeforeFee: amountBeforeFee, feePercent: feePercent});
23
-
24
- return feeAmount == 0 && amountBeforeFee != 0 && feePercent != 0 ? 1 : feeAmount;
25
- }
26
-
27
- /// @notice Returns the floor-rounded fee that would be taken from `amountBeforeFee`.
28
- /// @dev Fee rounding error is bounded by N-1 wei (N = number of splits). Economically insignificant. Rounds down
29
- /// (mulDiv floors), so the fee beneficiary may receive up to 1 wei less per split.
30
- /// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
31
- /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
32
- /// @return The floor-rounded fee amount, as a fixed point number with the same number of decimals as the provided
33
- /// `amount`.
34
- function feeAmountFromFloor(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
35
- return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);
36
- }
37
-
38
10
  /// @notice Returns the fee amount that, when added to `amountAfterFee`, produces the gross amount needed to yield
39
11
  /// `amountAfterFee` after the fee is deducted.
40
12
  /// @dev Use this to back-calculate the fee from a desired post-fee payout.
41
- /// @dev If a nonzero amount and nonzero fee would otherwise produce a zero fee, returns 1 so feeable dust payouts
42
- /// cannot bypass protocol fees by splitting across tiny transfers.
43
13
  /// @param amountAfterFee The desired post-fee amount, as a fixed point number.
44
14
  /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
45
15
  /// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
46
16
  function feeAmountResultingIn(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {
47
- uint256 feeAmount = feeAmountResultingInFloor({amountAfterFee: amountAfterFee, feePercent: feePercent});
48
-
49
- return feeAmount == 0 && amountAfterFee != 0 && feePercent != 0 ? 1 : feeAmount;
50
- }
51
-
52
- /// @notice Returns the floor-rounded fee amount that, when added to `amountAfterFee`, produces the gross amount
53
- /// needed to yield `amountAfterFee` after the fee is deducted.
54
- /// @dev Use this when adjusting an existing held-fee entry, where applying the 1-unit minimum again would double
55
- /// charge dust.
56
- /// @param amountAfterFee The desired post-fee amount, as a fixed point number.
57
- /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
58
- /// @return The floor-rounded fee amount, as a fixed point number with the same number of decimals as the provided
59
- /// `amount`.
60
- function feeAmountResultingInFloor(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {
61
17
  return mulDiv(amountAfterFee, JBConstants.MAX_FEE, JBConstants.MAX_FEE - feePercent) - amountAfterFee;
62
18
  }
63
19
 
64
- /// @notice Returns the floor-rounded fee amount resulting in `amountAfterFee` for a 2.5% fee.
65
- /// @dev Equivalent to `feeAmountResultingInFloor(amountAfterFee, 25)`, but avoids the generic `mulDiv` path.
66
- /// @param amountAfterFee The desired post-fee amount, as a fixed point number.
67
- /// @return The floor-rounded fee amount.
68
- function feeAmountResultingInFloorForFee25(uint256 amountAfterFee) internal pure returns (uint256) {
69
- // The specialized denominator is `(JBConstants.MAX_FEE - 25) / 25`.
70
- return amountAfterFee / 39;
20
+ /// @notice Returns the fee that would be taken from `amountBeforeFee`.
21
+ /// @dev Use this to forward-calculate the fee from a known pre-fee amount.
22
+ /// @dev Fee rounding error is bounded by N-1 wei (N = number of splits). Economically
23
+ /// insignificant. Rounds down (mulDiv floors), so the fee beneficiary may receive up to 1 wei less per split.
24
+ /// @param amountBeforeFee The amount before the fee is applied, as a fixed point number.
25
+ /// @param feePercent The fee percent, out of `JBConstants.MAX_FEE`.
26
+ /// @return The fee amount, as a fixed point number with the same number of decimals as the provided `amount`.
27
+ function feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
28
+ return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);
71
29
  }
72
30
  }
@@ -7,7 +7,8 @@ import {JBTokenAmount} from "./JBTokenAmount.sol";
7
7
  /// @custom:member projectId The ID of the project to cash out from.
8
8
  /// @custom:member rulesetId The ID of the ruleset the cash out is made during.
9
9
  /// @custom:member cashOutCount The number of project tokens to cash out.
10
- /// @custom:member cashOutTaxRate The current ruleset's cash out tax rate.
10
+ /// @custom:member cashOutTaxRate The current ruleset's cash out tax rate, out of
11
+ /// `JBConstants.MAX_CASH_OUT_TAX_RATE`.
11
12
  /// @custom:member reclaimedAmount The token amount reclaimed from the project's terminal balance. Includes the
12
13
  /// token
13
14
  /// reclaimed, the value, the number of decimals included, and the currency of the amount.
@@ -15,7 +15,8 @@ import {JBTokenAmount} from "./JBTokenAmount.sol";
15
15
  /// Includes the token of the surplus, the surplus value, the number of decimals
16
16
  /// included, and the currency of the surplus.
17
17
  /// @custom:member useTotalSurplus If true, use surplus across all of a project's terminals when calculating cash outs.
18
- /// @custom:member cashOutTaxRate The cash out tax rate of the ruleset the cash out is made during.
18
+ /// @custom:member cashOutTaxRate The cash out tax rate of the ruleset the cash out is made during, out of
19
+ /// `JBConstants.MAX_CASH_OUT_TAX_RATE`.
19
20
  /// @custom:member beneficiaryIsFeeless Whether the cash out's beneficiary is a feeless address. Useful for data hooks
20
21
  /// that charge their own fees — they can skip fees when value stays in the protocol (e.g. project-to-project
21
22
  /// routing).
@@ -13,7 +13,8 @@ import {JBTokenAmount} from "./JBTokenAmount.sol";
13
13
  /// @custom:member beneficiary The specified address that should be the beneficiary of anything that this payment
14
14
  /// yields.
15
15
  /// @custom:member weight The weight of the ruleset during which the payment is made.
16
- /// @custom:member reservedPercent The reserved percent of the ruleset the payment is made during.
16
+ /// @custom:member reservedPercent The reserved percent of the ruleset the payment is made during, out of
17
+ /// `JBConstants.MAX_RESERVED_PERCENT`.
17
18
  /// @custom:member metadata Extra data specified by the payer.
18
19
  struct JBBeforePayRecordedContext {
19
20
  address terminal;
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  /// @custom:member amount The total amount the fee was taken from, as a fixed point number with the same number of
5
- /// decimals as the terminal in which this struct was created.
5
+ /// decimals as the token's accounting context.
6
6
  /// @custom:member beneficiary The address that will receive the tokens that are minted as a result of the fee payment.
7
7
  /// @custom:member unlockTimestamp The timestamp at which the fee is unlocked and can be processed.
8
8
  struct JBFee {
@@ -15,8 +15,9 @@ import {IJBRulesetApprovalHook} from "./../interfaces/IJBRulesetApprovalHook.sol
15
15
  /// @custom:member duration How many seconds the ruleset lasts. 0 = no auto-cycling (must be explicitly replaced).
16
16
  /// @custom:member weight Tokens minted per unit paid (18 decimals). The terminal divides payment amount by weight to
17
17
  /// determine token issuance. Higher weight = more tokens per unit of payment.
18
- /// @custom:member weightCutPercent How much to reduce weight each cycle (out of 1,000,000,000). 100,000,000 = 10% cut
19
- /// per cycle. 0 = no decay. Only applies when a cycle auto-rolls without an explicitly queued replacement.
18
+ /// @custom:member weightCutPercent How much to reduce weight each cycle, out of
19
+ /// `JBConstants.MAX_WEIGHT_CUT_PERCENT`. 100,000,000 = 10% cut per cycle. 0 = no decay. Only applies when a cycle
20
+ /// auto-rolls without an explicitly queued replacement.
20
21
  /// @custom:member approvalHook A contract that gates whether queued rulesets can take effect (e.g. `JBDeadline` for
21
22
  /// minimum notice periods). If the hook rejects a queued ruleset, the current one continues.
22
23
  /// @custom:member metadata Packed 256-bit field containing reservedPercent, cashOutTaxRate, baseCurrency, boolean
@@ -14,7 +14,8 @@ import {JBSplitGroup} from "./JBSplitGroup.sol";
14
14
  /// @custom:member duration How long the ruleset lasts in seconds. 0 = stays active until explicitly replaced.
15
15
  /// @custom:member weight Tokens minted per unit of payment (18 decimals). Pass 1 to inherit decayed weight from the
16
16
  /// previous ruleset. Pass 0 for no token issuance.
17
- /// @custom:member weightCutPercent Decay rate per cycle (out of 1,000,000,000). 100,000,000 = 10% cut. 0 = no decay.
17
+ /// @custom:member weightCutPercent Decay rate per cycle, out of `JBConstants.MAX_WEIGHT_CUT_PERCENT`. 100,000,000 =
18
+ /// 10% cut. 0 = no decay.
18
19
  /// @custom:member approvalHook Contract that must approve the *next* queued ruleset for it to take effect.
19
20
  /// @custom:member metadata The ruleset's behavioral flags and parameters (see `JBRulesetMetadata`).
20
21
  /// @custom:member splitGroups How payouts and reserved tokens are distributed during this ruleset.
@@ -3,10 +3,11 @@ pragma solidity ^0.8.0;
3
3
 
4
4
  /// @notice Human-readable configuration for a ruleset's behavioral flags and parameters. This struct is packed into
5
5
  /// 256 bits for on-chain storage (see `JBRulesetMetadataResolver` for the packing layout).
6
- /// @custom:member reservedPercent Percentage of newly minted tokens set aside for the reserved token split group
7
- /// (0–10,000 basis points). 5,000 = 50% reserved.
8
- /// @custom:member cashOutTaxRate Tax applied when holders cash out tokens (0–10,000 basis points). Higher rate = less
9
- /// reclaim per token. 0 = proportional, 10,000 = no reclaim (100% tax).
6
+ /// @custom:member reservedPercent Percentage of newly minted tokens set aside for the reserved token split group,
7
+ /// out of `JBConstants.MAX_RESERVED_PERCENT`. 5,000 = 50% reserved.
8
+ /// @custom:member cashOutTaxRate Tax applied when holders cash out tokens, out of
9
+ /// `JBConstants.MAX_CASH_OUT_TAX_RATE`. Higher rate = less reclaim per token. 0 = proportional, 10,000 = no reclaim
10
+ /// (100% tax).
10
11
  /// @custom:member baseCurrency The currency used to interpret the ruleset's weight for token issuance. Convention:
11
12
  /// `uint32(uint160(tokenAddress))` for tokens, or `JBCurrencyIds.ETH`/`JBCurrencyIds.USD` for well-known currencies.
12
13
  /// @custom:member pausePay If `true`, the project cannot receive payments during this ruleset.