The Hacken 2025 TRUST ReportKey findings on trust, security maturity, and the factors driving blockchain adoption.
Learn more

Audit name:

[SCA] Derivable | DEX | Aug2023

Date:

Dec 3, 2023

Table of Content

Introduction
Audit Summary
Document Information
System Overview
Executive Summary
Risks
Findings
Appendix 1. Severity Definitions
Appendix 2. Scope
Disclaimer

Want a comprehensive audit report like this?

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.

titlecontent
PlatformEVM
LanguageSolidity
TagsERC1155; ERC20; DEX
Timeline07/08/2023 - 04/12/2023
Methodologyhttps://hackenio.cc/sc_methodology

    Review Scope

    Repository 1https://github.com/derivable-labs/derivable-core
    Repository 2https://github.com/derivable-labs/shadow-token
    Repository 3https://github.com/derivable-labs/erc1155-maturity
    Commit 17b6e1a113131569504f02cf8dabac210f288d5ef
    Commit 2622ba0d5908e0a6d84717c6e80d5b4ac3dbfbcba
    Commit 3d1a4c1699415c87780ca40d14e184768bec7b8ab

    Audit Summary

    Total10/10
    Security Score

    10/10

    Test Coverage

    100%

    Code Quality Score

    10/10

    Documentation Quality Score

    10/10

    10Total Findings
    9Resolved
    0Accepted
    1Mitigated

    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

    NameSmart Contract Code Review and Security Analysis Report for Derivable
    Audited ByHacken
    Website-
    Changelog14/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-0621Requirements Violation
    fixed

    High
    F-2023-0624Check-Effects Interaction Violation
    fixed

    Medium
    F-2023-0623Unfinalized Code
    fixed

    Medium
    F-2023-0622EIP Standards Violation
    fixed

    Medium
    F-2023-0625Missing Zero Address Validation
    fixed

    Low
    I-2023-0133Bad Variable Naming
    mitigated

    Observation
    I-2023-0132Bad Require Messages
    fixed

    Observation
    I-2023-0131Non-Explicit Unit Size
    fixed

    Observation
    I-2023-0130Floating Pragma
    fixed

    Observation
    I-2023-0129Solidity Style Guide Violation
    fixed

    Observation
    1-10 of 10 findings

    Identify vulnerabilities in your smart contracts.

    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 1https://github.com/derivable-labs/derivable-core
    Repository 2https://github.com/derivable-labs/shadow-token
    Repository 3https://github.com/derivable-labs/erc1155-maturity
    Commit 17b6e1a113131569504f02cf8dabac210f288d5ef
    Commit 2622ba0d5908e0a6d84717c6e80d5b4ac3dbfbcba
    Commit 3d1a4c1699415c87780ca40d14e184768bec7b8ab
    WhitepaperNot provided
    Requirementsderivable-core
    Technical Requirementsderivable-core

    Contracts in Scope

    contracts
    Fetcher.sol (Repository 1) - contracts › Fetcher.sol (Repository 1)
    PoolBase.sol (Repository 1) - contracts › PoolBase.sol (Repository 1)
    PoolFactory.sol (Repository 1) - contracts › PoolFactory.sol (Repository 1)
    PoolLogic.sol (Repository 1) - contracts › PoolLogic.sol (Repository 1)
    Token.sol (Repository 1) - contracts › Token.sol (Repository 1)
    subs
    Storage.sol (Repository 1) - contracts › subs › Storage.sol (Repository 1)
    Constants.sol (Repository 1) - contracts › subs › Constants.sol (Repository 1)
    MetaProxy.sol (Repository 2) - contracts › MetaProxy.sol (Repository 2)
    Shadow.sol (Repository 2) - contracts › Shadow.sol (Repository 2)
    ShadowFactory.sol (Repository 2) - contracts › ShadowFactory.sol (Repository 2)
    token
    ERC1155
    ERC1155Maturity.sol (Repository 3) - contracts › token › ERC1155 › ERC1155Maturity.sol (Repository 3)
    libs
    TimeBalance.sol (Repository 3) - contracts › token › ERC1155 › libs › TimeBalance.sol (Repository 3)

    Disclaimer