Kompound is a smart contract project that enables users to interact with the Compound protocol for lending and borrowing assets. It supports both ERC20 tokens and ETH, and implements a "long" strategy. The project also includes liquidation functionality.
The Kompound project is designed with a modular architecture, comprising several smart contracts that interact with each other and with external protocols like Compound and Uniswap. The core contracts handle lending, borrowing, and liquidation functionalities, while interfaces define the interactions with external protocols.
graph LR
A[User] --> B(KompoundErc20);
A --> C(kompoundEth);
B --> D(Compound Protocol);
C --> D;
D --> E(ERC20 Tokens);
D --> F(ETH);
B --> G(Uniswap);
C --> G;
G --> H(Liquidity Pool);
To deploy the contracts on a Hardhat node, follow these steps:
-
Start a Hardhat node:
npx hardhat node
-
Deploy the contracts using Hardhat Ignition, specifying the network as
localhost
:npx hardhat ignition deploy ./ignition/modules/KompoundModule.ts --network localhost
KompoundErc20.sol
: Handles interactions with ERC20 tokens in the Compound protocol.kompoundEth.sol
: Handles interactions with ETH in the Compound protocol.KompoundLong.sol
: Implements a "long" strategy within the Compound protocol.KompoundLiquidate.sol
: Handles liquidation events within the Compound protocol.
IERC20.sol
: Standard ERC20 interface.compound/
: Interfaces for interacting with the Compound protocol's core contracts (CErc20, CEth, Comptroller).uniswap/
: Interfaces for interacting with Uniswap V2 (Factory, Pair, Router).
MockCERC20.sol
,MockCEther.sol
,MockComptroller.sol
,MockERC20.sol
,MockPriceFeed.sol
: Mock contracts for testing purposes.
KompoundModule.ts
: Hardhat Ignition module for deploying the Kompound contracts.MainnetKompoundModule.ts
: Hardhat Ignition module for deploying the Kompound contracts on mainnet.
To get started with the project, follow these steps:
-
Clone the repository:
git clone <repository_url>
-
Install the dependencies:
yarn install
-
Compile the contracts:
npx hardhat compile
-
Run the tests:
npx hardhat test
-
Deploy the contracts using Hardhat Ignition:
npx hardhat ignition deploy ./ignition/modules/KompoundModule.ts
This project is licensed under the MIT License - see the LICENSE file for details.