跳到主要内容

_currentFeeDiscount

Contract: JBPayoutRedemptionPaymentTerminal​‌

Get the fee discount from the fee gauge for the specified project.

Definition

function _currentFeeDiscount(uint256 _projectId) private view returns (uint256) { ... }
  • Arguments:
    • _projectId is 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

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

    Internal references:

    External references:

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