Introduction
We express our gratitude to the Derivable team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Derion is a Perpetual Automated Market Maker (AMM) Protocol that offers infinite liquidity and no liquidation through a continuous compounding position with a novel family of asymptotic power curves.
| title | content |
|---|---|
| Platform | EVM |
| Language | Solidity |
| Tags | ERC1155; ERC20; DEX |
| Timeline | 07/08/2023 - 04/12/2023 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository 1 | https://github.com/derivable-labs/derivable-core→ |
| Repository 2 | https://github.com/derivable-labs/shadow-token→ |
| Repository 3 | https://github.com/derivable-labs/erc1155-maturity→ |
| Commit 1 | 7b6e1a113131569504f02cf8dabac210f288d5ef |
| Commit 2 | 622ba0d5908e0a6d84717c6e80d5b4ac3dbfbcba |
| Commit 3 | d1a4c1699415c87780ca40d14e184768bec7b8ab |
Review Scope
- Repository 2
- https://github.com/derivable-labs/shadow-token→
- Commit 1
- 7b6e1a113131569504f02cf8dabac210f288d5ef
- Commit 2
- 622ba0d5908e0a6d84717c6e80d5b4ac3dbfbcba
- Commit 3
- d1a4c1699415c87780ca40d14e184768bec7b8ab
Audit Summary
10/10
100%
10/10
10/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 Derivable |
| Audited By | Hacken |
| Website | - |
| Changelog | 14/08/2023 - Initial Review |
| 20/09/2023 - Second Review | |
| 04/12/2023 - Third Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Derivable
- Audited By
- Hacken
- Website
- -
- Changelog
- 14/08/2023 - Initial Review
- 20/09/2023 - Second Review
- 04/12/2023 - Third Review
System Overview
The Derivable project audit consists of different parts.
Derivable pool is a liquidity pool of perpetual derivatives for a single leverage. The participants of this system are long traders, short traders, and liquidity providers.
The ERC1155Maturity module implements an ERC1155 token with the additional functionality of adding a soft lock mechanism for newly minted tokens. These tokens gain their full functionality after the maturing time has elapsed.
The Shadow Token module is an extension of ERC-1155 that allows any of its IDs to deploy a Shadow ERC-20 token with its contract address for DeFi composability.
The files in the scope:
ERC1155Maturity.sol - The ERC1155 modification which allows for the maturing functionality.
IERC1155Maturity.sol - The interface for ERC1155Maturity.sol
TimeBalance.sol - The helper library for handling the maturing times of ERC1155Maturity.sol
MetaProxy.sol - The helper library for deploying shadow ERC20 contracts.
Shadow.sol - The ERC20 contract that is deployed by individual IDs of ERC1155Maturity tokens.
ShadowFactory.sol - The extension of ERC1155Maturity.sol which can deploy shadow tokens.
IERC1155Supply.sol - The interface for returning the totalSupply of ERC1155 tokens.
IShadowFactory.sol - The interface for the ShadowFactory.sol
PoolFactory.sol - Factory contract to deploy Derivable pool using ERC-3448.
PoolLogic.sol - The mathematic and finance logic of Derivable pool.
PoolBase.sol - The base implementation of Derivable pool.
Fetcher.sol - Interacts with oracles to obtain prices for swaps.
Token.sol - A single ERC-1155 token shared by all Derivable pools which is also a ShadowFactory extension.
Constants.sol - The contract for storing constant values.
Storage.sol - The contract responsible for some of the variables in PoolBase.sol.
Privileged roles
Users: Can trade long/short positions, and become liquidity providers.
Pools: Can mint, burn its specific tokens that are used in the pools. A pool has this functionality on its own tokens only.
Descriptor Setter: Sets a new descriptor or sets the address for ITokenDescriptor, which is responsible for storing the metadata of a token.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
Technical description is partially provided.
Code quality
The total Code quality score is 10 out of 10.
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.
Security score
Upon auditing, the code was found to contain 0 critical, 1 high, 3 medium, and 1 low severity issues. Out of these, 5 issues have been addressed and resolved, leading to a Security score of 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 10. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
There are no additional risks.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2023-0621 | Requirements Violation | fixed | High | |
| F-2023-0624 | Check-Effects Interaction Violation | fixed | Medium | |
| F-2023-0623 | Unfinalized Code | fixed | Medium | |
| F-2023-0622 | EIP Standards Violation | fixed | Medium | |
| F-2023-0625 | Missing Zero Address Validation | fixed | Low | |
| I-2023-0133 | Bad Variable Naming | mitigated | Observation | |
| I-2023-0132 | Bad Require Messages | fixed | Observation | |
| I-2023-0131 | Non-Explicit Unit Size | fixed | Observation | |
| I-2023-0130 | Floating Pragma | fixed | Observation | |
| I-2023-0129 | Solidity Style Guide Violation | 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 1 | https://github.com/derivable-labs/derivable-core→ |
| Repository 2 | https://github.com/derivable-labs/shadow-token→ |
| Repository 3 | https://github.com/derivable-labs/erc1155-maturity→ |
| Commit 1 | 7b6e1a113131569504f02cf8dabac210f288d5ef |
| Commit 2 | 622ba0d5908e0a6d84717c6e80d5b4ac3dbfbcba |
| Commit 3 | d1a4c1699415c87780ca40d14e184768bec7b8ab |
| Whitepaper | Not provided |
| Requirements | derivable-core→ |
| Technical Requirements | derivable-core→ |
Scope Details
- Repository 2
- https://github.com/derivable-labs/shadow-token→
- Commit 1
- 7b6e1a113131569504f02cf8dabac210f288d5ef
- Commit 2
- 622ba0d5908e0a6d84717c6e80d5b4ac3dbfbcba
- Commit 3
- d1a4c1699415c87780ca40d14e184768bec7b8ab
- Whitepaper
- Not provided
- Requirements
- derivable-core→
- Technical Requirements
- derivable-core→