Introduction
We express our gratitude to the CoinRaces team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Coinraces is a Prediction Market game where users can place bets on different assets and win rewards for the best performances.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for CoinRaces |
| Audited By | Olesia Bilenka |
| Approved By | Grzegorz Trawinski |
| Website | https://coinraces.io/→ |
| Changelog | 04/02/2025 - Preliminary Report |
| Platform | Ethereum, Base. |
| Language | Solidity |
| Tags | GameFi, Oracle, Prediction Markets |
| Methodology | https://hackenio.cc/sc_methodology→ |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for CoinRaces
- Audited By
- Olesia Bilenka
- Approved By
- Grzegorz Trawinski
- Website
- https://coinraces.io/→
- Changelog
- 04/02/2025 - Preliminary Report
- Platform
- Ethereum, Base.
- Language
- Solidity
- Tags
- GameFi, Oracle, Prediction Markets
- Methodology
- https://hackenio.cc/sc_methodology→
Review Scope | |
|---|---|
| Repository | https://github.com/Coinraces/smartcontract→ |
| Commit | 1cef0e6 |
Review Scope
- Commit
- 1cef0e6
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report
Documentation quality
Functional requirements are partially missed.
Technical description is not provided.
Code quality
The code duplicates commonly known contracts instead of reusing them.
Several template code patterns were found.
The development environment is configured.
Test coverage
Code coverage of the project is 17.99% (branch coverage), with a mutation score of 77%.
Deployment and basic user interactions are covered with tests.
Negative cases coverage is missed.
Interactions by several users are not tested thoroughly.
System Overview
Coinraces is a Prediction Market game where users can place bets on different assets and win rewards for the best performances.
Players can place bets on one of eight currencies or on two predefined groups of four currencies. Bets can be placed until a round begins, and only for the upcoming round. Once a round starts, betting for that round is no longer possible. To participate, players pay a fee, which is capped at 10% and defaults to 5%.
The initial set of currencies is defined in the contract but can be updated by the contract owner. Currency values are sourced from Pyth.
The scope consists of a single contract PredictionMarket to handle all protocol features.
Privileged roles
PredictionMarket contract owner:
Initializes the first round, setting up the initial price update data for the Pyth oracle.
May withdraw any ERC20 tokens from the contract.
Pauses and unpauses the contract.
Sets up the Pyth oracles, fee parameters and unclaimed prices receiver.
Can schedule a block time update
Potential Risks
The PredictionMarket contract includes the function recoverERC20(), which allows the owner to withdraw any ERC20 funds from the contract without restrictions.
The functioning of the system significantly relies on specific external contracts from Pyth Network →. Any flaws or vulnerabilities in these contracts adversely affect the audited project, potentially leading to security breaches or loss of funds.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2025-8582 | Fee Percentage can Change After Placing Bets | fixed | Medium | |
| F-2025-8602 | Unhandled Case When Performances Are Equal in calculateWinners | accepted | Low | |
| F-2025-8604 | Redundant Calculation of totalToPayout in processIndividualBets and processGroupBets | fixed | Observation | |
| F-2025-8600 | Redundant Assignment of Default Values | fixed | Observation | |
| F-2025-8598 | Unused Parameter in initializeRoundZero and Redundant Function Call | fixed | Observation | |
| F-2025-8595 | Potential Gas Limit Reversion in claimWinnings Due to Unbounded Loop | fixed | Observation | |
| F-2025-8586 | Inefficient Gas Usages Due to Redundant Assignments | fixed | Observation | |
| F-2025-8574 | Redundant Comparison to Boolean Value | fixed | Observation | |
| F-2025-8569 | Built-in Transfer may Become Unusable | fixed | Observation | |
| F-2025-8567 | Risk of Ownership Control Loss in Owner-Dependent Contract | fixed | Observation |
Appendix 1. Definitions
Severities
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. |
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.
Potential Risks
The "Potential Risks" section identifies issues that are not direct security vulnerabilities but could still affect the project’s performance, reliability, or user trust. These risks arise from design choices, architectural decisions, or operational practices that, while not immediately exploitable, may lead to problems under certain conditions. Additionally, potential risks can impact the quality of the audit itself, as they may involve external factors or components beyond the scope of the audit, leading to incomplete assessments or oversight of key areas. This section aims to provide a broader perspective on factors that could affect the project's long-term security, functionality, and the comprehensiveness of the audit findings.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
|---|---|
| Repository | https://github.com/Coinraces/smartcontract→ |
| Commit | 1cef0e6 |
| Whitepaper | https://hackenio.cc/hacken-methodologies→ |
| Requirements | |
| Technical Requirements |
Scope Details
- Commit
- 1cef0e6
- Requirements
- Technical Requirements
Assets in Scope
Appendix 3. Additional Valuables
Verification of System Invariants
During the audit of Project/Client Name], Hacken followed its methodology by performing fuzz-testing on the project's main functions. [Echidna →, a tool used for fuzz-testing, was employed to check how the protocol behaves under various inputs. Due to the complex and dynamic interactions within the protocol, unexpected edge cases might arise. Therefore, it was important to use fuzz-testing to ensure that several system invariants hold true in all situations.
Fuzz-testing allows the input of many random data points into the system, helping to identify issues that regular testing might miss. A specific Echidna fuzzing suite was prepared for this task, and throughout the assessment, [Number of Invariants] invariants were tested over 5,000,000 runs. This thorough testing ensured that the system works correctly even with unexpected or unusual inputs.
Invariant | Test Result | Run Count |
|---|---|---|
| Debt should never decrease on open | Passed | 1M+ |
| Debt should never increase on close | Passed | 2M+ |
| Total position must decrease accordingly on close | Failed | 2M+ |
| Close should never decrease user reserve balances | Failed | 1M+ |
| Expiry must be in the future | Passed | 2M+ |
Invariant
- Debt should never decrease on open
Test Result
- Passed
Run Count
- 1M+
Invariant
- Debt should never increase on close
Test Result
- Passed
Run Count
- 2M+
Invariant
- Total position must decrease accordingly on close
Test Result
- Failed
Run Count
- 2M+
Invariant
- Close should never decrease user reserve balances
Test Result
- Failed
Run Count
- 1M+
Invariant
- Expiry must be in the future
Test Result
- Passed
Run Count
- 2M+
Additional Recommendations
The smart contracts in the scope of this audit could benefit from the introduction of automatic emergency actions for critical activities, such as unauthorized operations like ownership changes or proxy upgrades, as well as unexpected fund manipulations, including large withdrawals or minting events. Adding such mechanisms would enable the protocol to react automatically to unusual activity, ensuring that the contract remains secure and functions as intended.
To improve functionality, these emergency actions could be designed to trigger under specific conditions, such as:
Detecting changes to ownership or critical permissions.
Monitoring large or unexpected transactions and minting events.
Pausing operations when irregularities are identified.
These enhancements would provide an added layer of security, making the contract more robust and better equipped to handle unexpected situations while maintaining smooth operations.