@bananapus/core-v6 0.0.38 → 0.0.40
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 +67 -58
- package/src/JBDeadline.sol +4 -4
- package/src/JBDirectory.sol +38 -36
- package/src/JBERC20.sol +10 -9
- package/src/JBFeelessAddresses.sol +6 -3
- package/src/JBFundAccessLimits.sol +26 -22
- package/src/JBMultiTerminal.sol +128 -125
- package/src/JBPermissions.sol +35 -38
- package/src/JBPrices.sol +25 -20
- package/src/JBProjects.sol +6 -3
- package/src/JBRulesets.sol +45 -42
- package/src/JBSplits.sol +19 -17
- package/src/JBTerminalStore.sol +57 -50
- package/src/JBTokens.sol +42 -32
- package/src/abstract/JBControlled.sol +3 -1
- package/src/abstract/JBPermissioned.sol +3 -1
- package/src/enums/JBApprovalStatus.sol +7 -1
- package/src/interfaces/IJBCashOutTerminal.sol +5 -5
- package/src/interfaces/IJBController.sol +13 -12
- package/src/interfaces/IJBDirectory.sol +3 -1
- package/src/interfaces/IJBMigratable.sol +5 -5
- package/src/interfaces/IJBMultiTerminal.sol +3 -2
- package/src/interfaces/IJBPayoutTerminal.sol +3 -3
- package/src/interfaces/IJBPermissions.sol +6 -5
- package/src/interfaces/IJBPermitTerminal.sol +1 -1
- package/src/interfaces/IJBPrices.sol +7 -5
- package/src/interfaces/IJBRulesets.sol +2 -1
- package/src/interfaces/IJBSplits.sol +2 -1
- package/src/interfaces/IJBTerminal.sol +13 -11
- package/src/interfaces/IJBTerminalStore.sol +23 -21
- package/src/interfaces/IJBTokens.sol +8 -7
- package/src/libraries/JBCashOuts.sol +8 -3
- 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 +10 -7
- package/src/libraries/JBRulesetMetadataResolver.sol +4 -0
- package/src/libraries/JBSplitGroupIds.sol +2 -1
- package/src/libraries/JBSurplus.sol +4 -2
- package/src/periphery/JBMatchingPriceFeed.sol +2 -0
- package/src/structs/JBAccountingContext.sol +7 -4
- package/src/structs/JBAfterCashOutRecordedContext.sol +8 -8
- package/src/structs/JBAfterPayRecordedContext.sol +5 -5
- package/src/structs/JBBeforeCashOutRecordedContext.sol +7 -7
- package/src/structs/JBBeforePayRecordedContext.sol +5 -5
- package/src/structs/JBFundAccessLimitGroup.sol +10 -17
- package/src/structs/JBPermissionsData.sol +3 -3
- package/src/structs/JBRuleset.sol +18 -26
- package/src/structs/JBRulesetConfig.sol +13 -25
- package/src/structs/JBRulesetMetadata.sol +25 -32
- package/src/structs/JBSplitHookContext.sol +2 -2
|
@@ -17,7 +17,7 @@ interface IJBPayoutTerminal is IJBTerminal {
|
|
|
17
17
|
/// @notice A direct payout transfer reverted.
|
|
18
18
|
/// @param projectId The ID of the project the payout was for.
|
|
19
19
|
/// @param addr The address the payout was sent to.
|
|
20
|
-
/// @param token The token
|
|
20
|
+
/// @param token The token to pay out.
|
|
21
21
|
/// @param amount The amount of the payout.
|
|
22
22
|
/// @param fee The fee taken from the payout.
|
|
23
23
|
/// @param reason The revert reason.
|
|
@@ -98,7 +98,7 @@ interface IJBPayoutTerminal is IJBTerminal {
|
|
|
98
98
|
|
|
99
99
|
/// @notice Sends a project's payouts to its payout split group according to its ruleset's payout limits.
|
|
100
100
|
/// @param projectId The ID of the project to send payouts for.
|
|
101
|
-
/// @param token The token
|
|
101
|
+
/// @param token The token to pay out.
|
|
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.
|
|
@@ -115,7 +115,7 @@ interface IJBPayoutTerminal is IJBTerminal {
|
|
|
115
115
|
|
|
116
116
|
/// @notice Uses a project's surplus allowance to send funds to a beneficiary.
|
|
117
117
|
/// @param projectId The ID of the project to use the surplus allowance of.
|
|
118
|
-
/// @param token The token
|
|
118
|
+
/// @param token The token to pay out.
|
|
119
119
|
/// @param amount The amount of the surplus allowance to use.
|
|
120
120
|
/// @param currency The currency the amount is denominated in.
|
|
121
121
|
/// @param minTokensPaidOut The minimum number of terminal tokens expected to be paid out.
|
|
@@ -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.
|
|
@@ -26,7 +27,7 @@ interface IJBPermissions {
|
|
|
26
27
|
|
|
27
28
|
/// @notice Checks if an operator has a specific permission for an account and project.
|
|
28
29
|
/// @param operator The operator to check.
|
|
29
|
-
/// @param account The account
|
|
30
|
+
/// @param account The account the operator acts on behalf of.
|
|
30
31
|
/// @param projectId The project ID the permission is scoped to. 0 represents all projects.
|
|
31
32
|
/// @param permissionId The permission ID to check for.
|
|
32
33
|
/// @param includeRoot Whether to return true if the operator has the ROOT permission.
|
|
@@ -46,7 +47,7 @@ interface IJBPermissions {
|
|
|
46
47
|
|
|
47
48
|
/// @notice Checks if an operator has all of the specified permissions for an account and project.
|
|
48
49
|
/// @param operator The operator to check.
|
|
49
|
-
/// @param account The account
|
|
50
|
+
/// @param account The account the operator acts on behalf of.
|
|
50
51
|
/// @param projectId The project ID the permissions are scoped to. 0 represents all projects.
|
|
51
52
|
/// @param permissionIds An array of permission IDs to check for.
|
|
52
53
|
/// @param includeRoot Whether to return true if the operator has the ROOT permission.
|
|
@@ -66,13 +67,13 @@ interface IJBPermissions {
|
|
|
66
67
|
|
|
67
68
|
/// @notice Returns the packed permissions that an operator has for an account and project.
|
|
68
69
|
/// @param operator The address of the operator.
|
|
69
|
-
/// @param account The address of the account
|
|
70
|
+
/// @param account The address of the account operated on behalf of.
|
|
70
71
|
/// @param projectId The project ID the permissions are scoped to. 0 is a wildcard for all projects.
|
|
71
72
|
/// @return The packed permissions as a uint256 bitmap.
|
|
72
73
|
function permissionsOf(address operator, address account, uint256 projectId) external view returns (uint256);
|
|
73
74
|
|
|
74
75
|
/// @notice Sets permissions for an operator on behalf of an account.
|
|
75
76
|
/// @param account The account setting its operator's permissions.
|
|
76
|
-
/// @param permissionsData The data specifying the permissions
|
|
77
|
+
/// @param permissionsData The data specifying the permissions to grant to the operator.
|
|
77
78
|
function setPermissionsFor(address account, JBPermissionsData calldata permissionsData) external;
|
|
78
79
|
}
|
|
@@ -13,7 +13,7 @@ interface IJBPermitTerminal is IJBTerminal {
|
|
|
13
13
|
/// @param reason The failure reason.
|
|
14
14
|
event Permit2AllowanceFailed(address indexed token, address indexed owner, bytes reason);
|
|
15
15
|
|
|
16
|
-
/// @notice The Permit2 contract used for token approvals.
|
|
16
|
+
/// @notice The Permit2 contract used for gasless ERC-20 token approvals during payments.
|
|
17
17
|
// forge-lint: disable-next-line(mixed-case-function)
|
|
18
18
|
function PERMIT2() external returns (IPermit2);
|
|
19
19
|
}
|
|
@@ -4,12 +4,14 @@ 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.
|
|
11
13
|
/// @param pricingCurrency The currency the feed's output price is in terms of.
|
|
12
|
-
/// @param unitCurrency The currency
|
|
14
|
+
/// @param unitCurrency The currency the feed prices.
|
|
13
15
|
/// @param feed The price feed that was added.
|
|
14
16
|
/// @param caller The address that added the price feed.
|
|
15
17
|
event AddPriceFeed(
|
|
@@ -29,7 +31,7 @@ interface IJBPrices {
|
|
|
29
31
|
/// @notice Returns the price feed for a project's currency pair.
|
|
30
32
|
/// @param projectId The ID of the project to get the price feed of.
|
|
31
33
|
/// @param pricingCurrency The currency the feed's output price is in terms of.
|
|
32
|
-
/// @param unitCurrency The currency
|
|
34
|
+
/// @param unitCurrency The currency the feed prices.
|
|
33
35
|
/// @return The price feed for the currency pair.
|
|
34
36
|
function priceFeedFor(
|
|
35
37
|
uint256 projectId,
|
|
@@ -43,7 +45,7 @@ interface IJBPrices {
|
|
|
43
45
|
/// @notice Returns the unit price for a currency pair.
|
|
44
46
|
/// @param projectId The ID of the project to get the price for.
|
|
45
47
|
/// @param pricingCurrency The currency the returned price is in terms of.
|
|
46
|
-
/// @param unitCurrency The currency
|
|
48
|
+
/// @param unitCurrency The currency to price.
|
|
47
49
|
/// @param decimals The number of decimals the returned price should use.
|
|
48
50
|
/// @return The unit price.
|
|
49
51
|
function pricePerUnitOf(
|
|
@@ -59,7 +61,7 @@ interface IJBPrices {
|
|
|
59
61
|
/// @notice Adds a price feed for a project's currency pair.
|
|
60
62
|
/// @param projectId The ID of the project to add the price feed for.
|
|
61
63
|
/// @param pricingCurrency The currency the feed's output price is in terms of.
|
|
62
|
-
/// @param unitCurrency The currency
|
|
64
|
+
/// @param unitCurrency The currency the feed prices.
|
|
63
65
|
/// @param feed The price feed to add.
|
|
64
66
|
function addPriceFeedFor(
|
|
65
67
|
uint256 projectId,
|
|
@@ -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.
|
|
@@ -105,9 +107,9 @@ interface IJBTerminal is IERC165 {
|
|
|
105
107
|
returns (uint256);
|
|
106
108
|
|
|
107
109
|
/// @notice Simulates paying a project through this terminal without modifying state.
|
|
108
|
-
/// @param projectId The ID of the project
|
|
109
|
-
/// @param token The token
|
|
110
|
-
/// @param amount The amount of tokens
|
|
110
|
+
/// @param projectId The ID of the project to pay.
|
|
111
|
+
/// @param token The token to pay with.
|
|
112
|
+
/// @param amount The amount of tokens to pay.
|
|
111
113
|
/// @param beneficiary The address to mint project tokens to.
|
|
112
114
|
/// @param metadata Extra data to pass along to the data hook and pay hooks.
|
|
113
115
|
/// @return ruleset The project's current ruleset.
|
|
@@ -137,8 +139,8 @@ interface IJBTerminal is IERC165 {
|
|
|
137
139
|
|
|
138
140
|
/// @notice Adds funds to a project's balance.
|
|
139
141
|
/// @param projectId The ID of the project to add funds to.
|
|
140
|
-
/// @param token The token
|
|
141
|
-
/// @param amount The amount of tokens
|
|
142
|
+
/// @param token The token added.
|
|
143
|
+
/// @param amount The amount of tokens added.
|
|
142
144
|
/// @param shouldReturnHeldFees Whether held fees should be returned based on the amount added.
|
|
143
145
|
/// @param memo A memo to pass along to the emitted event.
|
|
144
146
|
/// @param metadata Extra data to pass along to the emitted event.
|
|
@@ -154,16 +156,16 @@ interface IJBTerminal is IERC165 {
|
|
|
154
156
|
payable;
|
|
155
157
|
|
|
156
158
|
/// @notice Migrates a project's funds from this terminal to another.
|
|
157
|
-
/// @param projectId The ID of the project
|
|
158
|
-
/// @param token The address of the token
|
|
159
|
+
/// @param projectId The ID of the project to migrate.
|
|
160
|
+
/// @param token The address of the token to migrate.
|
|
159
161
|
/// @param to The terminal to migrate to.
|
|
160
162
|
/// @return balance The amount of funds that were migrated.
|
|
161
163
|
function migrateBalanceOf(uint256 projectId, address token, IJBTerminal to) external returns (uint256 balance);
|
|
162
164
|
|
|
163
165
|
/// @notice Pays a project in a specified token.
|
|
164
|
-
/// @param projectId The ID of the project
|
|
165
|
-
/// @param token The token
|
|
166
|
-
/// @param amount The amount of tokens
|
|
166
|
+
/// @param projectId The ID of the project to pay.
|
|
167
|
+
/// @param token The token to pay with.
|
|
168
|
+
/// @param amount The amount of tokens to pay.
|
|
167
169
|
/// @param beneficiary The address to mint project tokens to.
|
|
168
170
|
/// @param minReturnedTokens The minimum number of project tokens expected in return.
|
|
169
171
|
/// @param memo A memo to pass along to the emitted event.
|
|
@@ -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);
|
|
@@ -57,7 +59,7 @@ interface IJBTerminalStore {
|
|
|
57
59
|
|
|
58
60
|
/// @notice Returns the reclaimable surplus for a project given a cash-out count, total supply, and surplus.
|
|
59
61
|
/// @param projectId The ID of the project.
|
|
60
|
-
/// @param cashOutCount The number of tokens
|
|
62
|
+
/// @param cashOutCount The number of tokens to cash out.
|
|
61
63
|
/// @param totalSupply The total token supply.
|
|
62
64
|
/// @param surplus The project's surplus.
|
|
63
65
|
/// @return The reclaimable surplus amount.
|
|
@@ -74,7 +76,7 @@ interface IJBTerminalStore {
|
|
|
74
76
|
/// @notice Returns the reclaimable surplus for a project across multiple terminals, considering only specific
|
|
75
77
|
/// tokens.
|
|
76
78
|
/// @param projectId The ID of the project.
|
|
77
|
-
/// @param cashOutCount The number of tokens
|
|
79
|
+
/// @param cashOutCount The number of tokens to cash out.
|
|
78
80
|
/// @param terminals The terminals to include in the surplus calculation. If empty, all project terminals are used.
|
|
79
81
|
/// @param tokens The tokens to include in the surplus calculation.
|
|
80
82
|
/// @param decimals The number of decimals to express the result with.
|
|
@@ -112,7 +114,7 @@ interface IJBTerminalStore {
|
|
|
112
114
|
|
|
113
115
|
/// @notice Returns the reclaimable surplus for a project across all terminals using all accounting contexts.
|
|
114
116
|
/// @param projectId The ID of the project.
|
|
115
|
-
/// @param cashOutCount The number of tokens
|
|
117
|
+
/// @param cashOutCount The number of tokens to cash out.
|
|
116
118
|
/// @param decimals The number of decimals to express the result with.
|
|
117
119
|
/// @param currency The currency to express the result in.
|
|
118
120
|
/// @return The reclaimable surplus amount.
|
|
@@ -143,9 +145,9 @@ interface IJBTerminalStore {
|
|
|
143
145
|
/// @notice Simulates a cash out without modifying state.
|
|
144
146
|
/// @param terminal The terminal to simulate the cash out from.
|
|
145
147
|
/// @param holder The address cashing out.
|
|
146
|
-
/// @param projectId The ID of the project
|
|
147
|
-
/// @param cashOutCount The number of project tokens
|
|
148
|
-
/// @param tokenToReclaim The token
|
|
148
|
+
/// @param projectId The ID of the project to cash out from.
|
|
149
|
+
/// @param cashOutCount The number of project tokens to cash out.
|
|
150
|
+
/// @param tokenToReclaim The token to reclaim.
|
|
149
151
|
/// @param beneficiaryIsFeeless Whether the cash out's beneficiary is a feeless address.
|
|
150
152
|
/// @param metadata Extra data to pass along to the data hook.
|
|
151
153
|
/// @return ruleset The project's current ruleset.
|
|
@@ -173,8 +175,8 @@ interface IJBTerminalStore {
|
|
|
173
175
|
/// @notice Simulates a payment without modifying state.
|
|
174
176
|
/// @param terminal The terminal to simulate the payment from.
|
|
175
177
|
/// @param payer The address of the payer.
|
|
176
|
-
/// @param amount The amount
|
|
177
|
-
/// @param projectId The ID of the project
|
|
178
|
+
/// @param amount The amount to pay.
|
|
179
|
+
/// @param projectId The ID of the project to pay.
|
|
178
180
|
/// @param beneficiary The address to mint project tokens to.
|
|
179
181
|
/// @param metadata Extra data to pass along to the data hook.
|
|
180
182
|
/// @return ruleset The project's current ruleset.
|
|
@@ -235,15 +237,15 @@ interface IJBTerminalStore {
|
|
|
235
237
|
|
|
236
238
|
/// @notice Records a balance addition for a project.
|
|
237
239
|
/// @param projectId The ID of the project.
|
|
238
|
-
/// @param token The token
|
|
239
|
-
/// @param amount The amount
|
|
240
|
+
/// @param token The token added.
|
|
241
|
+
/// @param amount The amount added.
|
|
240
242
|
function recordAddedBalanceFor(uint256 projectId, address token, uint256 amount) external;
|
|
241
243
|
|
|
242
244
|
/// @notice Records a cash out from a project.
|
|
243
245
|
/// @param holder The address cashing out.
|
|
244
|
-
/// @param projectId The ID of the project
|
|
245
|
-
/// @param cashOutCount The number of project tokens
|
|
246
|
-
/// @param tokenToReclaim The token
|
|
246
|
+
/// @param projectId The ID of the project to cash out from.
|
|
247
|
+
/// @param cashOutCount The number of project tokens to cash out.
|
|
248
|
+
/// @param tokenToReclaim The token to reclaim.
|
|
247
249
|
/// @param beneficiaryIsFeeless Whether the cash out's beneficiary is a feeless address. Passed through to data
|
|
248
250
|
/// hooks so they can skip their own fees when value stays in the protocol (e.g. project-to-project routing).
|
|
249
251
|
/// @param metadata Extra data to pass along to the data hook.
|
|
@@ -269,8 +271,8 @@ interface IJBTerminalStore {
|
|
|
269
271
|
|
|
270
272
|
/// @notice Records a payment to a project.
|
|
271
273
|
/// @param payer The address of the payer.
|
|
272
|
-
/// @param amount The amount
|
|
273
|
-
/// @param projectId The ID of the project
|
|
274
|
+
/// @param amount The amount to pay.
|
|
275
|
+
/// @param projectId The ID of the project to pay.
|
|
274
276
|
/// @param beneficiary The address to mint project tokens to.
|
|
275
277
|
/// @param metadata Extra data to pass along to the data hook.
|
|
276
278
|
/// @return ruleset The project's current ruleset.
|
|
@@ -288,8 +290,8 @@ interface IJBTerminalStore {
|
|
|
288
290
|
|
|
289
291
|
/// @notice Records a payout from a project.
|
|
290
292
|
/// @param projectId The ID of the project paying out.
|
|
291
|
-
/// @param token The token
|
|
292
|
-
/// @param amount The amount
|
|
293
|
+
/// @param token The token to pay out.
|
|
294
|
+
/// @param amount The amount to pay out.
|
|
293
295
|
/// @param currency The currency the amount is denominated in.
|
|
294
296
|
/// @return ruleset The project's current ruleset.
|
|
295
297
|
/// @return amountPaidOut The amount paid out in the token's native decimals.
|
|
@@ -303,14 +305,14 @@ interface IJBTerminalStore {
|
|
|
303
305
|
returns (JBRuleset memory ruleset, uint256 amountPaidOut);
|
|
304
306
|
|
|
305
307
|
/// @notice Records a terminal migration for a project.
|
|
306
|
-
/// @param projectId The ID of the project
|
|
307
|
-
/// @param token The token
|
|
308
|
+
/// @param projectId The ID of the project to migrate.
|
|
309
|
+
/// @param token The token to migrate.
|
|
308
310
|
/// @return balance The balance that was migrated.
|
|
309
311
|
function recordTerminalMigration(uint256 projectId, address token) external returns (uint256 balance);
|
|
310
312
|
|
|
311
313
|
/// @notice Records surplus allowance usage for a project.
|
|
312
314
|
/// @param projectId The ID of the project using surplus allowance.
|
|
313
|
-
/// @param token The token
|
|
315
|
+
/// @param token The token to use.
|
|
314
316
|
/// @param amount The amount of surplus allowance to use.
|
|
315
317
|
/// @param currency The currency the amount is denominated in.
|
|
316
318
|
/// @return ruleset The project's current ruleset.
|
|
@@ -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.
|
|
@@ -87,7 +88,7 @@ interface IJBTokens {
|
|
|
87
88
|
/// @return The credit balance.
|
|
88
89
|
function creditBalanceOf(address holder, uint256 projectId) external view returns (uint256);
|
|
89
90
|
|
|
90
|
-
/// @notice
|
|
91
|
+
/// @notice The project ID that a given ERC-20 token contract is associated with.
|
|
91
92
|
/// @param token The token to get the project ID of.
|
|
92
93
|
/// @return The project ID.
|
|
93
94
|
function projectIdOf(IJBToken token) external view returns (uint256);
|
|
@@ -115,13 +116,13 @@ interface IJBTokens {
|
|
|
115
116
|
|
|
116
117
|
/// @notice Burns tokens and/or credits from a holder's balance.
|
|
117
118
|
/// @param holder The address to burn tokens from.
|
|
118
|
-
/// @param projectId The ID of the project
|
|
119
|
+
/// @param projectId The ID of the project to burn tokens for.
|
|
119
120
|
/// @param count The number of tokens to burn.
|
|
120
121
|
function burnFrom(address holder, uint256 projectId, uint256 count) external;
|
|
121
122
|
|
|
122
123
|
/// @notice Claims tokens from a holder's credits into a beneficiary's account.
|
|
123
124
|
/// @param holder The address to claim credits from.
|
|
124
|
-
/// @param projectId The ID of the project
|
|
125
|
+
/// @param projectId The ID of the project to claim tokens for.
|
|
125
126
|
/// @param count The number of tokens to claim.
|
|
126
127
|
/// @param beneficiary The address to send the claimed tokens to.
|
|
127
128
|
function claimTokensFor(address holder, uint256 projectId, uint256 count, address beneficiary) external;
|
|
@@ -143,7 +144,7 @@ interface IJBTokens {
|
|
|
143
144
|
|
|
144
145
|
/// @notice Mints tokens or credits for a holder.
|
|
145
146
|
/// @param holder The address to mint tokens for.
|
|
146
|
-
/// @param projectId The ID of the project
|
|
147
|
+
/// @param projectId The ID of the project to mint tokens for.
|
|
147
148
|
/// @param count The number of tokens to mint.
|
|
148
149
|
/// @return token The project's token, if one exists.
|
|
149
150
|
function mintFor(address holder, uint256 projectId, uint256 count) external returns (IJBToken token);
|
|
@@ -154,14 +155,14 @@ interface IJBTokens {
|
|
|
154
155
|
function setTokenFor(uint256 projectId, IJBToken token) external;
|
|
155
156
|
|
|
156
157
|
/// @notice Sets the name and symbol of a project's token.
|
|
157
|
-
/// @param projectId The ID of the project
|
|
158
|
+
/// @param projectId The ID of the project to update the token for.
|
|
158
159
|
/// @param name The new name.
|
|
159
160
|
/// @param symbol The new symbol.
|
|
160
161
|
function setTokenMetadataFor(uint256 projectId, string calldata name, string calldata symbol) external;
|
|
161
162
|
|
|
162
163
|
/// @notice Transfers credits from one holder to another.
|
|
163
164
|
/// @param holder The address to transfer credits from.
|
|
164
|
-
/// @param projectId The ID of the project
|
|
165
|
+
/// @param projectId The ID of the project to transfer credits for.
|
|
165
166
|
/// @param recipient The address to transfer credits to.
|
|
166
167
|
/// @param count The number of credits to transfer.
|
|
167
168
|
function transferCreditsFrom(address holder, uint256 projectId, address recipient, uint256 count) external;
|
|
@@ -5,15 +5,20 @@ 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();
|
|
12
17
|
|
|
13
18
|
/// @notice Returns the amount of surplus terminal tokens which can be reclaimed based on the total surplus, the
|
|
14
|
-
/// number of tokens
|
|
19
|
+
/// number of tokens to cash out, the total token supply, and the ruleset's cash out tax rate.
|
|
15
20
|
/// @param surplus The total amount of surplus terminal tokens.
|
|
16
|
-
/// @param cashOutCount The number of tokens
|
|
21
|
+
/// @param cashOutCount The number of tokens to cash out, as a fixed point number with 18 decimals.
|
|
17
22
|
/// @param totalSupply The total token supply, as a fixed point number with 18 decimals.
|
|
18
23
|
/// @param cashOutTaxRate The current ruleset's cash out tax rate.
|
|
19
24
|
/// @return reclaimableSurplus The amount of surplus tokens that can be reclaimed.
|
|
@@ -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(
|
|
@@ -41,9 +44,9 @@ library JBPayoutSplitGroupLib {
|
|
|
41
44
|
/// @param splits The splits contract to read splits from.
|
|
42
45
|
/// @param store The terminal store used to restore balance when a payout fails.
|
|
43
46
|
/// @param projectId The ID of the project to send the payouts of.
|
|
44
|
-
/// @param token The address of the token
|
|
45
|
-
/// @param rulesetId The ID of the ruleset of the split group
|
|
46
|
-
/// @param amount The total amount
|
|
47
|
+
/// @param token The address of the token to pay out.
|
|
48
|
+
/// @param rulesetId The ID of the ruleset of the split group to pay.
|
|
49
|
+
/// @param amount The total amount to pay out.
|
|
47
50
|
/// @param caller The original caller of the terminal payout flow.
|
|
48
51
|
/// @return leftoverAmount The leftover amount after split payouts.
|
|
49
52
|
/// @return amountEligibleForFees The amount of payouts that are eligible for fees.
|
|
@@ -118,8 +121,8 @@ library JBPayoutSplitGroupLib {
|
|
|
118
121
|
/// @param store The terminal store used to restore balance when a payout fails.
|
|
119
122
|
/// @param split The split to pay.
|
|
120
123
|
/// @param projectId The ID of the project the split was specified by.
|
|
121
|
-
/// @param token The address of the token
|
|
122
|
-
/// @param amount The total amount that the split is
|
|
124
|
+
/// @param token The address of the token to pay out.
|
|
125
|
+
/// @param amount The total amount that the split is paid.
|
|
123
126
|
/// @param caller The original caller of the terminal payout flow.
|
|
124
127
|
/// @return netPayoutAmount The amount sent to the split after subtracting fees.
|
|
125
128
|
function _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,10 +3,12 @@ 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
|
-
/// @dev This amount changes as the value of the balances changes in relation to the currency
|
|
11
|
+
/// @dev This amount changes as the value of the balances changes in relation to the currency used to measure
|
|
10
12
|
/// the project's payout limits.
|
|
11
13
|
/// @param projectId The ID of the project to get the total surplus for.
|
|
12
14
|
/// @param terminals The terminals to look for surplus within.
|
|
@@ -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,16 +3,16 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {JBTokenAmount} from "./JBTokenAmount.sol";
|
|
5
5
|
|
|
6
|
-
/// @custom:member holder The holder of the tokens
|
|
7
|
-
/// @custom:member projectId The ID of the project
|
|
8
|
-
/// @custom:member rulesetId The ID of the ruleset the cash out is
|
|
9
|
-
/// @custom:member cashOutCount The number of project tokens
|
|
6
|
+
/// @custom:member holder The holder of the tokens to cash out.
|
|
7
|
+
/// @custom:member projectId The ID of the project to cash out from.
|
|
8
|
+
/// @custom:member rulesetId The ID of the ruleset the cash out is made during.
|
|
9
|
+
/// @custom:member cashOutCount The number of project tokens to cash out.
|
|
10
10
|
/// @custom:member cashOutTaxRate The current ruleset's cash out tax rate.
|
|
11
|
-
/// @custom:member reclaimedAmount The token amount
|
|
12
|
-
/// token
|
|
11
|
+
/// @custom:member reclaimedAmount The token amount reclaimed from the project's terminal balance. Includes the
|
|
12
|
+
/// token
|
|
13
13
|
/// reclaimed, the value, the number of decimals included, and the currency of the amount.
|
|
14
|
-
/// @custom:member forwardedAmount The token amount
|
|
15
|
-
///
|
|
14
|
+
/// @custom:member forwardedAmount The token amount forwarded to the cash out hook. Includes the token
|
|
15
|
+
/// forwarded, the value, the number of decimals included, and the currency of the amount.
|
|
16
16
|
/// @custom:member beneficiary The address the reclaimed amount will be sent to.
|
|
17
17
|
/// @custom:member hookMetadata Extra data specified by the data hook, which is sent to the cash out hook.
|
|
18
18
|
/// @custom:member cashOutMetadata Extra data specified by the account cashing out, which is sent to the cash out hook.
|