Platform: Code4rena
Start Date: 11/12/2023
Pot Size: $90,500 USDC
Total HM: 29
Participants: 127
Period: 17 days
Judge: TrungOre
Total Solo HM: 4
Id: 310
League: ETH
Rank: 70/127
Findings: 1
Award: $114.88
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Sathish9098
Also found by: 0xSmartContract, 14si2o_Flint, JayShreeRAM, Myd, SBSecurity, beber89, hunter_w3b, invitedtea, pavankv
114.8801 USDC - $114.88
I formulated multiple stages with clearly defined goals in order to have a clear purpose and structure for the audit.
Stage | Activity | Time Spent |
---|---|---|
Preparation | When the contest was announced, I dedicated one week to better understand the defi lending space. I spent 3 days on Aave/Compound and MakerDao. This gave me a basic insight on how defi lending works and immensely helped me in my first lending audit. | 21h |
Reading | I started with documentation. After which, I went over the code 3 times bottom to top while taking as many notes as possible. The two main complexity for me were the governance structure and the calculations of the rebase mechanism | 43h |
Drawing | In order to clarify the vague mental model of the protocol that I currently had after the reading stage, I created diagrams that illustrated some of the main mechanisms of the protocol | 9h |
Investigation | By now I had a very long list of questions and preliminary findings so I took each item and investigated until I was certain I had the answer and/or I had clearly identified an issue. This involved heavy use of Foundry tests. | 32h |
Reports | One by one I wrote the submissions for all my findings and prepared foundry poc's where I deemed it necessary | 18h |
Total | 119h |
I created a number of diagrams to better illustrate how certain important mechanism function in the ECG system.
https://asset.cloudinary.com/dkwl8aepc/22b0d833ff69d4f0bc593259b05b963e
https://asset.cloudinary.com/dkwl8aepc/555c62c7ecb2ce64f9f2c4cae60edfb6
https://asset.cloudinary.com/dkwl8aepc/06caf4b4315578e65aeda6f7102abab0
https://asset.cloudinary.com/dkwl8aepc/1a66929965813130b79f833781c6b312
A critical question any defi lending question tries to answer is:
The correct value of collateral determines whether a loan is a happy source of profit or a disastrous bomb of bad debt just waiting to explode. It makes or breaks a lending protocol.
The first large lending protocols such as Aave, Compound and MakerDao all chose to delegate this task to an Oracle, a trusted external source of information.
Oracle protocols such as Chainlink often aggregate price information from many different sources to minimize the risk of price manipulations or stale prices.
Yet millions and millions are lost every year to due to exploits related to oracle manipulation.
The Ethereum Credit Guild is part of a new wave of lending protocols that try to answer the question of value without relying on external pricefeeds.
The documentation provides a good high-level overview of the system with an extremely detailed architecture diagram. This could be expanded with a more detailed description of the individual contracts.
There is a very high test coverage, which is very good. However, the tests only describe the most straightforward scenarios. There are no tests with multiple actors lending and borrowing, simulating an actual market environment.
Almost all functions have NatSpec and there are small comments throughout the code illustration the purpose of small pieces of code. So the code is quite clean.
The protocol suggest a number of attack ideas. In this section I answers to those questions for which I believe to have done sufficient investigation.
The Ethereum Credit Guild provides a novel approach to the idea of lending in defi combining open governance, with almost full free reign for actors, optimistic vetocray and economic incentives for them to be good shepherds.
An extremely complex puzzle which is very difficult and tricky to get right. There are some challenges as I have outlined in the risk part, but I do not believe these are impossible to overcome.
It has been absolute pleasure working with Eswak and OneTrueKirk, very rarely have I audited with with a protocol team that was this helpful and responsive!
119 hours
#0 - c4-pre-sort
2024-01-05T17:44:56Z
0xSorryNotSorry marked the issue as sufficient quality report
#1 - c4-judge
2024-01-31T04:52:35Z
Trumpero marked the issue as grade-b