Skip to main content

_currentFeeDiscount

Contract: JBPayoutRedemptionPaymentTerminal​‌

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

Definition

function _currentFeeDiscount(uint256 _projectId) private view returns (uint256 feeDiscount) { ... }
  • 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 protocol project doesn't have a terminal that accepts this terminal's token, no fee can be taken so a max discount should be returned.

    // Can't take a fee if the protocol project doesn't have a terminal that accepts the token.
    if (directory.primaryTerminalOf(_PROTOCOL_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)) )
    feeDiscount = 0;
    else
    // If the guage reverts, set the discount to 0.
    try feeGauge.currentDiscountFor(_projectId) returns (uint256 discount) {
    feeDiscount = discount;
    } catch {
    feeDiscount = 0;
    }

    Internal references:

    External references:

  3. If there gauge provided an invalid discount, set the discount to 0.

    // If the fee discount is greater than the max, nullify the discount.
    if (feeDiscount > JBConstants.MAX_FEE_DISCOUNT) feeDiscount = 0;

    Library references: