Calling Contract Functions
Retrieve information or execute transactions on the blockchain
State Getters
State-getters are easily called and require no arguments. For the ComptrollerLib
, you can reference what queries are available here.
State Changing Functions
Contract function calls that change state on Ethereum can be thought of as two steps:
Passing arguments to the function to instantiate a transaction object
Doing Ethereum things with that object
Preparing Arguments: Helper Functions
Extension contract class methods require their arguments to be encoded into formatted strings to be interpreted by the smart contracts. The Enzyme SDK ships with helper functions that, when passed the correct parameters, output the appropriate string. TypeScript will describe the arguments that must be passed to your class' helper functions. These arguments are named semantically and should be easily interpreted. You can browse these utility functions (and some others) here, and see one in use here and here.
For example, to trade into or out of a cToken on Compound via Enzyme, you need to prepare three parameters: cToken
, which is the address of the cToken in question, minIncomingAssetAmount
and outgoingAssetAmount
which are self-explanatory. These parameters then must be passed to an compoundArgs
function which encodes them in the appropriate way. The value returned from that function is then passed to the contract method to execute the trade.
These methods will be used frequently in the examples to follow.
Call On Extension
Extensions
are contracts that enable Vault configuration and interaction in a modular fashion. There are currently three types of extensions - fees, policies, and integration adapters.
All integration adapters must be called via a vault's Comptroller:
Assemble and encode
integration adapter contract
-specific function argumentsAssemble and encode
integrationManager
-specific argumentsPass encoded arguments to
ComptrollerProxy.callOnExtension.args()
along with three integration-specific arguments:
The
IntegrationManager
contract's address. This address is specific to each release of the protocol and can be found here.A
selector
that defines the function being called on the integration adapter. These selectors can be found here. The correct selector should be imported from the SDK.A member of the
IntegrationManagerActionId
enum, most usually.CallOnIntegration
. The enum should be imported from the SDK.
From there, your transaction is ready to verify, estimate, and send.
Last updated