跳到主要内容

JBETHERC20SplitsPayer

Sends ETH or ERC20's to a group of splits as it receives direct payments or has its functions called.

Git Source

Inherits: JBETHERC20ProjectPayer, ReentrancyGuard, IJBSplitsPayer

Inherit from this contract or borrow from its logic to forward ETH or ERC20's to a group of splits from within other contracts.

Adheres to:

  • IJBSplitsPayer: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.

Inherits from:

  • JBETHERC20ProjectPayer: Sends ETH or ERC20's to a project treasury as it receives direct payments or has it's functions called.
  • ReentrancyGuard: Contract module that helps prevent reentrant calls to a function.

State Variables

splitsStore

The contract that stores splits for each project.

IJBSplitsStore public immutable override splitsStore;

defaultSplitsProjectId

The ID of project for which the default splits are stored.

uint256 public override defaultSplitsProjectId;

defaultSplitsDomain

The domain within which the default splits are stored.

uint256 public override defaultSplitsDomain;

defaultSplitsGroup

The group within which the default splits are stored.

uint256 public override defaultSplitsGroup;

Functions

supportsInterface

Indicates if this contract adheres to the specified interface.

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 _interfaceId)
public
view
virtual
override(JBETHERC20ProjectPayer, IERC165)
returns (bool);

Parameters

NameTypeDescription
_interfaceIdbytes4The ID of the interface to check for adherance to.

Returns

NameTypeDescription
<none>boolA flag indicating if this contract adheres to the specified interface.

constructor

constructor(IJBSplitsStore _splitsStore) JBETHERC20ProjectPayer(_splitsStore.directory());

Parameters

NameTypeDescription
_splitsStoreIJBSplitsStoreA contract that stores splits for each project.

initialize

The re-initialize check is done in the inherited paroject payer

function initialize(
uint256 _defaultSplitsProjectId,
uint256 _defaultSplitsDomain,
uint256 _defaultSplitsGroup,
uint256 _defaultProjectId,
address payable _defaultBeneficiary,
bool _defaultPreferClaimedTokens,
string memory _defaultMemo,
bytes memory _defaultMetadata,
bool _preferAddToBalance,
address _owner
) external override;

Parameters

NameTypeDescription
_defaultSplitsProjectIduint256The ID of project for which the default splits are stored.
_defaultSplitsDomainuint256The splits domain to payout when this contract receives direct payments.
_defaultSplitsGroupuint256The splits group to payout when this contract receives direct payments.
_defaultProjectIduint256The ID of the project whose treasury should be forwarded the splits payer contract's received payment leftovers after distributing to the default splits group.
_defaultBeneficiaryaddress payableThe address that'll receive the project's tokens.
_defaultPreferClaimedTokensboolA flag indicating whether issued tokens should be automatically claimed into the beneficiary's wallet.
_defaultMemostringA memo to pass along to the emitted event, and passed along the the funding cycle's data source and delegate. A data source can alter the memo before emitting in the event and forwarding to the delegate.
_defaultMetadatabytesBytes to send along to the project's data source and delegate, if provided.
_preferAddToBalanceboolA flag indicating if received payments should call the pay function or the addToBalance function of a project.
_owneraddressThe address that will own the contract.

receive

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.

receive() external payable virtual override nonReentrant;

setDefaultSplits

Sets the splits in the splits store that payments this contract receives will be split between.

function setDefaultSplits(
uint256 _projectId,
uint256 _domain,
uint256 _group,
JBGroupedSplits[] memory _groupedSplits
) external virtual override onlyOwner;

Parameters

NameTypeDescription
_projectIduint256The ID of project for which the default splits are stored.
_domainuint256The domain within which the default splits are stored.
_groupuint256The group within which the default splits are stored.
_groupedSplitsJBGroupedSplits[]The split groups to set.

setDefaultSplitsReference

Sets the location of the splits that payments this contract receives will be split between.

function setDefaultSplitsReference(uint256 _projectId, uint256 _domain, uint256 _group)
public
virtual
override
onlyOwner;

Parameters

NameTypeDescription
_projectIduint256The ID of project for which the default splits are stored.
_domainuint256The domain within which the default splits are stored.
_groupuint256The group within which the default splits are stored.

pay

Make a payment to the specified project after first splitting the amount among the stored default splits.

function pay(
uint256 _projectId,
address _token,
uint256 _amount,
uint256 _decimals,
address _beneficiary,
uint256 _minReturnedTokens,
bool _preferClaimedTokens,
string calldata _memo,
bytes calldata _metadata
) public payable virtual override nonReentrant;

Parameters

NameTypeDescription
_projectIduint256The ID of the project that is being paid after.
_tokenaddressThe token being paid in.
_amountuint256The amount of tokens being paid, as a fixed point number. If the token is ETH, this is ignored and msg.value is used in its place.
_decimalsuint256The number of decimals in the _amount fixed point number. If the token is ETH, this is ignored and 18 is used in its place, which corresponds to the amount of decimals expected in msg.value.
_beneficiaryaddressThe address who will receive tokens from the payment made with leftover funds.
_minReturnedTokensuint256The minimum number of project tokens expected in return, as a fixed point number with 18 decimals.
_preferClaimedTokensboolA flag indicating whether the request prefers to mint project tokens into the beneficiaries wallet rather than leaving them unclaimed. This is only possible if the project has an attached token contract. Leaving them unclaimed saves gas.
_memostringA memo to pass along to the emitted event, and passed along the the funding cycle's data source and delegate. A data source can alter the memo before emitting in the event and forwarding to the delegate.
_metadatabytesBytes to send along to the data source, delegate, and emitted event, if provided.

addToBalanceOf

Add to the balance of the specified project after first splitting the amount among the stored default splits.

function addToBalanceOf(
uint256 _projectId,
address _token,
uint256 _amount,
uint256 _decimals,
string calldata _memo,
bytes calldata _metadata
) public payable virtual override nonReentrant;

Parameters

NameTypeDescription
_projectIduint256The ID of the project that is being paid after.
_tokenaddressThe token being paid in.
_amountuint256The amount of tokens being paid, as a fixed point number. If the token is ETH, this is ignored and msg.value is used in its place.
_decimalsuint256The number of decimals in the _amount fixed point number. If the token is ETH, this is ignored and 18 is used in its place, which corresponds to the amount of decimals expected in msg.value.
_memostringA memo to pass along to the emitted event.
_metadatabytesExtra data to pass along to the terminal.

_payToSplits

Split an amount between all splits.

function _payToSplits(
uint256 _splitsProjectId,
uint256 _splitsDomain,
uint256 _splitsGroup,
address _token,
uint256 _amount,
uint256 _decimals,
address _defaultBeneficiary
) internal virtual returns (uint256 leftoverAmount);

Parameters

NameTypeDescription
_splitsProjectIduint256The ID of the project to which the splits belong.
_splitsDomainuint256The splits domain to which the group belongs.
_splitsGroupuint256The splits group to pay.
_tokenaddressThe token the amonut being split is in.
_amountuint256The amount of tokens being split, as a fixed point number. If the _token is ETH, this is ignored and msg.value is used in its place.
_decimalsuint256The number of decimals in the _amount fixed point number.
_defaultBeneficiaryaddressThe address that will benefit from any non-specified beneficiaries in splits.

Returns

NameTypeDescription
leftoverAmountuint256The amount leftover after all splits were paid.

_payTo

Split an amount between all splits.

function _payTo(
JBSplit[] memory _splits,
address _token,
uint256 _amount,
uint256 _decimals,
address _defaultBeneficiary
) internal virtual returns (uint256 leftoverAmount);

Parameters

NameTypeDescription
_splitsJBSplit[]The splits.
_tokenaddressThe token the amonut being split is in.
_amountuint256The amount of tokens being split, as a fixed point number. If the _token is ETH, this is ignored and msg.value is used in its place.
_decimalsuint256The number of decimals in the _amount fixed point number.
_defaultBeneficiaryaddressThe address that will benefit from any non-specified beneficiaries in splits.

Returns

NameTypeDescription
leftoverAmountuint256The amount leftover after all splits were paid.