Missing brivault::cancelParticipation Event, Lead to silent refunds & broken off-chain tracking/auditability.
Description
When a participant calls cancelParticipation(), their refund and share burn are processed correctly, but no event is emitted to record this action on-chain, As a result, off-chain systems (indexers, dashboards, and auditors) cannot detect or track user cancellations, leading to broken off-chain transparency and inconsistent analytics.
function cancelParticipation () public {
if (block.timestamp >= eventStartDate){
revert eventStarted();
}
uint256 refundAmount = stakedAsset[msg.sender];
stakedAsset[msg.sender] = 0;
uint256 shares = balanceOf(msg.sender);
_burn(msg.sender, shares);
IERC20(asset()).safeTransfer(msg.sender, refundAmount);
}
Risk
Likelihood:
Impact:
Proof of Concept
Put this test into `briVault.t.sol` to prove that no event occurs after a `cancelParticipation` function is called.
```javescript
function test_CancelParticipation_NoEventEmitted() public {
vm.startPrank(owner);
briVault.setCountry(countries);
vm.stopPrank();
vm.startPrank(user1);
mockToken.approve(address(briVault), 5 ether);
briVault.deposit(5 ether, user1);
briVault.joinEvent(10);
vm.stopPrank();
vm.expectEmit(false, false, false, false);
vm.startPrank(user1);
briVault.cancelParticipation();
vm.stopPrank();
console.log("No event emitted after cancelParticipation()");
}
```
Recommended Mitigation
1. Define and emit a `ParticipationCancelled` event at the end of the function to ensure off-chain tracking and auditabilit.
```diff
function cancelParticipation () public {
if (block.timestamp >= eventStartDate){
revert eventStarted();
}
uint256 refundAmount = stakedAsset[msg.sender];
stakedAsset[msg.sender] = 0;
uint256 shares = balanceOf(msg.sender);
_burn(msg.sender, shares);
IERC20(asset()).safeTransfer(msg.sender, refundAmount);
+ emit ParticipationCancelled(msg.sender, refundAmount, shares);
}
+ event ParticipationCancelled(address indexed user, uint256 refundAmount, uint256 burnedShares);
```