跳到主要内容

_addToBalanceOf

Contract: JBPayoutRedemptionPaymentTerminal​‌

Receives funds belonging to the specified project.

Definition

function _addToBalanceOf(
uint256 _projectId,
uint256 _amount,
bool _shouldRefundHeldFees,
string memory _memo,
bytes memory _metadata
) private { ... }
  • Arguments:
    • _projectId is the ID of the project to which the funds received belong.
    • _amount is the amount of tokens to add, as a fixed point number with the same number of decimals as this terminal. If this is an ETH terminal, this is ignored and msg.value is used instead.
    • _shouldRefundHeldFees is a flag indicating if held fees should be refunded based on the amount being added.
    • _memo is a memo to pass along to the emitted event.
    • _metadata is extra data to pass along to the emitted event.
  • The function is private to this contract.
  • The function doesn't return anything.

Body

  1. Refund any held fees. This is useful to allow a project to distribute funds from the protocol and subsequently add them back without paying eventually having to pay double fees.

    // Refund any held fees to make sure the project doesn't pay double for funds going in and out of the protocol.
    uint256 _refundedFees = _shouldRefundHeldFees ? _refundHeldFees(_projectId, _amount) : 0;

    Internal references:

  2. Record the added funds.

    // Record the added funds with any refunded fees.
    store.recordAddedBalanceFor(_projectId, _amount + _refundedFees);

    Internal references:

    External references:

  3. Emit a AddToBalance event with the relevant parameters.

    emit AddToBalance(_projectId, _amount, _refundedFees, _memo, _metadata, msg.sender);

    Event references: