For the complete documentation index, see llms.txt. This page is also available as Markdown.

Adding Authorized Traders

Grant permission to accounts to trade on behalf of your Vault

You may want to grant or revoke approval from a particular Ethereum address to make trades on behalf of your Vault. Below is the process for querying which addresses are currently and editing that list appropriately.

import { IntegrationManager } from '@enzymefinance/protocol';
import { providers, Wallet } from 'ethers';

// an example provider
const provider = providers.StaticJsonRpcProvider(ethNodeAddress, ethNetwork); 

// an example wallet (a subclass of Signer that can be called directly)
const wallet = new Wallet(investorsEthPrivateKey, provider)

// the IntegrationManager contract address, available at contracts.enzyme.finance
const integrationManagerAddress = '0x23k20d...';

// the Vault's comptroller address, available at the vault dashboard at app.enzyme.finance
const vaultComptrollerAddress = '0x2d9es...';

// an arbitrary address; we'll permission it if it's not already and
// revoke permission if it is.
const arbitraryAddress = '0x94d0s...';

// instantiate the Integration Manager contract
const integrationManagerContract = new IntegrationManager(
    integrationManagerAddress,
    wallet,
);

// determine whether the arbitrary address is currently permissioned
const isCurrentlyPermissioned = await integrationManagerContract.isAuthUserForFund(
    vaultComptrollerAddress,
    arbitraryAddress,
);

// conditionally instantiate the transaction
const authUserTx = !isCurrentlyPermissioneded
    ? integrationManagerContract.addAuthUserForFund.args(
        vaultComptrollerAddress,
        arbitraryAddress,
    ) 
    : integrationManagerContract.removeAuthUserForFund.args(
        vaultComptrollerAddress,
        arbitraryAddress,
    );

// send the transaction
const authUserTxReceipt = await authUserTx.send();
console.log('Pending transaction:', authUserTxReceipt.hash);
console.log('Transaction included in block number:', authUserTxReceipt.blockNumber);

Last updated

Was this helpful?