Editing a Vault's Permissioned Investors

Changing a Vault's policy settings

In the example below, we'll query the settings for a vault's implementation of the investor whitelist policy, then update it. Note that most policies cannot be changed once a Vault has been configured and deployed; only the investor whitelist and the investment limits.

import { InvestorWhitelist, PolicyManager, investorWhitelistArgs } from '@enzymefinance/protocol';
import { providers, BigNumber, Wallet, constants } from 'ethers';

const provider = providers.StaticJsonRpcProvider(ethNodeAddress, ethNetwork); 
const signer = new Wallet(investorsEthPrivateKey, provider);

// the address of the investor whitelist policy, available at contracts.enzyme.finance
const whitelistPolicyAddress = '0xsow9o...';

// the address of the policy manager contract, avalable at contracts.enzyme.finance
const policyManagerAddress = '0xw923...';

// the comptroller address of the vault in question, available at the 
// vault's overview page at app.enzyme.finance
const vaultComptrollerAddress = '0xwdfn289s...'; 

const whitelistContract = new InvestorWhitelist(
    whitelistPolicyAddress,
    provider,
);

// an arbitrary address to add or remove to the whitelist
// if the address does not exist in the list, we'll update it
// if the address does exist in the list, we'll remove it
const arbitraryAddress = '0x2iws...';

const addressIsInList = await whitelistContract.isInList(arbitraryAddress);

const investorsToAdd = addressIsInList ? undefined : [arbitraryAddress];
const investorsToRemove = addressIsInList ? [arbitraryAddress] : undefined;

const updatedPolicySettings = investorWhitelistArgs({
    investorsToAdd,
    investorsToRemove,
});

const policyManagerContract = new PolicyManager(
    policyManagerAddress,
    signer
);

const policyUpdateTx = policyManagerContract.updatePolicySettingsForFund.args(
    vaultComptrollerAddress,
    whitelistPolicyAddress,
    updatedPolicySettings,
);

const policyUpdateTxReceipt = await policyUpdateTransaction.send();
console.log('Pending transaction:', policyUpdateTxReceipt.hash);
console.log('Transaction included in block number:', policyUpdateTxReceipt.blockNumber);

Last updated