Redeeming Shares in an Enzyme Vault
Selling your shares in a vault
There are two distinct functions for redeeming shares in an Enzyme vault; one is used if you want to redeem all of your shares, and another is used if you want to redeem a specific amount.
import { ComptrollerLib, StandardToken } from '@enzymefinance/protocol';
import { providers, BigNumber, Wallet, constants, utils } from 'ethers';
const provider = providers.StaticJsonRpcProvider(ethNodeAddress, ethNetwork);
const signer = new Wallet(investorsEthPrivateKey, provider);
// the vault's address, available on the vault's dashboard in the Enzyme app
const vaultAddress = '0x8syweo...';
// instantiate the vault token contract
const vaultToken = new StandardToken(vaultAddress, provider);
// check the investor's current balance
const sharesBalance = await vaultToken.balanceOf(signer.address);
// this is an arbitrary number
const sharesToRedeem = utils.parseUnits('1', 18);
// the vault's comptroller address, available on the vault's dashboard in the Enzyme app
const comptrollerAddress = '0x8syweo...'
const comptrollerContract = new ComptrollerLib(comptrollerAddress, signer);
const redeemTx =
? comptrollerContract.redeemSharesDetailed.args(
[], // additional assets
[], // assets to skip. These two parameters are adjustable but most commonly left empty
: comptrollerContract.redeemShares();
const redeemTxReceipt = await redeemTx.send();
console.log('Pending transaction:', redeemTxReceipt.transactionHash);
console.log('Transaction included in block number:', redeemTxReceipt.blockNumber);
Copy link