@bananapus/core-v6 0.0.38 → 0.0.39
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/foundry.toml +1 -1
- package/package.json +1 -1
- package/src/JBChainlinkV3PriceFeed.sol +4 -1
- package/src/JBChainlinkV3SequencerPriceFeed.sol +4 -2
- package/src/JBController.sol +52 -43
- package/src/JBDeadline.sol +4 -4
- package/src/JBDirectory.sol +34 -32
- package/src/JBERC20.sol +5 -4
- package/src/JBFeelessAddresses.sol +6 -3
- package/src/JBFundAccessLimits.sol +25 -21
- package/src/JBMultiTerminal.sol +53 -50
- package/src/JBPermissions.sol +34 -37
- package/src/JBPrices.sol +23 -18
- package/src/JBProjects.sol +6 -3
- package/src/JBRulesets.sol +44 -41
- package/src/JBSplits.sol +18 -16
- package/src/JBTerminalStore.sol +26 -19
- package/src/JBTokens.sol +36 -26
- package/src/abstract/JBControlled.sol +3 -1
- package/src/abstract/JBPermissioned.sol +3 -1
- package/src/enums/JBApprovalStatus.sol +7 -1
- package/src/interfaces/IJBController.sol +3 -2
- package/src/interfaces/IJBDirectory.sol +3 -1
- package/src/interfaces/IJBMultiTerminal.sol +3 -2
- package/src/interfaces/IJBPermissions.sol +2 -1
- package/src/interfaces/IJBPrices.sol +3 -1
- package/src/interfaces/IJBRulesets.sol +2 -1
- package/src/interfaces/IJBSplits.sol +2 -1
- package/src/interfaces/IJBTerminal.sol +3 -1
- package/src/interfaces/IJBTerminalStore.sol +3 -1
- package/src/interfaces/IJBTokens.sol +2 -1
- package/src/libraries/JBCashOuts.sol +6 -1
- package/src/libraries/JBConstants.sol +12 -3
- package/src/libraries/JBCurrencyIds.sol +2 -0
- package/src/libraries/JBFees.sol +5 -1
- package/src/libraries/JBFixedPointNumber.sol +2 -0
- package/src/libraries/JBPayoutSplitGroupLib.sol +5 -2
- package/src/libraries/JBRulesetMetadataResolver.sol +4 -0
- package/src/libraries/JBSplitGroupIds.sol +2 -1
- package/src/libraries/JBSurplus.sol +3 -1
- package/src/periphery/JBMatchingPriceFeed.sol +2 -0
- package/src/structs/JBAccountingContext.sol +7 -4
- package/src/structs/JBFundAccessLimitGroup.sol +10 -17
- package/src/structs/JBRuleset.sol +18 -26
- package/src/structs/JBRulesetConfig.sol +13 -25
- package/src/structs/JBRulesetMetadata.sol +25 -32
|
@@ -3,7 +3,8 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {JBPermissionsData} from "./../structs/JBPermissionsData.sol";
|
|
5
5
|
|
|
6
|
-
/// @notice
|
|
6
|
+
/// @notice Interface for the protocol's permission system. Allows any address to authorize operators to perform
|
|
7
|
+
/// specific actions on its behalf, scoped to individual projects or globally (wildcard project ID 0).
|
|
7
8
|
interface IJBPermissions {
|
|
8
9
|
/// @notice Permissions were set for an operator on behalf of an account.
|
|
9
10
|
/// @param operator The operator whose permissions were set.
|
|
@@ -4,7 +4,9 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
import {IJBPriceFeed} from "./IJBPriceFeed.sol";
|
|
5
5
|
import {IJBProjects} from "./IJBProjects.sol";
|
|
6
6
|
|
|
7
|
-
/// @notice
|
|
7
|
+
/// @notice Interface for the price feed registry. Resolves exchange rates between currencies via immutable price feeds
|
|
8
|
+
/// (typically Chainlink). Used when payout limits or surplus allowances are denominated in a different currency than
|
|
9
|
+
/// the token held in the terminal.
|
|
8
10
|
interface IJBPrices {
|
|
9
11
|
/// @notice A price feed was added for a project's currency pair.
|
|
10
12
|
/// @param projectId The ID of the project the price feed was added for.
|
|
@@ -5,7 +5,8 @@ import {IJBRulesetApprovalHook} from "./IJBRulesetApprovalHook.sol";
|
|
|
5
5
|
import {JBApprovalStatus} from "./../enums/JBApprovalStatus.sol";
|
|
6
6
|
import {JBRuleset} from "./../structs/JBRuleset.sol";
|
|
7
7
|
|
|
8
|
-
/// @notice
|
|
8
|
+
/// @notice Interface for the ruleset storage and lifecycle contract. Rulesets define a project's economic parameters
|
|
9
|
+
/// (weight, duration, cash-out rate, etc.) and are queued as a linked list with approval hooks gating transitions.
|
|
9
10
|
interface IJBRulesets {
|
|
10
11
|
/// @notice A ruleset was initialized from a base ruleset.
|
|
11
12
|
/// @param rulesetId The ID of the initialized ruleset.
|
|
@@ -4,7 +4,8 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
import {JBSplit} from "./../structs/JBSplit.sol";
|
|
5
5
|
import {JBSplitGroup} from "./../structs/JBSplitGroup.sol";
|
|
6
6
|
|
|
7
|
-
/// @notice
|
|
7
|
+
/// @notice Interface for the split storage contract. Splits define how payouts and reserved tokens are distributed —
|
|
8
|
+
/// each split specifies a recipient and their percentage share. Splits can be locked until a timestamp.
|
|
8
9
|
interface IJBSplits {
|
|
9
10
|
/// @notice A split was set for a project.
|
|
10
11
|
/// @param projectId The ID of the project the split was set for.
|
|
@@ -9,7 +9,9 @@ import {JBAfterPayRecordedContext} from "../structs/JBAfterPayRecordedContext.so
|
|
|
9
9
|
import {JBPayHookSpecification} from "../structs/JBPayHookSpecification.sol";
|
|
10
10
|
import {JBRuleset} from "../structs/JBRuleset.sol";
|
|
11
11
|
|
|
12
|
-
/// @notice A terminal
|
|
12
|
+
/// @notice Base interface for all Juicebox terminals. A terminal accepts payments for projects, reports surplus, and
|
|
13
|
+
/// supports balance migration. Projects register their terminals in `JBDirectory`; the primary terminal for a token
|
|
14
|
+
/// receives payments routed by frontends.
|
|
13
15
|
interface IJBTerminal is IERC165 {
|
|
14
16
|
/// @notice Funds were added to a project's balance.
|
|
15
17
|
/// @param projectId The ID of the project that received the funds.
|
|
@@ -11,7 +11,9 @@ import {JBPayHookSpecification} from "../structs/JBPayHookSpecification.sol";
|
|
|
11
11
|
import {JBRuleset} from "../structs/JBRuleset.sol";
|
|
12
12
|
import {JBTokenAmount} from "../structs/JBTokenAmount.sol";
|
|
13
13
|
|
|
14
|
-
/// @notice
|
|
14
|
+
/// @notice Interface for the terminal's accounting engine. Records balances, enforces payout limits and surplus
|
|
15
|
+
/// allowances, calculates token issuance per payment, and determines cash-out reclaim amounts via the bonding curve.
|
|
16
|
+
/// Terminals delegate all state-changing accounting to this contract.
|
|
15
17
|
interface IJBTerminalStore {
|
|
16
18
|
/// @notice The directory of terminals and controllers for projects.
|
|
17
19
|
function DIRECTORY() external view returns (IJBDirectory);
|
|
@@ -3,7 +3,8 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {IJBToken} from "./IJBToken.sol";
|
|
5
5
|
|
|
6
|
-
/// @notice Manages
|
|
6
|
+
/// @notice Interface for the dual-token system. Manages credits (internal balances) and ERC-20 tokens for every
|
|
7
|
+
/// project. Credits are minted first and can later be claimed as transferable ERC-20 tokens.
|
|
7
8
|
interface IJBTokens {
|
|
8
9
|
/// @notice Tokens or credits were burned from a holder's balance.
|
|
9
10
|
/// @param holder The address whose tokens were burned.
|
|
@@ -5,7 +5,12 @@ import {mulDiv} from "@prb/math/src/Common.sol";
|
|
|
5
5
|
|
|
6
6
|
import {JBConstants} from "./JBConstants.sol";
|
|
7
7
|
|
|
8
|
-
/// @notice
|
|
8
|
+
/// @notice Implements the bonding curve math for cash outs. When a token holder cashes out, this library calculates
|
|
9
|
+
/// how much of the project's surplus they can reclaim based on their share of the total supply and the current
|
|
10
|
+
/// cash-out tax rate. A 0% tax rate gives a proportional share; a 100% tax rate returns nothing (all surplus stays).
|
|
11
|
+
/// @dev Formula: `surplus * count * [(MAX - taxRate) + taxRate * (count / supply)] / (supply * MAX)`.
|
|
12
|
+
/// Also provides an inverse function (`cashOutCountFrom`) for determining how many tokens to burn for a desired
|
|
13
|
+
/// reclaim amount.
|
|
9
14
|
library JBCashOuts {
|
|
10
15
|
/// @notice Thrown when the desired output cannot be achieved (e.g., cash out tax rate is 100%).
|
|
11
16
|
error JBCashOuts_DesiredOutputNotAchievable();
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
-
/// @notice
|
|
4
|
+
/// @notice Protocol-wide constants. These define the boundaries for economic parameters throughout Juicebox.
|
|
5
5
|
library JBConstants {
|
|
6
|
-
/// @notice
|
|
7
|
-
/// 0x000000000000000000000000000000000000EEEe.
|
|
6
|
+
/// @notice The sentinel address used to represent each chain's native token (ETH on mainnet, etc.).
|
|
8
7
|
address public constant NATIVE_TOKEN = address(0x000000000000000000000000000000000000EEEe);
|
|
8
|
+
|
|
9
|
+
/// @notice The maximum reserved token percentage (basis points). 10,000 = 100% of minted tokens go to reserves.
|
|
9
10
|
uint16 public constant MAX_RESERVED_PERCENT = 10_000;
|
|
11
|
+
|
|
12
|
+
/// @notice The maximum cash-out tax rate (basis points). 10,000 = 100% tax, meaning token holders reclaim nothing.
|
|
10
13
|
uint16 public constant MAX_CASH_OUT_TAX_RATE = 10_000;
|
|
14
|
+
|
|
15
|
+
/// @notice The maximum weight cut percent (9-decimal precision). 1,000,000,000 = 100% cut per cycle (no issuance).
|
|
11
16
|
uint32 public constant MAX_WEIGHT_CUT_PERCENT = 1_000_000_000;
|
|
17
|
+
|
|
18
|
+
/// @notice The denominator for split percentages (9-decimal precision). A split of 1,000,000,000 = 100%.
|
|
12
19
|
uint32 public constant SPLITS_TOTAL_PERCENT = 1_000_000_000;
|
|
20
|
+
|
|
21
|
+
/// @notice The fee denominator. The protocol fee is `FEE / MAX_FEE` (currently 25/1000 = 2.5%).
|
|
13
22
|
uint16 public constant MAX_FEE = 1000;
|
|
14
23
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
+
/// @notice Well-known currency IDs used as the `baseCurrency` in ruleset metadata. These are distinct from accounting
|
|
5
|
+
/// context currencies (which use `uint32(uint160(tokenAddress))`). Only used for price feed lookups in `JBPrices`.
|
|
4
6
|
library JBCurrencyIds {
|
|
5
7
|
uint32 public constant ETH = 1;
|
|
6
8
|
uint32 public constant USD = 2;
|
package/src/libraries/JBFees.sol
CHANGED
|
@@ -5,7 +5,11 @@ import {mulDiv} from "@prb/math/src/Common.sol";
|
|
|
5
5
|
|
|
6
6
|
import {JBConstants} from "./../libraries/JBConstants.sol";
|
|
7
7
|
|
|
8
|
-
/// @notice
|
|
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.
|
|
9
13
|
library JBFees {
|
|
10
14
|
/// @notice Returns the fee that would be taken from `amountBeforeFee`.
|
|
11
15
|
/// @dev Use this to forward-calculate the fee from a known pre-fee amount.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
+
/// @notice Utility for converting between fixed-point numbers with different decimal precisions (e.g. 6-decimal USDC
|
|
5
|
+
/// amounts to 18-decimal internal accounting).
|
|
4
6
|
library JBFixedPointNumber {
|
|
5
7
|
function adjustDecimals(uint256 value, uint256 decimals, uint256 targetDecimals) internal pure returns (uint256) {
|
|
6
8
|
// If decimals need adjusting, multiply or divide the price by the decimal adjuster to get the normalized
|
|
@@ -23,8 +23,11 @@ interface IJBPayoutSplitGroupExecutor {
|
|
|
23
23
|
returns (uint256 netPayoutAmount);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/// @notice
|
|
27
|
-
///
|
|
26
|
+
/// @notice Handles distributing payouts to a project's split recipients. Iterates through each split, sends the
|
|
27
|
+
/// proportional amount, and gracefully handles failures — if a split payout reverts (e.g. a hook is broken), the
|
|
28
|
+
/// amount is returned to the project's balance rather than blocking all other splits.
|
|
29
|
+
/// @dev Extracted as an external library to reduce `JBMultiTerminal` bytecode size. Called via DELEGATECALL, so events
|
|
30
|
+
/// are emitted from the terminal's address.
|
|
28
31
|
library JBPayoutSplitGroupLib {
|
|
29
32
|
event PayoutReverted(uint256 indexed projectId, JBSplit split, uint256 amount, bytes reason, address caller);
|
|
30
33
|
event SendPayoutToSplit(
|
|
@@ -4,6 +4,10 @@ pragma solidity 0.8.28;
|
|
|
4
4
|
import {JBRuleset} from "./../structs/JBRuleset.sol";
|
|
5
5
|
import {JBRulesetMetadata} from "./../structs/JBRulesetMetadata.sol";
|
|
6
6
|
|
|
7
|
+
/// @notice Unpacks the 256-bit packed `metadata` field from a `JBRuleset` into individual parameters. The metadata
|
|
8
|
+
/// encodes: reservedPercent, cashOutTaxRate, baseCurrency, 14 boolean flags (pausePay, allowOwnerMinting, etc.),
|
|
9
|
+
/// a data hook address, and 14 bits of custom metadata. Used throughout the protocol to read ruleset configuration
|
|
10
|
+
/// without storing each field separately.
|
|
7
11
|
library JBRulesetMetadataResolver {
|
|
8
12
|
function reservedPercent(JBRuleset memory ruleset) internal pure returns (uint16) {
|
|
9
13
|
return uint16(ruleset.metadata >> 4);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity 0.8.28;
|
|
3
3
|
|
|
4
|
-
/// @notice
|
|
4
|
+
/// @notice Well-known split group IDs. The reserved tokens group (ID 1) defines how a project's reserved tokens are
|
|
5
|
+
/// distributed. Payout split groups use the token address cast to `uint256(uint160(token))` as their group ID.
|
|
5
6
|
library JBSplitGroupIds {
|
|
6
7
|
uint256 public constant RESERVED_TOKENS = 1;
|
|
7
8
|
}
|
|
@@ -3,7 +3,9 @@ pragma solidity 0.8.28;
|
|
|
3
3
|
|
|
4
4
|
import {IJBTerminal} from "../interfaces/IJBTerminal.sol";
|
|
5
5
|
|
|
6
|
-
/// @notice Surplus
|
|
6
|
+
/// @notice Calculates a project's total surplus across all its terminals. Surplus is the amount held beyond what's
|
|
7
|
+
/// needed to cover the project's payout limits — it represents the pool available for cash outs and surplus allowance
|
|
8
|
+
/// usage. Aggregates across multiple terminals and tokens, converting to a common currency via `JBPrices`.
|
|
7
9
|
library JBSurplus {
|
|
8
10
|
/// @notice Gets the total current surplus amount across all of a project's terminals.
|
|
9
11
|
/// @dev This amount changes as the value of the balances changes in relation to the currency being used to measure
|
|
@@ -3,6 +3,8 @@ pragma solidity 0.8.28;
|
|
|
3
3
|
|
|
4
4
|
import {IJBPriceFeed} from "../interfaces/IJBPriceFeed.sol";
|
|
5
5
|
|
|
6
|
+
/// @notice A trivial price feed that always returns 1:1 (one unit = one unit). Used when a payout limit is
|
|
7
|
+
/// denominated in the same currency as the terminal's token, so no actual conversion is needed.
|
|
6
8
|
contract JBMatchingPriceFeed is IJBPriceFeed {
|
|
7
9
|
constructor() {}
|
|
8
10
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
/// @
|
|
5
|
-
///
|
|
6
|
-
///
|
|
7
|
-
///
|
|
4
|
+
/// @notice Describes how a terminal accounts for a specific token — its address, decimal precision, and which
|
|
5
|
+
/// currency
|
|
6
|
+
/// it's priced in. Used when recording payments, payouts, and cash outs to ensure correct fixed-point arithmetic.
|
|
7
|
+
/// @custom:member token The token address (use `JBConstants.NATIVE_TOKEN` for ETH).
|
|
8
|
+
/// @custom:member decimals The number of decimals for this token's fixed-point amounts (e.g. 18 for ETH, 6 for USDC).
|
|
9
|
+
/// @custom:member currency The currency ID for price feed lookups. Convention: `uint32(uint160(tokenAddress))` for
|
|
10
|
+
/// tokens, or `JBCurrencyIds.ETH`/`JBCurrencyIds.USD` for well-known currencies.
|
|
8
11
|
struct JBAccountingContext {
|
|
9
12
|
address token;
|
|
10
13
|
uint8 decimals;
|
|
@@ -3,23 +3,16 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {JBCurrencyAmount} from "./JBCurrencyAmount.sol";
|
|
5
5
|
|
|
6
|
-
/// @
|
|
7
|
-
/// the project can
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
///
|
|
11
|
-
/// @dev
|
|
12
|
-
///
|
|
13
|
-
/// @
|
|
14
|
-
///
|
|
15
|
-
/// @custom:member
|
|
16
|
-
/// @custom:member token The token that the payout limits and surplus allowances apply to within the `terminal`.
|
|
17
|
-
/// @custom:member payoutLimits An array of payout limits. The payout limits cumulatively dictate the maximum value of
|
|
18
|
-
/// `token`s a project can pay out from its balance in a terminal during a ruleset. Each payout limit can have a unique
|
|
19
|
-
/// currency and amount.
|
|
20
|
-
/// @custom:member surplusAllowances An array of surplus allowances. The surplus allowances cumulatively dictates the
|
|
21
|
-
/// maximum value of `token`s a project can pay out from its surplus (balance less payouts) in a terminal during a
|
|
22
|
-
/// ruleset. Each surplus allowance can have a unique currency and amount.
|
|
6
|
+
/// @notice Defines how much a project can withdraw from a specific terminal and token each funding cycle.
|
|
7
|
+
/// @dev Example — payout limit of 5 USD in an ETH terminal: the project can distribute up to 5 USD worth of ETH to
|
|
8
|
+
/// its splits per cycle. Example — surplus allowance of 5 USD: the project owner can pull up to 5 USD worth of ETH
|
|
9
|
+
/// from the surplus (balance above payout limits).
|
|
10
|
+
/// @dev Multiple limits in different currencies are additive — each can be used independently within one cycle.
|
|
11
|
+
/// @dev Amounts use the same decimal precision as the terminal token (e.g. 18 for ETH, 6 for USDC).
|
|
12
|
+
/// @custom:member terminal The terminal address these limits apply to.
|
|
13
|
+
/// @custom:member token The token address within that terminal these limits apply to.
|
|
14
|
+
/// @custom:member payoutLimits Maximum amounts distributable to splits per cycle, each in a specific currency.
|
|
15
|
+
/// @custom:member surplusAllowances Maximum amounts withdrawable from surplus per cycle, each in a specific currency.
|
|
23
16
|
struct JBFundAccessLimitGroup {
|
|
24
17
|
address terminal;
|
|
25
18
|
address token;
|
|
@@ -3,32 +3,24 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {IJBRulesetApprovalHook} from "./../interfaces/IJBRulesetApprovalHook.sol";
|
|
5
5
|
|
|
6
|
-
/// @
|
|
7
|
-
///
|
|
8
|
-
///
|
|
9
|
-
/// @
|
|
10
|
-
///
|
|
11
|
-
/// @custom:member
|
|
12
|
-
///
|
|
13
|
-
/// @custom:member
|
|
14
|
-
///
|
|
15
|
-
///
|
|
16
|
-
///
|
|
17
|
-
///
|
|
18
|
-
/// @custom:member
|
|
19
|
-
///
|
|
20
|
-
///
|
|
21
|
-
///
|
|
22
|
-
///
|
|
23
|
-
///
|
|
24
|
-
/// a percentage out of `JBConstants.MAX_WEIGHT_CUT_PERCENT`. If it's 0, the next ruleset will have the same `weight` by
|
|
25
|
-
/// default. If it's 90%, the next ruleset's `weight` will be 10% smaller. If a ruleset explicitly sets a new `weight`,
|
|
26
|
-
/// the `weightCutPercent` doesn't apply.
|
|
27
|
-
/// @custom:member approvalHook An address of a contract that says whether a queued ruleset should be approved or
|
|
28
|
-
/// rejected. If a
|
|
29
|
-
/// ruleset is rejected, it won't go into effect. An approval hook can be used to create rules which dictate how a
|
|
30
|
-
/// project owner can change their ruleset over time.
|
|
31
|
-
/// @custom:member metadata Extra data associated with a ruleset which can be used by other contracts.
|
|
6
|
+
/// @notice A ruleset defines how a project behaves during a period of time — token issuance rate, cash-out terms,
|
|
7
|
+
/// payout rules, and permissions. Rulesets cycle automatically: when one expires, the next queued (and approved) one
|
|
8
|
+
/// takes effect. If nothing is queued, the current ruleset auto-cycles with decayed weight.
|
|
9
|
+
/// @dev Timestamps are unix timestamps (seconds since epoch).
|
|
10
|
+
/// @custom:member cycleNumber Which cycle this is (starts at 1, increments each cycle).
|
|
11
|
+
/// @custom:member id The ruleset's ID — the unix timestamp when it was first stored. Stays the same across
|
|
12
|
+
/// auto-cycles.
|
|
13
|
+
/// @custom:member basedOnId The ID of the ruleset that was active when this one was created (forms a linked list).
|
|
14
|
+
/// @custom:member start When this ruleset became/becomes active.
|
|
15
|
+
/// @custom:member duration How many seconds the ruleset lasts. 0 = no auto-cycling (must be explicitly replaced).
|
|
16
|
+
/// @custom:member weight Tokens minted per unit paid (18 decimals). The terminal divides payment amount by weight to
|
|
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.
|
|
20
|
+
/// @custom:member approvalHook A contract that gates whether queued rulesets can take effect (e.g. `JBDeadline` for
|
|
21
|
+
/// minimum notice periods). If the hook rejects a queued ruleset, the current one continues.
|
|
22
|
+
/// @custom:member metadata Packed 256-bit field containing reservedPercent, cashOutTaxRate, baseCurrency, boolean
|
|
23
|
+
/// flags, data hook address, and custom metadata. Decoded by `JBRulesetMetadataResolver`.
|
|
32
24
|
struct JBRuleset {
|
|
33
25
|
uint48 cycleNumber;
|
|
34
26
|
uint48 id;
|
|
@@ -6,31 +6,19 @@ import {JBFundAccessLimitGroup} from "./JBFundAccessLimitGroup.sol";
|
|
|
6
6
|
import {JBRulesetMetadata} from "./JBRulesetMetadata.sol";
|
|
7
7
|
import {JBSplitGroup} from "./JBSplitGroup.sol";
|
|
8
8
|
|
|
9
|
-
/// @
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
///
|
|
13
|
-
///
|
|
14
|
-
///
|
|
15
|
-
///
|
|
16
|
-
///
|
|
17
|
-
///
|
|
18
|
-
///
|
|
19
|
-
/// @custom:member
|
|
20
|
-
///
|
|
21
|
-
///
|
|
22
|
-
/// equal weight. If the number is 90%, the next ruleset will have a 10% smaller weight. This weight is out of
|
|
23
|
-
/// `JBConstants.MAX_WEIGHT_CUT_PERCENT`.
|
|
24
|
-
/// @custom: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
|
-
/// @custom:member metadata Metadata specifying the controller-specific parameters that a ruleset can have. These
|
|
28
|
-
/// properties cannot change until the next ruleset starts.
|
|
29
|
-
/// @custom:member splitGroups An array of splits to use for any number of groups while the ruleset is active.
|
|
30
|
-
/// @custom:member fundAccessLimitGroups An array of structs which dictate the amount of funds a project can access from
|
|
31
|
-
/// its balance in each payment terminal while the ruleset is active. Amounts are fixed point numbers using the same
|
|
32
|
-
/// number of decimals as the corresponding terminal. The `_payoutLimit` and `_surplusAllowance` parameters must fit in
|
|
33
|
-
/// a `uint232`.
|
|
9
|
+
/// @notice The configuration passed to `JBController.launchRulesetsFor` or `queueRulesetsOf` to define a new ruleset.
|
|
10
|
+
/// Includes the economic parameters (weight, duration, decay), the metadata (permissions and hooks), the split
|
|
11
|
+
/// recipients, and the fund access limits.
|
|
12
|
+
/// @custom:member mustStartAtOrAfter The earliest timestamp the ruleset can begin. Pass 0 to start immediately after
|
|
13
|
+
/// the previous ruleset ends.
|
|
14
|
+
/// @custom:member duration How long the ruleset lasts in seconds. 0 = stays active until explicitly replaced.
|
|
15
|
+
/// @custom:member weight Tokens minted per unit of payment (18 decimals). Pass 1 to inherit decayed weight from the
|
|
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.
|
|
18
|
+
/// @custom:member approvalHook Contract that must approve the *next* queued ruleset for it to take effect.
|
|
19
|
+
/// @custom:member metadata The ruleset's behavioral flags and parameters (see `JBRulesetMetadata`).
|
|
20
|
+
/// @custom:member splitGroups How payouts and reserved tokens are distributed during this ruleset.
|
|
21
|
+
/// @custom:member fundAccessLimitGroups How much the project can withdraw from each terminal per cycle.
|
|
34
22
|
struct JBRulesetConfig {
|
|
35
23
|
uint48 mustStartAtOrAfter;
|
|
36
24
|
uint32 duration;
|
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
/// @
|
|
5
|
-
/// `
|
|
6
|
-
/// @custom:member
|
|
7
|
-
///
|
|
8
|
-
/// @custom:member
|
|
9
|
-
///
|
|
10
|
-
/// @custom:member
|
|
11
|
-
///
|
|
12
|
-
///
|
|
13
|
-
/// @custom:member
|
|
14
|
-
///
|
|
15
|
-
/// @custom:member
|
|
16
|
-
///
|
|
17
|
-
/// @custom:member allowSetTerminals
|
|
18
|
-
/// @custom:member allowSetController
|
|
19
|
-
/// @custom:member allowAddAccountingContext
|
|
20
|
-
///
|
|
21
|
-
/// @custom:member
|
|
22
|
-
///
|
|
23
|
-
/// @custom:member
|
|
24
|
-
///
|
|
25
|
-
/// @custom:member
|
|
26
|
-
/// @custom:member
|
|
27
|
-
///
|
|
28
|
-
/// @custom:member
|
|
29
|
-
/// ruleset.
|
|
30
|
-
/// @custom:member useDataHookForCashOut A flag indicating if the data hook should be used for cash out transactions
|
|
31
|
-
/// during
|
|
32
|
-
/// this ruleset.
|
|
33
|
-
/// @custom:member dataHook The data hook to use during this ruleset.
|
|
34
|
-
/// @custom:member metadata Metadata of the metadata, only the 14 least significant bits can be used, the 2 most
|
|
35
|
-
/// significant bits are disregarded.
|
|
4
|
+
/// @notice Human-readable configuration for a ruleset's behavioral flags and parameters. This struct is packed into
|
|
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).
|
|
10
|
+
/// @custom:member baseCurrency The currency used to interpret the ruleset's weight for token issuance. Convention:
|
|
11
|
+
/// `uint32(uint160(tokenAddress))` for tokens, or `JBCurrencyIds.ETH`/`JBCurrencyIds.USD` for well-known currencies.
|
|
12
|
+
/// @custom:member pausePay If `true`, the project cannot receive payments during this ruleset.
|
|
13
|
+
/// @custom:member pauseCreditTransfers If `true`, token credit transfers are disabled during this ruleset.
|
|
14
|
+
/// @custom:member allowOwnerMinting If `true`, the project owner (or MINT_TOKENS operator) can mint tokens on demand.
|
|
15
|
+
/// @custom:member allowSetCustomToken If `true`, the project can set a custom ERC-20 token via `setTokenFor`.
|
|
16
|
+
/// @custom:member allowTerminalMigration If `true`, terminals can be migrated to new implementations.
|
|
17
|
+
/// @custom:member allowSetTerminals If `true`, the project's terminal list can be modified.
|
|
18
|
+
/// @custom:member allowSetController If `true`, the project's controller can be changed.
|
|
19
|
+
/// @custom:member allowAddAccountingContext If `true`, new token accounting contexts can be added to terminals.
|
|
20
|
+
/// @custom:member allowAddPriceFeed If `true`, the project can register new price feeds in `JBPrices`.
|
|
21
|
+
/// @custom:member ownerMustSendPayouts If `true`, only the project owner can trigger payout distribution.
|
|
22
|
+
/// @custom:member holdFees If `true`, fees are accumulated but not processed until a future ruleset (or manually).
|
|
23
|
+
/// @custom:member useTotalSurplusForCashOuts If `true`, cash-out calculations use surplus across all terminals (not
|
|
24
|
+
/// just the one being cashed out from).
|
|
25
|
+
/// @custom:member useDataHookForPay If `true`, the data hook is called before recording payments.
|
|
26
|
+
/// @custom:member useDataHookForCashOut If `true`, the data hook is called before recording cash outs.
|
|
27
|
+
/// @custom:member dataHook Contract called before pay/cash-out to potentially override token counts or add hooks.
|
|
28
|
+
/// @custom:member metadata 14 bits of application-specific metadata (upper 2 bits are ignored).
|
|
36
29
|
struct JBRulesetMetadata {
|
|
37
30
|
uint16 reservedPercent;
|
|
38
31
|
uint16 cashOutTaxRate;
|