_processFee
Contract: JBPayoutRedemptionPaymentTerminal
- Step by step
- Code
- Errors
- Bug bounty
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
-
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:
-
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) { ... }-
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:
-
-
Otherwise if the terminal is different, transfer the fee over.
else { ... }
-
Call any pre-transfer logic.
// Trigger any inherited pre-transfer logic.
_beforeTransferTo(address(_terminal), _amount);Virtual references:
-
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:
JBTokens
.ETH
-
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:
-
/**
@notice
Process a fee of the specified amount.
@param _amount The fee amount, as a floating point number with the same amount of decimals as this terminal.
@param _beneficiary The address to mint the platform's tokens for.
*/
function _processFee(uint256 _amount, address _beneficiary) private {
// Get the terminal for the protocol project.
IJBPaymentTerminal _terminal = directory.primaryTerminalOf(_FEE_BENEFICIARY_PROJECT_ID, token);
// When processing the admin fee, save gas if the admin is using this contract as its terminal.
if (_terminal == this)
_pay(
_amount,
address(this),
_FEE_BENEFICIARY_PROJECT_ID,
_beneficiary,
0,
false,
'',
bytes('')
); // Use the local pay call.
else {
// Trigger any inherited pre-transfer logic.
_beforeTransferTo(address(_terminal), _amount);
// If this terminal's token is ETH, send it in msg.value.
uint256 _payableValue = token == JBTokens.ETH ? _amount : 0;
// 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.
}
}
String | Description |
---|---|
ZERO_VALUE_SENT | Thrown if the transaction had no value. |
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 |