IMainHub
Functions
Section titled “Functions”version
Section titled “version”Returns the version of the MainHub.
function version() external pure returns (uint256);superAdminAddress
Section titled “superAdminAddress”Returns the root admin address for projects created by the main hub.
function superAdminAddress() external view returns (address);feeRecipientAddress
Section titled “feeRecipientAddress”Returns the current platform fee recipient address.
function feeRecipientAddress() external view returns (address feeRecipient);Returns
| Name | Type | Description |
|---|---|---|
feeRecipient | address | The fee recipient address. |
getCertificateNFTManagerAddress
Section titled “getCertificateNFTManagerAddress”Returns the CertificateNFTManager address.
This contract controls the NFT minting and ownerships.
function getCertificateNFTManagerAddress() external view returns (address nftManagerAddress);Returns
| Name | Type | Description |
|---|---|---|
nftManagerAddress | address | The CertificateNFTManager address. |
getTokenRouterAddress
Section titled “getTokenRouterAddress”Returns the TokenRouter address.
The TokenRouter is used to interact with Uniswap, among other things.
function getTokenRouterAddress() external view returns (address tokenRouterAddress);Returns
| Name | Type | Description |
|---|---|---|
tokenRouterAddress | address | The TokenRouter address. |
isProject
Section titled “isProject”Checks if an address is a project.
function isProject(address projectAddress) external view returns (bool isProject);Parameters
| Name | Type | Description |
|---|---|---|
projectAddress | address | The project address. |
Returns
| Name | Type | Description |
|---|---|---|
isProject | bool | Whether the address is a project. |
getProjectsCount
Section titled “getProjectsCount”Returns the projects count.
This function is used for pagination.
function getProjectsCount() external view returns (uint256 projectsCount);Returns
| Name | Type | Description |
|---|---|---|
projectsCount | uint256 | The projects count. |
getPaginatedProjects
Section titled “getPaginatedProjects”Returns the projects paginated.
function getPaginatedProjects( uint256 offset, uint256 limit) external view returns (address[] memory projects);Parameters
| Name | Type | Description |
|---|---|---|
offset | uint256 | The offset to start from. |
limit | uint256 | The limit. |
Returns
| Name | Type | Description |
|---|---|---|
projects | address[] | The projects. |
getDepositTokensCount
Section titled “getDepositTokensCount”Returns the deposit tokens count.
This function is used for pagination.
function getDepositTokensCount() external view returns (uint256 tokensCount);Returns
| Name | Type | Description |
|---|---|---|
tokensCount | uint256 | The deposit tokens count. |
getPaginatedDepositTokens
Section titled “getPaginatedDepositTokens”Returns the deposit tokens paginated.
function getPaginatedDepositTokens( uint256 offset, uint256 limit) external view returns (address[] memory tokens);Parameters
| Name | Type | Description |
|---|---|---|
offset | uint256 | The offset. |
limit | uint256 | The limit. |
Returns
| Name | Type | Description |
|---|---|---|
tokens | address[] | The deposit tokens. |
getPaginatedProjectsByDepositToken
Section titled “getPaginatedProjectsByDepositToken”Returns paginated projects by deposit token.
function getPaginatedProjectsByDepositToken( address depositTokenAddress, uint256 offset, uint256 limit) external view returns (address[] memory projects);Parameters
| Name | Type | Description |
|---|---|---|
depositTokenAddress | address | The deposit token address. |
offset | uint256 | The offset. |
limit | uint256 | The limit. |
getDeployerAddressesCount
Section titled “getDeployerAddressesCount”Gets the unique deployer addresses count.
This function is used for pagination.
function getDeployerAddressesCount() external view returns (uint256 count);Returns
| Name | Type | Description |
|---|---|---|
count | uint256 | The deployer addresses count. |
getPaginatedDeployerAddresses
Section titled “getPaginatedDeployerAddresses”Returns the unique deployer addresses in paginated format.
function getPaginatedDeployerAddresses( uint256 offset, uint256 limit) external view returns (address[] memory deployerAddresses);Parameters
| Name | Type | Description |
|---|---|---|
offset | uint256 | The offset to start from. |
limit | uint256 | The limit of deployer addresses to return. |
Returns
| Name | Type | Description |
|---|---|---|
deployerAddresses | address[] | The deployer addresses array. |
getProjectsCountByDeployerAddress
Section titled “getProjectsCountByDeployerAddress”Returns the count of projects deployed by an address.
This function is used for pagination.
function getProjectsCountByDeployerAddress(address deployerAddress) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
deployerAddress | address | The deployer address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The count of projects deployed by the address. |
getPaginatedProjectsByDeployerAddress
Section titled “getPaginatedProjectsByDeployerAddress”Returns paginated projects by deployer address.
function getPaginatedProjectsByDeployerAddress( address deployerAddress, uint256 offset, uint256 limit) external view returns (address[] memory projects);Parameters
| Name | Type | Description |
|---|---|---|
deployerAddress | address | The deployer address. |
offset | uint256 | The offset. |
limit | uint256 | The limit. |
Returns
| Name | Type | Description |
|---|---|---|
projects | address[] | The projects. |
previewFee
Section titled “previewFee”Returns a preview quote for a specific fee.
function previewFee( FeeType feeType, address accountPaying, uint256 originalAmount) external view returns (address chargeToken, uint256 chargeAmount);Parameters
| Name | Type | Description |
|---|---|---|
feeType | FeeType | The fee type. |
accountPaying | address | The account paying the fee. |
originalAmount | uint256 | The original amount. |
Returns
| Name | Type | Description |
|---|---|---|
chargeToken | address | The token address to charge. |
chargeAmount | uint256 | The amount to charge. |
certificateNFTManagerAddress
Section titled “certificateNFTManagerAddress”Returns the certificate manager address.
function certificateNFTManagerAddress() external view returns (address nftManagerAddress);Returns
| Name | Type | Description |
|---|---|---|
nftManagerAddress | address | The certificate manager address. |
getPlatformFee
Section titled “getPlatformFee”This function is used to get the fee details.
function getPlatformFee( FeeType feeType, address accountPaying) external view returns (PlatformFee memory feeDetails);Parameters
| Name | Type | Description |
|---|---|---|
feeType | FeeType | The fee type. |
accountPaying | address | The account paying the fee. |
Returns
| Name | Type | Description |
|---|---|---|
feeDetails | PlatformFee | The fee details. |
getRoyaltyFee
Section titled “getRoyaltyFee”This function is used to get the current royalty fee.
function getRoyaltyFee(address projectAddress) external view returns (uint256 royaltyFee);Parameters
| Name | Type | Description |
|---|---|---|
projectAddress | address | The project address. |
Returns
| Name | Type | Description |
|---|---|---|
royaltyFee | uint256 | The current royalty fee. |
setCertificateNFTManagerAddress
Section titled “setCertificateNFTManagerAddress”Sets the certificate manager address.
Only the root admin can call this function.
function setCertificateNFTManagerAddress(address newCertificateNFTManagerAddress) external;Parameters
| Name | Type | Description |
|---|---|---|
newCertificateNFTManagerAddress | address | The address of the certificate manager. |
setFeeRecipientAddress
Section titled “setFeeRecipientAddress”Sets the fee recipient address.
Only the root admin can call this function.
function setFeeRecipientAddress(address newFeeRecipientAddress) external;Parameters
| Name | Type | Description |
|---|---|---|
newFeeRecipientAddress | address | The address of the fee recipient. |
setSuperAdminAddress
Section titled “setSuperAdminAddress”Sets the super admin address.
Only the root admin can call this function.
function setSuperAdminAddress(address newSuperAdminAddress) external;Parameters
| Name | Type | Description |
|---|---|---|
newSuperAdminAddress | address | The address of the super admin. |
setTokenRouterAddress
Section titled “setTokenRouterAddress”Sets the TokenRouter address.
Only the root admin can call this function.
function setTokenRouterAddress(address newTokenRouterAddress) external;Parameters
| Name | Type | Description |
|---|---|---|
newTokenRouterAddress | address | The address of the TokenRouter. |
setProjectDiamondData
Section titled “setProjectDiamondData”Sets the project facet cuts.
Only the root admin can call this function.
function setProjectDiamondData(ProjectDiamondData calldata data) external;Parameters
| Name | Type | Description |
|---|---|---|
data | ProjectDiamondData | The project diamond data. |
setPlatformFee
Section titled “setPlatformFee”Sets the platform fee.
Only the root admin can call this function.
function setPlatformFee( FeeType feeType, PlatformFee calldata platformFee, address accountOverride) external;Parameters
| Name | Type | Description |
|---|---|---|
feeType | FeeType | The fee type. |
platformFee | PlatformFee | The platform fee. |
accountOverride | address | The account to override the fee for. |
setRoyaltyFee
Section titled “setRoyaltyFee”Sets the royalty fee in the Marketplace for a project.
Use address(0) for global default.
function setRoyaltyFee(address projectAddress, uint256 royaltyFee) external;Parameters
| Name | Type | Description |
|---|---|---|
projectAddress | address | The project address to set the royalty fee for. |
royaltyFee | uint256 | The royalty fee to set bps (1/100000). |
payFee
Section titled “payFee”This function effectively charges the fee.
function payFee( FeeType feeType, address accountPaying, address paymentTokenAddress, uint256 originalAmount) external returns (uint256 chargeAmount);Parameters
| Name | Type | Description |
|---|---|---|
feeType | FeeType | The fee type. |
accountPaying | address | The account paying the fee. |
paymentTokenAddress | address | The payment token address suggested by the project (will be checked against the fee token) |
originalAmount | uint256 | The original amount. |
Returns
| Name | Type | Description |
|---|---|---|
chargeAmount | uint256 | The amount charged. |
createProject
Section titled “createProject”Creates a project.
function createProject(ProjectArgs calldata projectArgs) external payable returns (address projectAddress);Parameters
| Name | Type | Description |
|---|---|---|
projectArgs | ProjectArgs | The init args. |
Returns
| Name | Type | Description |
|---|---|---|
projectAddress | address | The project address. |
Events
Section titled “Events”ProjectCreated
Section titled “ProjectCreated”Event emitted when a project is created
event ProjectCreated(address indexed projectAddress, address indexed baseTokenAddress);Parameters
| Name | Type | Description |
|---|---|---|
projectAddress | address | The address of the project |
baseTokenAddress | address | The address of the base token |
FeeRecipientAddressChange
Section titled “FeeRecipientAddressChange”event FeeRecipientAddressChange(address oldFeeRecipientAddress, address newFeeRecipientAddress);SuperAdminAddressChange
Section titled “SuperAdminAddressChange”event SuperAdminAddressChange(address oldSuperAdminAddress, address newSuperAdminAddress);CertificateNFTManagerAddressChange
Section titled “CertificateNFTManagerAddressChange”event CertificateNFTManagerAddressChange( address oldCertificateNFTManagerAddress, address newCertificateNFTManagerAddress);TokenRouterAddressChange
Section titled “TokenRouterAddressChange”event TokenRouterAddressChange(address oldTokenRouterAddress, address newTokenRouterAddress);ProjectDiamondDataChange
Section titled “ProjectDiamondDataChange”Event emitted when a project diamond data is changed
event ProjectDiamondDataChange(ProjectDiamondData newDiamondData);Parameters
| Name | Type | Description |
|---|---|---|
newDiamondData | ProjectDiamondData | The new diamond data, see ProjectDiamondData struct |
RoyaltyFeeChange
Section titled “RoyaltyFeeChange”Event emitted when a royalty fee is changed
event RoyaltyFeeChange(address indexed projectAddress, RoyaltyFee newRoyaltyFee);Parameters
| Name | Type | Description |
|---|---|---|
projectAddress | address | (indexed) The project address |
newRoyaltyFee | RoyaltyFee | The new royalty fee, see RoyaltyFee struct |
RoyaltyFeeRemoval
Section titled “RoyaltyFeeRemoval”Event emitted when a royalty fee is removed
event RoyaltyFeeRemoval(address indexed projectAddress);Parameters
| Name | Type | Description |
|---|---|---|
projectAddress | address | (indexed) The project address |
PlatformFeeChange
Section titled “PlatformFeeChange”Event emitted when a platform fee is changed
event PlatformFeeChange(address indexed beneficiary, FeeType indexed feeType, PlatformFee newFee);Parameters
| Name | Type | Description |
|---|---|---|
beneficiary | address | {indexed} The beneficiary of the fee |
feeType | FeeType | {indexed} The type of fee (FeeType enum) |
newFee | PlatformFee | The new fee details, see PlatformFee struct |
Errors
Section titled “Errors”ZeroAddress
Section titled “ZeroAddress”Error for when the address is the zero address
Used when the zero address could catastrophically affect the system
error ZeroAddress();NotAProject
Section titled “NotAProject”Error for when the address is not a project
error NotAProject();InvalidChargeType
Section titled “InvalidChargeType”Error for when the charge type for quoting/payment is invalid
error InvalidChargeType();InsufficientEth
Section titled “InsufficientEth”Error for when the sent ether is insufficient
error InsufficientEth();SendFeeFailed
Section titled “SendFeeFailed”Error for when the fee cannot be sent to the recipient
error SendFeeFailed();CannotReceiveEther
Section titled “CannotReceiveEther”Error for when ETH is sent directly to the MainHub
error CannotReceiveEther();FeeTooHigh
Section titled “FeeTooHigh”Error for when the fee is too high
error FeeTooHigh();InvalidPaymentToken
Section titled “InvalidPaymentToken”Error for when the token for payment is not a valid token
error InvalidPaymentToken(address expectedTokenAddress, address receivedTokenAddress);Parameters
| Name | Type | Description |
|---|---|---|
expectedTokenAddress | address | The expected token address |
receivedTokenAddress | address | The received token address |
InsufficientAllowance
Section titled “InsufficientAllowance”Error for when the allowance is insufficient
error InsufficientAllowance();InsufficientTokenBalance
Section titled “InsufficientTokenBalance”Error for when the token balance is insufficient
error InsufficientTokenBalance(uint256 expectedBalance, uint256 actualBalance);Parameters
| Name | Type | Description |
|---|---|---|
expectedBalance | uint256 | The expected balance |
actualBalance | uint256 | The actual balance |
Structs
Section titled “Structs”FeeToken
Section titled “FeeToken”FeeToken is a struct to represent the token used for fees
struct FeeToken { address tokenAddress; bool isEther; bool isAnyToken;}Properties
| Name | Type | Description |
|---|---|---|
tokenAddress | address | The address of the token |
isEther | bool | Whether the token is Ether |
isAnyToken | bool | Whether to accept any token |
HolderDiscount
Section titled “HolderDiscount”HolderDiscount is a struct to represent the discount for holders
struct HolderDiscount { uint256 percentage; uint256 requiredBalance;}Properties
| Name | Type | Description |
|---|---|---|
percentage | uint256 | The percentage of the discount |
requiredBalance | uint256 | The required balance to receive the discount |
HolderDiscountTier
Section titled “HolderDiscountTier”HolderDiscountTier is a struct to represent the discount tiers for holders
struct HolderDiscountTier { address tokenAddress; HolderDiscount[] discountTiers;}Properties
| Name | Type | Description |
|---|---|---|
tokenAddress | address | The address of the token |
discountTiers | HolderDiscount[] | The discount tiers |
PlatformFee
Section titled “PlatformFee”PlatformFee is a struct to represent the fees for the platform
struct PlatformFee { ChargeType chargeType; uint256 chargeAmount; FeeToken feeToken; HolderDiscountTier holderDiscountTier;}Properties
| Name | Type | Description |
|---|---|---|
chargeType | ChargeType | The type of charge (percentage or flat) |
chargeAmount | uint256 | The amount of the charge |
feeToken | FeeToken | The token used for the fee |
holderDiscountTier | HolderDiscountTier | The discount tier for holders |
RoyaltyFee
Section titled “RoyaltyFee”RoyaltyFee is a struct to represent the royalty fee for a project
struct RoyaltyFee { bool active; uint256 percentage;}Properties
| Name | Type | Description |
|---|---|---|
active | bool | Whether the royalty fee is active |
percentage | uint256 | The percentage of the royalty fee |
ProjectDiamondData
Section titled “ProjectDiamondData”ProjectDiamondData is a struct to represent the diamond data for a project
struct ProjectDiamondData { address diamondCutFacetAddress; address diamondInitAddress; IDiamondCut.FacetCut[] cuts;}Properties
| Name | Type | Description |
|---|---|---|
diamondCutFacetAddress | address | The address of the diamond cut facet |
diamondInitAddress | address | The address of the diamond init |
cuts | IDiamondCut.FacetCut[] | The facet cuts for the diamond |
ChargeType
Section titled “ChargeType”ChargeType is an enum to represent the different types of charges
- PERCENTAGE The charge is a percentage of the original amount
- FLAT The charge is a flat amount
enum ChargeType { PERCENTAGE, FLAT}FeeType
Section titled “FeeType”FeeType is an enum to represent the different types of fees
- PROJECT_CREATION The fee for creating a project
- REWARD_SLOT_CREATION The fee for creating a reward slot
- REWARD_DEPOSIT The fee for depositing rewards
- EARLY_WITHDRAWAL The fee for early withdrawal (taken from the project owner when a user withdraws early from a reward slot)
- CERTIFICATE_LIQUIDATION The fee for liquidating a certificate
- REWARD_COMPOUNDING The fee for compounding rewards
enum FeeType { PROJECT_CREATION, REWARD_SLOT_CREATION, REWARD_DEPOSIT, EARLY_WITHDRAWAL, CERTIFICATE_LIQUIDATION, REWARD_COMPOUNDING}