From 66a1a5a0218840fded83684209c8e6900f413387 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Wed, 8 May 2024 18:34:16 +0530 Subject: [PATCH] Return 0 if uninitialized --- 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