TokenMaster Pools
TokenMaster has three pool types to choose from: Standard Pool, Stable Pool, and Promotional Pool.
Common Pool Functionality
Functions
The following functions are general to all TokenMaster Tokens. Platforms integrating TokenMaster should use these functions to retrieve pool data and (optionally) to generate administrative transactions to recover funds deposited by user errors.
Functions listed below Calls restricted to only TokenMaster Router are for reference only and may only be called by the TokenMaster Router contract through its corresponding function to enforce reentrancy guarding, creator control logic, supply relevant parameters that are stored in the router contract, and provide primary or fallback router token transfer support.
// Permits the token owner to withdraw native tokens or ERC20 tokens that are mistakenly deposited to the pool.
function withdrawUnrelatedToken(address tokenAddress, address withdrawTo, uint256 withdrawAmount) external;
// Address of the token the TokenMaster Token is paired with. Zero address if paired with chain native token.
function PAIRED_TOKEN() external view returns(address);
// Current splits of the paired token value by market, creator, infrastructure and partner.
function pairedTokenShares() external view returns(uint256 marketShare, uint256 creatorShare, uint256 infrastructureShare, uint256 partnerShare);
// Calls restricted to only TokenMaster Router
function buyTokens(
address buyer,
uint256 pairedTokenIn,
uint256 pooledTokenToBuy
) external payable returns(uint256 totalCost, uint256 refundByRouterAmount);
function sellTokens(
address seller,
uint256 pooledTokenToSell,
uint256 pairedTokenMinimumOut
) external returns (address pairedToken, uint256 pairedValueToSeller, uint256 transferByRouterAmount);
function spendTokens(address spender, uint256 pooledTokenToSpend) external;
function withdrawCreatorShare(
address withdrawTo,
uint256 withdrawAmount,
address infrastructureFeeRecipient,
address partnerFeeRecipient
) external returns (
address pairedToken,
uint256 transferByRouterAmountCreator,
uint256 transferByRouterAmountInfrastructure,
uint256 transferByRouterAmountPartner
);
function transferCreatorShareToMarket(
uint256 transferAmount,
address infrastructureFeeRecipient,
address partnerFeeRecipient
) external returns(address pairedToken, uint256 transferByRouterAmountInfrastructure, uint256 transferByRouterAmountPartner);
function withdrawFees(
address infrastructureFeeRecipient,
address partnerFeeRecipient
) external returns (
address pairedToken,
uint256 transferByRouterAmountInfrastructure,
uint256 transferByRouterAmountPartner
);
Events
Platforms integrating TokenMaster should index the following events on all tokens that are relevant to the platform to monitor withdrawal/transfer of creator share and fees.
/// @dev Emitted when a creator withdraws their share or when fees are withdrawn.
event CreatorShareWithdrawn(address to, uint256 withdrawAmount, uint256 infrastructureAmount, uint256 partnerAmount);
/// @dev Emitted when a creator transfers a portion of their share to the market bonded value. Infrastructure and partner amounts are transferred to their respective receivers.
event CreatorShareTransferredToMarket(address to, uint256 transferAmount, uint256 infrastructureAmount, uint256 partnerAmount);
Ownership
All TokenMaster Pools utilize a two-step ownership transfer process, implement access control for granting role-based permissions, and prevent ownership renouncing.
Ownership Transfer Process
- Current owner calls
transferOwnership(address newOwner)specifying the address to transfer ownership to.- A
OwnershipTransferStarted(address,address)event will be emitted when this function is called. - Until the new owner accepts ownership, the current owner will remain the owner and may transfer ownership to another account, canceling out the previous pending new owner.
- A
- New owner calls
acceptOwnership()to become the contract owner.
Roles
In addition to the primary owner of a TokenMaster Token, tokens have role-based permissions that may be granted and revoked by the token owner.
To grant a role the owner must call grantRole(bytes32 role, address account) to grant role (using role identifier) to account.
To revoke a role the owner must call revokeRole(bytes32 role, address account) to revoke role (using role identifier) from account.
There are two roles that are used in TokenMaster generally - DEFAULT_ADMIN and ORDER_MANAGER. An account with the default admin role will have permissions equivalent to the token owner in TokenMaster Router for setting token settings. An account with the order manager role will have permission to disable and re-enable specific advanced buy, sell and spend orders in TokenMaster Router.
| Role | Role Identifier |
|---|---|
| DEFAULT_ADMIN | 0x0000000000000000000000000000000000000000000000000000000000000000 |
| ORDER_MANAGER | 0x3c6581d0b5cf40e66836017f19054f4ad048ab86f3953ec1b557d00fbaf735ac |
ERC-165 Interfaces
TokenMaster Pools can be inspected with ERC-165's supportsInterface(bytes4 interfaceId) function to detect the pool's type and functionality it supports. This enables developers to programmatically query supported features of a pool, ensuring seamless integration.
Overview
ERC-165 is a standard for interface detection in Ethereum smart contracts. It defines a method to query whether a contract implements a specific interface. In the context of TokenMaster, it allows developers to identify pool types and their supported functionalities.
Supported Interface IDs
The following table lists the interface IDs and the corresponding pool types or functionalities they represent:
| Interface ID | Type / Functionality |
|---|---|
0xb080171e | General TokenMaster ERC20C interface (required by all pools). |
0x1f4456b6 | Standard Pool functionality. |
0x049ac6b3 | Creator emissions support. |
0xcffb014c | Promotional Pool functionality. |
0xa18b736c | Direct minting and burning support. |
0x511e5ebf | Stable Pool functionality. |
Example Usage
Below is an example of how developers can use the supportsInterface function to check for specific features in a pool:
// Address of the TokenMaster Pool contract
const poolAddress: Address = '0xYourPoolAddressHere'; // Replace with the pool address
// ERC-165 interface ID for Stable Pool functionality
const stablePoolInterfaceId = '0x511e5ebf';
async function checkStablePoolSupport() {
try {
// Encode the supportsInterface call
const callData = encodeFunctionData({
abi,
functionName: 'supportsInterface',
args: [stablePoolInterfaceId],
});
// Perform the call
const result = await client.readContract({
address: poolAddress,
abi,
functionName: 'supportsInterface',
args: [stablePoolInterfaceId],
});
if (result) {
console.log('This pool supports Stable Pool functionality.');
} else {
console.log('This pool does NOT support Stable Pool functionality.');
}
} catch (error) {
console.error('Error checking Stable Pool support:', error);
}
}
Ownership Renouncing
TokenMaster Tokens prevent renouncing ownership due to the nature of the tokens creator controls and fees generated. Creators that may have been considering renouncing should consider all implications of not having full ownership access to a TokenMaster Token and alternatives such as governance contracts or timelocks that can hold ownership for a period of time.
