diff --git a/.gas-snapshot b/.gas-snapshot index 5247a09f1..055a7663e 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -14,7 +14,7 @@ AuditorTest:testEnableEnterExitMultipleMarkets() (gas: 1836303) AuditorTest:testEnableMarket() (gas: 156448) AuditorTest:testEnableMarketAlreadyListed() (gas: 184745) AuditorTest:testEnableMarketAuditorMismatch() (gas: 67682) -AuditorTest:testEnableMarketShouldRevertWithInvalidPriceFeed() (gas: 233210) +AuditorTest:testEnableMarketShouldRevertWithInvalidPriceFeed() (gas: 233198) AuditorTest:testEnterExitMarket() (gas: 313882) AuditorTest:testExitMarketOwning() (gas: 280975) DebtManagerTest:testAllowanceSurplus() (gas: 965332) @@ -139,136 +139,137 @@ InstallmentsRouterTest:testMoreBorrowsThanMaxPools() (gas: 634146) InterestRateModelTest:testFixedBorrowRate() (gas: 2063742) InterestRateModelTest:testFixedRateRevertAlreadyMatured() (gas: 2057902) InterestRateModelTest:testFixedRateRevertUtilizationExceeded() (gas: 2065065) -InterestRateModelTest:testFixedRateTimeSensitivity(uint256,uint256,uint256) (runs: 256, μ: 2084598, ~: 2084899) +InterestRateModelTest:testFixedRateTimeSensitivity(uint256,uint256,uint256) (runs: 259, μ: 2084803, ~: 2084899) InterestRateModelTest:testFloatingBorrowRate() (gas: 2057206) InterestRateModelTest:testMinTimeToMaturity() (gas: 2075242) InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 267435) MarketTest:testAccountLiquidityAdjustedDebt() (gas: 499481) MarketTest:testAnotherUserRedeemWhenOwnerHasShortfall() (gas: 819094) MarketTest:testAnotherUserWithdrawWhenOwnerHasShortfall() (gas: 806786) -MarketTest:testBorrowAfterFreezing() (gas: 491460) -MarketTest:testBorrowAtMaturity() (gas: 499450) +MarketTest:testBorrowAfterFreezing() (gas: 491397) +MarketTest:testBorrowAtMaturity() (gas: 499472) MarketTest:testBorrowAtMaturityAfterFreezing() (gas: 573201) -MarketTest:testBorrowAtMaturityUpdatesFloatingDebtAndFloatingAssets() (gas: 884691) -MarketTest:testBorrowAtMaturityWhenFrozen() (gas: 93718) +MarketTest:testBorrowAtMaturityUpdatesFloatingDebtAndFloatingAssets() (gas: 884625) +MarketTest:testBorrowAtMaturityWhenFrozen() (gas: 93740) MarketTest:testBorrowAtMaturityWithZeroAssets() (gas: 40425) MarketTest:testBorrowDisagreement() (gas: 295456) -MarketTest:testBorrowFromFreeLunchShouldNotRevertWithFloatingFullUtilization() (gas: 1276328) -MarketTest:testBorrowWhenFrozen() (gas: 93224) -MarketTest:testCappedLiquidation() (gas: 1188631) +MarketTest:testBorrowFromFreeLunchShouldNotRevertWithFloatingFullUtilization() (gas: 1276372) +MarketTest:testBorrowWhenFrozen() (gas: 93157) +MarketTest:testBorrowWithZeroAssets() (gas: 39793) +MarketTest:testCappedLiquidation() (gas: 1188653) MarketTest:testChargeTreasuryToEarlyWithdraws() (gas: 1183503) MarketTest:testChargeTreasuryToFixedBorrows() (gas: 1588080) -MarketTest:testClearBadDebtAvoidingFixedBorrowsIfAccumulatorLower() (gas: 2275884) +MarketTest:testClearBadDebtAvoidingFixedBorrowsIfAccumulatorLower() (gas: 2275906) MarketTest:testClearBadDebtCalledByAccount() (gas: 34955) -MarketTest:testClearBadDebtExactlyRepaysFixedBorrowWithAccumulatorAmount() (gas: 1993389) -MarketTest:testClearBadDebtPartiallyRepaysEachFixedBorrow() (gas: 1953800) -MarketTest:testClearBadDebtPartiallyRepaysFloatingDebt() (gas: 2284006) +MarketTest:testClearBadDebtExactlyRepaysFixedBorrowWithAccumulatorAmount() (gas: 1993411) +MarketTest:testClearBadDebtPartiallyRepaysEachFixedBorrow() (gas: 1953822) +MarketTest:testClearBadDebtPartiallyRepaysFloatingDebt() (gas: 2284028) MarketTest:testClearBadDebtShouldAccrueAccumulatedEarningsBeforeSpreadingLosses() (gas: 2060568) -MarketTest:testClearBadDebtWithEmptyAccumulatorShouldNotRevert() (gas: 969910) -MarketTest:testClearMaturity() (gas: 1659156) -MarketTest:testCollectTreasuryFreeLunchToEarlyWithdraws() (gas: 1712217) -MarketTest:testCollectTreasuryFreeLunchToEarlyWithdrawsWithZeroFees() (gas: 541351) -MarketTest:testCollectTreasuryFreeLunchToFixedBorrows() (gas: 1771314) -MarketTest:testCollectTreasuryFreeLunchToFixedBorrowsWithZeroFees() (gas: 704732) +MarketTest:testClearBadDebtWithEmptyAccumulatorShouldNotRevert() (gas: 969932) +MarketTest:testClearMaturity() (gas: 1659178) +MarketTest:testCollectTreasuryFreeLunchToEarlyWithdraws() (gas: 1712239) +MarketTest:testCollectTreasuryFreeLunchToEarlyWithdrawsWithZeroFees() (gas: 541373) +MarketTest:testCollectTreasuryFreeLunchToFixedBorrows() (gas: 1771336) +MarketTest:testCollectTreasuryFreeLunchToFixedBorrowsWithZeroFees() (gas: 704645) MarketTest:testCrossMaturityLiquidation() (gas: 2608710) -MarketTest:testDepositAfterFreezing() (gas: 256227) -MarketTest:testDepositAtMaturity() (gas: 180694) -MarketTest:testDepositAtMaturityAfterFreezing() (gas: 254643) -MarketTest:testDepositAtMaturityWhenFrozen() (gas: 93209) +MarketTest:testDepositAfterFreezing() (gas: 256160) +MarketTest:testDepositAtMaturity() (gas: 180716) +MarketTest:testDepositAtMaturityAfterFreezing() (gas: 254665) +MarketTest:testDepositAtMaturityWhenFrozen() (gas: 93231) MarketTest:testDepositAtMaturityWithZeroAssets() (gas: 39977) MarketTest:testDepositDisagreement() (gas: 57120) -MarketTest:testDepositShouldUpdateFlexibleBorrowVariables() (gas: 716949) -MarketTest:testDepositToSmartPool() (gas: 181849) +MarketTest:testDepositShouldUpdateFlexibleBorrowVariables() (gas: 716993) +MarketTest:testDepositToSmartPool() (gas: 181871) MarketTest:testDepositWhenFrozen() (gas: 176515) -MarketTest:testDistributeMultipleAccumulatedEarnings() (gas: 1345998) +MarketTest:testDistributeMultipleAccumulatedEarnings() (gas: 1345931) MarketTest:testDistributionOfLossesShouldReduceFromFloatingBackupBorrowedAccordingly() (gas: 6252360) MarketTest:testEarlyRepaymentWithExcessiveAmountOfFees() (gas: 3407638) -MarketTest:testEarlyWithdrawFromFreeLunchShouldNotRevertWithFloatingFullUtilization() (gas: 1032095) +MarketTest:testEarlyWithdrawFromFreeLunchShouldNotRevertWithFloatingFullUtilization() (gas: 1032117) MarketTest:testEmergencyAdminRole() (gas: 317196) -MarketTest:testEmitFrozen() (gas: 91114) -MarketTest:testFixedBorrowFailingWhenFlexibleBorrowAccruesDebt() (gas: 1530830) +MarketTest:testEmitFrozen() (gas: 91047) +MarketTest:testFixedBorrowFailingWhenFlexibleBorrowAccruesDebt() (gas: 1530874) MarketTest:testFixedBorrowRateToMaturity() (gas: 562485) -MarketTest:testFlexibleBorrow() (gas: 423634) -MarketTest:testFlexibleBorrowAccountingDebt() (gas: 607109) -MarketTest:testFlexibleBorrowChargingDebtToTreasury() (gas: 751133) -MarketTest:testFlexibleBorrowExceedingReserve() (gas: 878386) -MarketTest:testFlexibleBorrowExceedingReserveIncludingFixedBorrow() (gas: 1267421) -MarketTest:testFlexibleBorrowExceedingReserveWithNewDebt() (gas: 1001187) -MarketTest:testFlexibleBorrowFromAnotherUserSubtractsAllowance() (gas: 469243) -MarketTest:testFlexibleBorrowFromAnotherUserWithAllowance() (gas: 458681) -MarketTest:testFlexibleBorrowFromAnotherUserWithoutAllowance() (gas: 252359) -MarketTest:testFrontRunSmartPoolEarningsDistributionWithBigPenaltyRepayment() (gas: 1349906) -MarketTest:testFullPause() (gas: 5882714) +MarketTest:testFlexibleBorrow() (gas: 423678) +MarketTest:testFlexibleBorrowAccountingDebt() (gas: 607131) +MarketTest:testFlexibleBorrowChargingDebtToTreasury() (gas: 751199) +MarketTest:testFlexibleBorrowExceedingReserve() (gas: 878430) +MarketTest:testFlexibleBorrowExceedingReserveIncludingFixedBorrow() (gas: 1267465) +MarketTest:testFlexibleBorrowExceedingReserveWithNewDebt() (gas: 1001231) +MarketTest:testFlexibleBorrowFromAnotherUserSubtractsAllowance() (gas: 469265) +MarketTest:testFlexibleBorrowFromAnotherUserWithAllowance() (gas: 458703) +MarketTest:testFlexibleBorrowFromAnotherUserWithoutAllowance() (gas: 252381) +MarketTest:testFrontRunSmartPoolEarningsDistributionWithBigPenaltyRepayment() (gas: 1349928) +MarketTest:testFullPause() (gas: 5882758) MarketTest:testInitiallyUnfrozen() (gas: 15614) -MarketTest:testInsufficientProtocolLiquidity() (gas: 1940266) +MarketTest:testInsufficientProtocolLiquidity() (gas: 1940310) MarketTest:testLiquidateAndChargeIncentiveForLenders() (gas: 2401575) MarketTest:testLiquidateAndDistributeLosses() (gas: 3197014) -MarketTest:testLiquidateAndSeizeExactAmountWithDustAsCollateral() (gas: 2789573) +MarketTest:testLiquidateAndSeizeExactAmountWithDustAsCollateral() (gas: 2789595) MarketTest:testLiquidateAndSeizeFromEmptyCollateral() (gas: 1039213) MarketTest:testLiquidateAndSubtractLossesFromAccumulator() (gas: 3895469) -MarketTest:testLiquidateFlexibleAndFixedBorrowPositionsInSingleCall() (gas: 2607168) -MarketTest:testLiquidateFlexibleBorrow() (gas: 2142946) -MarketTest:testLiquidateFlexibleBorrowChargeLendersAssetsToLiquidator() (gas: 1150182) -MarketTest:testLiquidateFlexibleBorrowConsideringDebtOverTime() (gas: 1166251) -MarketTest:testLiquidateLeavingDustAsCollateral() (gas: 3601339) -MarketTest:testLiquidateWhenFrozen() (gas: 1230769) +MarketTest:testLiquidateFlexibleAndFixedBorrowPositionsInSingleCall() (gas: 2607212) +MarketTest:testLiquidateFlexibleBorrow() (gas: 2142990) +MarketTest:testLiquidateFlexibleBorrowChargeLendersAssetsToLiquidator() (gas: 1150226) +MarketTest:testLiquidateFlexibleBorrowConsideringDebtOverTime() (gas: 1166273) +MarketTest:testLiquidateLeavingDustAsCollateral() (gas: 3601361) +MarketTest:testLiquidateWhenFrozen() (gas: 1230791) MarketTest:testLiquidateWithTwoUnitsAsMaxAssets() (gas: 1568077) -MarketTest:testLiquidateWithZeroAsMaxAssets() (gas: 1039162) -MarketTest:testLiquidationClearingDebtOfAllAccountMarkets() (gas: 3078619) -MarketTest:testLiquidationResultingInZeroCollateralAndZeroDebt() (gas: 1958695) -MarketTest:testMaturityInsufficientProtocolLiquidity() (gas: 1424315) -MarketTest:testMultipleBorrowsForMultipleAssets() (gas: 2463381809) -MarketTest:testMultipleDepositsToSmartPool() (gas: 915573) -MarketTest:testMultipleFixedBorrowsRepays() (gas: 1313863) +MarketTest:testLiquidateWithZeroAsMaxAssets() (gas: 1039184) +MarketTest:testLiquidationClearingDebtOfAllAccountMarkets() (gas: 3078663) +MarketTest:testLiquidationResultingInZeroCollateralAndZeroDebt() (gas: 1958609) +MarketTest:testMaturityInsufficientProtocolLiquidity() (gas: 1424359) +MarketTest:testMultipleBorrowsForMultipleAssets() (gas: 2463409399) +MarketTest:testMultipleDepositsToSmartPool() (gas: 915595) +MarketTest:testMultipleFixedBorrowsRepays() (gas: 1313796) MarketTest:testMultipleLiquidationSameUser() (gas: 2928224) -MarketTest:testNotEnteredMarketShouldNotBeSeized() (gas: 8562362) -MarketTest:testOnlyAdminCanFreezeUnfreeze() (gas: 207703) -MarketTest:testOperationsShouldUpdateFloatingAssetsAverage() (gas: 1374209) -MarketTest:testOperationsWithBtcWbtcRate() (gas: 8263714) -MarketTest:testOperationsWithStEthAsset() (gas: 8139678) -MarketTest:testPausable() (gas: 158136) +MarketTest:testNotEnteredMarketShouldNotBeSeized() (gas: 8569292) +MarketTest:testOnlyAdminCanFreezeUnfreeze() (gas: 207636) +MarketTest:testOperationsShouldUpdateFloatingAssetsAverage() (gas: 1374231) +MarketTest:testOperationsWithBtcWbtcRate() (gas: 8270610) +MarketTest:testOperationsWithStEthAsset() (gas: 8146520) +MarketTest:testPausable() (gas: 158158) MarketTest:testPauserRole() (gas: 78161) -MarketTest:testPreviewOperationsWithSmartPoolCorrectlyAccountingEarnings() (gas: 1960168) +MarketTest:testPreviewOperationsWithSmartPoolCorrectlyAccountingEarnings() (gas: 1960190) MarketTest:testRepayAtMaturity() (gas: 578478) -MarketTest:testRepayDisagreement() (gas: 576767) -MarketTest:testRepayFlexibleBorrow() (gas: 1076240) -MarketTest:testRepayWhenFrozen() (gas: 535326) -MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferring() (gas: 7522637) -MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferringFrom() (gas: 7577923) +MarketTest:testRepayDisagreement() (gas: 576789) +MarketTest:testRepayFlexibleBorrow() (gas: 1076306) +MarketTest:testRepayWhenFrozen() (gas: 535348) +MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferring() (gas: 7529606) +MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferringFrom() (gas: 7584870) MarketTest:testRoundingDownAssetsWhenTransferingFromAnAccountWithoutShortfall() (gas: 1030163) MarketTest:testRoundingDownAssetsWhenTransferingWithAnAccountWithoutShortfall() (gas: 974729) -MarketTest:testRoundingUpAllowanceWhenBorrowingAtMaturity() (gas: 845587) +MarketTest:testRoundingUpAllowanceWhenBorrowingAtMaturity() (gas: 845500) MarketTest:testRoundingUpAllowanceWhenWithdrawingAtMaturity() (gas: 763364) -MarketTest:testSetAssetSymbol() (gas: 54907) +MarketTest:testSetAssetSymbol() (gas: 54929) MarketTest:testSetAssetSymbolNotAdmin() (gas: 66288) MarketTest:testSetDampSpeedFactorShouldUpdateFloatingAssetsAverage() (gas: 386894) MarketTest:testSetEarningsAccumulatorSmoothFactorShouldDistributeEarnings() (gas: 704407) -MarketTest:testSetInterestRateModelShouldUpdateFloatingDebt() (gas: 2821264) -MarketTest:testSetInterestRateModelWithAddressZeroShouldNotUpdateFloatingDebt() (gas: 2582153) -MarketTest:testShareValueNotDecreasingAfterDeposit() (gas: 707842) -MarketTest:testShareValueNotDecreasingWhenMintingToTreasury() (gas: 763156) -MarketTest:testSingleFloatingBorrow() (gas: 417427) -MarketTest:testSingleFloatingRepay() (gas: 484649) +MarketTest:testSetInterestRateModelShouldUpdateFloatingDebt() (gas: 2821286) +MarketTest:testSetInterestRateModelWithAddressZeroShouldNotUpdateFloatingDebt() (gas: 2582175) +MarketTest:testShareValueNotDecreasingAfterDeposit() (gas: 707864) +MarketTest:testShareValueNotDecreasingWhenMintingToTreasury() (gas: 763200) +MarketTest:testSingleFloatingBorrow() (gas: 417449) +MarketTest:testSingleFloatingRepay() (gas: 484671) MarketTest:testSmartPoolEarningsDistribution() (gas: 1104437) -MarketTest:testSmartPoolSharesDoNotAccountUnassignedEarningsFromMoreThanOneIntervalPastMaturities() (gas: 528421) -MarketTest:testSumDebtPlusEffectsShouldntRoundUpWhenWithdrawing() (gas: 1005521) -MarketTest:testTotalAssetsProjectingBackupEarningsCorrectly() (gas: 508216) -MarketTest:testTotalAssetsProjectingFloatingDebtCorrectly() (gas: 713848) +MarketTest:testSmartPoolSharesDoNotAccountUnassignedEarningsFromMoreThanOneIntervalPastMaturities() (gas: 528443) +MarketTest:testSumDebtPlusEffectsShouldntRoundUpWhenWithdrawing() (gas: 1005543) +MarketTest:testTotalAssetsProjectingBackupEarningsCorrectly() (gas: 508238) +MarketTest:testTotalAssetsProjectingFloatingDebtCorrectly() (gas: 713870) MarketTest:testUpdateAccumulatedEarningsFactorToZero() (gas: 1468787) MarketTest:testUpdateFloatingAssetsAverageWhenDepositingAndBorrowingContinuously() (gas: 344661) MarketTest:testUpdateFloatingAssetsAverageWhenDepositingRightBeforeBorrow() (gas: 630219) -MarketTest:testUpdateFloatingAssetsAverageWhenDepositingRightBeforeEarlyWithdraw() (gas: 612557) -MarketTest:testUpdateFloatingAssetsAverageWhenDepositingSomeSecondsBeforeBorrow() (gas: 854926) -MarketTest:testUpdateFloatingAssetsAverageWhenWithdrawingRightBeforeBorrow() (gas: 643349) -MarketTest:testUpdateFloatingAssetsAverageWhenWithdrawingRightBeforeEarlyWithdraw() (gas: 625709) +MarketTest:testUpdateFloatingAssetsAverageWhenDepositingRightBeforeEarlyWithdraw() (gas: 612579) +MarketTest:testUpdateFloatingAssetsAverageWhenDepositingSomeSecondsBeforeBorrow() (gas: 854948) +MarketTest:testUpdateFloatingAssetsAverageWhenWithdrawingRightBeforeBorrow() (gas: 643371) +MarketTest:testUpdateFloatingAssetsAverageWhenWithdrawingRightBeforeEarlyWithdraw() (gas: 625731) MarketTest:testUpdateFloatingAssetsAverageWhenWithdrawingSomeSecondsBeforeBorrow() (gas: 373134) MarketTest:testUpdateFloatingAssetsAverageWithDampSpeedDown() (gas: 358070) -MarketTest:testUpdateFloatingAssetsAverageWithDampSpeedUp() (gas: 199697) -MarketTest:testUpdateFloatingDebtBeforeSettingTreasury() (gas: 106395) -MarketTest:testWithdrawAtMaturity() (gas: 287122) -MarketTest:testWithdrawFromSmartPool() (gas: 279199) -MarketTest:testWithdrawShouldUpdateFlexibleBorrowVariables() (gas: 863981) -MarketTest:testWithdrawWhenFrozen() (gas: 325961) +MarketTest:testUpdateFloatingAssetsAverageWithDampSpeedUp() (gas: 199719) +MarketTest:testUpdateFloatingDebtBeforeSettingTreasury() (gas: 106329) +MarketTest:testWithdrawAtMaturity() (gas: 287144) +MarketTest:testWithdrawFromSmartPool() (gas: 279221) +MarketTest:testWithdrawShouldUpdateFlexibleBorrowVariables() (gas: 864003) +MarketTest:testWithdrawWhenFrozen() (gas: 325983) PoolLibTest:testAtomicDepositBorrowRepayWithdraw() (gas: 46018) PoolLibTest:testBackupBorrow() (gas: 33676) PoolLibTest:testEarningsAccrual() (gas: 38999) @@ -280,24 +281,24 @@ PreviewerTest:testAccountsReturningUtilizationForDifferentMaturities() (gas: 418 PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 862391) PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 2232872) PreviewerTest:testAccountsWithEmptyAccount() (gas: 690558) -PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 17625370) -PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 7788395) +PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 17632262) +PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 7788405) PreviewerTest:testEmptyExactly() (gas: 5668798) PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 688149) -PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 13309444) -PreviewerTest:testFixedPoolsA() (gas: 19286841) +PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 13316358) +PreviewerTest:testFixedPoolsA() (gas: 19293755) PreviewerTest:testFixedPoolsChangingMaturityInTime() (gas: 1627253) -PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 14822954) -PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 15628885) -PreviewerTest:testFlexibleAvailableLiquidity() (gas: 17210927) -PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 4400994) -PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 12562166) -PreviewerTest:testFloatingRateAndUtilization() (gas: 1128224) -PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 7186893) -PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2469656) -PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 10999676) -PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 13189788) -PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 10141538) +PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 14829846) +PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 15635777) +PreviewerTest:testFlexibleAvailableLiquidity() (gas: 17217863) +PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 4401038) +PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 12569102) +PreviewerTest:testFloatingRateAndUtilization() (gas: 1128246) +PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 7198150) +PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2469700) +PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 11006596) +PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 13196746) +PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 10148436) PreviewerTest:testPreviewBorrowAtAllMaturitiesReturningAccurateAmount() (gas: 4222096) PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmount() (gas: 623347) PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmountWithIntermediateOperations() (gas: 1935493) @@ -340,88 +341,88 @@ PreviewerTest:testPreviewWithdrawAtMaturityWithOneUnit() (gas: 244783) PreviewerTest:testPreviewWithdrawAtMaturityWithSameTimestamp() (gas: 221971) PreviewerTest:testPreviewWithdrawAtMaturityWithZeroAmount() (gas: 244740) PreviewerTest:testReserveFactor() (gas: 707280) -PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6732312) -PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 7504407) +PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6732300) +PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 7504451) PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 6811623) -PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 19283875) -PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 18415133) -PreviewerTest:testRewardsRateX() (gas: 8150961) -PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 632562) +PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 19290811) +PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 18422035) +PreviewerTest:testRewardsRateX() (gas: 8150983) +PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 632538) PriceFeedDoubleTest:testPriceFeedDoubleReturningPrice() (gas: 53190) PriceFeedDoubleTest:testPriceFeedDoubleWithActualOnChainValues() (gas: 76310) PriceFeedDoubleTest:testPriceFeedDoubleWithNegativePriceShouldRevert() (gas: 165716) -PriceFeedDoubleTest:testPriceFeedDoubleWithUsdPriceFeed() (gas: 488705) +PriceFeedDoubleTest:testPriceFeedDoubleWithUsdPriceFeed() (gas: 488693) PriceFeedPoolTest:testPriceFeedPoolReturningPrice() (gas: 27382) -PriceFeedPoolTest:testPriceFeedPoolReturningPriceWithToken0False() (gas: 2137871) -PriceFeedPoolTest:testPriceFeedPoolWithAllDifferentDecimals() (gas: 2130988) -PriceFeedPoolTest:testPriceFeedPoolWithAllDifferentDecimalsWithToken0False() (gas: 2136051) -PriceFeedPoolTest:testPriceFeedPoolWithDifferentDecimals() (gas: 2130990) -PriceFeedPoolTest:testPriceFeedPoolWithDifferentDecimalsWithToken0False() (gas: 2136108) +PriceFeedPoolTest:testPriceFeedPoolReturningPriceWithToken0False() (gas: 2137883) +PriceFeedPoolTest:testPriceFeedPoolWithAllDifferentDecimals() (gas: 2131000) +PriceFeedPoolTest:testPriceFeedPoolWithAllDifferentDecimalsWithToken0False() (gas: 2136063) +PriceFeedPoolTest:testPriceFeedPoolWithDifferentDecimals() (gas: 2131002) +PriceFeedPoolTest:testPriceFeedPoolWithDifferentDecimalsWithToken0False() (gas: 2136120) PriceFeedWrapperTest:testPriceFeedWrapperReturningPrice() (gas: 19129) PriceFeedWrapperTest:testPriceFeedWrapperReturningPriceAfterRebase() (gas: 48989) PriceFeedWrapperTest:testPriceFeedWrapperWithActualOnChainValues() (gas: 75210) PriceFeedWrapperTest:testPriceFeedWrapperWithNegativePriceShouldRevert() (gas: 164216) -PriceFeedWrapperTest:testPriceFeedWrapperWithUsdPriceFeed() (gas: 1278197) -RewardsControllerTest:testAccrueRewardsForWholeDistributionPeriod() (gas: 1245234) +PriceFeedWrapperTest:testPriceFeedWrapperWithUsdPriceFeed() (gas: 1278185) +RewardsControllerTest:testAccrueRewardsForWholeDistributionPeriod() (gas: 1245256) RewardsControllerTest:testAccrueRewardsWithBadDebtClearingOfFixedBorrow() (gas: 3320587) -RewardsControllerTest:testAccrueRewardsWithRepayOfBorrowBalance() (gas: 1602508) +RewardsControllerTest:testAccrueRewardsWithRepayOfBorrowBalance() (gas: 1602530) RewardsControllerTest:testAccrueRewardsWithRepayOfFixedBorrowBalance() (gas: 1786858) -RewardsControllerTest:testAccrueRewardsWithSeizeOfAllDepositShares() (gas: 1991051) -RewardsControllerTest:testAfterDistributionPeriodEnd() (gas: 1818257) -RewardsControllerTest:testAllClaimableUSDCWithAnotherAccountInPool() (gas: 2273310) -RewardsControllerTest:testAllClaimableUSDCWithDeposit() (gas: 1627684) -RewardsControllerTest:testAllClaimableUSDCWithFloatingBorrow() (gas: 1560022) -RewardsControllerTest:testAllClaimableUSDCWithFloatingRefund() (gas: 1667214) -RewardsControllerTest:testAllClaimableUSDCWithFloatingRepay() (gas: 1673728) -RewardsControllerTest:testAllClaimableUSDCWithMint() (gas: 1284274) -RewardsControllerTest:testAllClaimableUSDCWithRedeem() (gas: 1640377) -RewardsControllerTest:testAllClaimableUSDCWithTransfer() (gas: 2220286) -RewardsControllerTest:testAllClaimableUSDCWithTransferFrom() (gas: 2135225) -RewardsControllerTest:testAllClaimableUSDCWithWithdraw() (gas: 1641412) -RewardsControllerTest:testAllClaimableWETH() (gas: 1247767) +RewardsControllerTest:testAccrueRewardsWithSeizeOfAllDepositShares() (gas: 1991095) +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: 1127872) -RewardsControllerTest:testAllClaimableWithTimeElapsedZero() (gas: 1624595) -RewardsControllerTest:testClaim() (gas: 1192139) -RewardsControllerTest:testClaimAll() (gas: 2188694) +RewardsControllerTest:testAllClaimableWithTimeElapsedZero() (gas: 1624639) +RewardsControllerTest:testClaim() (gas: 1192161) +RewardsControllerTest:testClaimAll() (gas: 2188738) RewardsControllerTest:testClaimMarketWithoutRewards() (gas: 1240977) -RewardsControllerTest:testClaimWithNotEnabledRewardAsset() (gas: 1222615) +RewardsControllerTest:testClaimWithNotEnabledRewardAsset() (gas: 1222637) RewardsControllerTest:testConfigSettingNewStartWithOnGoingDistributionShouldNotUpdate() (gas: 430182) RewardsControllerTest:testConfigWithDistributionNotYetStartedShouldNotFail() (gas: 613404) RewardsControllerTest:testConfigWithTransitionFactorHigherOrEqThanCap() (gas: 107189) RewardsControllerTest:testConfigWithZeroDepositAllocationWeightFactorShouldRevert() (gas: 71542) RewardsControllerTest:testDifferentDistributionTimeForDifferentRewards() (gas: 2025643) -RewardsControllerTest:testEmitAccrue() (gas: 1317894) -RewardsControllerTest:testEmitClaimRewards() (gas: 1112353) +RewardsControllerTest:testEmitAccrue() (gas: 1317916) +RewardsControllerTest:testEmitClaimRewards() (gas: 1112375) RewardsControllerTest:testEmitConfigUpdate() (gas: 439567) -RewardsControllerTest:testEmitIndexUpdate() (gas: 1445508) -RewardsControllerTest:testLastUndistributed() (gas: 2189639) -RewardsControllerTest:testOperationAfterDistributionEnded() (gas: 722954) -RewardsControllerTest:testOperationsBeforeDistributionStart() (gas: 1674554) -RewardsControllerTest:testPermitClaim() (gas: 1275279) -RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 11464301) +RewardsControllerTest:testEmitIndexUpdate() (gas: 1445530) +RewardsControllerTest:testLastUndistributed() (gas: 2189661) +RewardsControllerTest:testOperationAfterDistributionEnded() (gas: 722976) +RewardsControllerTest:testOperationsBeforeDistributionStart() (gas: 1674576) +RewardsControllerTest:testPermitClaim() (gas: 1275301) +RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 11471253) RewardsControllerTest:testSetDistributionOperationShouldUpdateIndex() (gas: 136200) -RewardsControllerTest:testSetDistributionWithOnGoingMarketOperations() (gas: 1202336) -RewardsControllerTest:testSetHigherTotalDistribution() (gas: 1831179) -RewardsControllerTest:testSetLowerAndEqualDistributionPeriodThanCurrentTimestampShouldRevert() (gas: 1274674) -RewardsControllerTest:testSetLowerAndEqualTotalDistributionThanReleasedShouldRevert() (gas: 1267699) -RewardsControllerTest:testSetLowerDistributionPeriod() (gas: 2284154) -RewardsControllerTest:testSetLowerDistributionPeriodAndLowerTotalDistribution() (gas: 2286879) -RewardsControllerTest:testSetLowerTotalDistribution() (gas: 1831092) -RewardsControllerTest:testSetNewDistributionPeriod() (gas: 3143950) -RewardsControllerTest:testSetNewDistributionPeriodAfterDistributionEnds() (gas: 1406644) -RewardsControllerTest:testSetNewTargetDebt() (gas: 1671503) -RewardsControllerTest:testSetNewTargetDebtAfterDistributionEnds() (gas: 1734944) -RewardsControllerTest:testSetNewTargetDebtWithClaimOnlyAtEnd() (gas: 1389639) -RewardsControllerTest:testSetNewTreasuryFeeShouldImpactAllocation() (gas: 658860) -RewardsControllerTest:testSetTargetDebtMultipleTimes() (gas: 2719280) -RewardsControllerTest:testSetTargetDebtMultipleTimesAfterEnd() (gas: 2756050) -RewardsControllerTest:testSetTotalDistributionMultipleTimes() (gas: 1838200) -RewardsControllerTest:testTriggerHandleBorrowHookBeforeUpdatingFloatingDebt() (gas: 1858531) -RewardsControllerTest:testUpdateConfig() (gas: 1328833) -RewardsControllerTest:testUpdateIndexesWithUtilizationEqualToOne() (gas: 1257749) -RewardsControllerTest:testUpdateIndexesWithUtilizationHigherThanOne() (gas: 1352490) +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: 1858553) +RewardsControllerTest:testUpdateConfig() (gas: 1328855) +RewardsControllerTest:testUpdateIndexesWithUtilizationEqualToOne() (gas: 1257771) +RewardsControllerTest:testUpdateIndexesWithUtilizationHigherThanOne() (gas: 1352512) RewardsControllerTest:testUpdateWithTotalDebtZeroShouldUpdateLastUndistributed() (gas: 575506) -RewardsControllerTest:testUtilizationEqualZero() (gas: 921841) +RewardsControllerTest:testUtilizationEqualZero() (gas: 921863) RewardsControllerTest:testWithTwelveFixedPools() (gas: 8054985) RewardsControllerTest:testWithdrawAllRewardBalance() (gas: 71913) RewardsControllerTest:testWithdrawOnlyAdminRole() (gas: 122309) diff --git a/contracts/Market.sol b/contracts/Market.sol index a07ed3a6a..8172a1965 100644 --- a/contracts/Market.sol +++ b/contracts/Market.sol @@ -142,6 +142,7 @@ contract Market is Initializable, AccessControlUpgradeable, PausableUpgradeable, address receiver, address borrower ) external whenNotPaused whenNotFrozen returns (uint256 borrowShares) { + if (assets == 0) revert ZeroBorrow(); spendAllowance(borrower, assets); RewardsController memRewardsController = rewardsController; diff --git a/test/InterestRateModel.t.sol b/test/InterestRateModel.t.sol index 52d6d3be4..0b72c1d54 100644 --- a/test/InterestRateModel.t.sol +++ b/test/InterestRateModel.t.sol @@ -234,7 +234,9 @@ contract InterestRateModelTest is Test { asset.approve(address(market), type(uint128).max); if (floatingAssets != 0) market.deposit(floatingAssets, address(this)); vm.warp(timestamp); - market.borrow(floatingDebt, address(this), address(this)); + if (floatingDebt != 0) { + market.borrow(floatingDebt, address(this), address(this)); + } Vars memory v; v.backupBorrowed = 0; diff --git a/test/Market.t.sol b/test/Market.t.sol index b7decde24..eac06516a 100644 --- a/test/Market.t.sol +++ b/test/Market.t.sol @@ -227,6 +227,11 @@ contract MarketTest is Test { market.borrowAtMaturity(FixedLib.INTERVAL, 0, 0, address(this), address(this)); } + function testBorrowWithZeroAssets() external { + vm.expectRevert(ZeroBorrow.selector); + market.borrow(0, address(this), BOB); + } + function testDepositAtMaturityWithZeroAssets() external { vm.expectRevert(ZeroDeposit.selector); market.depositAtMaturity(FixedLib.INTERVAL, 0, 0, address(this)); diff --git a/test/Previewer.t.sol b/test/Previewer.t.sol index 612982552..8b4912c18 100644 --- a/test/Previewer.t.sol +++ b/test/Previewer.t.sol @@ -1051,7 +1051,7 @@ contract PreviewerTest is Test { market.deposit(10_000 ether, address(this)); market.borrow(2_000 ether, address(this), address(this)); vm.warp(block.timestamp + 1 weeks); - market.borrow(0, address(this), address(this)); + market.borrow(1, address(this), address(this)); Previewer.MarketAccount[] memory data = previewer.exactly(address(this)); assertEq(data[0].rewardRates.length, 1); assertEq(data[0].rewardRates[0].maturities.length, 12); diff --git a/test/Protocol.t.sol b/test/Protocol.t.sol index 73c0f9c19..f5d777495 100644 --- a/test/Protocol.t.sol +++ b/test/Protocol.t.sol @@ -410,7 +410,9 @@ contract ProtocolTest is Test { uint256 expectedShares = market.previewBorrow(assets); (uint256 collateral, uint256 debt) = previewAccountLiquidity(account, market, assets, expectedShares); - if ( + if (assets == 0) { + vm.expectRevert(ZeroBorrow.selector); + } else if ( market.floatingBackupBorrowed() + market.totalFloatingBorrowAssets() + assets > (market.floatingAssets() + previewNewFloatingDebt(market)).mulWadDown(1e18 - RESERVE_FACTOR) ) {