Introduction
We express our gratitude to the ENKI team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
ENKI is a blockchain ecosystem that can distribute rewards to its users on both chains. It combines ERC4626 standar with the Vesting opportunities. Users holding Staked ENKI Metis receive their rewards in eMetis, maintaining consistency and simplicity in the reward cycle. The vesting mechanism, tied to the ENKI token, encourages sustained engagement and investment in the ecosystem, aligning user incentives with the long-term success of ENKI.
| title | content |
|---|---|
| Platform | Ethereum (L1), Metis Andromeda (L2) |
| Language | Solidity |
| Tags | Multi-chain, Vesting, Incentive |
| Timeline | 20/02/2024 - 12/03/2024 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository | https://github.com/ENKIXYZ/lsd-contracts/tree/v2/contracts→ |
| Commit | 934933f |
| Remediation Commit | addd1fd |
Review Scope
- Commit
- 934933f
- Remediation Commit
- addd1fd
Audit Summary
10/10
100.0%
9/10
6/10
The system users should acknowledge all the risks summed up in the risks section of the report
Document Information
This report may contain confidential information about IT systems and the intellectual property of the Customer, as well as information about potential vulnerabilities and methods of their exploitation.
The report can be disclosed publicly after prior consent by another Party. Any subsequent publication of this report shall be without mandatory consent.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for ENKI |
| Audited By | Ataberk Yavuzer, Vladyslav Khomenko |
| Approved By | Grzegorz Trawinski |
| Website | https://www.enkixyz.com/→ |
| Changelog | 28/02/2024 - Preliminary Report |
| 11/03/2024 - Final Report |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for ENKI
- Audited By
- Ataberk Yavuzer, Vladyslav Khomenko
- Approved By
- Grzegorz Trawinski
- Website
- https://www.enkixyz.com/→
- Changelog
- 28/02/2024 - Preliminary Report
- 11/03/2024 - Final Report
System Overview
ENKI Protocol is a blockchain ecosystem with the following contracts:
ENKI Metis (eMetis) — an ERC-20 token, pegged 1:1 to Metis tokens circulating in ENKI system. It supports gasless transfers. ENKI Metis Minter — contract that allows the exchange of Metis for eMetis. Exchanging the other way is currently disabled due to outside factors (restrictions in the Metis Sequencer). Staked ENKI Metis (seMetis) — a token of an ERC4626 vault. Staking eMetis in it lets users earn rewards in form of eMetis for participating in ENKI system. Unstaking eMetis is done in 2 steps: part of the tokens are released immediately, other part is temporarily locked in vesting contract. Vesting — this contract holds eMetis and postpones its withdrawal to ensure participants of the ENKI system are committed to it. To withdraw eMetis users have to deposit ENKI coins and wait for vesting period to pass. eMetis is then unlocked gradually. ENKI — utility token of the ENKI protocol, used to provide access to the eMetis in the Vesting contract. Rewards Dispatcher — this contract distributes rewards for participating in ENKI system in form of eMetis. The protocol takes it's cut of the yield and sends the rest to seMetis vault for users to claim. Config — common contract that stores configuration for the whole system. Dealer and SequencerAgent — contracts that manage the layer 1 part of the system.
Privileged roles
Owner & Timelock:
Grant timelock and eMetis minter roles.
Timelock & Operator:
Grant and revoke various roles and capabilities.
Pause and unpause the protocol.
Make protocol public and vice versa.
Set protocol fee.
Set a cut of eMetis that goes to Vesting contract when eMetis is unstaked.
Minter:
Mint and burn eMetis tokens.
User:
Exchange Metis for eMetis.
Stake eMetis to generate rewards.
Unstake it and get part of the stake and rewards. Other part is kept in Vesting contract.
Stake ENKI to unlock the eMetis in Vesting contract.
Unstake ENKI and claim eMetis.
Beta User:
Can participate while the system is not public.
Executive Summary
Documentation quality
The total Documentation Quality score is 6 out of 10.
Whitepaper is not provided.
Litepaper is provided.
Functional requirements are partially missed.
Technical description is not provided.
Code quality
The total Code Quality score is 9 out of 10.
Several template code patterns were found.
The development environment is configured.
Test coverage
Code coverage of the project is 100% (branch coverage).
Deployment and basic user interactions are covered with tests.
ERC4626 test coverage is missed.
Interactions by several users are not tested thoroughly.
Security score
Upon auditing, the code was found to contain 0 critical, 1 high, 1 medium, and 5 low severity issues, leading to a security score of 4 out of 10. All significant findings were resolved during the remediation phase. The security score increased to 10 out of 10.
All identified issues are detailed in the “Findings” section of this report.
Summary
The comprehensive audit of the customer's smart contract yields an overall score of 9.4. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
The minter_burn_from() function allows accounts, whitelisted by the contract managers to burn eMetis tokens of any account.
The unstake() function has modifier forUser which prevent users from calling it when the protocol is paused. This way ENKI tokens can be temporarily withheld from users.
There is no safeguard against price manipulation on seMetis contract.
The RewardDispatcher contract grants unlimited approval to eMetisMinter contract. That contract can consume all eMetis tokens from RewardDispatcher contract.
There is a couple of centralization risks on Config contracts. Timelock and Operator roles can change vesting configuration while its already active.
Findings
Dealer.lockFor() and Dealer.setActive() functions do not check previous agent entriesCode ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2024-1063 | Price manipulation on the first liquidation | fixed | High | |
| F-2024-1101 | The contract managers are able to withdraw tokens from the contracts | fixed | Medium | |
| F-2024-1079 | Dealer.lockFor() and Dealer.setActive() functions do not check previous agent entries | fixed | Low | |
| F-2024-1071 | Owner can renounce its ownership | fixed | Low | |
| F-2024-1068 | Risk of centralization due to authority of Timelock and Operator roles in Vesting settings | accepted | Low | |
| F-2024-1066 | Timelock and Operator roles can renounce their permissions | fixed | Low | |
| F-2024-1064 | Unlimited approval granted to unrelated contract | fixed | Low | |
| F-2024-1077 | For loop optimizations | accepted | Observation | |
| F-2024-1076 | Unused imports | fixed | Observation | |
| F-2024-1074 | Floating pragma | fixed | Observation |
Appendix 1. Severity Definitions
When auditing smart contracts, Hacken is using a risk-based approach that considers Likelihood, Impact, Exploitability and Complexity metrics to evaluate findings and score severities.
Reference on how risk scoring is done is available through the repository in our Github organization:
Severity | Description |
|---|---|
Critical | Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation. |
High | High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation. |
Medium | Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category. |
Low | Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score. |
Severity
- Critical
Description
- Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation.
Severity
- High
Description
- High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation.
Severity
- Medium
Description
- Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category.
Severity
- Low
Description
- Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
|---|---|
| Repository | https://github.com/ENKIXYZ/lsd-contracts/tree/v2/contracts→ |
| Commit | 934933fc5963075ab6cbfa3a13bcf17b36480268 |
| Remediation Commit | addd1fd48d70a68ce6366088ab8fe80abd983a3b |
| Whitepaper | N/A |
| Requirements | N/A |
| Technical Requirements | N/A |
Scope Details
- Commit
- 934933fc5963075ab6cbfa3a13bcf17b36480268
- Remediation Commit
- addd1fd48d70a68ce6366088ab8fe80abd983a3b
- Whitepaper
- N/A
- Requirements
- N/A
- Technical Requirements
- N/A