From 51035a93e3273a76fd393e74904e5cb5f62fc437 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Wed, 8 May 2024 20:42:15 +0530 Subject: [PATCH] Return 0 if uninitialized (#415) --- contracts/FixedRateRewardsSource.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/FixedRateRewardsSource.sol b/contracts/FixedRateRewardsSource.sol index 2c51f4d4..0727b0f1 100644 --- a/contracts/FixedRateRewardsSource.sol +++ b/contracts/FixedRateRewardsSource.sol @@ -89,8 +89,10 @@ contract FixedRateRewardsSource is Governable, Initializable { /// @return rewardAmount Amount of reward that'll be distributed if collected now function previewRewards() public view returns (uint256) { RewardConfig memory _config = rewardConfig; + if (_config.lastCollect == 0) { + return 0; + } return (block.timestamp - _config.lastCollect) * _config.rewardsPerSecond; - // return _previewRewards(rewardConfig); } /// @dev Set address of the strategist