Skip to content

Commit

Permalink
🦺 irm: limit parameters range
Browse files Browse the repository at this point in the history
  • Loading branch information
itofarina authored and cruzdanilo committed Dec 19, 2023
1 parent 59acfb9 commit 9cad450
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-rings-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@exactly/protocol": patch
---

🦺 irm: limit parameters range
32 changes: 16 additions & 16 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ EscrowedEXATest:testWithdrawMaxShouldGiveReserveBackWhenDepleted() (gas: 329348)
EscrowedEXATest:testWithdrawMaxWithInvalidSender() (gas: 342488)
InterestRateModelTest:testFixedBorrowRate() (gas: 16450)
InterestRateModelTest:testFloatingBorrowRate() (gas: 10320)
InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 38533)
InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 38754)
MarketTest:testAccountLiquidityAdjustedDebt() (gas: 383831)
MarketTest:testAnotherUserRedeemWhenOwnerHasShortfall() (gas: 489509)
MarketTest:testAnotherUserWithdrawWhenOwnerHasShortfall() (gas: 477075)
Expand Down Expand Up @@ -162,7 +162,7 @@ MarketTest:testDepositShouldUpdateFlexibleBorrowVariables() (gas: 448254)
MarketTest:testDepositToSmartPool() (gas: 160015)
MarketTest:testDistributeMultipleAccumulatedEarnings() (gas: 592925)
MarketTest:testDistributionOfLossesShouldReduceFromFloatingBackupBorrowedAccordingly() (gas: 2067235)
MarketTest:testEarlyRepaymentWithExcessiveAmountOfFees() (gas: 2365749)
MarketTest:testEarlyRepaymentWithExcessiveAmountOfFees() (gas: 2366061)
MarketTest:testEarlyWithdrawFromFreeLunchShouldNotRevertWithFloatingFullUtilization() (gas: 617061)
MarketTest:testFixedBorrowFailingWhenFlexibleBorrowAccruesDebt() (gas: 792249)
MarketTest:testFlexibleBorrow() (gas: 331625)
Expand Down Expand Up @@ -211,8 +211,8 @@ MarketTest:testRoundingUpAllowanceWhenBorrowingAtMaturity() (gas: 503512)
MarketTest:testRoundingUpAllowanceWhenWithdrawingAtMaturity() (gas: 526862)
MarketTest:testSetDampSpeedFactorShouldUpdateFloatingAssetsAverage() (gas: 243874)
MarketTest:testSetEarningsAccumulatorSmoothFactorShouldDistributeEarnings() (gas: 498598)
MarketTest:testSetInterestRateModelShouldUpdateFloatingDebt() (gas: 2024682)
MarketTest:testSetInterestRateModelWithAddressZeroShouldNotUpdateFloatingDebt() (gas: 1887371)
MarketTest:testSetInterestRateModelShouldUpdateFloatingDebt() (gas: 2024994)
MarketTest:testSetInterestRateModelWithAddressZeroShouldNotUpdateFloatingDebt() (gas: 1887683)
MarketTest:testShareValueNotDecreasingAfterDeposit() (gas: 474574)
MarketTest:testShareValueNotDecreasingWhenMintingToTreasury() (gas: 480569)
MarketTest:testSingleFloatingBorrow() (gas: 328751)
Expand Down Expand Up @@ -247,24 +247,24 @@ PreviewerTest:testAccountsReturningUtilizationForDifferentMaturities() (gas: 341
PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 807897)
PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 1689343)
PreviewerTest:testAccountsWithEmptyAccount() (gas: 656553)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 15046830)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 15047124)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 7013341)
PreviewerTest:testEmptyExactly() (gas: 5225383)
PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 651134)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 11156105)
PreviewerTest:testFixedPoolsA() (gas: 16265567)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 11156399)
PreviewerTest:testFixedPoolsA() (gas: 16265861)
PreviewerTest:testFixedPoolsChangingMaturityInTime() (gas: 1590533)
PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 12635629)
PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 13515643)
PreviewerTest:testFlexibleAvailableLiquidity() (gas: 14710040)
PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 12635923)
PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 13515937)
PreviewerTest:testFlexibleAvailableLiquidity() (gas: 14710334)
PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 3633520)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 10746152)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 10746446)
PreviewerTest:testFloatingRateAndUtilization() (gas: 973554)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 6289934)
PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2101880)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 9464882)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 10945432)
PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 8987296)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 9465176)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 10945726)
PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 8987590)
PreviewerTest:testPreviewBorrowAtAllMaturitiesReturningAccurateAmount() (gas: 3056390)
PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmount() (gas: 522367)
PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmountWithIntermediateOperations() (gas: 1182851)
Expand Down Expand Up @@ -308,8 +308,8 @@ PreviewerTest:testPreviewWithdrawAtMaturityWithZeroAmount() (gas: 220110)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6249941)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 6451623)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 6204960)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 16993794)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 16242760)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 16994088)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 16243054)
PreviewerTest:testRewardsRateX() (gas: 7237419)
PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 433304)
PriceFeedDoubleTest:testPriceFeedDoubleReturningPrice() (gas: 26165)
Expand Down
13 changes: 12 additions & 1 deletion contracts/InterestRateModel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ contract InterestRateModel {
int256 timePreference_,
uint256 maturitySpeed_
) {
assert(maxUtilization_ > 1e18);
assert(
curveA_ != 0 &&
maxUtilization_ > 1e18 &&
floatingNaturalUtilization_ != 0 &&
floatingNaturalUtilization_ < 1e18 &&
sigmoidSpeed_ != 0 &&
growthSpeed_ != 0 &&
maxRate_ != 0 &&
maxRate_ <= 15_000e16 &&
spreadFactor_ != 0 &&
maturitySpeed_ != 0
);

market = market_;

Expand Down

0 comments on commit 9cad450

Please sign in to comment.