From 10ed0540887f9836785aec441f4d0d9a34c01517 Mon Sep 17 00:00:00 2001 From: Santiago Sanchez Avalos Date: Wed, 19 Apr 2023 13:20:38 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20market:=20remove=20unneces?= =?UTF-8?q?sary=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/heavy-wolves-wonder.md | 5 ++++ .gas-snapshot | 40 +++++++++++++++---------------- contracts/Market.sol | 4 ++-- 3 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 .changeset/heavy-wolves-wonder.md diff --git a/.changeset/heavy-wolves-wonder.md b/.changeset/heavy-wolves-wonder.md new file mode 100644 index 000000000..4ab6d6fe3 --- /dev/null +++ b/.changeset/heavy-wolves-wonder.md @@ -0,0 +1,5 @@ +--- +"@exactly-protocol/protocol": patch +--- + +⚡️ market: remove unnecessary checks diff --git a/.gas-snapshot b/.gas-snapshot index 3e62a842c..881668aec 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -83,20 +83,20 @@ MarketTest:testLiquidateWithZeroAsMaxAssets() (gas: 612540) MarketTest:testLiquidationClearingDebtOfAllAccountMarkets() (gas: 1318490) MarketTest:testLiquidationResultingInZeroCollateralAndZeroDebt() (gas: 913182) MarketTest:testMaturityInsufficientProtocolLiquidity() (gas: 877259) -MarketTest:testMultipleBorrowsForMultipleAssets() (gas: 601653099) +MarketTest:testMultipleBorrowsForMultipleAssets() (gas: 601613003) MarketTest:testMultipleDepositsToSmartPool() (gas: 326688) MarketTest:testMultipleFixedBorrowsRepays() (gas: 755233) MarketTest:testMultipleLiquidationSameUser() (gas: 1288228) -MarketTest:testNotEnteredMarketShouldNotBeSeized() (gas: 7101370) +MarketTest:testNotEnteredMarketShouldNotBeSeized() (gas: 7091333) MarketTest:testOperationsShouldUpdateFloatingAssetsAverage() (gas: 639876) -MarketTest:testOperationsWithBtcWbtcRate() (gas: 6989939) -MarketTest:testOperationsWithStEthAsset() (gas: 6943359) +MarketTest:testOperationsWithBtcWbtcRate() (gas: 6979902) +MarketTest:testOperationsWithStEthAsset() (gas: 6933322) MarketTest:testPreviewOperationsWithSmartPoolCorrectlyAccountingEarnings() (gas: 862638) MarketTest:testRepayAtMaturity() (gas: 352598) MarketTest:testRepayDisagreement() (gas: 429606) MarketTest:testRepayFlexibleBorrow() (gas: 549006) -MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferring() (gas: 6390828) -MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferringFrom() (gas: 6419574) +MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferring() (gas: 6380790) +MarketTest:testRoundingDownAssetsToValidateShortfallWhenTransferringFrom() (gas: 6409536) MarketTest:testRoundingDownAssetsWhenTransferingFromAnAccountWithoutShortfall() (gas: 588729) MarketTest:testRoundingDownAssetsWhenTransferingWithAnAccountWithoutShortfall() (gas: 561864) MarketTest:testRoundingUpAllowanceWhenBorrowingAtMaturity() (gas: 489301) @@ -139,24 +139,24 @@ PreviewerTest:testAccountsReturningUtilizationForDifferentMaturities() (gas: 334 PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 817676) PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 1567906) PreviewerTest:testAccountsWithEmptyAccount() (gas: 669155) -PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 13302499) +PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 13292475) PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 6655321) PreviewerTest:testEmptyExactly() (gas: 4947271) PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 665268) -PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 9577211) -PreviewerTest:testFixedPoolsA() (gas: 15075788) +PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 9567187) +PreviewerTest:testFixedPoolsA() (gas: 15065764) PreviewerTest:testFixedPoolsChangingMaturityInTime() (gas: 1619713) -PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 9984330) -PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 11946964) -PreviewerTest:testFlexibleAvailableLiquidity() (gas: 13532985) +PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 9974306) +PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 11936940) +PreviewerTest:testFlexibleAvailableLiquidity() (gas: 13522961) PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 3491385) -PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 9145712) +PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 9135688) PreviewerTest:testFloatingRateAndUtilization() (gas: 935395) PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 5985320) PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2045904) -PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 7892694) -PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 9317743) -PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 7422433) +PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 7882657) +PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 9307719) +PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 7412396) PreviewerTest:testPreviewBorrowAtAllMaturitiesReturningAccurateAmount() (gas: 1774808) PreviewerTest:testPreviewBorrowAtAllMaturitiesReturningMaxUint256() (gas: 347776) PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmount() (gas: 477081) @@ -202,7 +202,7 @@ PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6015488) PreviewerTest:testRewardsRate() (gas: 6773812) PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 6145096) PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 5902992) -PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 14205814) +PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 14195790) PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 433282) PriceFeedDoubleTest:testPriceFeedDoubleReturningPrice() (gas: 26143) PriceFeedDoubleTest:testPriceFeedDoubleWithActualOnChainValues() (gas: 30976) @@ -226,8 +226,8 @@ RewardsControllerTest:testAllClaimableUSDCWithFloatingRefund() (gas: 1319578) RewardsControllerTest:testAllClaimableUSDCWithFloatingRepay() (gas: 1324908) RewardsControllerTest:testAllClaimableUSDCWithMint() (gas: 1212417) RewardsControllerTest:testAllClaimableUSDCWithRedeem() (gas: 1267798) -RewardsControllerTest:testAllClaimableUSDCWithTransfer() (gas: 1906455) -RewardsControllerTest:testAllClaimableUSDCWithTransferFrom() (gas: 1783130) +RewardsControllerTest:testAllClaimableUSDCWithTransfer() (gas: 1906398) +RewardsControllerTest:testAllClaimableUSDCWithTransferFrom() (gas: 1783072) RewardsControllerTest:testAllClaimableUSDCWithWithdraw() (gas: 1268846) RewardsControllerTest:testAllClaimableWETH() (gas: 1189976) RewardsControllerTest:testAllClaimableWithMaturedFixedPool() (gas: 1058718) @@ -248,7 +248,7 @@ RewardsControllerTest:testEmitIndexUpdate() (gas: 1080136) RewardsControllerTest:testLastUndistributed() (gas: 1527232) RewardsControllerTest:testOperationAfterDistributionEnded() (gas: 625495) RewardsControllerTest:testOperationsBeforeDistributionStart() (gas: 1257041) -RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 9760768) +RewardsControllerTest:testSetDistributionConfigWithDifferentDecimals() (gas: 9750731) RewardsControllerTest:testSetDistributionOperationShouldUpdateIndex() (gas: 111881) RewardsControllerTest:testSetDistributionWithOnGoingMarketOperations() (gas: 967008) RewardsControllerTest:testSetHigherTotalDistribution() (gas: 1323648) diff --git a/contracts/Market.sol b/contracts/Market.sol index 78327dcd5..990c33359 100644 --- a/contracts/Market.sol +++ b/contracts/Market.sol @@ -756,7 +756,7 @@ contract Market is Initializable, AccessControlUpgradeable, PausableUpgradeable, RewardsController memRewardsController = rewardsController; if (address(memRewardsController) != address(0)) { memRewardsController.handleDeposit(msg.sender); - if (msg.sender != to) memRewardsController.handleDeposit(to); + memRewardsController.handleDeposit(to); } return super.transfer(to, shares); } @@ -772,7 +772,7 @@ contract Market is Initializable, AccessControlUpgradeable, PausableUpgradeable, RewardsController memRewardsController = rewardsController; if (address(memRewardsController) != address(0)) { memRewardsController.handleDeposit(from); - if (from != to) memRewardsController.handleDeposit(to); + memRewardsController.handleDeposit(to); } return super.transferFrom(from, to, shares); }