receive
Contract: JBETHERC20SplitsPayer
Interface: IJBSplitsPayer
- Step by step
- Code
- Bug bounty
Received funds are paid to the default split group using the stored default properties.
This function is called automatically when the contract receives an ETH payment.
Definitionβ
receive() external payable virtual override { ... }
- The function is triggered when the contract receives ETH.
- The function can be accessed externally by anyone.
- The function doesn't return anything.
Bodyβ
-
Pay the splits and get a reference to the leftover amount.
// Pay the splits and get a reference to the amount leftover.
uint256 _leftoverAmount = _payToSplits(
defaultSplitsProjectId,
defaultSplitsDomain,
defaultSplitsGroup,
JBTokens.ETH,
address(this).balance,
18, // decimals.
defaultBeneficiary != address(0) ? defaultBeneficiary : msg.sender
);Internal references:
-
If there's no leftover amount, there's nothing left to do.
// If there is no leftover amount, nothing left to pay.
if (_leftoverAmount == 0) return; -
Pay the leftover ETH to the default project ID using the default parameters. Use the
addToBalance
function if there's a preference to do so. If there's no default project ID, send to the default beneficiary if there is one, otherwise send to the message sender.// If there's a default project ID, try to pay it.
if (defaultProjectId != 0)
if (defaultPreferAddToBalance)
// Pay the project by adding to its balance if prefered.
_addToBalanceOf(
defaultProjectId,
JBTokens.ETH,
_leftoverAmount,
18, // decimals.
defaultMemo,
defaultMetadata
);
// Otherwise, issue a payment to the project.
else
_pay(
defaultProjectId,
JBTokens.ETH,
_leftoverAmount,
18, // decimals.
defaultBeneficiary != address(0) ? defaultBeneficiary : msg.sender,
0, // min returned tokens.
defaultPreferClaimedTokens,
defaultMemo,
defaultMetadata
);
// If no project was specified, send the funds directly to the beneficiary or the msg.sender.
else
Address.sendValue(
defaultBeneficiary != address(0) ? payable(defaultBeneficiary) : payable(msg.sender),
_leftoverAmount
);Library references:
Internal references:
/**
@notice
Received funds are paid to the default split group using the stored default properties.
@dev
This function is called automatically when the contract receives an ETH payment.
*/
receive() external payable virtual override nonReentrant {
// Pay the splits and get a reference to the amount leftover.
uint256 _leftoverAmount = _payToSplits(
defaultSplitsProjectId,
defaultSplitsDomain,
defaultSplitsGroup,
JBTokens.ETH,
address(this).balance,
18, // decimals.
defaultBeneficiary != address(0) ? defaultBeneficiary : msg.sender
);
// If there is no leftover amount, nothing left to pay.
if (_leftoverAmount == 0) return;
// If there's a default project ID, try to pay it.
if (defaultProjectId != 0)
if (defaultPreferAddToBalance)
// Pay the project by adding to its balance if prefered.
_addToBalanceOf(
defaultProjectId,
JBTokens.ETH,
_leftoverAmount,
18, // decimals.
defaultMemo,
defaultMetadata
);
// Otherwise, issue a payment to the project.
else
_pay(
defaultProjectId,
JBTokens.ETH,
_leftoverAmount,
18, // decimals.
defaultBeneficiary != address(0) ? defaultBeneficiary : msg.sender,
0, // min returned tokens.
defaultPreferClaimedTokens,
defaultMemo,
defaultMetadata
);
// If no project was specified, send the funds directly to the beneficiary or the msg.sender.
else
Address.sendValue(
defaultBeneficiary != address(0) ? payable(defaultBeneficiary) : payable(msg.sender),
_leftoverAmount
);
}
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 |