_addToBalanceOf
Contract: JBPayoutRedemptionPaymentTerminal
- Step by step
- Code
- Events
- Bug bounty
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
-
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:
-
Record the added funds.
// Record the added funds with any refunded fees.
store.recordAddedBalanceFor(_projectId, _amount + _refundedFees);Internal references:
External references:
-
Emit a
AddToBalance
event with the relevant parameters.emit AddToBalance(_projectId, _amount, _refundedFees, _memo, _metadata, msg.sender);
Event references:
/**
@notice
Receives funds belonging to the specified project.
@param _projectId The ID of the project to which the funds received belong.
@param _amount 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.
@param _shouldRefundHeldFees A flag indicating if held fees should be refunded based on the amount being added.
@param _memo A memo to pass along to the emitted event.
@param _metadata Extra data to pass along to the emitted event.
*/
function _addToBalanceOf(
uint256 _projectId,
uint256 _amount,
bool _shouldRefundHeldFees,
string memory _memo,
bytes memory _metadata
) private {
// 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;
// Record the added funds with any refunded fees.
store.recordAddedBalanceFor(_projectId, _amount + _refundedFees);
emit AddToBalance(_projectId, _amount, _refundedFees, _memo, _metadata, msg.sender);
}
Name | Data |
---|---|
AddToBalance |
|
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 |