_feeAmount
Contract: JBPayoutRedemptionPaymentTerminal
- Step by step
- Code
- Bug bounty
Returns the fee amount based on the provided amount for the specified project.
Definition
function _feeAmount(
uint256 _amount,
uint256 _fee,
uint256 _feeDiscount
) private pure returns (uint256) { ... }
- Arguments:
_amount
is the amount that the fee is based on, as a fixed point number with the same amount of decimals as this terminal._fee
is the percentage of the fee, out of MAX_FEE._feeDiscount
is the percentage discount that should be applied out of the max amount, out of MAX_FEE_DISCOUNT.
- The view function is private to this contract.
- The view function does not alter state on the blockchain.
- The function returns the amount of the fee, as a fixed point number with the same amount of decimals as this terminal.
Body
-
Calculate the discounted fee by subtracting the discount from the fee.
// Calculate the discounted fee.
uint256 _discountedFee = _fee -
PRBMath.mulDiv(_fee, _feeDiscount, JBConstants.MAX_FEE_DISCOUNT);Library references:
PRBMath
.mulDiv(...)
JBConstants
.MAX_FEE_DISCOUNT
-
Return the amount of tokens from the specified amount that should be paid as a fee.
// The amount of tokens from the `_amount` to pay as a fee.
return
_amount - PRBMath.mulDiv(_amount, JBConstants.MAX_FEE, _discountedFee + JBConstants.MAX_FEE);Library references:
PRBMath
.mulDiv(...)
JBConstants
.MAX_FEE
/**
@notice
Returns the fee amount based on the provided amount for the specified project.
@param _amount The amount that the fee is based on, as a fixed point number with the same amount of decimals as this terminal.
@param _fee The percentage of the fee, out of MAX_FEE.
@param _feeDiscount The percentage discount that should be applied out of the max amount, out of MAX_FEE_DISCOUNT.
@return The amount of the fee, as a fixed point number with the same amount of decimals as this terminal.
*/
function _feeAmount(
uint256 _amount,
uint256 _fee,
uint256 _feeDiscount
) private pure returns (uint256) {
// Calculate the discounted fee.
uint256 _discountedFee = _fee -
PRBMath.mulDiv(_fee, _feeDiscount, JBConstants.MAX_FEE_DISCOUNT);
// The amount of tokens from the `_amount` to pay as a fee.
return
_amount - PRBMath.mulDiv(_amount, JBConstants.MAX_FEE, _discountedFee + JBConstants.MAX_FEE);
}
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 |