FV-SOL-5-C5 Event Misreporting

TLDR

Failing to emit an event during a critical update like reward distribution, making it hard to track transactions or actions on-chain

Game

The wrong balance might be logged.

Can you identify how this misreporting could happen?

// SPDX-License-Identifier: MIT
// Open me in VSCode and really think before opening the hints!
// Add @audit tags wherever suspicious
// Go to the solidity docs to complete missing knowledge of what's happening here
// Solve by drafting a fix!
pragma solidity ^0.8.0;

contract EventMisreportingGame {
    uint256 public totalDeposits;
    mapping(address => uint256) public balances;

    event DepositMade(address indexed user, uint256 amount, uint256 totalDeposits);

    // Function to allow users to deposit and log the event
    function deposit() public payable {
        balances[msg.sender] += msg.value;
        totalDeposits += msg.value;
        
        emit DepositMade(msg.sender, balances[msg.sender], totalDeposits);
    }
}

Last updated