The Efficiency Protocol is Efficiency DAOs lending interface, based on Compound Protocol's Contracts.
The Efficiency Protocol offers supplying or borrowing assets through the BSC network. Through the eToken contracts, accounts on the blockchain supply capital (Bnb or BEP-20 tokens) to receive eTokens or borrow assets from the protocol (holding other assets as collateral). The Efficiency eToken contracts track these balances and algorithmically set interest rates for borrowers.
Before getting started with this repo, please read about Compound Protocol
For questions about interacting with Efficiency, please visit our Discord server.
For security concerns, please visit https://efficiency.finance/security or email security@efficiency.finance.
We detail a few of the core contracts in the Efficiency protocol.
- CToken, CErc20 and CEther
- The Compound cTokens, which are self-contained borrowing and lending contracts. CToken contains the core logic and CErc20 and CEther add public interfaces for Erc20 tokens and ether, respectively. Each CToken is assigned an interest rate and risk model (see InterestRateModel and Comptroller sections), and allows accounts to *mint* (supply capital), *redeem* (withdraw capital), *borrow* and *repay a borrow*. Each CToken is an ERC-20 compliant token where balances represent ownership of the market.
- Comptroller
- The risk model contract, which validates permissible user actions and disallows actions if they do not fit certain risk parameters. For instance, the Comptroller enforces that each borrowing user must maintain a sufficient collateral balance across all cTokens.
- Follow the existing naming schema (ControllerGX)
- Update the scenario runner in scenario/src/Builder/ComptrollerImplBuilder.ts
- Create unit tests and fork simulations as necessary
- Call
npx saddle deploy Comptroller -n mainnet
to deploy to mainnet and generate new ABI - The ABI can also be generated by deploying to mainnet in a fork simulation
- Call
node script/comptroller-abi
to merge the new Comptroller ABI with the Unitroller ABI - Ensure that commit contains new generated Comptroller ABI
-
Updating the Comptroller
- Comp
- The Compound Governance Token (COMP). Holders of this token have the ability to govern the protocol via the governor contract.
- Governor Alpha
- The administrator of the Compound timelock contract. Holders of Comp token may create and vote on proposals which will be queued into the Compound timelock and then have effects on Compound cToken and Comptroller contracts. This contract may be replaced in the future with a beta version.
- InterestRateModel
- Contracts which define interest rate models. These models algorithmically determine interest rates based on the current utilization of a given market (that is, how much of the supplied assets are liquid versus borrowed).
- Careful Math
- Library for safe math operations.
- ErrorReporter
- Library for tracking error codes and failure conditions.
- Exponential
- Library for handling fixed-point decimal numbers.
- SafeToken
- Library for safely handling Erc20 interaction.
- WhitePaperInterestRateModel
- Initial interest rate model, as defined in the Whitepaper. This contract accepts a base rate and slope parameter in its constructor.
To run efficiency protocol, pull the repository from GitHub and install its dependencies. You will need yarn or npm installed.
git clone https://github.com/EfficiencyDAO/compound-protocol
cd compound-protocol
yarn install --lock-file # or `npm install`
Hardhat contract tests are defined under the test directory. To run the tests run:
yarn test
Efficiency has forked compound protocol since commit : a3214f67b73310d547e00fc578e8355911c9d376. New features and PRs (back to compound) will be added in as necessary.
The summary of changes is as follows:
- Include hardhat for updated deployment configuration and testing
- Include Governance/EFF.sol to deploy the EFF token
- Setup an eMarkets deployment sequence with hardhat-deploy
- Remove
msg.sender == address(0)
from CToken and Comptroller - Remove
fixBadAccruals
from Comptroller, TBD after proposal 65 - Prevent EFF token transfer to contract address
- Remove SimplePriceOracle as its unused and unsafe
- Updated SafeMath contract to a compatible version for solidity 0.8.x
- Add checks for whether contract's underlying balance stays the same before and after Sweep
- Optimize Comptroller's
liquidateCalculateSeizeTokens
function to prevent loss of precision - Gas optimization on Comptroller by reducing boolean === true checks
- Add a check to see if collateral to be seized has entered the market
- Use timestamps instead of block number for interest rate calculation
- Include FeedPriceOracle.sol, to fetch oracle prices from Chainlink
- Include Lockdrop.sol, for EFF lockdrop token distribution
- Prevent claim unlock times greater than 2 years for Lockdrop.sol
- Optimize gas, zero out account balance before ext call for Lockdrop.sol