Class Instantiation
Importing a Contract Class and making it your own
Instantiating a Contract Class requires two steps. First, import the Contract you need from the SDK. Imports are explicit; read through the protocol architecture docs or the repo to understand which contract (or contracts) you will need.
import { ComptrollerLib } from '@enzymefinance/protocol'
Next, instantiate a new class by passing it two parameters:
  1. 1.
    The address at which the contract is located on chain. Vault-specific contract addresses are available on the Vault's overview page on the Enzyme app. Non vault-specific contract addresses can be found here.
  2. 2.
    A Signer object. A Signer is a class imported from ethers and instantiated per their documentation. It describes the user on whose behalf the contract is being instantiated (and who will eventually call any methods on the class) and a connection to an Ethereum node.
Ethers provides a good description of the Signer object, and it's beyond the scope of this document to go into more detail. You can see an example of how a signer object is instantiated and passed to an Enzyme class in practice in the example Enzyme Bot repo and accompanying blog post.
const address = '0xw23r...' // for example only
const signer = new Signer(privateKey, ethNodeAddress) // for example only
​
const vaultComptroller = new ComptrollerLib(address, signer)
Copy link