@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
package/src/JBMultiTerminal.sol
CHANGED
|
@@ -45,8 +45,13 @@ import {JBSplit} from "./structs/JBSplit.sol";
|
|
|
45
45
|
import {JBSplitHookContext} from "./structs/JBSplitHookContext.sol";
|
|
46
46
|
import {JBTokenAmount} from "./structs/JBTokenAmount.sol";
|
|
47
47
|
|
|
48
|
-
/// @notice
|
|
49
|
-
///
|
|
48
|
+
/// @notice The main entry point for all money movement in Juicebox. Handles payments (ETH or ERC-20), cash outs
|
|
49
|
+
/// (burning tokens to reclaim funds), payouts (distributing funds to splits), and surplus allowance withdrawals.
|
|
50
|
+
/// Charges a 2.5% protocol fee on outflows (held for 28 days before processing). Supports Permit2 for gasless
|
|
51
|
+
/// ERC-20 approvals.
|
|
52
|
+
/// @dev Each project can have multiple terminals for different tokens. The terminal delegates accounting to
|
|
53
|
+
/// `JBTerminalStore` and splits distribution to `JBSplits`. Fees are sent to project #1 (the fee beneficiary).
|
|
54
|
+
/// All external hook calls (pay hooks, cash-out hooks, split hooks) are wrapped in try-catch to prevent griefing.
|
|
50
55
|
contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
51
56
|
// A library that parses the packed ruleset metadata into a friendlier format.
|
|
52
57
|
using JBRulesetMetadataResolver for JBRuleset;
|
|
@@ -99,10 +104,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
99
104
|
/// @notice The directory of terminals and controllers for PROJECTS.
|
|
100
105
|
IJBDirectory public immutable override DIRECTORY;
|
|
101
106
|
|
|
102
|
-
/// @notice The contract that stores addresses that shouldn't incur fees when
|
|
107
|
+
/// @notice The contract that stores addresses that shouldn't incur fees when paid towards or from.
|
|
103
108
|
IJBFeelessAddresses public immutable override FEELESS_ADDRESSES;
|
|
104
109
|
|
|
105
|
-
/// @notice The
|
|
110
|
+
/// @notice The Permit2 contract used for token approvals and transfers.
|
|
106
111
|
IPermit2 public immutable override PERMIT2;
|
|
107
112
|
|
|
108
113
|
/// @notice Mints ERC-721s that represent project ownership and transfers.
|
|
@@ -135,23 +140,23 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
135
140
|
/// @custom:param token The token that was received.
|
|
136
141
|
mapping(uint256 projectId => mapping(address token => uint256)) internal _feeFreeSurplusOf;
|
|
137
142
|
|
|
138
|
-
/// @notice Fees
|
|
143
|
+
/// @notice Fees currently held for each project.
|
|
139
144
|
/// @dev Projects can temporarily hold fees and unlock them later by adding funds to the project's balance.
|
|
140
145
|
/// @dev Held fees can be processed at any time by this terminal's owner.
|
|
141
|
-
/// @custom:param projectId The ID of the project
|
|
142
|
-
/// @custom:param token The token
|
|
146
|
+
/// @custom:param projectId The ID of the project holding fees.
|
|
147
|
+
/// @custom:param token The token the fees are held in.
|
|
143
148
|
mapping(uint256 projectId => mapping(address token => JBFee[])) internal _heldFeesOf;
|
|
144
149
|
|
|
145
150
|
/// @notice The next index to use when processing a next held fee.
|
|
146
|
-
/// @custom:param projectId The ID of the project
|
|
147
|
-
/// @custom:param token The token
|
|
151
|
+
/// @custom:param projectId The ID of the project holding fees.
|
|
152
|
+
/// @custom:param token The token the fees are held in.
|
|
148
153
|
mapping(uint256 projectId => mapping(address token => uint256)) internal _nextHeldFeeIndexOf;
|
|
149
154
|
|
|
150
155
|
//*********************************************************************//
|
|
151
156
|
// -------------------------- constructor ---------------------------- //
|
|
152
157
|
//*********************************************************************//
|
|
153
158
|
|
|
154
|
-
/// @param feelessAddresses A contract that stores addresses that shouldn't incur fees when
|
|
159
|
+
/// @param feelessAddresses A contract that stores addresses that shouldn't incur fees when paid towards or
|
|
155
160
|
/// from.
|
|
156
161
|
/// @param permissions A contract storing permissions.
|
|
157
162
|
/// @param projects A contract which mints ERC-721s that represent project ownership and transfers.
|
|
@@ -185,10 +190,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
185
190
|
// ---------------------- external transactions ---------------------- //
|
|
186
191
|
//*********************************************************************//
|
|
187
192
|
|
|
188
|
-
/// @notice
|
|
189
|
-
///
|
|
190
|
-
/// @dev Only
|
|
191
|
-
///
|
|
193
|
+
/// @notice Registers new tokens that this terminal can accept for a project. Once a token's accounting context is
|
|
194
|
+
/// added, the project can receive payments in that token.
|
|
195
|
+
/// @dev Only the project's owner, an operator with `ADD_ACCOUNTING_CONTEXTS` permission, or the project's
|
|
196
|
+
/// controller can call this.
|
|
192
197
|
/// @param projectId The ID of the project having to add accounting contexts for.
|
|
193
198
|
/// @param accountingContexts The accounting contexts to add.
|
|
194
199
|
function addAccountingContextsFor(
|
|
@@ -219,13 +224,14 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
219
224
|
}
|
|
220
225
|
}
|
|
221
226
|
|
|
222
|
-
/// @notice Adds funds to a project's balance without minting tokens.
|
|
223
|
-
///
|
|
227
|
+
/// @notice Adds funds to a project's balance without minting tokens. Useful for topping up a project or returning
|
|
228
|
+
/// funds. Can also unlock previously held fees by returning them to the project's balance.
|
|
229
|
+
/// @dev If `shouldReturnHeldFees` is true, the added amount offsets held fees proportionally.
|
|
224
230
|
/// @param projectId The ID of the project to add funds to the balance of.
|
|
225
231
|
/// @param amount The amount of tokens to add to the balance, as a fixed point number with the same number of
|
|
226
232
|
/// decimals as this terminal. If this is a native token terminal, this is ignored and `msg.value` is used instead.
|
|
227
|
-
/// @param token The token
|
|
228
|
-
/// @param shouldReturnHeldFees
|
|
233
|
+
/// @param token The token to add to the balance.
|
|
234
|
+
/// @param shouldReturnHeldFees If true, return held fees proportional to the amount added.
|
|
229
235
|
/// @param memo A memo to pass along to the emitted event.
|
|
230
236
|
/// @param metadata Extra data to pass along to the emitted event.
|
|
231
237
|
function addToBalanceOf(
|
|
@@ -251,15 +257,14 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
251
257
|
});
|
|
252
258
|
}
|
|
253
259
|
|
|
254
|
-
/// @notice
|
|
255
|
-
///
|
|
256
|
-
/// @dev Only
|
|
257
|
-
///
|
|
258
|
-
/// @param holder The account whose tokens are being cashed out.
|
|
260
|
+
/// @notice Burns project tokens to reclaim a share of the project's surplus (determined by the bonding curve) or
|
|
261
|
+
/// to trigger custom logic through the ruleset's data hook and cash out hook.
|
|
262
|
+
/// @dev Only the token holder or an operator with `CASH_OUT_TOKENS` permission from that holder can call this.
|
|
263
|
+
/// @param holder The account cashing out tokens.
|
|
259
264
|
/// @param projectId The ID of the project the project tokens belong to.
|
|
260
265
|
/// @param cashOutCount The number of project tokens to cash out and burn, as a fixed point number with 18
|
|
261
266
|
/// decimals.
|
|
262
|
-
/// @param tokenToReclaim The token
|
|
267
|
+
/// @param tokenToReclaim The token to reclaim.
|
|
263
268
|
/// @param minTokensReclaimed The minimum number of terminal tokens expected in return, as a fixed point number with
|
|
264
269
|
/// the same number of decimals as this terminal. If the amount of tokens minted for the beneficiary would be less
|
|
265
270
|
/// than this amount, the cash out is reverted.
|
|
@@ -303,8 +308,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
303
308
|
/// @dev Only accepts calls from this terminal itself.
|
|
304
309
|
/// @param split The split to pay.
|
|
305
310
|
/// @param projectId The ID of the project the split belongs to.
|
|
306
|
-
/// @param token The address of the token
|
|
307
|
-
/// @param amount The total amount
|
|
311
|
+
/// @param token The address of the token to pay to the split.
|
|
312
|
+
/// @param amount The total amount to pay to the split, as a fixed point number with the same number of
|
|
308
313
|
/// decimals as this terminal.
|
|
309
314
|
/// @return netPayoutAmount The amount sent to the split after subtracting fees.
|
|
310
315
|
function executePayout(
|
|
@@ -452,7 +457,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
452
457
|
/// @notice Process a specified amount of fees for a project.
|
|
453
458
|
/// @dev Only accepts calls from this terminal itself.
|
|
454
459
|
/// @param projectId The ID of the project paying the fee.
|
|
455
|
-
/// @param token The token the fee is
|
|
460
|
+
/// @param token The token the fee is paid in.
|
|
456
461
|
/// @param amount The fee amount, as a fixed point number with 18 decimals.
|
|
457
462
|
/// @param beneficiary The address to mint tokens to (from the project which receives fees), and pass along to the
|
|
458
463
|
/// ruleset's data hook and pay hook if applicable.
|
|
@@ -501,9 +506,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
501
506
|
/// @notice Migrate a project's funds and operations to a new terminal that accepts the same token type.
|
|
502
507
|
/// @dev Only a project's owner or an operator with the `MIGRATE_TERMINAL` permission from that owner can migrate
|
|
503
508
|
/// the project's terminal.
|
|
504
|
-
/// @param projectId The ID of the project
|
|
505
|
-
/// @param token The address of the token
|
|
506
|
-
/// @param to The terminal
|
|
509
|
+
/// @param projectId The ID of the project to migrate.
|
|
510
|
+
/// @param token The address of the token to migrate.
|
|
511
|
+
/// @param to The terminal to migrate to, which will receive the project's funds and operations.
|
|
507
512
|
/// @return balance The amount of funds that were migrated, as a fixed point number with the same amount of decimals
|
|
508
513
|
/// as this terminal.
|
|
509
514
|
function migrateBalanceOf(
|
|
@@ -563,12 +568,13 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
563
568
|
}
|
|
564
569
|
}
|
|
565
570
|
|
|
566
|
-
/// @notice Pay a project with tokens.
|
|
567
|
-
///
|
|
568
|
-
/// @param
|
|
571
|
+
/// @notice Pay a project with tokens. The project's current ruleset determines how many project tokens the
|
|
572
|
+
/// beneficiary will receive.
|
|
573
|
+
/// @param projectId The ID of the project to pay.
|
|
574
|
+
/// @param amount The amount of tokens to send, as a fixed point number with the same number of
|
|
569
575
|
/// decimals as this terminal. If this terminal's token is native, this is ignored and `msg.value` is used in its
|
|
570
576
|
/// place.
|
|
571
|
-
/// @param token The token
|
|
577
|
+
/// @param token The token to pay with.
|
|
572
578
|
/// @param beneficiary The address to mint tokens to, and pass along to the ruleset's data hook and pay hook if
|
|
573
579
|
/// applicable.
|
|
574
580
|
/// @param minReturnedTokens The minimum number of project tokens expected in return for this payment, as a fixed
|
|
@@ -622,19 +628,13 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
622
628
|
_checkMin({value: beneficiaryTokenCount, min: minReturnedTokens});
|
|
623
629
|
}
|
|
624
630
|
|
|
625
|
-
/// @notice
|
|
626
|
-
///
|
|
627
|
-
///
|
|
628
|
-
/// @dev
|
|
629
|
-
///
|
|
630
|
-
///
|
|
631
|
-
///
|
|
632
|
-
/// (e.g. the fee terminal rejects the payment), the catch block calls `_recordAddedBalanceFor` to credit the fee
|
|
633
|
-
/// amount back to the project. This credit is backed by the tokens that failed to transfer out. No phantom balance
|
|
634
|
-
/// is created because the tokens never left.
|
|
635
|
-
/// @dev The index-increment-before-`_processFee` pattern is intentional: locked (not-yet-unlocked) fees are skipped
|
|
636
|
-
/// via the `unlockTimestamp` check, and advancing the index before the external call prevents reentrancy from
|
|
637
|
-
/// reprocessing the same fee entry.
|
|
631
|
+
/// @notice Processes held fees for a project, sending them to the protocol's fee project. Fees are held for 28 days
|
|
632
|
+
/// after a payout — processing them finalizes the fee payment.
|
|
633
|
+
/// @dev Only processes fees whose `unlockTimestamp` has passed. Stops early if it encounters a still-locked fee.
|
|
634
|
+
/// @dev Reentrancy-safe: re-reads `_nextHeldFeeIndexOf` from storage each iteration and advances the index before
|
|
635
|
+
/// the external `_processFee` call, preventing double-processing.
|
|
636
|
+
/// @dev If `_processFee` reverts (fee terminal rejects), the fee amount is returned to the project's balance
|
|
637
|
+
/// (forgiven, not retried). A `FeeReverted` event is emitted for off-chain observability.
|
|
638
638
|
/// @param projectId The ID of the project to process held fees for.
|
|
639
639
|
/// @param token The token to process held fees for.
|
|
640
640
|
/// @param count The number of fees to process.
|
|
@@ -657,6 +657,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
657
657
|
|
|
658
658
|
// Can't process fees that aren't yet unlocked. Fees unlock sequentially in the array, so nothing left to do
|
|
659
659
|
// if the current fee isn't yet unlocked.
|
|
660
|
+
// forge-lint: disable-next-line(block-timestamp)
|
|
660
661
|
if (heldFee.unlockTimestamp > block.timestamp) break;
|
|
661
662
|
|
|
662
663
|
// Delete the entry and advance the index *before* the external call. This is intentional:
|
|
@@ -694,20 +695,17 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
694
695
|
}
|
|
695
696
|
}
|
|
696
697
|
|
|
697
|
-
/// @notice
|
|
698
|
-
/// payout limit.
|
|
699
|
-
/// @dev If
|
|
700
|
-
///
|
|
701
|
-
/// @dev
|
|
702
|
-
///
|
|
703
|
-
/// be used to incentivize calling this function.
|
|
704
|
-
/// @dev payouts sent to addresses which aren't feeless incur the protocol fee.
|
|
705
|
-
/// @dev Payouts a projects don't incur fees if its terminal is feeless.
|
|
698
|
+
/// @notice Distributes funds from a project's balance to its payout split recipients, up to the current ruleset's
|
|
699
|
+
/// payout limit. Anyone can call this on behalf of any project.
|
|
700
|
+
/// @dev If splits don't add up to 100%, the remainder goes to the project owner. A wildcard split (no hook,
|
|
701
|
+
/// projectId, or beneficiary) sends its share to `msg.sender` — useful for incentivizing the call.
|
|
702
|
+
/// @dev Payouts to non-feeless addresses incur the 2.5% protocol fee. Projects whose terminal is feeless are
|
|
703
|
+
/// exempt.
|
|
706
704
|
/// @param projectId The ID of the project having its payouts sent.
|
|
707
|
-
/// @param token The token
|
|
705
|
+
/// @param token The token to send.
|
|
708
706
|
/// @param amount The total number of terminal tokens to send, as a fixed point number with same number of decimals
|
|
709
707
|
/// as this terminal.
|
|
710
|
-
/// @param currency The expected currency of the payouts
|
|
708
|
+
/// @param currency The expected currency of the payouts. Must match the currency of one of the
|
|
711
709
|
/// project's current ruleset's payout limits.
|
|
712
710
|
/// @param minTokensPaidOut The minimum number of terminal tokens that the `amount` should be worth (if expressed
|
|
713
711
|
/// in terms of this terminal's currency), as a fixed point number with the same number of decimals as this
|
|
@@ -730,15 +728,15 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
730
728
|
_checkMin({value: amountPaidOut, min: minTokensPaidOut});
|
|
731
729
|
}
|
|
732
730
|
|
|
733
|
-
/// @notice
|
|
734
|
-
///
|
|
735
|
-
///
|
|
736
|
-
/// @dev Incurs the protocol fee unless the caller is a feeless address.
|
|
731
|
+
/// @notice Withdraws funds from a project's surplus (beyond what's needed for payouts) up to the current ruleset's
|
|
732
|
+
/// surplus allowance. Sent directly to a beneficiary address rather than through splits.
|
|
733
|
+
/// @dev Only the project's owner or an operator with `USE_ALLOWANCE` permission can call this.
|
|
734
|
+
/// @dev Incurs the 2.5% protocol fee unless the caller is a feeless address.
|
|
737
735
|
/// @param projectId The ID of the project to use the surplus allowance of.
|
|
738
|
-
/// @param token The token
|
|
736
|
+
/// @param token The token to pay out from the surplus.
|
|
739
737
|
/// @param amount The amount of terminal tokens to use from the project's current surplus allowance, as a fixed
|
|
740
738
|
/// point number with the same amount of decimals as this terminal.
|
|
741
|
-
/// @param currency The expected currency of the amount
|
|
739
|
+
/// @param currency The expected currency of the amount to pay out. Must match the currency of one of the
|
|
742
740
|
/// project's current ruleset's surplus allowances.
|
|
743
741
|
/// @param minTokensPaidOut The minimum number of terminal tokens that should be returned from the surplus allowance
|
|
744
742
|
/// (excluding fees), as a fixed point number with 18 decimals. If the amount of surplus used would be less than
|
|
@@ -787,8 +785,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
787
785
|
// ------------------------- external views -------------------------- //
|
|
788
786
|
//*********************************************************************//
|
|
789
787
|
|
|
790
|
-
/// @notice
|
|
791
|
-
/// @dev See the `JBAccountingContext` struct for more information.
|
|
788
|
+
/// @notice Returns the accounting context (decimals, currency) for a specific token that a project accepts.
|
|
792
789
|
/// @param projectId The ID of the project to get token accounting context of.
|
|
793
790
|
/// @param token The token to check the accounting context of.
|
|
794
791
|
/// @return The token's accounting context for the token.
|
|
@@ -804,15 +801,16 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
804
801
|
return STORE.accountingContextOf({terminal: address(this), projectId: projectId, token: token});
|
|
805
802
|
}
|
|
806
803
|
|
|
807
|
-
/// @notice
|
|
804
|
+
/// @notice Returns accounting contexts for all tokens a project currently accepts through this terminal.
|
|
808
805
|
/// @param projectId The ID of the project to get the accepted tokens of.
|
|
809
806
|
/// @return tokenContexts The accounting contexts of the accepted tokens.
|
|
810
807
|
function accountingContextsOf(uint256 projectId) external view override returns (JBAccountingContext[] memory) {
|
|
811
808
|
return STORE.accountingContextsOf({terminal: address(this), projectId: projectId});
|
|
812
809
|
}
|
|
813
810
|
|
|
814
|
-
/// @notice
|
|
815
|
-
///
|
|
811
|
+
/// @notice Returns the project's current surplus in this terminal, converted to a specified currency. The surplus
|
|
812
|
+
/// is the balance minus what's needed for payout limits.
|
|
813
|
+
/// @dev If `tokens` is empty, includes all tokens the project accepts.
|
|
816
814
|
/// @param projectId The ID of the project to get the current surplus of.
|
|
817
815
|
/// @param tokens The tokens to include in the surplus calculation. If empty, all tokens are included.
|
|
818
816
|
/// @param decimals The number of decimals to include in the fixed point returned value.
|
|
@@ -837,11 +835,12 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
837
835
|
});
|
|
838
836
|
}
|
|
839
837
|
|
|
840
|
-
/// @notice
|
|
841
|
-
///
|
|
842
|
-
/// @dev Held fees can be
|
|
843
|
-
///
|
|
844
|
-
/// @param
|
|
838
|
+
/// @notice Returns the fees currently held for a project. Fees are held for 28 days after a payout before
|
|
839
|
+
/// they can be processed (sent to the fee project).
|
|
840
|
+
/// @dev Held fees can be returned to the project by calling `addToBalanceOf` with `shouldReturnHeldFees = true`
|
|
841
|
+
/// before the 28-day lock expires.
|
|
842
|
+
/// @param projectId The ID of the project holding fees.
|
|
843
|
+
/// @param token The token the fees are held in.
|
|
845
844
|
/// @param count The maximum number of held fees to return.
|
|
846
845
|
/// @return heldFees The held fees.
|
|
847
846
|
function heldFeesOf(
|
|
@@ -878,9 +877,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
878
877
|
}
|
|
879
878
|
}
|
|
880
879
|
|
|
881
|
-
/// @notice Simulates
|
|
882
|
-
///
|
|
883
|
-
/// @param
|
|
880
|
+
/// @notice Simulates a cash out without modifying state — use this to preview how many tokens a holder would
|
|
881
|
+
/// reclaim.
|
|
882
|
+
/// @param holder The address cashing out tokens.
|
|
883
|
+
/// @param projectId The ID of the project cashing out tokens.
|
|
884
884
|
/// @param cashOutCount The number of project tokens to cash out.
|
|
885
885
|
/// @param tokenToReclaim The token to reclaim from the project's surplus.
|
|
886
886
|
/// @param beneficiary The address that would receive the reclaimed tokens.
|
|
@@ -919,10 +919,12 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
919
919
|
});
|
|
920
920
|
}
|
|
921
921
|
|
|
922
|
-
/// @notice Simulates
|
|
923
|
-
///
|
|
924
|
-
///
|
|
925
|
-
/// @param
|
|
922
|
+
/// @notice Simulates a payment without modifying state — use this to preview how many project tokens a payer
|
|
923
|
+
/// would
|
|
924
|
+
/// receive.
|
|
925
|
+
/// @param projectId The ID of the project to pay.
|
|
926
|
+
/// @param token The token to pay with.
|
|
927
|
+
/// @param amount The amount of tokens to pay.
|
|
926
928
|
/// @param beneficiary The address to mint project tokens to.
|
|
927
929
|
/// @param metadata Extra data to pass along to the data hook and pay hooks.
|
|
928
930
|
/// @return ruleset The project's current ruleset.
|
|
@@ -984,9 +986,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
984
986
|
//*********************************************************************//
|
|
985
987
|
|
|
986
988
|
/// @notice Accepts an incoming token.
|
|
987
|
-
/// @param projectId The ID of the project
|
|
988
|
-
/// @param token The token
|
|
989
|
-
/// @param amount The number of tokens
|
|
989
|
+
/// @param projectId The ID of the project to accept the transfer for.
|
|
990
|
+
/// @param token The token to accept.
|
|
991
|
+
/// @param amount The number of tokens to accept.
|
|
990
992
|
/// @param metadata The metadata in which permit2 context is provided.
|
|
991
993
|
/// @return amount The number of tokens which have been accepted.
|
|
992
994
|
function _acceptFundsFor(
|
|
@@ -1050,10 +1052,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1050
1052
|
|
|
1051
1053
|
/// @notice Adds funds to a project's balance without minting tokens.
|
|
1052
1054
|
/// @param projectId The ID of the project to add funds to the balance of.
|
|
1053
|
-
/// @param token The address of the token
|
|
1055
|
+
/// @param token The address of the token to add to the project's balance.
|
|
1054
1056
|
/// @param amount The amount of tokens to add as a fixed point number with the same number of decimals as this
|
|
1055
1057
|
/// terminal. If this is a native token terminal, this is ignored and `msg.value` is used instead.
|
|
1056
|
-
/// @param shouldReturnHeldFees
|
|
1058
|
+
/// @param shouldReturnHeldFees If true, return held fees proportional to the amount added.
|
|
1057
1059
|
/// @param memo A memo to pass along to the emitted event.
|
|
1058
1060
|
/// @param metadata Extra data to pass along to the emitted event.
|
|
1059
1061
|
function _addToBalanceOf(
|
|
@@ -1086,10 +1088,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1086
1088
|
|
|
1087
1089
|
/// @notice Logic to be triggered before transferring tokens from this terminal.
|
|
1088
1090
|
/// @param to The address the transfer is going to.
|
|
1089
|
-
/// @param token The token
|
|
1090
|
-
/// @param amount The number of tokens
|
|
1091
|
+
/// @param token The token to transfer.
|
|
1092
|
+
/// @param amount The number of tokens to transfer, as a fixed point number with the same number of decimals
|
|
1091
1093
|
/// as this terminal.
|
|
1092
|
-
/// @return payValue The value to attach to the transaction
|
|
1094
|
+
/// @return payValue The value to attach to the transaction.
|
|
1093
1095
|
function _beforeTransferTo(address to, address token, uint256 amount) internal returns (uint256) {
|
|
1094
1096
|
// If the token is the native token, no allowance needed, and the full amount should be used as the payValue.
|
|
1095
1097
|
if (token == JBConstants.NATIVE_TOKEN) return amount;
|
|
@@ -1129,9 +1131,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1129
1131
|
/// those
|
|
1130
1132
|
/// tokens.
|
|
1131
1133
|
/// @param holder The account cashing out tokens.
|
|
1132
|
-
/// @param projectId The ID of the project
|
|
1134
|
+
/// @param projectId The ID of the project cashing out tokens.
|
|
1133
1135
|
/// @param cashOutCount The number of project tokens to cash out, as a fixed point number with 18 decimals.
|
|
1134
|
-
/// @param tokenToReclaim The address of the token
|
|
1136
|
+
/// @param tokenToReclaim The address of the token to reclaim.
|
|
1135
1137
|
/// @param beneficiary The address to send the reclaimed terminal tokens to.
|
|
1136
1138
|
/// @param metadata Bytes to send along to the emitted event, as well as the data hook and cash out hook if
|
|
1137
1139
|
/// applicable.
|
|
@@ -1279,9 +1281,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1279
1281
|
/// @notice Fund a project either by calling this terminal's internal `addToBalance` function or by calling the
|
|
1280
1282
|
/// recipient terminal's `addToBalance` function.
|
|
1281
1283
|
/// @param terminal The terminal on which the project is expecting to receive funds.
|
|
1282
|
-
/// @param projectId The ID of the project
|
|
1283
|
-
/// @param token The token
|
|
1284
|
-
/// @param amount The amount
|
|
1284
|
+
/// @param projectId The ID of the project to fund.
|
|
1285
|
+
/// @param token The token to use.
|
|
1286
|
+
/// @param amount The amount to fund, as a fixed point number with the amount of decimals that the terminal's
|
|
1285
1287
|
/// accounting context specifies.
|
|
1286
1288
|
/// @param metadata Additional metadata to include with the payment.
|
|
1287
1289
|
function _efficientAddToBalance(
|
|
@@ -1314,9 +1316,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1314
1316
|
/// @notice Pay a project either by calling this terminal's internal `pay` function or by calling the recipient
|
|
1315
1317
|
/// terminal's `pay` function.
|
|
1316
1318
|
/// @param terminal The terminal on which the project is expecting to receive payments.
|
|
1317
|
-
/// @param projectId The ID of the project
|
|
1318
|
-
/// @param token The token
|
|
1319
|
-
/// @param amount The amount
|
|
1319
|
+
/// @param projectId The ID of the project to pay.
|
|
1320
|
+
/// @param token The token to pay with.
|
|
1321
|
+
/// @param amount The amount to pay, as a fixed point number with the amount of decimals that the terminal's
|
|
1320
1322
|
/// accounting context specifies.
|
|
1321
1323
|
/// @param beneficiary The address to receive any platform tokens minted.
|
|
1322
1324
|
/// @param metadata Additional metadata to include with the payment.
|
|
@@ -1366,9 +1368,9 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1366
1368
|
|
|
1367
1369
|
/// @notice Fund a project on another terminal by granting a temporary pull allowance for this call only.
|
|
1368
1370
|
/// @param terminal The recipient terminal.
|
|
1369
|
-
/// @param projectId The ID of the project
|
|
1370
|
-
/// @param token The token
|
|
1371
|
-
/// @param amount The amount
|
|
1371
|
+
/// @param projectId The ID of the project to fund.
|
|
1372
|
+
/// @param token The token to use.
|
|
1373
|
+
/// @param amount The amount to fund.
|
|
1372
1374
|
/// @param metadata Additional metadata to include with the payment.
|
|
1373
1375
|
function _externalAddToBalance(
|
|
1374
1376
|
IJBTerminal terminal,
|
|
@@ -1400,15 +1402,15 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1400
1402
|
}
|
|
1401
1403
|
|
|
1402
1404
|
/// @notice Fulfills a list of cash out hook specifications.
|
|
1403
|
-
/// @param projectId The ID of the project
|
|
1404
|
-
/// @param beneficiaryReclaimAmount The number of tokens
|
|
1405
|
-
/// @param holder The address
|
|
1406
|
-
/// @param cashOutCount The number of tokens
|
|
1405
|
+
/// @param projectId The ID of the project to cash out from.
|
|
1406
|
+
/// @param beneficiaryReclaimAmount The number of tokens to cash out from the project.
|
|
1407
|
+
/// @param holder The address holding the tokens to cash out.
|
|
1408
|
+
/// @param cashOutCount The number of tokens to cash out.
|
|
1407
1409
|
/// @param metadata Bytes to send along to the emitted event and cash out hooks as applicable.
|
|
1408
|
-
/// @param ruleset The ruleset
|
|
1410
|
+
/// @param ruleset The ruleset active during this cash out as a `JBRuleset` struct.
|
|
1409
1411
|
/// @param cashOutTaxRate The cash out tax rate influencing the reclaim amount.
|
|
1410
1412
|
/// @param beneficiary The address which will receive any terminal tokens that are cashed out.
|
|
1411
|
-
/// @param specifications The hook specifications
|
|
1413
|
+
/// @param specifications The hook specifications to fulfill.
|
|
1412
1414
|
/// @return amountEligibleForFees The amount of funds which were allocated to cash out hooks and are eligible for
|
|
1413
1415
|
/// fees.
|
|
1414
1416
|
function _fulfillCashOutHookSpecificationsFor(
|
|
@@ -1501,13 +1503,13 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1501
1503
|
}
|
|
1502
1504
|
|
|
1503
1505
|
/// @notice Fulfills a list of pay hook specifications.
|
|
1504
|
-
/// @param projectId The ID of the project
|
|
1506
|
+
/// @param projectId The ID of the project to pay.
|
|
1505
1507
|
/// @param specifications The pay hook specifications to be fulfilled.
|
|
1506
1508
|
/// @param tokenAmount The amount of tokens that the project was paid.
|
|
1507
1509
|
/// @param payer The address that sent the payment.
|
|
1508
|
-
/// @param ruleset The ruleset
|
|
1510
|
+
/// @param ruleset The ruleset active during this payment.
|
|
1509
1511
|
/// @param beneficiary The address which will receive any tokens that the payment yields.
|
|
1510
|
-
/// @param newlyIssuedTokenCount The
|
|
1512
|
+
/// @param newlyIssuedTokenCount The number of tokens issued and sent to the beneficiary.
|
|
1511
1513
|
/// @param metadata Bytes to send along to the emitted event and pay hooks as applicable.
|
|
1512
1514
|
function _fulfillPayHookSpecificationsFor(
|
|
1513
1515
|
uint256 projectId,
|
|
@@ -1586,10 +1588,11 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1586
1588
|
}
|
|
1587
1589
|
}
|
|
1588
1590
|
|
|
1589
|
-
/// @notice
|
|
1590
|
-
///
|
|
1591
|
-
/// @param
|
|
1592
|
-
/// @param
|
|
1591
|
+
/// @notice Internal implementation of payment logic. Records the payment in the store, mints tokens via the
|
|
1592
|
+
/// controller, and fulfills any pay hook specifications from the data hook.
|
|
1593
|
+
/// @param projectId The ID of the project to pay.
|
|
1594
|
+
/// @param token The address of the token to pay the project with.
|
|
1595
|
+
/// @param amount The amount of tokens to send, as a fixed point number with the same number of
|
|
1593
1596
|
/// decimals as this terminal. If this terminal's token is the native token, `amount` is ignored and `msg.value` is
|
|
1594
1597
|
/// used in its place.
|
|
1595
1598
|
/// @param payer The address making the payment.
|
|
@@ -1668,11 +1671,11 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1668
1671
|
|
|
1669
1672
|
/// @notice Process a fee of the specified amount from a project.
|
|
1670
1673
|
/// @param projectId The ID of the project paying the fee.
|
|
1671
|
-
/// @param token The token the fee is
|
|
1674
|
+
/// @param token The token the fee is paid in.
|
|
1672
1675
|
/// @param amount The fee amount, as a fixed point number with 18 decimals.
|
|
1673
1676
|
/// @param beneficiary The address which will receive any platform tokens minted.
|
|
1674
1677
|
/// @param feeTerminal The terminal that'll receive the fee.
|
|
1675
|
-
/// @param wasHeld A flag indicating if the fee
|
|
1678
|
+
/// @param wasHeld A flag indicating if the fee to process was held by this terminal.
|
|
1676
1679
|
function _processFee(
|
|
1677
1680
|
uint256 projectId,
|
|
1678
1681
|
address token,
|
|
@@ -1727,7 +1730,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1727
1730
|
/// @notice Returns held fees to the project who paid them based on the specified amount.
|
|
1728
1731
|
/// @dev Partial replenishments use the raw floor calculation so repaying a dust amount cannot both credit the
|
|
1729
1732
|
/// payer project and leave the fee project owed the 1-unit minimum fee.
|
|
1730
|
-
/// @param projectId The project held fees
|
|
1733
|
+
/// @param projectId The project to return held fees to.
|
|
1731
1734
|
/// @param token The token that the held fees are in.
|
|
1732
1735
|
/// @param amount The amount to base the calculation on, as a fixed point number with the same number of decimals
|
|
1733
1736
|
/// as this terminal.
|
|
@@ -1808,10 +1811,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1808
1811
|
|
|
1809
1812
|
/// @notice Sends payouts to a project's payout split group using the specified ruleset.
|
|
1810
1813
|
/// @param projectId The ID of the project to send the payouts of.
|
|
1811
|
-
/// @param token The token
|
|
1814
|
+
/// @param token The token to pay out.
|
|
1812
1815
|
/// @param amount The number of terminal tokens to pay out, as a fixed point number with same number of decimals as
|
|
1813
1816
|
/// this terminal.
|
|
1814
|
-
/// @param currency The expected currency of the amount
|
|
1817
|
+
/// @param currency The expected currency of the amount to pay out. Must match the currency of one of the
|
|
1815
1818
|
/// project's current ruleset's payout limits.
|
|
1816
1819
|
/// @return amountPaidOut The total amount that was paid out.
|
|
1817
1820
|
function _sendPayoutsOf(
|
|
@@ -1922,10 +1925,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1922
1925
|
|
|
1923
1926
|
/// @notice Takes a fee into the platform's project (with the `_FEE_BENEFICIARY_PROJECT_ID`).
|
|
1924
1927
|
/// @param projectId The ID of the project paying the fee.
|
|
1925
|
-
/// @param token The address of the token that the fee is
|
|
1928
|
+
/// @param token The address of the token that the fee is paid in.
|
|
1926
1929
|
/// @param amount The fee's token amount, as a fixed point number with 18 decimals.
|
|
1927
1930
|
/// @param beneficiary The address to mint the platform's project's tokens for.
|
|
1928
|
-
/// @param shouldHoldFees If fees should be tracked and held instead of
|
|
1931
|
+
/// @param shouldHoldFees If fees should be tracked and held instead of processing them immediately.
|
|
1929
1932
|
/// @return feeAmount The amount of the fee taken.
|
|
1930
1933
|
function _takeFeeFrom(
|
|
1931
1934
|
uint256 projectId,
|
|
@@ -1978,8 +1981,8 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1978
1981
|
/// @notice Transfers tokens.
|
|
1979
1982
|
/// @param from The address the transfer should originate from.
|
|
1980
1983
|
/// @param to The address the transfer should go to.
|
|
1981
|
-
/// @param token The token
|
|
1982
|
-
/// @param amount The number of tokens
|
|
1984
|
+
/// @param token The token to transfer.
|
|
1985
|
+
/// @param amount The number of tokens to transfer, as a fixed point number with the same number of decimals
|
|
1983
1986
|
/// as this terminal.
|
|
1984
1987
|
function _transferFrom(address from, address payable to, address token, uint256 amount) internal {
|
|
1985
1988
|
if (from == address(this)) {
|
|
@@ -2008,10 +2011,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
2008
2011
|
/// @dev Incurs the protocol fee unless the caller is a feeless address.
|
|
2009
2012
|
/// @param projectId The ID of the project to use the surplus allowance of.
|
|
2010
2013
|
/// @param owner The project's owner.
|
|
2011
|
-
/// @param token The token
|
|
2014
|
+
/// @param token The token to pay out from the surplus.
|
|
2012
2015
|
/// @param amount The amount of terminal tokens to use from the project's current surplus allowance, as a fixed
|
|
2013
2016
|
/// point number with the same amount of decimals as this terminal.
|
|
2014
|
-
/// @param currency The expected currency of the amount
|
|
2017
|
+
/// @param currency The expected currency of the amount to pay out. Must match the currency of one of the
|
|
2015
2018
|
/// project's current ruleset's surplus allowances.
|
|
2016
2019
|
/// @param beneficiary The address to send the funds to.
|
|
2017
2020
|
/// @param feeBeneficiary The address to send the tokens resulting from paying the fee.
|
|
@@ -2171,7 +2174,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
2171
2174
|
|
|
2172
2175
|
/// @notice Packages a payment amount with the token's accounting context.
|
|
2173
2176
|
/// @param projectId The ID of the project the token amount belongs to.
|
|
2174
|
-
/// @param token The token
|
|
2177
|
+
/// @param token The token to pay with.
|
|
2175
2178
|
/// @param value The token amount's value.
|
|
2176
2179
|
/// @return tokenAmount The packaged token amount.
|
|
2177
2180
|
function _tokenAmountOf(
|