Skip to main content

_processFee

Contract: JBPayoutRedemptionPaymentTerminal​‌

Process a fee of the specified amount.

Definition

function _processFee(uint256 _amount, address _beneficiary) { ... }
  • Arguments:
    • _amount is the fee amount, as a floating point number with the same amount of decimals as this terminal.
    • _beneficiary is the address to mint the platform's tokens for.
  • The function is private to this contract.
  • The function doesn't return anything.

Body

  1. Get the terminal that the protocol project is accepting funds through for this terminal's token.

    // Get the terminal for the protocol project.
    IJBPaymentTerminal _terminal = directory.primaryTerminalOf(_FEE_BENEFICIARY_PROJECT_ID, token);

    Internal references:

    External references:

  2. If the protocol's terminal is the same as this terminal, save gas by paying the contract internally.

    // When processing the admin fee, save gas if the admin is using this contract as its terminal.
    if (_terminal == this) { ... }
    1. Pay the protocol using the internal pay function.

      _pay(
      _amount,
      address(this),
      _FEE_BENEFICIARY_PROJECT_ID,
      _beneficiary,
      0,
      false,
      '',
      bytes('')
      ); // Use the local pay call.

      Internal references:

  3. Otherwise if the terminal is different, transfer the fee over.

    else { ... }
    1. Call any pre-transfer logic.

      // Trigger any inherited pre-transfer logic.
      _beforeTransferTo(address(_terminal), _amount);

      Virtual references:

    2. Get a reference to the ETH amount that should be attached to the transaction. Only attach anything if the token being paid is ETH.

      // If this terminal's token is ETH, send it in msg.value.
      uint256 _payableValue = token == JBTokens.ETH ? _amount : 0;

      Library references:

    3. Send the payment.

      // Send the payment.
      _terminal.pay{value: _payableValue}(
      _FEE_BENEFICIARY_PROJECT_ID,
      _amount,
      token,
      _beneficiary,
      0,
      false,
      '',
      bytes('')
      ); // Use the external pay call of the correct terminal.

      Internal references:

      External references: