Skip to content

Commit

Permalink
⚡️ rewards: hardcode guaranteed boolean values
Browse files Browse the repository at this point in the history
  • Loading branch information
santichez committed Apr 21, 2023
1 parent 10ed054 commit f8ab2a6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-seas-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@exactly-protocol/protocol": patch
---

⚡️ rewards: hardcode guaranteed boolean values
120 changes: 60 additions & 60 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 817676)
PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 1567906)
PreviewerTest:testAccountsWithEmptyAccount() (gas: 669155)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 13292475)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 6655321)
PreviewerTest:testEmptyExactly() (gas: 4947271)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 6641425)
PreviewerTest:testEmptyExactly() (gas: 4933502)
PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 665268)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 9567187)
PreviewerTest:testFixedPoolsA() (gas: 15065764)
Expand All @@ -152,7 +152,7 @@ PreviewerTest:testFlexibleAvailableLiquidity() (gas: 13522961)
PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 3491385)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 9135688)
PreviewerTest:testFloatingRateAndUtilization() (gas: 935395)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 5985320)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 5971551)
PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2045904)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 7882657)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 9307719)
Expand Down Expand Up @@ -198,11 +198,11 @@ PreviewerTest:testPreviewWithdrawAtMaturityWithMaturedMaturity() (gas: 193941)
PreviewerTest:testPreviewWithdrawAtMaturityWithOneUnit() (gas: 202895)
PreviewerTest:testPreviewWithdrawAtMaturityWithSameTimestamp() (gas: 193846)
PreviewerTest:testPreviewWithdrawAtMaturityWithZeroAmount() (gas: 202941)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6015488)
PreviewerTest:testRewardsRate() (gas: 6773812)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 6145096)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 5902992)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 14195790)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6001592)
PreviewerTest:testRewardsRate() (gas: 6759779)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 6131327)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 5889223)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 14181757)
PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 433282)
PriceFeedDoubleTest:testPriceFeedDoubleReturningPrice() (gas: 26143)
PriceFeedDoubleTest:testPriceFeedDoubleWithActualOnChainValues() (gas: 30976)
Expand All @@ -213,65 +213,65 @@ PriceFeedWrapperTest:testPriceFeedWrapperReturningPriceAfterRebase() (gas: 22863
PriceFeedWrapperTest:testPriceFeedWrapperWithActualOnChainValues() (gas: 30295)
PriceFeedWrapperTest:testPriceFeedWrapperWithNegativePriceShouldRevert() (gas: 42290)
PriceFeedWrapperTest:testPriceFeedWrapperWithUsdPriceFeed() (gas: 1054289)
RewardsControllerTest:testAccrueRewardsForWholeDistributionPeriod() (gas: 1024050)
RewardsControllerTest:testAccrueRewardsWithBadDebtClearingOfFixedBorrow() (gas: 2087511)
RewardsControllerTest:testAccrueRewardsWithRepayOfBorrowBalance() (gas: 1132703)
RewardsControllerTest:testAccrueRewardsWithRepayOfFixedBorrowBalance() (gas: 1250467)
RewardsControllerTest:testAccrueRewardsWithSeizeOfAllDepositShares() (gas: 1312393)
RewardsControllerTest:testAfterDistributionPeriodEnd() (gas: 1520577)
RewardsControllerTest:testAllClaimableUSDCWithAnotherAccountInPool() (gas: 1980404)
RewardsControllerTest:testAllClaimableUSDCWithDeposit() (gas: 1577898)
RewardsControllerTest:testAllClaimableUSDCWithFloatingBorrow() (gas: 1412656)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRefund() (gas: 1319578)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRepay() (gas: 1324908)
RewardsControllerTest:testAllClaimableUSDCWithMint() (gas: 1212417)
RewardsControllerTest:testAllClaimableUSDCWithRedeem() (gas: 1267798)
RewardsControllerTest:testAllClaimableUSDCWithTransfer() (gas: 1906398)
RewardsControllerTest:testAllClaimableUSDCWithTransferFrom() (gas: 1783072)
RewardsControllerTest:testAllClaimableUSDCWithWithdraw() (gas: 1268846)
RewardsControllerTest:testAllClaimableWETH() (gas: 1189976)
RewardsControllerTest:testAllClaimableWithMaturedFixedPool() (gas: 1058718)
RewardsControllerTest:testAllClaimableWithTimeElapsedZero() (gas: 1187929)
RewardsControllerTest:testClaim() (gas: 992655)
RewardsControllerTest:testClaimAll() (gas: 1738599)
RewardsControllerTest:testAccrueRewardsForWholeDistributionPeriod() (gas: 1023365)
RewardsControllerTest:testAccrueRewardsWithBadDebtClearingOfFixedBorrow() (gas: 2087462)
RewardsControllerTest:testAccrueRewardsWithRepayOfBorrowBalance() (gas: 1132429)
RewardsControllerTest:testAccrueRewardsWithRepayOfFixedBorrowBalance() (gas: 1250193)
RewardsControllerTest:testAccrueRewardsWithSeizeOfAllDepositShares() (gas: 1312119)
RewardsControllerTest:testAfterDistributionPeriodEnd() (gas: 1519344)
RewardsControllerTest:testAllClaimableUSDCWithAnotherAccountInPool() (gas: 1978212)
RewardsControllerTest:testAllClaimableUSDCWithDeposit() (gas: 1576254)
RewardsControllerTest:testAllClaimableUSDCWithFloatingBorrow() (gas: 1411560)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRefund() (gas: 1318482)
RewardsControllerTest:testAllClaimableUSDCWithFloatingRepay() (gas: 1323812)
RewardsControllerTest:testAllClaimableUSDCWithMint() (gas: 1211321)
RewardsControllerTest:testAllClaimableUSDCWithRedeem() (gas: 1266702)
RewardsControllerTest:testAllClaimableUSDCWithTransfer() (gas: 1904754)
RewardsControllerTest:testAllClaimableUSDCWithTransferFrom() (gas: 1781976)
RewardsControllerTest:testAllClaimableUSDCWithWithdraw() (gas: 1267750)
RewardsControllerTest:testAllClaimableWETH() (gas: 1188332)
RewardsControllerTest:testAllClaimableWithMaturedFixedPool() (gas: 1057348)
RewardsControllerTest:testAllClaimableWithTimeElapsedZero() (gas: 1186970)
RewardsControllerTest:testClaim() (gas: 991833)
RewardsControllerTest:testClaimAll() (gas: 1737092)
RewardsControllerTest:testClaimMarketWithoutRewards() (gas: 938771)
RewardsControllerTest:testClaimWithNotEnabledRewardAsset() (gas: 1029523)
RewardsControllerTest:testConfigSettingNewStartWithOnGoingDistributionShouldNotUpdate() (gas: 366874)
RewardsControllerTest:testConfigWithDistributionNotYetStartedShouldNotFail() (gas: 496165)
RewardsControllerTest:testClaimWithNotEnabledRewardAsset() (gas: 1028427)
RewardsControllerTest:testConfigSettingNewStartWithOnGoingDistributionShouldNotUpdate() (gas: 366825)
RewardsControllerTest:testConfigWithDistributionNotYetStartedShouldNotFail() (gas: 496116)
RewardsControllerTest:testConfigWithTransitionFactorHigherOrEqThanCap() (gas: 145279)
RewardsControllerTest:testConfigWithZeroDepositAllocationWeightFactorShouldRevert() (gas: 91039)
RewardsControllerTest:testDifferentDistributionTimeForDifferentRewards() (gas: 1564460)
RewardsControllerTest:testEmitAccrue() (gas: 1017918)
RewardsControllerTest:testEmitClaimRewards() (gas: 911417)
RewardsControllerTest:testDifferentDistributionTimeForDifferentRewards() (gas: 1563638)
RewardsControllerTest:testEmitAccrue() (gas: 1017507)
RewardsControllerTest:testEmitClaimRewards() (gas: 910732)
RewardsControllerTest:testEmitConfigUpdate() (gas: 383168)
RewardsControllerTest:testEmitIndexUpdate() (gas: 1080136)
RewardsControllerTest:testLastUndistributed() (gas: 1527232)
RewardsControllerTest:testOperationAfterDistributionEnded() (gas: 625495)
RewardsControllerTest:testOperationsBeforeDistributionStart() (gas: 1257041)
RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 9750731)
RewardsControllerTest:testEmitIndexUpdate() (gas: 1079314)
RewardsControllerTest:testLastUndistributed() (gas: 1525999)
RewardsControllerTest:testOperationAfterDistributionEnded() (gas: 625221)
RewardsControllerTest:testOperationsBeforeDistributionStart() (gas: 1256219)
RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 9748950)
RewardsControllerTest:testSetDistributionOperationShouldUpdateIndex() (gas: 111881)
RewardsControllerTest:testSetDistributionWithOnGoingMarketOperations() (gas: 967008)
RewardsControllerTest:testSetHigherTotalDistribution() (gas: 1323648)
RewardsControllerTest:testSetLowerAndEqualDistributionPeriodThanCurrentTimestampShouldRevert() (gas: 912109)
RewardsControllerTest:testSetLowerAndEqualTotalDistributionThanReleasedShouldRevert() (gas: 909900)
RewardsControllerTest:testSetLowerDistributionPeriod() (gas: 1545155)
RewardsControllerTest:testSetLowerDistributionPeriodAndLowerTotalDistribution() (gas: 1547924)
RewardsControllerTest:testSetLowerTotalDistribution() (gas: 1323561)
RewardsControllerTest:testSetNewDistributionPeriod() (gas: 2049507)
RewardsControllerTest:testSetNewDistributionPeriodAfterDistributionEnds() (gas: 1155358)
RewardsControllerTest:testSetNewTargetDebt() (gas: 1237253)
RewardsControllerTest:testSetNewTargetDebtAfterDistributionEnds() (gas: 1268875)
RewardsControllerTest:testSetNewTargetDebtWithClaimOnlyAtEnd() (gas: 1125650)
RewardsControllerTest:testSetDistributionWithOnGoingMarketOperations() (gas: 966597)
RewardsControllerTest:testSetHigherTotalDistribution() (gas: 1322777)
RewardsControllerTest:testSetLowerAndEqualDistributionPeriodThanCurrentTimestampShouldRevert() (gas: 911962)
RewardsControllerTest:testSetLowerAndEqualTotalDistributionThanReleasedShouldRevert() (gas: 909753)
RewardsControllerTest:testSetLowerDistributionPeriod() (gas: 1543873)
RewardsControllerTest:testSetLowerDistributionPeriodAndLowerTotalDistribution() (gas: 1546642)
RewardsControllerTest:testSetLowerTotalDistribution() (gas: 1322690)
RewardsControllerTest:testSetNewDistributionPeriod() (gas: 2047814)
RewardsControllerTest:testSetNewDistributionPeriodAfterDistributionEnds() (gas: 1154898)
RewardsControllerTest:testSetNewTargetDebt() (gas: 1236382)
RewardsControllerTest:testSetNewTargetDebtAfterDistributionEnds() (gas: 1268004)
RewardsControllerTest:testSetNewTargetDebtWithClaimOnlyAtEnd() (gas: 1125190)
RewardsControllerTest:testSetNewTreasuryFeeShouldImpactAllocation() (gas: 513818)
RewardsControllerTest:testSetTargetDebtMultipleTimes() (gas: 1795961)
RewardsControllerTest:testSetTargetDebtMultipleTimesAfterEnd() (gas: 1800542)
RewardsControllerTest:testSetTotalDistributionMultipleTimes() (gas: 1298243)
RewardsControllerTest:testTriggerHandleBorrowHookBeforeUpdatingFloatingDebt() (gas: 1301187)
RewardsControllerTest:testUpdateConfig() (gas: 1066474)
RewardsControllerTest:testUpdateIndexesWithUtilizationEqualToOne() (gas: 1002508)
RewardsControllerTest:testUpdateIndexesWithUtilizationHigherThanOne() (gas: 1054055)
RewardsControllerTest:testSetTargetDebtMultipleTimes() (gas: 1794992)
RewardsControllerTest:testSetTargetDebtMultipleTimesAfterEnd() (gas: 1799573)
RewardsControllerTest:testSetTotalDistributionMultipleTimes() (gas: 1297685)
RewardsControllerTest:testTriggerHandleBorrowHookBeforeUpdatingFloatingDebt() (gas: 1300639)
RewardsControllerTest:testUpdateConfig() (gas: 1065740)
RewardsControllerTest:testUpdateIndexesWithUtilizationEqualToOne() (gas: 1002097)
RewardsControllerTest:testUpdateIndexesWithUtilizationHigherThanOne() (gas: 1053644)
RewardsControllerTest:testUpdateWithTotalDebtZeroShouldUpdateLastUndistributed() (gas: 426023)
RewardsControllerTest:testUtilizationEqualZero() (gas: 622730)
RewardsControllerTest:testWithTwelveFixedPools() (gas: 3993401)
RewardsControllerTest:testWithTwelveFixedPools() (gas: 3992990)
RewardsControllerTest:testWithdrawAllRewardBalance() (gas: 47213)
RewardsControllerTest:testWithdrawOnlyAdminRole() (gas: 84719)
4 changes: 2 additions & 2 deletions contracts/RewardsController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,11 @@ contract RewardsController is Initializable, AccessControlUpgradeable {
if (ops[i]) {
(, , uint256 floatingBorrowShares) = market.accounts(account);
accountBalanceOps[i] = AccountOperation({
operation: ops[i],
operation: true,
balance: floatingBorrowShares + accountFixedBorrowShares(market, account, distributionStart)
});
} else {
accountBalanceOps[i] = AccountOperation({ operation: ops[i], balance: market.balanceOf(account) });
accountBalanceOps[i] = AccountOperation({ operation: false, balance: market.balanceOf(account) });
}
unchecked {
++i;
Expand Down

0 comments on commit f8ab2a6

Please sign in to comment.