- Clone the repo
- Run
yarn install
The following env variables are used in the repo. One way to set up these env
variables is to create a .env
in the root directory of this repo.
Required env variables:
ETHERSCAN_KEY=<key>
INFURA_KEY=<key>
Optional env variables:
SNOWTRACE_KEY=<key>
COINMARKETCAP_API_KEY=<key>
REPORT_GAS=true
ETH_PK=<eth-key> # takes precedence over MNEMONIC
MNEMONIC=<mnemonic>
The repo's Git hooks are defined the .githooks/
directory.
You can enable them by running:
# requires git version 2.9 or greater
git config core.hooksPath .githooks
You can skip pre-commit checks with the -n
flag:
git commit -n -m "commit without running pre-commit hook"
Currently, Avalanche mainnet and testnet (fuji) are supported. This means that deployment scripts, scenarios, and spider all work for Avalanche.
To use this project with other chains, the block explorer API key for your target chain must be set in .env (e.g. SNOWTRACE_KEY
for Avalanche).
An example deployment command looks like:
yarn hardhat deploy --network fuji --deployment usdc
Comet.sol - Contract that inherits CometMainInterface.sol
and is the implementation for most of Comet's core functionalities. A small set of functions that do not fit within this contract are implemented in CometExt.sol
instead, which Comet DELEGATECALL
s to for unrecognized function signatures.
CometExt.sol - Contract that inherits CometExtInterface.sol
and is the implementation for extra functions that do not fit within Comet.sol
, such as approve
.
CometInterface.sol - Abstract contract that inherits CometMainInterface.sol
and CometExtInterface.sol
. This interface contains all the functions and events for Comet.sol
and CometExt.sol
and is ERC-20 compatible.
CometMainInterface.sol - Abstract contract that inherits CometCore.sol
and contains all the functions and events for Comet.sol
.
CometExtInterface.sol - Abstract contract that inherits CometCore.sol
and contains all the functions and events for CometExt.sol
.
CometCore.sol - Abstract contract that inherits CometStorage.sol
, CometConfiguration.sol
, and CometMath.sol
. This contracts contains functions and constants that are shared between Comet.sol
and CometExt.sol
.
CometStorage.sol - Contract that defines the storage variables used for the Comet protocol.
CometConfiguration.sol - Contract that defines the configuration structs passed into the constructors for Comet.sol
and CometExt.sol
.
CometMath.sol - Contract that defines math functions that are used throughout the Comet codebase.
CometFactory.sol - Contract that inherits CometConfiguration.sol
and is used to deploy new versions of Comet.sol
. This contract will mainly be called by the Configurator during the governance upgrade process.
Configurator.sol - Contract that inherits ConfiguratorStorage.sol
. This contract manages Comet's configurations and deploys new implementations of Comet.
ConfiguratorStorage.sol - Contract that inherits CometConfiguration.sol
and defines the storage variables for Configurator.sol
.
Bulker.sol - Contract that allows multiple Comet functions to be called in a single transaction.
CometRewards.sol - Contract that allows Comet users to claim rewards based on their protocol participation.
Third-party contracts (e.g. OZ proxies) live under contracts/vendor
.
There are currently two Comet-related contracts that extend directly from the vendor contracts. The contracts are:
ConfiguratorProxy.sol - This contract inherits OZ's TransparentUpgradeableProxy.sol
. We override the _beforeFallback
function so that the proxy's admin can directly call the implementation. We only need this feature for the Configurator's proxy.
CometProxyAdmin.sol - This contract inherits OZ's ProxyAdmin.sol
. We created a new function called deployAndUpgradeTo
, which calls Configurator.deploy(0xCometProxy)
and upgrades Comet proxy's implementation to this newly deployed Comet contract. This function is needed so we can pass the address of the new Comet to the Proxy.upgrade()
call in one transaction.
Look at the scripts section inside package.json
to find all commands.
Compiles contracts.
yarn build
Contract linting is done via Solhint.
yarn lint-contracts
yarn lint-contracts:fix // will attempt to automatically fix errors
Solhint configuration is saved in .solhint.json
.