跳到主要内容

_takeFeeFrom

Contract: JBPayoutRedemptionPaymentTerminal​‌

Takes a fee into the platform's project, which has an id of _FEE_BENEFICIARY_PROJECT_ID.

Definition

function _takeFeeFrom(
uint256 _projectId,
JBFundingCycle memory _fundingCycle,
uint256 _amount,
address _beneficiary,
uint256 _feeDiscount
) private returns (uint256 feeAmount) { ... }
  • Arguments:
    • _projectId is the ID of the project having fees taken from.
    • _fundingCycle is the JBFundingCycle during which the fee is being taken.
    • _amount is the amount to take a fee from.
    • _beneficiary is the address to mint the platforms tokens for.
    • _feeDiscount is the amount of discount to apply to the fee, out of the MAX_FEE.
  • The function is private to this contract.
  • The function returns the amount of the fee taken.

Body

  1. Get a reference to the amount that should be taken.

    // Get the fee discount.
    feeAmount = _feeAmount(_amount, fee, _feeDiscount);

    Internal references:

  2. If the funding cycle is configured to hold fees, add a JBFee data structure to the project's stored held fees to be either processed or refunded later, and emit a HoldFee event with the relevant parameters. Otherwise, take the fee and emit a ProcessFee event with the relevant parameters.

    if (_fundingCycle.shouldHoldFees()) {
    // Store the held fee.
    _heldFeesOf[_projectId].push(JBFee(_amount, uint32(fee), uint32(_feeDiscount), _beneficiary));

    emit HoldFee(_projectId, _amount, fee, _feeDiscount, _beneficiary, msg.sender);
    } else {
    // Process the fee.
    _processFee(feeAmount, _beneficiary); // Take the fee.

    emit ProcessFee(_projectId, feeAmount, false, _beneficiary, msg.sender);
    }

    Internal references:

    Event references: