跳到主要内容

JBMultiTerminal

Git Source

Inherits: JBPermissioned, ERC2771Context, IJBMultiTerminal

JBMultiTerminal manages native/ERC-20 payments, cash outs, and surplus allowance usage for any number of projects. Terminals are the entry point for operations involving inflows and outflows of funds.

State Variables

FEE

This terminal's fee (as a fraction out of JBConstants.MAX_FEE).

Fees are charged on payouts to addresses and surplus allowance usage, as well as cash outs while the cash out tax rate is less than 100%.

uint256 public constant override FEE = 25;

_FEE_BENEFICIARY_PROJECT_ID

Project ID #1 receives fees. It should be the first project launched during the deployment process.

uint256 internal constant _FEE_BENEFICIARY_PROJECT_ID = 1;

_FEE_HOLDING_SECONDS

The number of seconds fees can be held for.

uint256 internal constant _FEE_HOLDING_SECONDS = 2_419_200;

DIRECTORY

The directory of terminals and controllers for PROJECTS.

IJBDirectory public immutable override DIRECTORY;

FEELESS_ADDRESSES

The contract that stores addresses that shouldn't incur fees when being paid towards or from.

IJBFeelessAddresses public immutable override FEELESS_ADDRESSES;

PERMIT2

The permit2 utility.

IPermit2 public immutable override PERMIT2;

PROJECTS

Mints ERC-721s that represent project ownership and transfers.

IJBProjects public immutable override PROJECTS;

RULESETS

The contract storing and managing project rulesets.

IJBRulesets public immutable override RULESETS;

SPLITS

The contract that stores splits for each project.

IJBSplits public immutable override SPLITS;

STORE

The contract that stores and manages the terminal's data.

IJBTerminalStore public immutable override STORE;

TOKENS

The contract storing and managing project rulesets.

IJBTokens public immutable override TOKENS;

_accountingContextForTokenOf

Context describing how a token is accounted for by a project.

mapping(uint256 projectId => mapping(address token => JBAccountingContext)) internal _accountingContextForTokenOf;

_accountingContextsOf

A list of tokens accepted by each project.

mapping(uint256 projectId => JBAccountingContext[]) internal _accountingContextsOf;

_heldFeesOf

Fees that are being held for each project.

Projects can temporarily hold fees and unlock them later by adding funds to the project's balance.

Held fees can be processed at any time by this terminal's owner.

mapping(uint256 projectId => mapping(address token => JBFee[])) internal _heldFeesOf;

_nextHeldFeeIndexOf

The next index to use when processing a next held fee.

mapping(uint256 projectId => mapping(address token => uint256)) internal _nextHeldFeeIndexOf;

Functions

constructor

constructor(
IJBFeelessAddresses feelessAddresses,
IJBPermissions permissions,
IJBProjects projects,
IJBSplits splits,
IJBTerminalStore store,
IJBTokens tokens,
IPermit2 permit2,
address trustedForwarder
)
JBPermissioned(permissions)
ERC2771Context(trustedForwarder);

Parameters

NameTypeDescription
feelessAddressesIJBFeelessAddressesA contract that stores addresses that shouldn't incur fees when being paid towards or from.
permissionsIJBPermissionsA contract storing permissions.
projectsIJBProjectsA contract which mints ERC-721s that represent project ownership and transfers.
splitsIJBSplitsA contract that stores splits for each project.
storeIJBTerminalStoreA contract that stores the terminal's data.
tokensIJBTokens
permit2IPermit2A permit2 utility.
trustedForwarderaddressA trusted forwarder of transactions to this contract.

accountingContextForTokenOf

A project's accounting context for a token.

See the JBAccountingContext struct for more information.

function accountingContextForTokenOf(
uint256 projectId,
address token
)
external
view
override
returns (JBAccountingContext memory);

Parameters

NameTypeDescription
projectIduint256The ID of the project to get token accounting context of.
tokenaddressThe token to check the accounting context of.

Returns

NameTypeDescription
<none>JBAccountingContextThe token's accounting context for the token.

accountingContextsOf

The tokens accepted by a project.

function accountingContextsOf(uint256 projectId) external view override returns (JBAccountingContext[] memory);

Parameters

NameTypeDescription
projectIduint256The ID of the project to get the accepted tokens of.

Returns

NameTypeDescription
<none>JBAccountingContext[]tokenContexts The accounting contexts of the accepted tokens.

currentSurplusOf

Gets the total current surplus amount in this terminal for a project, in terms of a given currency.

This total surplus only includes tokens that the project accepts (as returned by accountingContextsOf(...)).

function currentSurplusOf(
uint256 projectId,
JBAccountingContext[] memory accountingContexts,
uint256 decimals,
uint256 currency
)
external
view
override
returns (uint256);

Parameters

NameTypeDescription
projectIduint256The ID of the project to get the current total surplus of.
accountingContextsJBAccountingContext[]The accounting contexts to use to calculate the surplus. Pass an empty array to use all of the project's accounting contexts.
decimalsuint256The number of decimals to include in the fixed point returned value.
currencyuint256The currency to express the returned value in terms of.

Returns

NameTypeDescription
<none>uint256The current surplus amount the project has in this terminal, in terms of currency and with the specified number of decimals.

heldFeesOf

Fees that are being held for a project.

Projects can temporarily hold fees and unlock them later by adding funds to the project's balance.

Held fees can be processed at any time by this terminal's owner.

function heldFeesOf(
uint256 projectId,
address token,
uint256 count
)
external
view
override
returns (JBFee[] memory heldFees);

Parameters

NameTypeDescription
projectIduint256The ID of the project that is holding fees.
tokenaddressThe token that the fees are held in.
countuint256

supportsInterface

Indicates whether this contract adheres to the specified interface.

See IERC165-supportsInterface.

function supportsInterface(bytes4 interfaceId) public pure override returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The ID of the interface to check for adherence to.

Returns

NameTypeDescription
<none>boolA flag indicating if the provided interface ID is supported.

_balanceOf

Checks this terminal's balance of a specific token.

function _balanceOf(address token) internal view returns (uint256);

Parameters

NameTypeDescription
tokenaddressThe address of the token to get this terminal's balance of.

Returns

NameTypeDescription
<none>uint256This terminal's balance.

_contextSuffixLength

ERC-2771 specifies the context as being a single address (20 bytes).

function _contextSuffixLength() internal view override(ERC2771Context, Context) returns (uint256);

_controllerOf

Returns the current controller of a project.

function _controllerOf(uint256 projectId) internal view returns (IJBController);

Parameters

NameTypeDescription
projectIduint256The ID of the project to get the controller of.

Returns

NameTypeDescription
<none>IJBControllercontroller The project's controller.

_isFeeless

Returns a flag indicating if interacting with an address should not incur fees.

function _isFeeless(address addr) internal view returns (bool);

Parameters

NameTypeDescription
addraddressThe address to check.

Returns

NameTypeDescription
<none>boolA flag indicating if the address should not incur fees.

_msgData

The calldata. Preferred to use over msg.data.

function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata);

Returns

NameTypeDescription
<none>bytescalldata The msg.data of this call.

_msgSender

The message's sender. Preferred to use over msg.sender.

function _msgSender() internal view override(ERC2771Context, Context) returns (address sender);

Returns

NameTypeDescription
senderaddressThe address which sent this call.

_ownerOf

The owner of a project.

function _ownerOf(uint256 projectId) internal view returns (address);

Parameters

NameTypeDescription
projectIduint256The ID of the project to get the owner of.

Returns

NameTypeDescription
<none>addressThe owner of the project.

_primaryTerminalOf

The primary terminal of a project for a token.

function _primaryTerminalOf(uint256 projectId, address token) internal view returns (IJBTerminal);

Parameters

NameTypeDescription
projectIduint256The ID of the project to get the primary terminal of.
tokenaddressThe token to get the primary terminal of.

Returns

NameTypeDescription
<none>IJBTerminalThe primary terminal of the project for the token.

addAccountingContextsFor

Adds accounting contexts for a project to this terminal so the project can begin accepting the tokens in those contexts.

Only a project's owner, an operator with the ADD_ACCOUNTING_CONTEXTS permission from that owner, or a project's controller can add accounting contexts for the project.

function addAccountingContextsFor(
uint256 projectId,
JBAccountingContext[] calldata accountingContexts
)
external
override;

Parameters

NameTypeDescription
projectIduint256The ID of the project having to add accounting contexts for.
accountingContextsJBAccountingContext[]The accounting contexts to add.

addToBalanceOf

Adds funds to a project's balance without minting tokens.

Adding to balance can unlock held fees if shouldUnlockHeldFees is true.

function addToBalanceOf(
uint256 projectId,
address token,
uint256 amount,
bool shouldReturnHeldFees,
string calldata memo,
bytes calldata metadata
)
external
payable
override;

Parameters

NameTypeDescription
projectIduint256The ID of the project to add funds to the balance of.
tokenaddressThe token being added to the balance.
amountuint256The amount of tokens to add to the balance, as a fixed point number with the same number of decimals as this terminal. If this is a native token terminal, this is ignored and msg.value is used instead.
shouldReturnHeldFeesboolA flag indicating if held fees should be returned based on the amount being added.
memostringA memo to pass along to the emitted event.
metadatabytesExtra data to pass along to the emitted event.

cashOutTokensOf

Holders can cash out a project's tokens to reclaim some of that project's surplus tokens, or to trigger rules determined by the current ruleset's data hook and cash out hook.

Only a token's holder or an operator with the CASH_OUT_TOKENS permission from that holder can cash out those tokens.

function cashOutTokensOf(
address holder,
uint256 projectId,
uint256 cashOutCount,
address tokenToReclaim,
uint256 minTokensReclaimed,
address payable beneficiary,
bytes calldata metadata
)
external
override
returns (uint256 reclaimAmount);

Parameters

NameTypeDescription
holderaddressThe account whose tokens are being cashed out.
projectIduint256The ID of the project the project tokens belong to.
cashOutCountuint256The number of project tokens to cash out, as a fixed point number with 18 decimals.
tokenToReclaimaddressThe token being reclaimed.
minTokensReclaimeduint256The minimum number of terminal tokens expected in return, as a fixed point number with the same number of decimals as this terminal. If the amount of tokens minted for the beneficiary would be less than this amount, the cash out is reverted.
beneficiaryaddress payableThe address to send the cashed out terminal tokens to, and to pass along to the ruleset's data hook and cash out hook if applicable.
metadatabytesBytes to send along to the emitted event, as well as the data hook and cash out hook if applicable.

Returns

NameTypeDescription
reclaimAmountuint256The amount of terminal tokens that the project tokens were cashed out for, as a fixed point number with 18 decimals.

executePayout

Executes a payout to a split.

Only accepts calls from this terminal itself.

function executePayout(
JBSplit calldata split,
uint256 projectId,
address token,
uint256 amount,
address originalMessageSender
)
external
returns (uint256 netPayoutAmount);

Parameters

NameTypeDescription
splitJBSplitThe split to pay.
projectIduint256The ID of the project the split belongs to.
tokenaddressThe address of the token being paid to the split.
amountuint256The total amount being paid to the split, as a fixed point number with the same number of decimals as this terminal.
originalMessageSenderaddress

Returns

NameTypeDescription
netPayoutAmountuint256The amount sent to the split after subtracting fees.

executeProcessFee

Process a specified amount of fees for a project.

Only accepts calls from this terminal itself.

function executeProcessFee(
uint256 projectId,
address token,
uint256 amount,
address beneficiary,
IJBTerminal feeTerminal
)
external;

Parameters

NameTypeDescription
projectIduint256The ID of the project paying the fee.
tokenaddressThe token the fee is being paid in.
amountuint256The fee amount, as a fixed point number with 18 decimals.
beneficiaryaddressThe address to mint tokens to (from the project which receives fees), and pass along to the ruleset's data hook and pay hook if applicable.
feeTerminalIJBTerminalThe terminal that'll receive the fees.

executeTransferTo

Transfer funds to an address.

Only accepts calls from this terminal itself.

function executeTransferTo(address payable addr, address token, uint256 amount) external;

Parameters

NameTypeDescription
addraddress payableThe address to transfer funds to.
tokenaddressThe token to transfer.
amountuint256The amount of tokens to transfer.

migrateBalanceOf

Migrate a project's funds and operations to a new terminal that accepts the same token type.

Only a project's owner or an operator with the MIGRATE_TERMINAL permission from that owner can migrate the project's terminal.

function migrateBalanceOf(
uint256 projectId,
address token,
IJBTerminal to
)
external
override
returns (uint256 balance);

Parameters

NameTypeDescription
projectIduint256The ID of the project being migrated.
tokenaddressThe address of the token being migrated.
toIJBTerminalThe terminal contract being migrated to, which will receive the project's funds and operations.

Returns

NameTypeDescription
balanceuint256The amount of funds that were migrated, as a fixed point number with the same amount of decimals as this terminal.

pay

Pay a project with tokens.

function pay(
uint256 projectId,
address token,
uint256 amount,
address beneficiary,
uint256 minReturnedTokens,
string calldata memo,
bytes calldata metadata
)
external
payable
override
returns (uint256 beneficiaryTokenCount);

Parameters

NameTypeDescription
projectIduint256The ID of the project being paid.
tokenaddressThe token being paid.
amountuint256The amount of terminal tokens being received, as a fixed point number with the same number of decimals as this terminal. If this terminal's token is native, this is ignored and msg.value is used in its place.
beneficiaryaddressThe address to mint tokens to, and pass along to the ruleset's data hook and pay hook if applicable.
minReturnedTokensuint256The minimum number of project tokens expected in return for this payment, as a fixed point number with the same number of decimals as this terminal. If the amount of tokens minted for the beneficiary would be less than this amount, the payment is reverted.
memostringA memo to pass along to the emitted event.
metadatabytesBytes to pass along to the emitted event, as well as the data hook and pay hook if applicable.

Returns

NameTypeDescription
beneficiaryTokenCountuint256The number of tokens minted to the beneficiary, as a fixed point number with 18 decimals.

processHeldFeesOf

Process any fees that are being held for the project.

function processHeldFeesOf(uint256 projectId, address token, uint256 count) external override;

Parameters

NameTypeDescription
projectIduint256The ID of the project to process held fees for.
tokenaddressThe token to process held fees for.
countuint256The number of fees to process.

sendPayoutsOf

Sends payouts to a project's current payout split group, according to its ruleset, up to its current payout limit.

If the percentages of the splits in the project's payout split group do not add up to 100%, the remainder is sent to the project's owner.

Anyone can send payouts on a project's behalf. Projects can include a wildcard split (a split with no hook, projectId, or beneficiary) to send funds to the _msgSender() which calls this function. This can be used to incentivize calling this function.

payouts sent to addresses which aren't feeless incur the protocol fee.

Payouts a projects don't incur fees if its terminal is feeless.

function sendPayoutsOf(
uint256 projectId,
address token,
uint256 amount,
uint256 currency,
uint256 minTokensPaidOut
)
external
override
returns (uint256 amountPaidOut);

Parameters

NameTypeDescription
projectIduint256The ID of the project having its payouts sent.
tokenaddressThe token being sent.
amountuint256The total number of terminal tokens to send, as a fixed point number with same number of decimals as this terminal.
currencyuint256The expected currency of the payouts being sent. Must match the currency of one of the project's current ruleset's payout limits.
minTokensPaidOutuint256The minimum number of terminal tokens that the amount should be worth (if expressed in terms of this terminal's currency), as a fixed point number with the same number of decimals as this terminal. If the amount of tokens paid out would be less than this amount, the send is reverted.

Returns

NameTypeDescription
amountPaidOutuint256The total amount paid out.

useAllowanceOf

Allows a project to pay out funds from its surplus up to the current surplus allowance.

Only a project's owner or an operator with the USE_ALLOWANCE permission from that owner can use the surplus allowance.

Incurs the protocol fee unless the caller is a feeless address.

function useAllowanceOf(
uint256 projectId,
address token,
uint256 amount,
uint256 currency,
uint256 minTokensPaidOut,
address payable beneficiary,
address payable feeBeneficiary,
string calldata memo
)
external
override
returns (uint256 netAmountPaidOut);

Parameters

NameTypeDescription
projectIduint256The ID of the project to use the surplus allowance of.
tokenaddressThe token being paid out from the surplus.
amountuint256The amount of terminal tokens to use from the project's current surplus allowance, as a fixed point number with the same amount of decimals as this terminal.
currencyuint256The expected currency of the amount being paid out. Must match the currency of one of the project's current ruleset's surplus allowances.
minTokensPaidOutuint256The minimum number of terminal tokens that should be returned from the surplus allowance (excluding fees), as a fixed point number with 18 decimals. If the amount of surplus used would be less than this amount, the transaction is reverted.
beneficiaryaddress payableThe address to send the surplus funds to.
feeBeneficiaryaddress payableThe address to send the tokens resulting from paying the fee.
memostringA memo to pass along to the emitted event.

Returns

NameTypeDescription
netAmountPaidOutuint256The number of tokens that were sent to the beneficiary, as a fixed point number with the same amount of decimals as the terminal.

_acceptFundsFor

Accepts an incoming token.

function _acceptFundsFor(
uint256 projectId,
address token,
uint256 amount,
bytes calldata metadata
)
internal
returns (uint256);

Parameters

NameTypeDescription
projectIduint256The ID of the project that the transfer is being accepted for.
tokenaddressThe token being accepted.
amountuint256The number of tokens being accepted.
metadatabytesThe metadata in which permit2 context is provided.

Returns

NameTypeDescription
<none>uint256amount The number of tokens which have been accepted.

_addToBalanceOf

Adds funds to a project's balance without minting tokens.

function _addToBalanceOf(
uint256 projectId,
address token,
uint256 amount,
bool shouldReturnHeldFees,
string memory memo,
bytes memory metadata
)
internal;

Parameters

NameTypeDescription
projectIduint256The ID of the project to add funds to the balance of.
tokenaddressThe address of the token being added to the project's balance.
amountuint256The amount of tokens to add as a fixed point number with the same number of decimals as this terminal. If this is a native token terminal, this is ignored and msg.value is used instead.
shouldReturnHeldFeesboolA flag indicating if held fees should be returned based on the amount being added.
memostringA memo to pass along to the emitted event.
metadatabytesExtra data to pass along to the emitted event.

_beforeTransferTo

Logic to be triggered before transferring tokens from this terminal.

function _beforeTransferTo(address to, address token, uint256 amount) internal returns (uint256);

Parameters

NameTypeDescription
toaddressThe address the transfer is going to.
tokenaddressThe token being transferred.
amountuint256The number of tokens being transferred, as a fixed point number with the same number of decimals as this terminal.

Returns

NameTypeDescription
<none>uint256payValue The value to attach to the transaction being sent.

_cashOutTokensOf

Holders can cash out their tokens to reclaim some of a project's surplus, or to trigger rules determined by the project's current ruleset's data hook.

Only a token holder or an operator with the CASH_OUT_TOKENS permission from that holder can cash out those tokens.

function _cashOutTokensOf(
address holder,
uint256 projectId,
uint256 cashOutCount,
address tokenToReclaim,
address payable beneficiary,
bytes memory metadata
)
internal
returns (uint256 reclaimAmount);

Parameters

NameTypeDescription
holderaddressThe account cashing out tokens.
projectIduint256The ID of the project whose tokens are being cashed out.
cashOutCountuint256The number of project tokens to cash out, as a fixed point number with 18 decimals.
tokenToReclaimaddressThe address of the token which is being cashed out.
beneficiaryaddress payableThe address to send the reclaimed terminal tokens to.
metadatabytesBytes to send along to the emitted event, as well as the data hook and cash out hook if applicable.

Returns

NameTypeDescription
reclaimAmountuint256The number of terminal tokens reclaimed for the beneficiary, as a fixed point number with 18 decimals.

_efficientAddToBalance

Fund a project either by calling this terminal's internal addToBalance function or by calling the recipient terminal's addToBalance function.

function _efficientAddToBalance(
IJBTerminal terminal,
uint256 projectId,
address token,
uint256 amount,
bytes memory metadata
)
internal;

Parameters

NameTypeDescription
terminalIJBTerminalThe terminal on which the project is expecting to receive funds.
projectIduint256The ID of the project being funded.
tokenaddressThe token being used.
amountuint256The amount being funded, as a fixed point number with the amount of decimals that the terminal's accounting context specifies.
metadatabytesAdditional metadata to include with the payment.

_efficientPay

Pay a project either by calling this terminal's internal pay function or by calling the recipient terminal's pay function.

function _efficientPay(
IJBTerminal terminal,
uint256 projectId,
address token,
uint256 amount,
address beneficiary,
bytes memory metadata
)
internal;

Parameters

NameTypeDescription
terminalIJBTerminalThe terminal on which the project is expecting to receive payments.
projectIduint256The ID of the project being paid.
tokenaddressThe token being paid in.
amountuint256The amount being paid, as a fixed point number with the amount of decimals that the terminal's accounting context specifies.
beneficiaryaddressThe address to receive any platform tokens minted.
metadatabytesAdditional metadata to include with the payment.

_fulfillPayHookSpecificationsFor

Fulfills a list of pay hook specifications.

function _fulfillPayHookSpecificationsFor(
uint256 projectId,
JBPayHookSpecification[] memory specifications,
JBTokenAmount memory tokenAmount,
address payer,
JBRuleset memory ruleset,
address beneficiary,
uint256 newlyIssuedTokenCount,
bytes memory metadata
)
internal;

Parameters

NameTypeDescription
projectIduint256The ID of the project being paid.
specificationsJBPayHookSpecification[]The pay hook specifications to be fulfilled.
tokenAmountJBTokenAmountThe amount of tokens that the project was paid.
payeraddressThe address that sent the payment.
rulesetJBRulesetThe ruleset the payment is being accepted during.
beneficiaryaddressThe address which will receive any tokens that the payment yields.
newlyIssuedTokenCountuint256The amount of tokens that are being issued and sent to the beneificary.
metadatabytesBytes to send along to the emitted event and pay hooks as applicable.

_fulfillCashOutHookSpecificationsFor

Fulfills a list of cash out hook specifications.

function _fulfillCashOutHookSpecificationsFor(
uint256 projectId,
JBTokenAmount memory beneficiaryReclaimAmount,
address holder,
uint256 cashOutCount,
bytes memory metadata,
JBRuleset memory ruleset,
uint256 cashOutTaxRate,
address payable beneficiary,
JBCashOutHookSpecification[] memory specifications
)
internal
returns (uint256 amountEligibleForFees);

Parameters

NameTypeDescription
projectIduint256The ID of the project being cashed out from.
beneficiaryReclaimAmountJBTokenAmountThe number of tokens that are being cashed out from the project.
holderaddressThe address that holds the tokens being cashed out.
cashOutCountuint256The number of tokens being cashed out.
metadatabytesBytes to send along to the emitted event and cash out hooks as applicable.
rulesetJBRulesetThe ruleset the cash out is being made during as a JBRuleset struct.
cashOutTaxRateuint256The cash out tax rate influencing the reclaim amount.
beneficiaryaddress payableThe address which will receive any terminal tokens that are cashed out.
specificationsJBCashOutHookSpecification[]The hook specifications being fulfilled.

Returns

NameTypeDescription
amountEligibleForFeesuint256The amount of funds which were allocated to cash out hooks and are eligible for fees.

_pay

Pay a project with tokens.

function _pay(
uint256 projectId,
address token,
uint256 amount,
address payer,
address beneficiary,
string memory memo,
bytes memory metadata
)
internal;

Parameters

NameTypeDescription
projectIduint256The ID of the project being paid.
tokenaddressThe address of the token which the project is being paid with.
amountuint256The amount of terminal tokens being received, as a fixed point number with the same number of decimals as this terminal. If this terminal's token is the native token, amount is ignored and msg.value is used in its place.
payeraddressThe address making the payment.
beneficiaryaddressThe address to mint tokens to, and pass along to the ruleset's data hook and pay hook if applicable.
memostringA memo to pass along to the emitted event.
metadatabytesBytes to send along to the emitted event, as well as the data hook and pay hook if applicable.

_processFee

Process a fee of the specified amount from a project.

function _processFee(
uint256 projectId,
address token,
uint256 amount,
address beneficiary,
IJBTerminal feeTerminal,
bool wasHeld
)
internal;

Parameters

NameTypeDescription
projectIduint256The ID of the project paying the fee.
tokenaddressThe token the fee is being paid in.
amountuint256The fee amount, as a fixed point number with 18 decimals.
beneficiaryaddressThe address which will receive any platform tokens minted.
feeTerminalIJBTerminalThe terminal that'll receive the fee.
wasHeldboolA flag indicating if the fee being processed was being held by this terminal.

_recordAddedBalanceFor

Records an added balance for a project.

function _recordAddedBalanceFor(uint256 projectId, address token, uint256 amount) internal;

Parameters

NameTypeDescription
projectIduint256The ID of the project to record the added balance for.
tokenaddressThe token to record the added balance for.
amountuint256The amount of the token to record, as a fixed point number with the same number of decimals as this terminal.

_returnHeldFees

Returns held fees to the project who paid them based on the specified amount.

function _returnHeldFees(uint256 projectId, address token, uint256 amount) internal returns (uint256 returnedFees);

Parameters

NameTypeDescription
projectIduint256The project held fees are being returned to.
tokenaddressThe token that the held fees are in.
amountuint256The amount to base the calculation on, as a fixed point number with the same number of decimals as this terminal.

Returns

NameTypeDescription
returnedFeesuint256The amount of held fees that were returned, as a fixed point number with the same number of decimals as this terminal

_sendPayoutsOf

Sends payouts to a project's current payout split group, according to its ruleset, up to its current payout limit.

If the percentages of the splits in the project's payout split group do not add up to 100%, the remainder is sent to the project's owner.

Anyone can send payouts on a project's behalf. Projects can include a wildcard split (a split with no hook, projectId, or beneficiary) to send funds to the _msgSender() which calls this function. This can be used to incentivize calling this function.

Payouts sent to addresses which aren't feeless incur the protocol fee.

function _sendPayoutsOf(
uint256 projectId,
address token,
uint256 amount,
uint256 currency
)
internal
returns (uint256 amountPaidOut);

Parameters

NameTypeDescription
projectIduint256The ID of the project to send the payouts of.
tokenaddressThe token being paid out.
amountuint256The number of terminal tokens to pay out, as a fixed point number with same number of decimals as this terminal.
currencyuint256The expected currency of the amount being paid out. Must match the currency of one of the project's current ruleset's payout limits.

Returns

NameTypeDescription
amountPaidOutuint256The total amount that was paid out.

_sendPayoutToSplit

Sends a payout to a split.

function _sendPayoutToSplit(
JBSplit memory split,
uint256 projectId,
address token,
uint256 amount
)
internal
returns (uint256);

Parameters

NameTypeDescription
splitJBSplitThe split to pay.
projectIduint256The ID of the project the split was specified by.
tokenaddressThe address of the token being paid out.
amountuint256The total amount that the split is being paid, as a fixed point number with the same number of decimals as this terminal.

Returns

NameTypeDescription
<none>uint256netPayoutAmount The amount sent to the split after subtracting fees.

_sendPayoutsToSplitGroupOf

Sends payouts to the payout splits group specified in a project's ruleset.

function _sendPayoutsToSplitGroupOf(
uint256 projectId,
address token,
uint256 rulesetId,
uint256 amount
)
internal
returns (uint256, uint256 amountEligibleForFees);

Parameters

NameTypeDescription
projectIduint256The ID of the project to send the payouts of.
tokenaddressThe address of the token being paid out.
rulesetIduint256The ID of the ruleset of the split group being paid.
amountuint256The total amount being paid out, as a fixed point number with the same number of decimals as this terminal.

Returns

NameTypeDescription
<none>uint256amount The leftover amount (zero if the splits add up to 100%).
amountEligibleForFeesuint256The total amount of funds which were paid out and are eligible for fees.

_takeFeeFrom

Takes a fee into the platform's project (with the _FEE_BENEFICIARY_PROJECT_ID).

function _takeFeeFrom(
uint256 projectId,
address token,
uint256 amount,
address beneficiary,
bool shouldHoldFees
)
internal
returns (uint256 feeAmount);

Parameters

NameTypeDescription
projectIduint256The ID of the project paying the fee.
tokenaddressThe address of the token that the fee is being paid in.
amountuint256The fee's token amount, as a fixed point number with 18 decimals.
beneficiaryaddressThe address to mint the platform's project's tokens for.
shouldHoldFeesboolIf fees should be tracked and held instead of being exercised immediately.

Returns

NameTypeDescription
feeAmountuint256The amount of the fee taken.

_transferFrom

Transfers tokens.

function _transferFrom(address from, address payable to, address token, uint256 amount) internal;

Parameters

NameTypeDescription
fromaddressThe address the transfer should originate from.
toaddress payableThe address the transfer should go to.
tokenaddressThe token being transfered.
amountuint256The number of tokens being transferred, as a fixed point number with the same number of decimals as this terminal.

_useAllowanceOf

Allows a project to send out funds from its surplus up to the current surplus allowance.

Only a project's owner or an operator with the USE_ALLOWANCE permission from that owner can use the surplus allowance.

Incurs the protocol fee unless the caller is a feeless address.

function _useAllowanceOf(
uint256 projectId,
address token,
uint256 amount,
uint256 currency,
address payable beneficiary,
address payable feeBeneficiary,
string memory memo
)
internal
returns (uint256 netAmountPaidOut);

Parameters

NameTypeDescription
projectIduint256The ID of the project to use the surplus allowance of.
tokenaddressThe token being paid out from the surplus.
amountuint256The amount of terminal tokens to use from the project's current surplus allowance, as a fixed point number with the same amount of decimals as this terminal.
currencyuint256The expected currency of the amount being paid out. Must match the currency of one of the project's current ruleset's surplus allowances.
beneficiaryaddress payableThe address to send the funds to.
feeBeneficiaryaddress payableThe address to send the tokens resulting from paying the fee.
memostringA memo to pass along to the emitted event.

Returns

NameTypeDescription
netAmountPaidOutuint256The amount of tokens paid out.

Errors

JBMultiTerminal_AccountingContextAlreadySet

error JBMultiTerminal_AccountingContextAlreadySet(address token);

JBMultiTerminal_AddingAccountingContextNotAllowed

error JBMultiTerminal_AddingAccountingContextNotAllowed();

JBMultiTerminal_FeeTerminalNotFound

error JBMultiTerminal_FeeTerminalNotFound();

JBMultiTerminal_NoMsgValueAllowed

error JBMultiTerminal_NoMsgValueAllowed(uint256 value);

JBMultiTerminal_OverflowAlert

error JBMultiTerminal_OverflowAlert(uint256 value, uint256 limit);

JBMultiTerminal_PermitAllowanceNotEnough

error JBMultiTerminal_PermitAllowanceNotEnough(uint256 amount, uint256 allowance);

JBMultiTerminal_RecipientProjectTerminalNotFound

error JBMultiTerminal_RecipientProjectTerminalNotFound(uint256 projectId, address token);

JBMultiTerminal_SplitHookInvalid

error JBMultiTerminal_SplitHookInvalid(IJBSplitHook hook);

JBMultiTerminal_TerminalTokensIncompatible

error JBMultiTerminal_TerminalTokensIncompatible();

JBMultiTerminal_TokenNotAccepted

error JBMultiTerminal_TokenNotAccepted(address token);

JBMultiTerminal_UnderMinReturnedTokens

error JBMultiTerminal_UnderMinReturnedTokens(uint256 count, uint256 min);

JBMultiTerminal_UnderMinTokensPaidOut

error JBMultiTerminal_UnderMinTokensPaidOut(uint256 amount, uint256 min);

JBMultiTerminal_UnderMinTokensReclaimed

error JBMultiTerminal_UnderMinTokensReclaimed(uint256 amount, uint256 min);

JBMultiTerminal_ZeroAccountingContextDecimals

error JBMultiTerminal_ZeroAccountingContextDecimals();

JBMultiTerminal_ZeroAccountingContextCurrency

error JBMultiTerminal_ZeroAccountingContextCurrency();