Skip to content

Commit

Permalink
🐛 rewards: fix released calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
santichez committed Jun 5, 2024
1 parent bb38a54 commit 2f5c8ba
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 87 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-beds-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@exactly/protocol": patch
---

🐛 rewards: fix released calculation
160 changes: 81 additions & 79 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ DebtManagerTest:testFloatingToFixedRollHigherThanAvailableLiquidityWithSlippage(
DebtManagerTest:testFloatingToFixedRollHigherThanAvailableLiquidityWithSlippageWithThreePools() (gas: 2787984)
DebtManagerTest:testFloatingToFixedRollWithAccurateSlippage() (gas: 1687218)
DebtManagerTest:testFloatingToFixedRollWithAccurateSlippageWithPreviousPosition() (gas: 1924341)
DebtManagerTest:testFuzzRolls(uint8[4],uint8[4],uint256[4],uint40[4],uint8[4]) (runs: 256, μ: 6508761, ~: 6529787)
DebtManagerTest:testFuzzRolls(uint8[4],uint8[4],uint256[4],uint40[4],uint8[4]) (runs: 256, μ: 6504217, ~: 6529787)
DebtManagerTest:testLateFixedRoll() (gas: 1310831)
DebtManagerTest:testLateFixedRollWithThreeLoops() (gas: 1897545)
DebtManagerTest:testLateFixedToFloatingRoll() (gas: 1273784)
Expand Down Expand Up @@ -141,11 +141,11 @@ InterestRateModelTest:testFixedBorrowRate() (gas: 2052054)
InterestRateModelTest:testFixedRateRevertAlreadyMatured() (gas: 2046236)
InterestRateModelTest:testFixedRateRevertUtilizationExceeded() (gas: 2053399)
InterestRateModelTest:testFloatingBorrowRate() (gas: 2045540)
InterestRateModelTest:testFuzzFixedRateGrowth(uint256,uint256,uint256,uint256) (runs: 256, μ: 2067117, ~: 2063904)
InterestRateModelTest:testFuzzFixedRateTimeSensitivity(uint256,uint256,uint256) (runs: 256, μ: 2073166, ~: 2073210)
InterestRateModelTest:testFuzzReferenceLegacyRateFixed(uint32,uint256,uint256[2],uint256[2],uint256,uint256,uint256) (runs: 256, μ: 9973344, ~: 10137900)
InterestRateModelTest:testFuzzReferenceRateFixed(uint256,uint256,uint256,uint256,uint256,uint256,(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,int256,uint256,uint256)) (runs: 256, μ: 2337454, ~: 2339865)
InterestRateModelTest:testFuzzReferenceRateFloating(uint256,uint256,(uint256,uint256,uint256,uint256,uint256,uint256,uint256)) (runs: 256, μ: 2275596, ~: 2276456)
InterestRateModelTest:testFuzzFixedRateGrowth(uint256,uint256,uint256,uint256) (runs: 256, μ: 2067148, ~: 2063904)
InterestRateModelTest:testFuzzFixedRateTimeSensitivity(uint256,uint256,uint256) (runs: 256, μ: 2073165, ~: 2073210)
InterestRateModelTest:testFuzzReferenceLegacyRateFixed(uint32,uint256,uint256[2],uint256[2],uint256,uint256,uint256) (runs: 256, μ: 9970772, ~: 10137385)
InterestRateModelTest:testFuzzReferenceRateFixed(uint256,uint256,uint256,uint256,uint256,uint256,(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,int256,uint256,uint256)) (runs: 256, μ: 2337320, ~: 2339917)
InterestRateModelTest:testFuzzReferenceRateFloating(uint256,uint256,(uint256,uint256,uint256,uint256,uint256,uint256,uint256)) (runs: 256, μ: 2275592, ~: 2276418)
InterestRateModelTest:testMinTimeToMaturity() (gas: 2063554)
InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 266682)
MarketTest:testAccountLiquidityAdjustedDebt() (gas: 499440)
Expand Down Expand Up @@ -284,7 +284,7 @@ PoolLibTest:testAtomicDepositBorrowRepayWithdraw() (gas: 46018)
PoolLibTest:testBackupBorrow() (gas: 33676)
PoolLibTest:testEarningsAccrual() (gas: 38999)
PoolLibTest:testEarningsDistribution() (gas: 32640)
PoolLibTest:testFuzzAddRemoveAll(uint8[12]) (runs: 256, μ: 55244, ~: 54164)
PoolLibTest:testFuzzAddRemoveAll(uint8[12]) (runs: 256, μ: 55186, ~: 54164)
PoolLibTest:testMaturityRangeLimit() (gas: 7873)
PoolLibTest:testMaturityRangeTooWide() (gas: 6831)
PreviewerTest:testAccountsReturningAccurateAmounts() (gas: 1393698)
Expand All @@ -293,8 +293,8 @@ PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 862391)
PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 2265026)
PreviewerTest:testAccountsWithEmptyAccount() (gas: 690558)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 17617503)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 7753427)
PreviewerTest:testEmptyExactly() (gas: 5645469)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 7774796)
PreviewerTest:testEmptyExactly() (gas: 5666767)
PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 688149)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 13301596)
PreviewerTest:testFixedPoolsA() (gas: 19318341)
Expand All @@ -305,7 +305,7 @@ PreviewerTest:testFlexibleAvailableLiquidity() (gas: 17242437)
PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 4401038)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 12554334)
PreviewerTest:testFloatingRateAndUtilization() (gas: 1128246)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 7174821)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 7196163)
PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2469700)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 10991846)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 13181978)
Expand Down Expand Up @@ -352,12 +352,12 @@ PreviewerTest:testPreviewWithdrawAtMaturityWithOneUnit() (gas: 251718)
PreviewerTest:testPreviewWithdrawAtMaturityWithSameTimestamp() (gas: 233406)
PreviewerTest:testPreviewWithdrawAtMaturityWithZeroAmount() (gas: 251675)
PreviewerTest:testReserveFactor() (gas: 707280)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6697322)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 7481122)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 6788297)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 19241268)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 18372292)
PreviewerTest:testRewardsRateX() (gas: 8127662)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6718669)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 7502464)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 6809617)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 19262635)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 18393705)
PreviewerTest:testRewardsRateX() (gas: 8149075)
PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 597567)
PriceFeedDoubleTest:testPriceFeedDoubleReturningPrice() (gas: 53190)
PriceFeedDoubleTest:testPriceFeedDoubleWithActualOnChainValues() (gas: 76310)
Expand All @@ -374,69 +374,71 @@ PriceFeedWrapperTest:testPriceFeedWrapperReturningPriceAfterRebase() (gas: 48989
PriceFeedWrapperTest:testPriceFeedWrapperWithActualOnChainValues() (gas: 75210)
PriceFeedWrapperTest:testPriceFeedWrapperWithNegativePriceShouldRevert() (gas: 164216)
PriceFeedWrapperTest:testPriceFeedWrapperWithUsdPriceFeed() (gas: 1243191)
RewardsControllerTest:testAccrueRewardsForWholeDistributionPeriod() (gas: 1245256)
RewardsControllerTest:testAccrueRewardsWithBadDebtClearingOfFixedBorrow() (gas: 3338579)
RewardsControllerTest:testAccrueRewardsWithRepayOfBorrowBalance() (gas: 1602527)
RewardsControllerTest:testAccrueRewardsWithRepayOfFixedBorrowBalance() (gas: 1791601)
RewardsControllerTest:testAccrueRewardsWithSeizeOfAllDepositShares() (gas: 1991092)
RewardsControllerTest:testAfterDistributionPeriodEnd() (gas: 1818279)
RewardsControllerTest:testAllClaimableUSDCWithAnotherAccountInPool() (gas: 2273354)
RewardsControllerTest:testAllClaimableUSDCWithDeposit() (gas: 1627706)
RewardsControllerTest:testAllClaimableUSDCWithFloatingBorrow() (gas: 1560044)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRefund() (gas: 1667236)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRepay() (gas: 1673750)
RewardsControllerTest:testAllClaimableUSDCWithMint() (gas: 1284296)
RewardsControllerTest:testAllClaimableUSDCWithRedeem() (gas: 1640399)
RewardsControllerTest:testAllClaimableUSDCWithTransfer() (gas: 2220308)
RewardsControllerTest:testAllClaimableUSDCWithTransferFrom() (gas: 2135247)
RewardsControllerTest:testAllClaimableUSDCWithWithdraw() (gas: 1641434)
RewardsControllerTest:testAllClaimableWETH() (gas: 1247789)
RewardsControllerTest:testAllClaimableWithMaturedFixedPool() (gas: 1127875)
RewardsControllerTest:testAllClaimableWithTimeElapsedZero() (gas: 1624639)
RewardsControllerTest:testClaim() (gas: 1192161)
RewardsControllerTest:testClaimAll() (gas: 2188738)
RewardsControllerTest:testClaimMarketWithoutRewards() (gas: 1240983)
RewardsControllerTest:testClaimWithNotEnabledRewardAsset() (gas: 1222637)
RewardsControllerTest:testConfigSettingNewStartWithOnGoingDistributionShouldNotUpdate() (gas: 430182)
RewardsControllerTest:testConfigWithDistributionNotYetStartedShouldNotFail() (gas: 613404)
RewardsControllerTest:testConfigWithTransitionFactorHigherOrEqThanCap() (gas: 107189)
RewardsControllerTest:testConfigWithZeroDepositAllocationWeightFactorShouldRevert() (gas: 71542)
RewardsControllerTest:testDifferentDistributionTimeForDifferentRewards() (gas: 2025649)
RewardsControllerTest:testEmitAccrue() (gas: 1317916)
RewardsControllerTest:testEmitClaimRewards() (gas: 1112375)
RewardsControllerTest:testEmitConfigUpdate() (gas: 439567)
RewardsControllerTest:testEmitIndexUpdate() (gas: 1445530)
RewardsControllerTest:testLastUndistributed() (gas: 2189661)
RewardsControllerTest:testOperationAfterDistributionEnded() (gas: 722976)
RewardsControllerTest:testOperationsBeforeDistributionStart() (gas: 1674576)
RewardsControllerTest:testPermitClaim() (gas: 1275282)
RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 11445059)
RewardsControllerTest:testSetDistributionOperationShouldUpdateIndex() (gas: 136200)
RewardsControllerTest:testSetDistributionWithOnGoingMarketOperations() (gas: 1202358)
RewardsControllerTest:testSetHigherTotalDistribution() (gas: 1831201)
RewardsControllerTest:testSetLowerAndEqualDistributionPeriodThanCurrentTimestampShouldRevert() (gas: 1274696)
RewardsControllerTest:testSetLowerAndEqualTotalDistributionThanReleasedShouldRevert() (gas: 1267721)
RewardsControllerTest:testSetLowerDistributionPeriod() (gas: 2284176)
RewardsControllerTest:testSetLowerDistributionPeriodAndLowerTotalDistribution() (gas: 2286901)
RewardsControllerTest:testSetLowerTotalDistribution() (gas: 1831114)
RewardsControllerTest:testSetNewDistributionPeriod() (gas: 3143972)
RewardsControllerTest:testSetNewDistributionPeriodAfterDistributionEnds() (gas: 1406666)
RewardsControllerTest:testSetNewTargetDebt() (gas: 1671525)
RewardsControllerTest:testSetNewTargetDebtAfterDistributionEnds() (gas: 1734966)
RewardsControllerTest:testSetNewTargetDebtWithClaimOnlyAtEnd() (gas: 1389661)
RewardsControllerTest:testSetNewTreasuryFeeShouldImpactAllocation() (gas: 658882)
RewardsControllerTest:testSetTargetDebtMultipleTimes() (gas: 2719324)
RewardsControllerTest:testSetTargetDebtMultipleTimesAfterEnd() (gas: 2756094)
RewardsControllerTest:testSetTotalDistributionMultipleTimes() (gas: 1838222)
RewardsControllerTest:testTriggerHandleBorrowHookBeforeUpdatingFloatingDebt() (gas: 1879339)
RewardsControllerTest:testUpdateConfig() (gas: 1328855)
RewardsControllerTest:testUpdateIndexesWithUtilizationEqualToOne() (gas: 1257771)
RewardsControllerTest:testUpdateIndexesWithUtilizationHigherThanOne() (gas: 1352512)
RewardsControllerTest:testUpdateWithTotalDebtZeroShouldUpdateLastUndistributed() (gas: 575506)
RewardsControllerTest:testUtilizationEqualZero() (gas: 921863)
RewardsControllerTest:testWithTwelveFixedPools() (gas: 8055024)
RewardsControllerTest:testWithdrawAllRewardBalance() (gas: 71913)
RewardsControllerTest:testWithdrawOnlyAdminRole() (gas: 122309)
RewardsControllerTest:testAccrueRewardsForWholeDistributionPeriod() (gas: 1245340)
RewardsControllerTest:testAccrueRewardsWithBadDebtClearingOfFixedBorrow() (gas: 3338689)
RewardsControllerTest:testAccrueRewardsWithRepayOfBorrowBalance() (gas: 1602615)
RewardsControllerTest:testAccrueRewardsWithRepayOfFixedBorrowBalance() (gas: 1791667)
RewardsControllerTest:testAccrueRewardsWithSeizeOfAllDepositShares() (gas: 1991136)
RewardsControllerTest:testAfterDistributionPeriodEnd() (gas: 1818318)
RewardsControllerTest:testAllClaimableUSDCWithAnotherAccountInPool() (gas: 2274274)
RewardsControllerTest:testAllClaimableUSDCWithDeposit() (gas: 1628778)
RewardsControllerTest:testAllClaimableUSDCWithFloatingBorrow() (gas: 1560766)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRefund() (gas: 1667587)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRepay() (gas: 1674188)
RewardsControllerTest:testAllClaimableUSDCWithMint() (gas: 1285018)
RewardsControllerTest:testAllClaimableUSDCWithRedeem() (gas: 1640837)
RewardsControllerTest:testAllClaimableUSDCWithTransfer() (gas: 2221382)
RewardsControllerTest:testAllClaimableUSDCWithTransferFrom() (gas: 2136277)
RewardsControllerTest:testAllClaimableUSDCWithWithdraw() (gas: 1641850)
RewardsControllerTest:testAllClaimableWETH() (gas: 1248424)
RewardsControllerTest:testAllClaimableWithMaturedFixedPool() (gas: 1128007)
RewardsControllerTest:testAllClaimableWithTimeElapsedZero() (gas: 1624655)
RewardsControllerTest:testAllRewards() (gas: 225819)
RewardsControllerTest:testClaim() (gas: 1192245)
RewardsControllerTest:testClaimAll() (gas: 2188888)
RewardsControllerTest:testClaimMarketWithoutRewards() (gas: 1241013)
RewardsControllerTest:testClaimWithNotEnabledRewardAsset() (gas: 1222743)
RewardsControllerTest:testConfigSettingNewStartWithOnGoingDistributionShouldNotUpdate() (gas: 430252)
RewardsControllerTest:testConfigWithDistributionNotYetStartedShouldNotFail() (gas: 613270)
RewardsControllerTest:testConfigWithTransitionFactorHigherOrEqThanCap() (gas: 107077)
RewardsControllerTest:testConfigWithZeroDepositAllocationWeightFactorShouldRevert() (gas: 71497)
RewardsControllerTest:testDifferentDistributionTimeForDifferentRewards() (gas: 2025692)
RewardsControllerTest:testEmitAccrue() (gas: 1318000)
RewardsControllerTest:testEmitClaimRewards() (gas: 1112437)
RewardsControllerTest:testEmitConfigUpdate() (gas: 439433)
RewardsControllerTest:testEmitIndexUpdate() (gas: 1445654)
RewardsControllerTest:testLastUndistributed() (gas: 2189825)
RewardsControllerTest:testOperationAfterDistributionEnded() (gas: 723020)
RewardsControllerTest:testOperationsBeforeDistributionStart() (gas: 1674571)
RewardsControllerTest:testPermitClaim() (gas: 1275235)
RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 11445208)
RewardsControllerTest:testSetDistributionOperationShouldUpdateIndex() (gas: 136066)
RewardsControllerTest:testSetDistributionWithOnGoingMarketOperations() (gas: 1202353)
RewardsControllerTest:testSetHigherTotalDistribution() (gas: 1831329)
RewardsControllerTest:testSetLowerAndEqualDistributionPeriodThanCurrentTimestampShouldRevert() (gas: 1274818)
RewardsControllerTest:testSetLowerAndEqualTotalDistributionThanReleasedShouldRevert() (gas: 1267843)
RewardsControllerTest:testSetLowerDistributionPeriod() (gas: 2284322)
RewardsControllerTest:testSetLowerDistributionPeriodAndLowerTotalDistribution() (gas: 2287047)
RewardsControllerTest:testSetLowerTotalDistribution() (gas: 1831264)
RewardsControllerTest:testSetNewDistributionPeriod() (gas: 3144136)
RewardsControllerTest:testSetNewDistributionPeriodAfterDistributionEnds() (gas: 1406549)
RewardsControllerTest:testSetNewTargetDebt() (gas: 1671653)
RewardsControllerTest:testSetNewTargetDebtAfterDistributionEnds() (gas: 1735001)
RewardsControllerTest:testSetNewTargetDebtWithClaimOnlyAtEnd() (gas: 1389771)
RewardsControllerTest:testSetNewTreasuryFeeShouldImpactAllocation() (gas: 658948)
RewardsControllerTest:testSetTargetDebtMultipleTimes() (gas: 2719544)
RewardsControllerTest:testSetTargetDebtMultipleTimesAfterEnd() (gas: 2756061)
RewardsControllerTest:testSetTotalDistributionMultipleTimes() (gas: 1838402)
RewardsControllerTest:testTriggerHandleBorrowHookBeforeUpdatingFloatingDebt() (gas: 1879427)
RewardsControllerTest:testUpdateConfig() (gas: 1328942)
RewardsControllerTest:testUpdateConfigIncreaseRewardDistribution() (gas: 405523)
RewardsControllerTest:testUpdateIndexesWithUtilizationEqualToOne() (gas: 1257811)
RewardsControllerTest:testUpdateIndexesWithUtilizationHigherThanOne() (gas: 1352552)
RewardsControllerTest:testUpdateWithTotalDebtZeroShouldUpdateLastUndistributed() (gas: 575527)
RewardsControllerTest:testUtilizationEqualZero() (gas: 921840)
RewardsControllerTest:testWithTwelveFixedPools() (gas: 8055328)
RewardsControllerTest:testWithdrawAllRewardBalance() (gas: 71935)
RewardsControllerTest:testWithdrawOnlyAdminRole() (gas: 122353)
SwapperTest:testSwapBasic() (gas: 216831)
SwapperTest:testSwapWithAllowance() (gas: 481530)
SwapperTest:testSwapWithInaccurateSlippageSendsETHToAccount() (gas: 297968)
Expand Down
24 changes: 16 additions & 8 deletions contracts/RewardsController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ contract RewardsController is Initializable, AccessControlUpgradeable {
return (rewardData.start, rewardData.end, rewardData.lastUpdate);
}

/// @notice Gets the release reward rate of a given market and reward.
/// @param market The market to get the release rate.
/// @param reward The reward asset.
/// @return The release reward rate.
function releaseRate(Market market, ERC20 reward) external view returns (uint256) {
return distribution[market].rewards[reward].releaseRate;
}

/// @notice Retrieves all rewards addresses.
function allRewards() external view returns (ERC20[] memory) {
return rewardList;
Expand Down Expand Up @@ -501,7 +509,7 @@ contract RewardsController is Initializable, AccessControlUpgradeable {
}
uint256 rewards;
{
uint256 releaseRate = rewardData.releaseRate;
uint256 rate = rewardData.releaseRate;
uint256 lastUndistributed = rewardData.lastUndistributed;
t.period = t.end - t.start;
uint256 distributionFactor = t.period > 0
Expand All @@ -512,11 +520,11 @@ contract RewardsController is Initializable, AccessControlUpgradeable {
uint256 exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());
newUndistributed =
lastUndistributed.mulWadDown(exponential) +
releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);
rate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);
} else {
newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;
newUndistributed = lastUndistributed + rate.mulWadDown(1e18 - target) * deltaTime;
}
rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));
rewards = uint256(int256(rate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));
} else if (rewardData.lastUpdate > t.end) {
newUndistributed =
lastUndistributed -
Expand All @@ -529,13 +537,13 @@ contract RewardsController is Initializable, AccessControlUpgradeable {
exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());
newUndistributed =
lastUndistributed.mulWadDown(exponential) +
releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);
rate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);
} else {
newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;
newUndistributed = lastUndistributed + rate.mulWadDown(1e18 - target) * deltaTime;
}
exponential = uint256((-int256(distributionFactor * (block.timestamp - t.end))).expWad());
newUndistributed = newUndistributed - newUndistributed.mulWadUp(1e18 - exponential);
rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));
rewards = uint256(int256(rate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));
}
if (rewards == 0) return (rewardData.borrowIndex, rewardData.depositIndex, newUndistributed);
}
Expand Down Expand Up @@ -678,7 +686,7 @@ contract RewardsController is Initializable, AccessControlUpgradeable {
released =
rewardData.lastConfigReleased +
rewardData.releaseRate *
(block.timestamp - rewardData.lastConfig);
(block.timestamp - Math.max(rewardData.lastConfig, start));
elapsed = block.timestamp - start;
if (configs[i].totalDistribution <= released || configs[i].distributionPeriod <= elapsed) {
revert InvalidConfig();
Expand Down
Loading

0 comments on commit 2f5c8ba

Please sign in to comment.