Q1 2025 Web3 Security ReportAccess control failures led to $1.63 billion in losses
Discover report insights
  • Hacken
  • Audits
  • polybet
  • [SCA] Polybet / Staking / Dec2023
Polybet logo

Polybet

Audit name:

[SCA] Polybet / Staking / Dec2023

Date:

Jan 21, 2024

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 Polybet team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.

Polybet is a staking platform that enables the staking of tokens (including various LP and PBT tokens) to earn PBT token rewards.

titlecontent
PlatformEVM
LanguageSolidity
TagsERC-20 Staking, ERC-20 Token
Timeline02.01.2024 - 09.01.2023
Methodologyhttps://hackenio.cc/sc_methodology

    Review Scope

    Repository; Commit
    • Review Scope

      Repository; Commit

    During the collaboration with Polybet, the system security was improved within several sequential commits. The last commit audited is 65d260c44293cc308aedec7308e93c1719c3bbc4.

    Audit Summary

    Total9.8/10
    Security Score

    10/10

    Test Coverage

    100%

    Code Quality Score

    9/10

    Documentation Quality Score

    10/10

    11Total Findings
    6Resolved
    5Accepted
    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 Polybet
    Audited ByStepan Chekhovskoi, Eren Gonen
    Approved ByAtaberk Yavuzer
    Websitehttps://polybet.com
    Changelog05.01.2024 - Preliminary Report
    09.01.2024 - Final Report
    • Document

      Name
      Smart Contract Code Review and Security Analysis Report for Polybet
      Audited By
      Stepan Chekhovskoi, Eren Gonen
      Approved By
      Ataberk Yavuzer
      Changelog
      05.01.2024 - Preliminary Report
      09.01.2024 - Final Report

    System Overview

    Polybet is a staking protocol with the following contracts:

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

    • Name: PBT

    • Symbol: PBT

    • Decimals: 18

    • Total supply: 1B tokens.

    PBTStaking — The PBT Staking contract enables users to stake PBT tokens and earn rewards in the form of additional PBT. It features a detailed reward mechanism based on the amount of tokens staked and the duration of staking, with a specific end block indicating the conclusion of the reward distribution period.

    • The deposit function automatically compounds earned rewards for staking.

    • The withdraw function withdraws all the earned rewards as well as the requested amount.

    PBTLPStaking - The LP token Staking contract enables users to stake LP tokens and earn rewards in the form of  PBT token. It features a detailed reward mechanism based on the amount of tokens staked and the duration of staking, with a specific end block indicating the conclusion of the reward distribution period.

    • Call to deposit or withdraw functions automatically causes rewards claim.

    PBTDistributor - The contract is designed for token distribution using a Merkle tree to verify claims. It allows users to claim PBT tokens if their address and claim amount are verified against the immutable Merkle root stored in the contract.

    Privileged roles

    The system does not introduce any privileged roles.

    Executive Summary

    Documentation quality

    The total Documentation Quality score is 10 out of 10.

    • Functional requirements are provided.

    • Technical description is provided.

    Code quality

    The total Code Quality score is 9 out of 10.

    • The PBTLPStaking and PBTStaking contracts have duplicated logic.

    • The development environment is configured.

    Test coverage

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

    • The code is fully covered with tests.

    Security score

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

    Risks

    The LP token (allowed to be staked in PBTLPStaking) contract is out of the audit scope, and therefore, the security of its interactions cannot be verified.

    System owners are required to manually transfer rewards to the PBTLPStaking, PBTStaking, and PBTDistributor contracts. There is no guarantee that the contracts are able to satisfy user reward claim requests. Due to the F-2024-0378 finding is not fully resolved, deposit to non-fully funded PBTStaking contract may lead to partial funds leak with a low probability. It is recommended to ensure the contract holds enough funds to cover estimated rewards before a deposit.

    PBTDistributor contract is not able to distribute funds to one user twice even if it was included in the provided Merkle tree several times.

    Findings

    Code
    Title
    Status
    Severity
    F-2024-0378Insufficient PBTStaking Funding Leads to User Funds Leak
    accepted

    Low
    F-2024-0373Undistributed Staking Rewards Lock
    accepted

    Low
    F-2024-0366LP Token Reentrancy Possibility
    fixed

    Low
    F-2024-0372Allowance of Deposits After Staking Period
    accepted

    Observation
    F-2024-0371Staking Contracts Logic Duplication
    accepted

    Observation
    F-2024-0370Lack of SafeERC20 Usage
    fixed

    Observation
    F-2024-0369Inefficient Gas Usage Due to Excessive Error Message Length
    fixed

    Observation
    F-2024-0368Possibly Unused Variable
    fixed

    Observation
    F-2024-0367Lack of Variable Visibility Modifier
    fixed

    Observation
    F-2024-0365Variables Could be Marked Immutable
    fixed

    Observation
    1-10 of 11 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/pJJ3030/jjcontracts
    Initial Commitbccf1b9ca9b845b85d8e3599a2c7020796e1d9db
    Remediation Commit65d260c44293cc308aedec7308e93c1719c3bbc4
    RequirementsREADME.md

    Contracts in Scope

    `contracts
    PBTDistributor.sol` - `contracts/PBTDistributor.sol`
    PBT.sol` - `contracts/PBT.sol`
    PBTLPStaking.sol` - `contracts/PBTLPStaking.sol`
    PBTStaking.sol` - `contracts/PBTStaking.sol`

    Disclaimer