JBMultiTerminal
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
Name | Type | Description |
---|---|---|
feelessAddresses | IJBFeelessAddresses | A contract that stores addresses that shouldn't incur fees when being paid towards or from. |
permissions | IJBPermissions | A contract storing permissions. |
projects | IJBProjects | A contract which mints ERC-721s that represent project ownership and transfers. |
splits | IJBSplits | A contract that stores splits for each project. |
store | IJBTerminalStore | A contract that stores the terminal's data. |
tokens | IJBTokens | |
permit2 | IPermit2 | A permit2 utility. |
trustedForwarder | address | A 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
Name | Type | Description |
---|---|---|
projectId | uint256 | The ID of the project to get token accounting context of. |
token | address | The token to check the accounting context of. |
Returns
Name | Type | Description |
---|---|---|
<none> | JBAccountingContext | The 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
Name | Type | Description |
---|---|---|
projectId | uint256 | The ID of the project to get the accepted tokens of. |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
projectId | uint256 | The ID of the project to get the current total surplus of. |
accountingContexts | JBAccountingContext[] | The accounting contexts to use to calculate the surplus. Pass an empty array to use all of the project's accounting contexts. |
decimals | uint256 | The number of decimals to include in the fixed point returned value. |
currency | uint256 | The currency to express the returned value in terms of. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
projectId | uint256 | The ID of the project that is holding fees. |
token | address | The token that the fees are held in. |
count | uint256 |
supportsInterface
Indicates whether this contract adheres to the specified interface.
See IERC165-supportsInterface.
function supportsInterface(bytes4 interfaceId) public pure override returns (bool);
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | The ID of the interface to check for adherence to. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | A 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
Name | Type | Description |
---|---|---|
token | address | The address of the token to get this terminal's balance of. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | This 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
Name | Type | Description |
---|---|---|
projectId | uint256 | The ID of the project to get the controller of. |
Returns
Name | Type | Description |
---|---|---|
<none> | IJBController | controller 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
Name | Type | Description |
---|---|---|
addr | address | The address to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | A 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
Name | Type | Description |
---|---|---|
<none> | bytes | calldata 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
Name | Type | Description |
---|---|---|
sender | address | The address which sent this call. |