A MaxConcentration
policy restricts a fund from trading if the trade would increase the size of a fund's position in one asset over a given threshold as a percentage of the fund's portfolio.
This example requires an environment instance as described here.
One thing to note: to deploy specific policy contracts, you must pass the corresponding byte code to the that contract's deployment method.
import { Hub, MaxConcentration, PolicyManager } from '@melonproject/melonjs';import { MaxConcentrationBytecode } from '@melonproject/melonjs/abis/MaxConcentration.bin';// your hub addressconst hubAddress = '0x05263237f43190ce0e93b48afb25dd60a03ad3c5';// the address of the fund's managerconst fundManager = '0x0b64bf0fae1b9ffa80cd880f5b82d467ee34c28e';// declare an instance of the fund's hub to access the spoke contract addressesconst hub = new Hub(environment, hubAddress);// the address of the fund's PolicyManger contractconst policyManagerAddress = hub.getRoutes().policyManager;// the number, in percent, you'd like to set for MaxConcentrationconst concentration = 10;// specify the gas price (refer to http://ethgasstation.info/)const gasPrice = 30000000000;// declare the instance of the fund's PolicyManager contractconst manager = new PolicyManager(environment, policyManagerAddress);// execute the deployment transactionconst deploymentTx = MaxConcentration.deploy(environment,MaxConcentrationByteCode,fundManager,concentration);const deploymentOpts = await deploymentTx.prepare({gasPrice});const deploymentReceipt = await deploymentTx.send(deploymentOpts);// assign the proper address and signature to pass to the registration transactionconst maxConcSig = deploymentReceipt.signature;const maxConcAddr = deploymentReceipt.address;// execute the registration transactionconst registerTx = manager.registerPolicy(fundManager, maxConcSig, maxConcAddr);const registerOpts = await registerTx.prepare({ gasPrice });const registerReceipt = await registerTx.send(registerOpts);