processFees
Contract: JBPayoutRedemptionPaymentTerminal
Interface: IJBPayoutRedemptionPaymentTerminal
- Step by step
- Code
- Events
- Bug bounty
Process any fees that are being held for the project.
Only a project owner, an operator, or the contract's owner can process held fees.
Definition
function processFees(uint256 _projectId)
external
virtual
override
requirePermissionAllowingOverride(
projects.ownerOf(_projectId),
_projectId,
JBOperations.PROCESS_FEES,
msg.sender == owner()
)
nonReentrant { ... }
- Arguments:
_projectId
is the ID of the project whos held fees should be processed.
- Through the
requirePermissionAllowingOverride
modifier, the function is only accessible by the project's owner, from an operator that has been given theJBOperations.PROCESS_FEES
permission by the project owner for the provided_projectId
, or from the owner of this contract. - The function can be overriden by inheriting contracts.
- The function cannot be accessed recursively or while other
nonReentrant
functions in this contract are in progress. - The resulting function overrides a function definition from the
IJBPayoutRedemptionPaymentTerminal
interface. - The function doesn't return anything.
Body
-
Get a reference to all held fees for the project.
// Get a reference to the project's held fees.
JBFee[] memory _heldFees = _heldFeesOf[_projectId];Internal references:
-
Remove all fees.
// Delete the held fee's now that they've been processed.
delete _heldFeesOf[_projectId];Internal references:
-
Iterate through the array. Take fee's for each
JBFee
data structure. Emit aProcessFee
event with the relevant parameters for each fee processed.// Push array length in stack
uint256 _heldFeeLength = _heldFees.length;
// Process each fee.
for (uint256 _i; _i < _heldFeeLength; ) {
// Get the fee amount.
uint256 _amount = _feeAmount(
_heldFees[_i].amount,
_heldFees[_i].fee,
_heldFees[_i].feeDiscount
);
// Process the fee.
_processFee(_amount, _heldFees[_i].beneficiary);
emit ProcessFee(_projectId, _amount, _heldFees[_i].beneficiary, msg.sender);
unchecked {
++_i;
}
}Internal references:
Event references:
/**
@notice
Process any fees that are being held for the project.
@dev
Only a project owner, an operator, or the contract's owner can process held fees.
@param _projectId The ID of the project whos held fees should be processed.
*/
function processFees(uint256 _projectId)
external
virtual
override
requirePermissionAllowingOverride(
projects.ownerOf(_projectId),
_projectId,
JBOperations.PROCESS_FEES,
msg.sender == owner()
)
{
// Get a reference to the project's held fees.
JBFee[] memory _heldFees = _heldFeesOf[_projectId];
// Delete the held fees.
delete _heldFeesOf[_projectId];
// Push array length in stack
uint256 _heldFeeLength = _heldFees.length;
// Process each fee.
for (uint256 _i; _i < _heldFeeLength; ) {
// Get the fee amount.
uint256 _amount = _feeAmount(
_heldFees[_i].amount,
_heldFees[_i].fee,
_heldFees[_i].feeDiscount
);
// Process the fee.
_processFee(_amount, _heldFees[_i].beneficiary);
emit ProcessFee(_projectId, _amount, true, _heldFees[_i].beneficiary, msg.sender);
unchecked {
++_i;
}
}
}
Name | Data |
---|---|
ProcessFee |
|
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |