Skip to content

Conversation

@8ball030
Copy link
Contributor

No description provided.

@8ball030 8ball030 mentioned this pull request Jul 14, 2025

/// @dev gets allocated Incentives
/// @return allocatedRewards Allocated rewards.
function getAllocatedIncentives() external view returns (uint256 allocatedRewards) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so sexy to be able to instansiate vars like this

require(msg.sender == owner, "Unauthorized account");
uint256 incentiveBalance = IToken(incentiveTokenAddress).balanceOf(address(this));
uint256 incentiveBalance = IToken(incentiveTokenAddress).balanceOf(address(this)) - allocatedRewards;
require(incentiveBalance > 0, "No incentive token balance to withdraw");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if in line
incentiveBalance = IToken(incentiveTokenAddress).balanceOf(address(this)) - allocatedRewards;
IToken(incentiveTokenAddress).balanceOf(address(this)) < allocatedRewards
u not calculate negative number, but "arithmetic revert"
require(incentiveBalance > 0, "No incentive token balance to withdraw"); - not needed, anyway uint can't be negative

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see;
8f0bc1b

require(msg.sender == owner, "Unauthorized account");
uint256 incentiveBalance = IToken(incentiveTokenAddress).balanceOf(address(this)) - allocatedRewards;
require(incentiveBalance > 0, "No incentive token balance to withdraw");
if (incentiveBalance == 0) revert NoAvailableIncentiveBalance();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary as no need to emit events if 0.
negative case is covered by the language itself which will revert.

@8ball030 8ball030 merged commit 3ea26c4 into main Jul 18, 2025
1 check passed
@8ball030 8ball030 deleted the fix/withdrawIncentiveBalanceRewardsChecks branch July 18, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants