Factory

General

Factory contracts are utilities for the creation of the many component contracts and infrastructure providing services to watermelon 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 returns (bool)

This public 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 watermelon 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 _version - The address of the Version contract. address _engine - The address of the Version’s Engine contract. address _factoryPriceSource - The address of the Version’s FactoryPriceSource contract. address _mlnToken - The address of the MLN Token contract.  

Structs

Settings

Member variables:

string name - The name of the watermelon fund. address[] exchanges - An array of exchange contract addresses registered for the watermelon fund. address[] adapters - An array of exchange adapter contract addresses registered for the watermelon fund. address denominationAsset - The address of the asset token in which the watermelon fund is denominated. address nativeAsset - The address of the asset token designated as the watermelon fund’s native asset, i.e. the watermelon fund’s native network token. address[] defaultAssets - An array of addresses designating the watermelon 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 watermelon fund’s price source. address[] fees - An array of addresses of the watermelon fund’s registered fee contracts. uint[] feeRates - An array of integers representing the fee rates registered for the watermelon 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 the executing the implementing function’s functionality.  

Events

NewFund()

`address manager` - The address of the water<b>melon</b> fund's manager.
`address hub` - The address of the water<b>melon</b> fund's `hub`.
`address[12] routes` - An array of 12 address representing relevant water<b>melon</b> fund component addresses.

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

Public State Variables

address public factoryPriceSource

This public state variable represents the Version’s price source contract.  

address public mlnToken

This public state variable represents MLN token contract.  

VersionInterface public version

This public state variable represents the Version contract.  

address public engine

This public state variable represents the Version’s watermelon Engine 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 _compliance, // address[] _policies, address[] _fees, uint[] _feeRates, uint[] _feePeriods, address[] _exchanges, address[] _adapters, address _denominationAsset, address _nativeAsset, address[] _defaultAssets, bool[] _takesCustody, address _priceSource ) componentNotSet(managersToHubs[msg.sender])

This public function takes the following parameters and initiates the set up process of a watermelon fund. The function implements the componentNotSet() modifier ensuring its one-time execution in the watermelon 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() componentNotSet(managersToRoutes[msg.sender].accounting) amguPayable payable

This public function creates the Accounting spoke of a watermelon 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 watermelon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment.  

function createFeeManager() componentNotSet(managersToRoutes[msg.sender].feeManager) amguPayable payable

This public function creates the FeeManager spoke of a watermelon 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 watermelon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment.  

function createParticipation() componentNotSet(managersToRoutes[msg.sender].participation) amguPayable payable

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

function createPolicyManager() componentNotSet(managersToRoutes[msg.sender].policyManager) amguPayable payable

This public function creates the PolicyManager spoke of a watermelon 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 watermelon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment.  

function createShares() componentNotSet(managersToRoutes[msg.sender].shares) amguPayable payable

This public function creates the Shares spoke of a watermelon 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 watermelon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment.  

function createTrading() componentNotSet(managersToRoutes[msg.sender].trading) amguPayable payable

This public function creates the Trading spoke of a watermelon 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 watermelon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment.  

function createVault() componentNotSet(managersToRoutes[msg.sender].vault) amguPayable payable

This public function creates the Vault spoke of a watermelon 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 watermelon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment.  

function completeSetup() amguPayable payable

This public function completes the set up of a watermelon 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 watermelon 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 watermelon fund setup process. The function is payable and also implements the amguPayable modifier, requiring amgu payment.  

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

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

function getLastFundId() public view returns (uint)

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

function engine() view returns (address)

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

function mlnToken() view returns (address)

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

function priceSource() view returns (address)

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

function version() view returns (address)

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

FundRanking.sol

Description

The contract defines a function which returns specified information on each watermelon 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) view returns( address[], uint[], uint[], string[], address[])

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

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