Skip to content

Commit

Permalink
Only call balanceOf and perform a transfer if flywheel isn't the zero…
Browse files Browse the repository at this point in the history
… addr
  • Loading branch information
kphed committed Nov 13, 2023
1 parent d493a37 commit 4875d5a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/FlywheelCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ contract FlywheelCore is Auth {

/// @notice swap out the flywheel rewards contract
function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external requiresAuth {
uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));
if (address(flywheelRewards) != address(0) && oldRewardBalance > 0) {
rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);
if (address(flywheelRewards) != address(0)) {
uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));

if (oldRewardBalance != 0)
rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);
}

flywheelRewards = newFlywheelRewards;
Expand Down

0 comments on commit 4875d5a

Please sign in to comment.