Q1 2025 Web3 Security ReportAccess control failures led to $1.63 billion in losses
Discover report insights
  • Hacken
  • Audits
  • betswap-gg
  • [SCA] Betswap.gg / ERC20 / Dec2023
Betswap.gg logo

Betswap.gg

Audit name:

[SCA] Betswap.gg / ERC20 / Dec2023

Date:

Dec 5, 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 Betswap.gg team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.

Betswap is a protocol that allows users to migrate from an old ERC-20 to a new ERC-20 that follows the OFT standard from LayerZero.

titlecontent
PlatformEthereum
LanguageSolidity
TagsERC20
Timeline13/11/2023 - 04/12/2023
Methodologyhttps://hackenio.cc/sc_methodology

    Review Scope

    Repositoryhttps://github.com/pbnather/OFT-migration
    Commit75c715e81d0df9b44a6c16a3c966fb58a0bdb91e

    Audit Summary

    Total8.4/10
    Security Score

    10/10

    Test Coverage

    59.38%

    Code Quality Score

    10/10

    Documentation Quality Score

    10/10

    7Total Findings
    7Resolved
    0Accepted
    0Mitigated

    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 Betswap.gg
    Audited By
    Approved By
    Websitehttps://hacken.io
    Changelog30/01/2024 - Preliminary Report
    • Document

      Name
      Smart Contract Code Review and Security Analysis Report for Betswap.gg
      Audited By
      Approved By
      Changelog
      30/01/2024 - Preliminary Report

    System Overview

    PROJECT_NAME is a staking protocol with the following contracts:

    Token  — simple ERC-20 token that mints all initial supply to a deployer. Additional minting is not allowed.

    It has the following attributes:

    • Name: TokenName

    • Symbol: TST

    • Decimals: 18

    • Total supply: 100m tokens.

    Staking — a contract that rewards users for staking their tokens. APY depends on the tokens provided by the owner and could not be calculated before reward tokens are deposited.

    Privileged roles

    • The owner of the contract can arbitrarily add, delete and modify the addresses stored. It is therefore entitled to impersonate or change the logic of critical components of the system at will.

    • The owner can revoke a vesting if upon creation such a parameter was provided. On revoking all vested tokens till the moment are automatically released to the beneficiary account.

    Executive Summary

    Documentation quality

    The total Documentation quality score is 10 out of 10.

    • Technical documentation is not present, but since most of this is a fork of LayerZero it can be derived from there.

    • Functional Requirements are present.

    • NatSpec is present

    Code quality

    The total Code quality score is 10 out of 10.

    Test coverage

    Code coverage of the project is 59.38% (branch coverage).

    • Forked contracts are not tested deeply.

    Security score

    Upon auditing, the code was found to contain 1 critical, 0 high, 0 medium, and 4 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 8.4. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.

    Risks

    The contract owner possesses significant control over the contract, which includes the ability to blacklist users from migrating the old token to the new one, grant users the possibility to migrate even after the deadline has passed, change the exchange rate between the old token and the new one, set the deadline for the end of the migration, pause the migration contract, withdraw any ERC20 token from the migration contract and mint and infinite supply of the new token.

    The variable exchangeRate indicates the exchange rate between the old token that needs to be migrated and the new token, this value can be changed, and the team has the responsibility to set a proper value for this variable.

    Part of the documentation is missing and needs to be derived from the forked repository.

    There are a lot of interactions with out-of-scope contracts such as LayerZeroReceiver.sol, LayerZeroUserApplicationConfig.sol, and LayerZeroEndpoint.sol, these contracts were not included in the scope but might have an impact on the execution of the code.

    Findings

    Code
    Title
    Status
    Severity
    F-2023-1580Unrestricted Access to Minting Functions
    fixed

    Critical
    F-2023-1584Unrestricted token withdrawal in emergencyWithdraw() function
    fixed

    Low
    F-2023-1583Deadline vulnerability in the require condition
    fixed

    Low
    F-2023-158Pragma mismatch in OFTMintable.sol: non-overriding mint function in lower pragma versions.
    fixed

    Low
    F-2023-158Implementation of indexing for events is absent in the Migration contract
    fixed

    Low
    I-2023-041Limited token burning flexibility in the OFTMintable contract
    fixed

    Observation
    I-2023-0414Floating pragma
    fixed

    Observation
    1-7 of 7 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

    Repositoryhttps://github.com/pbnather/OFT-migration
    Commit75c715e81d0df9b44a6c16a3c966fb58a0bdb91e
    WhitepaperProvided
    RequirementsProvided
    Technical RequirementsProvided

    Contracts in Scope

    contracts
    Migration.sol - contracts/Migration.sol
    OFTMintable.sol - contracts/OFTMintable.sol
    interfaces
    ILayerZeroEndpoint.sol - contracts/interfaces/ILayerZeroEndpoint.sol
    ILayerZeroReceiver.sol - contracts/interfaces/ILayerZeroReceiver.sol
    ILayerZeroUserApplicationConfig.sol - contracts/interfaces/ILayerZeroUserApplicationConfig.sol
    lzApp
    LzApp.sol - contracts/lzApp/LzApp.sol
    NonblockingLzApp.sol - contracts/lzApp/NonblockingLzApp.sol
    oft
    IOFT.sol - contracts/oft/IOFT.sol
    IOFTCore.sol - contracts/oft/IOFTCore.sol
    OFT.sol - contracts/oft/OFT.sol
    OFTCore.sol - contracts/oft/OFTCore.sol
    IOFTMintable.sol - contracts/IOFTMintable.sol
    util
    BytesLib.sol - contracts/util/BytesLib.sol
    ExcessivelySafeCall.sol - contracts/util/ExcessivelySafeCall.sol

    Disclaimer