Factory

General

Factory contracts are utilities for the creation of the many component contracts and infrastructure providing services to Melon funds.  

Factory.sol

Description

The contract is a base contract which defines base elements below. It is inherited by all factory contracts.  

Inherits from

None.  

On Construction

None.

 

Structs

None.

 

Enums

None.

 

Modifiers

None.

 

Events

event NewInstance()

`address indexed hub` - The address of the `hub` corresponding to the created contract.
`address indexed instance) - The address of the created contract.

This event is triggered when a the Factory creates a new contract. The parameters listed above are logged with the event.  

Public State Variables

mapping (address => bool) public childExists

This public mapping state variable maps an address to boolean. It is used to determine whether an address is that of a contract created by the Factory.  

Public Functions

function isInstance(address _child) public view returns (bool)

This public view function returns a boolean indicating whether the address provided corresponds to a contract created by the Factory contract.  

FundFactory.sol

Description

This contract manages and executes the orderly creation of a new Melon fund, linking all aspects of components, settings, routings and permissions.  

Inherits from

Factory, AmguConsumer (link)  

On Construction

The contract constructor requires the following address parameters and sets the corresponding address state variables:

address _accountingFactory - The address of the Version’s AccountingFactory contract. address _feeManagerFactory - The address of the Version’s FeeManagerFactory contract. address _participationFactory - The address of the Version’s ParticipationFactory contract. address _sharesFactory - The address of the Version’s SharesFactory contract. address _tradingFactory - The address of the Version’s TradingFactory contract. address _vaultFactory - The address of the Version’s VaultFactory contract. address _policyManagerFactory - The address of the Version’s PolicyManagerFactory contract. address _registry - The address of the Version’s Registry contract. address _version - The address of the Version contract.  

Structs

Settings

Member variables:

string name - The name of the Melon fund. address[] exchanges - An array of exchange contract addresses registered for the Melon fund. address[] adapters - An array of exchange adapter contract addresses registered for the Melon fund. address denominationAsset - The address of the asset token in which the Melon fund is denominated. address nativeAsset - The address of the asset token designated as the Melon fund’s native asset, i.e. the Melon fund’s native network token. address[] defaultAssets - An array of addresses designating the Melon fund’s accepted asset tokens for subscription. bool[] takesCustody - An array of booleans mirroring an exchange contract’s takesCustody state variable. address priceSource - The address of the Melon fund’s price source. address[] fees - An array of addresses of the Melon fund’s registered fee contracts. uint[] feeRates - An array of integers representing the fee rates registered for the Melon fund. uint[] feePeriods - An array of integer representing the the duration of a fee performance measurement period in seconds.  

Enums

None.

 

Modifiers

modifier componentNotSet(address _component)

This modifier enables a function to enforce the single execution of the implementing function and is evaluated prior to executing the implementing function’s functionality.  

modifier componentSet(address _component)

This modifier requires that the provided _component is set, i.e. exists. The condition is evaluated prior to executing the implementing function’s functionality.  

Events

NewFund()

`address indexed manager` - The address of the Melon fund's manager.
`address indexed hub` - The address of the Melon fund's `hub`.
`address[12] routes` - An array of 12 address representing relevant Melon fund component addresses.

This event is emitted when the FundFactory creates a new fund. The event logs the parameters listed above.  

Public State Variables

VersionInterface public version

This public state variable represents the Version contract.  

address public registry

This public state variable represents the Version’s Registry contract.  

AccountingFactory public accountingFactory

This public state variable represents the Version’s AccountingFactory contract.  

FeeManagerFactory public feeManagerFactory

This public state variable represents the Version’s FeeManagerFactory contract.  

ParticipationFactory public participationFactory

This public state variable represents the Version’s ParticipationFactory contract.  

PolicyManagerFactory public policyManagerFactory

This public state variable represents the Version’s PolicyManagerFactory contract.  

SharesFactory public sharesFactory

This public state variable represents the Version’s SharesFactory contract.  

TradingFactory public tradingFactory

This public state variable represents the Version’s TradingFactory contract.  

VaultFactory public vaultFactory

This public state variable represents the Version’s VaultFactory contract.  

address[] public funds

This public state variable address array represents all fund contract addresses created by the FundFactory.  

mapping (address => address) public managersToHubs

This public state variable mapping maps an address to an address, creating a relationship of manager to hub.  

mapping (address => Hub.Routes) public managersToRoutes

This public state variable mapping maps an address to a Routes struct, creating a relationship of manager to Routes.  

mapping (address => Settings) public managersToSettings

This public state variable mapping maps an address to Settings struct, creating a relationship of manager to Settings. This mapping is only used internally.  

Public Functions

function beginSetup( string _name, address[] _fees, uint[] _feeRates, uint[] _feePeriods, address[] _exchanges, address[] _adapters, address _denominationAsset, address _nativeAsset, address[] _defaultAssets, bool[] _takesCustody ) public componentNotSet(managersToHubs[msg.sender])

This public function takes the following parameters and initiates the set up process of a Melon fund. The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function requires that the Version is not shut down. The function then creates a new Hub owned by msg.sender with the name provided. The Hub is then added to the managersToHubs mapping, mapped to the msg.sender (manager). A Settings struct is constructed from the requisite parameter values and is added to the managersToSettings mapping, mapped to the msg.sender (manager). Finally, the function the proceeds to populate the managersToRoutes mapping by mapping the msg.sender (manager) address to the following individual Routes elements: priceSource, registry, version, engine and mlnToken.  

function createAccounting() external componentSet(managersToHubs[msg.sender]) componentNotSet(managersToRoutes[msg.sender].accounting) amguPayable(false) payable

This external function creates the Accounting spoke of a Melon fund and adds the resulting contract address to the managersToRoutes mapping, mapped to the msg.sender (manager). The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function createFeeManager() external componentSet(managersToHubs[msg.sender]) componentNotSet(managersToRoutes[msg.sender].feeManager) amguPayable(false) payable

This external function creates the FeeManager spoke of a Melon fund and adds the resulting contract address to the managersToRoutes mapping, mapped to the msg.sender (manager). The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function createParticipation() external componentSet(managersToHubs[msg.sender]) componentNotSet(managersToRoutes[msg.sender].participation) amguPayable(false) payable

This external function creates the Participation spoke of a Melon fund and adds the resulting contract address to the managersToRoutes mapping, mapped to the msg.sender (manager). The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function createPolicyManager() external componentSet(managersToHubs[msg.sender]) componentNotSet(managersToRoutes[msg.sender].policyManager) amguPayable(false) payable

This external function creates the PolicyManager spoke of a Melon fund and adds the resulting contract address to the managersToRoutes mapping, mapped to the msg.sender (manager). The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function createShares() external componentSet(managersToHubs[msg.sender]) componentNotSet(managersToRoutes[msg.sender].shares) amguPayable(false) payable

This external function creates the Shares spoke of a Melon fund and adds the resulting contract address to the managersToRoutes mapping, mapped to the msg.sender (manager). The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function createTrading() external componentSet(managersToHubs[msg.sender]) componentNotSet(managersToRoutes[msg.sender].trading) amguPayable(false) payable

This external function creates the Trading spoke of a Melon fund and adds the resulting contract address to the managersToRoutes mapping, mapped to the msg.sender (manager). The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function createVault() external componentSet(managersToHubs[msg.sender]) componentNotSet(managersToRoutes[msg.sender].vault) amguPayable(false) payable

This external function creates the Vault spoke of a Melon fund and adds the resulting contract address to the managersToRoutes mapping, mapped to the msg.sender (manager). The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function completeSetup() external amguPayable(false) payable

This external function completes the set up of a Melon fund. The function ensure the childExists mapping does not contain the hub address, then adds the hub address. The function then sets all of the hub’s spokes, routing, permissions and then adds the hub address to the funds state variable address array. The new Melon fund is then registered with the Version Registry. The function finally emits the NewFund() event, logging all parameter values as specified above. The function implements the componentNotSet() modifier ensuring its one-time execution in the Melon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment. Here, the deductIncentive parameter is set to false.  

function getFundById(uint withId) external view returns (address)

This external view function returns the address of the Melon fund given the withId value provided, which is the index of of the funds address array state variable.  

function getLastFundId() external view returns (uint)

This external view function returns the index position of the most recently added Melon fund to the funds array state variable.  

function engine() public view returns (address)

This public view function returns the address of the Melon Engine contract.  

function mlnToken() public view returns (address)

This public view function returns the address of the MLN token contract.  

function priceSource() public view returns (address)

This public view function returns the address of the PriceSource contract.  

function version() public view returns (address)

This public view function returns the address of the Version contract.  

function registry() public view returns (address)

This public view function returns the address of the Registry contract.  

FundRanking.sol

Description

The contract defines a function which returns specified information on each Melon fund created under a specific Version.  

Inherits from

None.

 

On Construction

None.

 

Structs

None.

 

Enums

None.

 

Modifiers

None.

 

Events

None.

 

Public State Variables

None.

 

Public Functions

function getFundDetails( address _factory) external view returns( address[], uint[], uint[], string[], address[])

This public view function gathers and returns the following Melon platform details for a specific Version, given the FundFactory address provided:

address[] - An exhaustive array of Hub (i.e. Melon fund) addresses. uint[] - An exhaustive array of each Melon fund’s current share price. uint[] - An exhaustive array of each Melon fund’s creation time. string[] - An exhaustive array of each Melon funds’ name. address[] - An exhaustive array of each Melon fund’s denomination asset token address.