_currentFeeDiscount
Contract: JBPayoutRedemptionPaymentTerminal
- Step by step
- Code
- Bug bounty
Get the fee discount from the fee gauge for the specified project.
Definition
function _currentFeeDiscount(uint256 _projectId) private view returns (uint256) { ... }
- Arguments:
- _projectIdis the ID of the project to get a fee discount for.
 
- The view function is private to this contract.
- The view function does not alter state on the blockchain.
- The function returns thhe fee discount, which should be interpreted as a percentage out MAX_FEE_DISCOUNT.
Body
- 
If the fee beneficiary project doesn't have a terminal that accepts this terminal's token, no fee can be taken so a max discount should be returned. if (
 directory.primaryTerminalOf(_FEE_BENEFICIARY_PROJECT_ID, token) ==
 IJBPaymentTerminal(address(0))
 ) return JBConstants.MAX_FEE_DISCOUNT;Library references: - JBConstants- .MAX_FEE_DISCOUNT
 
 Internal references: External references: 
- 
If there's a gauge, ask it for the discount. Otherwise, there is no discount. If the gauge reverts, set the discount to 0. // Get the fee discount.
 if (feeGauge != IJBFeeGauge(address(0)))
 // If the guage reverts, keep the discount at 0.
 try feeGauge.currentDiscountFor(_projectId) returns (uint256 discount) {
 // If the fee discount is greater than the max, we ignore the return value
 if (discount <= JBConstants.MAX_FEE_DISCOUNT) return discount;
 } catch {
 return 0;
 }Internal references: External references: 
/**
  @notice
  Get the fee discount from the fee gauge for the specified project.
  @param _projectId The ID of the project to get a fee discount for.
  @return feeDiscount The fee discount, which should be interpreted as a percentage out MAX_FEE_DISCOUNT.
*/
function _currentFeeDiscount(uint256 _projectId) internal view returns (uint256) {
  // Can't take a fee if the protocol project doesn't have a terminal that accepts the token.
  if (
    directory.primaryTerminalOf(_FEE_BENEFICIARY_PROJECT_ID, token) ==
    IJBPaymentTerminal(address(0))
  ) return JBConstants.MAX_FEE_DISCOUNT;
  // Get the fee discount.
  if (feeGauge != IJBFeeGauge(address(0)))
    // If the guage reverts, keep the discount at 0.
    try feeGauge.currentDiscountFor(_projectId) returns (uint256 discount) {
      // If the fee discount is greater than the max, we ignore the return value
      if (discount <= JBConstants.MAX_FEE_DISCOUNT) return discount;
    } catch {
      return 0;
    }
  return 0;
}
| 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 |