Skip to content

Latest commit

 

History

History
172 lines (128 loc) · 6.69 KB

File metadata and controls

172 lines (128 loc) · 6.69 KB

processFees

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Contract: JBPayoutRedemptionPaymentTerminal​‌

Interface: IJBPayoutRedemptionPaymentTerminal

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 the JBOperations.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

  1. 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:

  2. Remove all fees.

    // Delete the held fee's now that they've been processed.
    delete _heldFeesOf[_projectId];
    

    Internal references:

  3. Iterate through the array. Take fee's for each JBFee data structure. Emit a ProcessFee 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
  • uint256 indexed projectId
  • uint256 indexed amount
  • bool indexed wasHeld
  • address beneficiary
  • address caller
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