Skip to content

Commit

Permalink
⚡️ market: remove unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
santichez committed Apr 21, 2023
1 parent 8329997 commit 10ed054
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-wolves-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@exactly-protocol/protocol": patch
---

⚡️ market: remove unnecessary checks
40 changes: 20 additions & 20 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions contracts/Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 10ed054

Please sign in to comment.