Skip to content

IMainHub

Returns the version of the MainHub.

function version() external pure returns (uint256);

Returns the root admin address for projects created by the main hub.

function superAdminAddress() external view returns (address);

Returns the current platform fee recipient address.

function feeRecipientAddress() external view returns (address feeRecipient);

Returns

NameTypeDescription
feeRecipientaddressThe fee recipient address.

Returns the CertificateNFTManager address.

This contract controls the NFT minting and ownerships.

function getCertificateNFTManagerAddress() external view returns (address nftManagerAddress);

Returns

NameTypeDescription
nftManagerAddressaddressThe CertificateNFTManager address.

Returns the TokenRouter address.

The TokenRouter is used to interact with Uniswap, among other things.

function getTokenRouterAddress() external view returns (address tokenRouterAddress);

Returns

NameTypeDescription
tokenRouterAddressaddressThe TokenRouter address.

Checks if an address is a project.

function isProject(address projectAddress) external view returns (bool isProject);

Parameters

NameTypeDescription
projectAddressaddressThe project address.

Returns

NameTypeDescription
isProjectboolWhether the address is a project.

Returns the projects count.

This function is used for pagination.

function getProjectsCount() external view returns (uint256 projectsCount);

Returns

NameTypeDescription
projectsCountuint256The projects count.

Returns the projects paginated.

function getPaginatedProjects(
uint256 offset,
uint256 limit
)
external
view
returns (address[] memory projects);

Parameters

NameTypeDescription
offsetuint256The offset to start from.
limituint256The limit.

Returns

NameTypeDescription
projectsaddress[]The projects.

Returns the deposit tokens count.

This function is used for pagination.

function getDepositTokensCount() external view returns (uint256 tokensCount);

Returns

NameTypeDescription
tokensCountuint256The deposit tokens count.

Returns the deposit tokens paginated.

function getPaginatedDepositTokens(
uint256 offset,
uint256 limit
)
external
view
returns (address[] memory tokens);

Parameters

NameTypeDescription
offsetuint256The offset.
limituint256The limit.

Returns

NameTypeDescription
tokensaddress[]The deposit tokens.

Returns paginated projects by deposit token.

function getPaginatedProjectsByDepositToken(
address depositTokenAddress,
uint256 offset,
uint256 limit
)
external
view
returns (address[] memory projects);

Parameters

NameTypeDescription
depositTokenAddressaddressThe deposit token address.
offsetuint256The offset.
limituint256The limit.

Gets the unique deployer addresses count.

This function is used for pagination.

function getDeployerAddressesCount() external view returns (uint256 count);

Returns

NameTypeDescription
countuint256The deployer addresses count.

Returns the unique deployer addresses in paginated format.

function getPaginatedDeployerAddresses(
uint256 offset,
uint256 limit
)
external
view
returns (address[] memory deployerAddresses);

Parameters

NameTypeDescription
offsetuint256The offset to start from.
limituint256The limit of deployer addresses to return.

Returns

NameTypeDescription
deployerAddressesaddress[]The deployer addresses array.

Returns the count of projects deployed by an address.

This function is used for pagination.

function getProjectsCountByDeployerAddress(address deployerAddress) external view returns (uint256);

Parameters

NameTypeDescription
deployerAddressaddressThe deployer address.

Returns

NameTypeDescription
<none>uint256The count of projects deployed by the address.

Returns paginated projects by deployer address.

function getPaginatedProjectsByDeployerAddress(
address deployerAddress,
uint256 offset,
uint256 limit
)
external
view
returns (address[] memory projects);

Parameters

NameTypeDescription
deployerAddressaddressThe deployer address.
offsetuint256The offset.
limituint256The limit.

Returns

NameTypeDescription
projectsaddress[]The projects.

Returns a preview quote for a specific fee.

function previewFee(
FeeType feeType,
address accountPaying,
uint256 originalAmount
)
external
view
returns (address chargeToken, uint256 chargeAmount);

Parameters

NameTypeDescription
feeTypeFeeTypeThe fee type.
accountPayingaddressThe account paying the fee.
originalAmountuint256The original amount.

Returns

NameTypeDescription
chargeTokenaddressThe token address to charge.
chargeAmountuint256The amount to charge.

Returns the certificate manager address.

function certificateNFTManagerAddress() external view returns (address nftManagerAddress);

Returns

NameTypeDescription
nftManagerAddressaddressThe certificate manager address.

This function is used to get the fee details.

function getPlatformFee(
FeeType feeType,
address accountPaying
)
external
view
returns (PlatformFee memory feeDetails);

Parameters

NameTypeDescription
feeTypeFeeTypeThe fee type.
accountPayingaddressThe account paying the fee.

Returns

NameTypeDescription
feeDetailsPlatformFeeThe fee details.

This function is used to get the current royalty fee.

function getRoyaltyFee(address projectAddress) external view returns (uint256 royaltyFee);

Parameters

NameTypeDescription
projectAddressaddressThe project address.

Returns

NameTypeDescription
royaltyFeeuint256The current royalty fee.

Sets the certificate manager address.

Only the root admin can call this function.

function setCertificateNFTManagerAddress(address newCertificateNFTManagerAddress) external;

Parameters

NameTypeDescription
newCertificateNFTManagerAddressaddressThe address of the certificate manager.

Sets the fee recipient address.

Only the root admin can call this function.

function setFeeRecipientAddress(address newFeeRecipientAddress) external;

Parameters

NameTypeDescription
newFeeRecipientAddressaddressThe address of the fee recipient.

Sets the super admin address.

Only the root admin can call this function.

function setSuperAdminAddress(address newSuperAdminAddress) external;

Parameters

NameTypeDescription
newSuperAdminAddressaddressThe address of the super admin.

Sets the TokenRouter address.

Only the root admin can call this function.

function setTokenRouterAddress(address newTokenRouterAddress) external;

Parameters

NameTypeDescription
newTokenRouterAddressaddressThe address of the TokenRouter.

Sets the project facet cuts.

Only the root admin can call this function.

function setProjectDiamondData(ProjectDiamondData calldata data) external;

Parameters

NameTypeDescription
dataProjectDiamondDataThe project diamond data.

Sets the platform fee.

Only the root admin can call this function.

function setPlatformFee(
FeeType feeType,
PlatformFee calldata platformFee,
address accountOverride
)
external;

Parameters

NameTypeDescription
feeTypeFeeTypeThe fee type.
platformFeePlatformFeeThe platform fee.
accountOverrideaddressThe account to override the fee for.

Sets the royalty fee in the Marketplace for a project.

Use address(0) for global default.

function setRoyaltyFee(address projectAddress, uint256 royaltyFee) external;

Parameters

NameTypeDescription
projectAddressaddressThe project address to set the royalty fee for.
royaltyFeeuint256The royalty fee to set bps (1/100000).

This function effectively charges the fee.

function payFee(
FeeType feeType,
address accountPaying,
address paymentTokenAddress,
uint256 originalAmount
)
external
returns (uint256 chargeAmount);

Parameters

NameTypeDescription
feeTypeFeeTypeThe fee type.
accountPayingaddressThe account paying the fee.
paymentTokenAddressaddressThe payment token address suggested by the project (will be checked against the fee token)
originalAmountuint256The original amount.

Returns

NameTypeDescription
chargeAmountuint256The amount charged.

Creates a project.

function createProject(ProjectArgs calldata projectArgs)
external
payable
returns (address projectAddress);

Parameters

NameTypeDescription
projectArgsProjectArgsThe init args.

Returns

NameTypeDescription
projectAddressaddressThe project address.

Event emitted when a project is created

event ProjectCreated(address indexed projectAddress, address indexed baseTokenAddress);

Parameters

NameTypeDescription
projectAddressaddressThe address of the project
baseTokenAddressaddressThe address of the base token
event FeeRecipientAddressChange(address oldFeeRecipientAddress, address newFeeRecipientAddress);
event SuperAdminAddressChange(address oldSuperAdminAddress, address newSuperAdminAddress);
event CertificateNFTManagerAddressChange(
address oldCertificateNFTManagerAddress, address newCertificateNFTManagerAddress
);
event TokenRouterAddressChange(address oldTokenRouterAddress, address newTokenRouterAddress);

Event emitted when a project diamond data is changed

event ProjectDiamondDataChange(ProjectDiamondData newDiamondData);

Parameters

NameTypeDescription
newDiamondDataProjectDiamondDataThe new diamond data, see ProjectDiamondData struct

Event emitted when a royalty fee is changed

event RoyaltyFeeChange(address indexed projectAddress, RoyaltyFee newRoyaltyFee);

Parameters

NameTypeDescription
projectAddressaddress(indexed) The project address
newRoyaltyFeeRoyaltyFeeThe new royalty fee, see RoyaltyFee struct

Event emitted when a royalty fee is removed

event RoyaltyFeeRemoval(address indexed projectAddress);

Parameters

NameTypeDescription
projectAddressaddress(indexed) The project address

Event emitted when a platform fee is changed

event PlatformFeeChange(address indexed beneficiary, FeeType indexed feeType, PlatformFee newFee);

Parameters

NameTypeDescription
beneficiaryaddress{indexed} The beneficiary of the fee
feeTypeFeeType{indexed} The type of fee (FeeType enum)
newFeePlatformFeeThe new fee details, see PlatformFee struct

Error for when the address is the zero address

Used when the zero address could catastrophically affect the system

error ZeroAddress();

Error for when the address is not a project

error NotAProject();

Error for when the charge type for quoting/payment is invalid

error InvalidChargeType();

Error for when the sent ether is insufficient

error InsufficientEth();

Error for when the fee cannot be sent to the recipient

error SendFeeFailed();

Error for when ETH is sent directly to the MainHub

error CannotReceiveEther();

Error for when the fee is too high

error FeeTooHigh();

Error for when the token for payment is not a valid token

error InvalidPaymentToken(address expectedTokenAddress, address receivedTokenAddress);

Parameters

NameTypeDescription
expectedTokenAddressaddressThe expected token address
receivedTokenAddressaddressThe received token address

Error for when the allowance is insufficient

error InsufficientAllowance();

Error for when the token balance is insufficient

error InsufficientTokenBalance(uint256 expectedBalance, uint256 actualBalance);

Parameters

NameTypeDescription
expectedBalanceuint256The expected balance
actualBalanceuint256The actual balance

FeeToken is a struct to represent the token used for fees

struct FeeToken {
address tokenAddress;
bool isEther;
bool isAnyToken;
}

Properties

NameTypeDescription
tokenAddressaddressThe address of the token
isEtherboolWhether the token is Ether
isAnyTokenboolWhether to accept any token

HolderDiscount is a struct to represent the discount for holders

struct HolderDiscount {
uint256 percentage;
uint256 requiredBalance;
}

Properties

NameTypeDescription
percentageuint256The percentage of the discount
requiredBalanceuint256The required balance to receive the discount

HolderDiscountTier is a struct to represent the discount tiers for holders

struct HolderDiscountTier {
address tokenAddress;
HolderDiscount[] discountTiers;
}

Properties

NameTypeDescription
tokenAddressaddressThe address of the token
discountTiersHolderDiscount[]The discount tiers

PlatformFee is a struct to represent the fees for the platform

struct PlatformFee {
ChargeType chargeType;
uint256 chargeAmount;
FeeToken feeToken;
HolderDiscountTier holderDiscountTier;
}

Properties

NameTypeDescription
chargeTypeChargeTypeThe type of charge (percentage or flat)
chargeAmountuint256The amount of the charge
feeTokenFeeTokenThe token used for the fee
holderDiscountTierHolderDiscountTierThe discount tier for holders

RoyaltyFee is a struct to represent the royalty fee for a project

struct RoyaltyFee {
bool active;
uint256 percentage;
}

Properties

NameTypeDescription
activeboolWhether the royalty fee is active
percentageuint256The percentage of the royalty fee

ProjectDiamondData is a struct to represent the diamond data for a project

struct ProjectDiamondData {
address diamondCutFacetAddress;
address diamondInitAddress;
IDiamondCut.FacetCut[] cuts;
}

Properties

NameTypeDescription
diamondCutFacetAddressaddressThe address of the diamond cut facet
diamondInitAddressaddressThe address of the diamond init
cutsIDiamondCut.FacetCut[]The facet cuts for the diamond

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 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
}