Skip to content

Commit

Permalink
✅ irm: fuzz parameters on differential tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Jan 19, 2024
1 parent 648947a commit 1da95b3
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 130 deletions.
36 changes: 18 additions & 18 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ EscrowedEXATest:testWithdrawFromUnknownStream() (gas: 899015)
EscrowedEXATest:testWithdrawMaxFromMultipleStreams() (gas: 1014578)
EscrowedEXATest:testWithdrawMaxShouldGiveReserveBackWhenDepleted() (gas: 329285)
EscrowedEXATest:testWithdrawMaxWithInvalidSender() (gas: 342488)
InterestRateModelTest:testFixedBorrowRate() (gas: 17380)
InterestRateModelTest:testFloatingBorrowRate() (gas: 10725)
InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 38822)
InterestRateModelTest:testFixedBorrowRate() (gas: 1622881)
InterestRateModelTest:testFloatingBorrowRate() (gas: 1616225)
InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 60820)
MarketTest:testAccountLiquidityAdjustedDebt() (gas: 383489)
MarketTest:testAnotherUserRedeemWhenOwnerHasShortfall() (gas: 488711)
MarketTest:testAnotherUserWithdrawWhenOwnerHasShortfall() (gas: 476505)
Expand Down Expand Up @@ -162,7 +162,7 @@ MarketTest:testDepositShouldUpdateFlexibleBorrowVariables() (gas: 447456)
MarketTest:testDepositToSmartPool() (gas: 160015)
MarketTest:testDistributeMultipleAccumulatedEarnings() (gas: 591785)
MarketTest:testDistributionOfLossesShouldReduceFromFloatingBackupBorrowedAccordingly() (gas: 2064134)
MarketTest:testEarlyRepaymentWithExcessiveAmountOfFees() (gas: 2414528)
MarketTest:testEarlyRepaymentWithExcessiveAmountOfFees() (gas: 2436532)
MarketTest:testEarlyWithdrawFromFreeLunchShouldNotRevertWithFloatingFullUtilization() (gas: 616605)
MarketTest:testFixedBorrowFailingWhenFlexibleBorrowAccruesDebt() (gas: 790083)
MarketTest:testFlexibleBorrow() (gas: 331283)
Expand Down Expand Up @@ -211,8 +211,8 @@ MarketTest:testRoundingUpAllowanceWhenBorrowingAtMaturity() (gas: 502600)
MarketTest:testRoundingUpAllowanceWhenWithdrawingAtMaturity() (gas: 526520)
MarketTest:testSetDampSpeedFactorShouldUpdateFloatingAssetsAverage() (gas: 243646)
MarketTest:testSetEarningsAccumulatorSmoothFactorShouldDistributeEarnings() (gas: 498256)
MarketTest:testSetInterestRateModelShouldUpdateFloatingDebt() (gas: 2071495)
MarketTest:testSetInterestRateModelWithAddressZeroShouldNotUpdateFloatingDebt() (gas: 1934185)
MarketTest:testSetInterestRateModelShouldUpdateFloatingDebt() (gas: 2093500)
MarketTest:testSetInterestRateModelWithAddressZeroShouldNotUpdateFloatingDebt() (gas: 1956190)
MarketTest:testShareValueNotDecreasingAfterDeposit() (gas: 473662)
MarketTest:testShareValueNotDecreasingWhenMintingToTreasury() (gas: 479429)
MarketTest:testSingleFloatingBorrow() (gas: 328409)
Expand Down Expand Up @@ -247,24 +247,24 @@ PreviewerTest:testAccountsReturningUtilizationForDifferentMaturities() (gas: 344
PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 808724)
PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 1701237)
PreviewerTest:testAccountsWithEmptyAccount() (gas: 657917)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 15073942)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 15095805)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 6961056)
PreviewerTest:testEmptyExactly() (gas: 5154447)
PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 652454)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 11146231)
PreviewerTest:testFixedPoolsA() (gas: 16307078)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 11168094)
PreviewerTest:testFixedPoolsA() (gas: 16328941)
PreviewerTest:testFixedPoolsChangingMaturityInTime() (gas: 1594625)
PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 12649750)
PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 13419439)
PreviewerTest:testFlexibleAvailableLiquidity() (gas: 14713502)
PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 12671613)
PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 13441302)
PreviewerTest:testFlexibleAvailableLiquidity() (gas: 14735365)
PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 3662843)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 10729434)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 10751297)
PreviewerTest:testFloatingRateAndUtilization() (gas: 977666)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 6227146)
PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2110157)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 9434504)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 10922291)
PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 8959402)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 9456367)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 10944154)
PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 8981265)
PreviewerTest:testPreviewBorrowAtAllMaturitiesReturningAccurateAmount() (gas: 3106487)
PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmount() (gas: 524407)
PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmountWithIntermediateOperations() (gas: 1189931)
Expand Down Expand Up @@ -308,8 +308,8 @@ PreviewerTest:testPreviewWithdrawAtMaturityWithZeroAmount() (gas: 220408)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6181312)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 6389417)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 6142939)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 16918109)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 16165445)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 16939972)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 16187308)
PreviewerTest:testRewardsRateX() (gas: 7187998)
PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 433304)
PriceFeedDoubleTest:testPriceFeedDoubleReturningPrice() (gas: 26165)
Expand Down
21 changes: 11 additions & 10 deletions scripts/irm-fixed.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#!/usr/bin/env bash

read -ra input <<< "$(cast abi-decode "_()(uint256,uint256,uint256,int256,int256,uint256,uint256,uint256,uint256,uint256)" "$1" | sed 's/ .*//' | xargs)"
read -ra input <<< "$(cast abi-decode "_()(uint256,uint256,int256,int256,int256,uint256,uint256,uint256,uint256,uint256)" "$1" | sed 's/ .*//' | xargs)"

rate=$(bc -l <<< "
scale = 2 * 18
wad = 1000000000000000000
ufixed = ${input[0]} / wad
uglobal = ${input[1]} / wad
fixedunat = ${input[2]} / wad
base = ${input[3]} / wad
base = ${input[0]} / wad
fixedunat = ${input[1]} / wad
spreadf = ${input[2]} / wad
tpref = ${input[3]} / wad
ttmspeed = ${input[4]} / wad
spreadf = ${input[5]} / wad
tpref = ${input[6]} / wad
maxpools = ${input[7]}
maturity = ${input[8]}
maturity = ${input[5]}
maxpools = ${input[6]}
ufixed = ${input[7]} / wad
uglobal = ${input[8]} / wad
timestamp = ${input[9]}
if (ufixed == 0) {
rate = base
} else { sqalpha = maxpools / fixedunat
} else {
sqalpha = maxpools / fixedunat
alpha = sqrt(sqalpha)
sqx = maxpools * ufixed / (uglobal * fixedunat)
x = sqrt(sqx)
Expand Down
18 changes: 9 additions & 9 deletions scripts/irm-floating.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env bash

read -ra input <<< "$(cast abi-decode "_()(uint256,uint256,uint256,int256,uint256,uint256,uint256,uint256)" "$1" | sed 's/ .*//' | xargs)"
read -ra input <<< "$(cast abi-decode "_()(uint256,int256,uint256,uint256,int256,int256,uint256,uint256)" "$1" | sed 's/ .*//' | xargs)"

rate=$(bc -l <<< "
scale = 2 * 18
wad = 1000000000000000000
ufloating = ${input[0]} / wad
uglobal = ${input[1]} / wad
unat = ${input[2]} / wad
a = ${input[3]} / wad
b = ${input[4]} / wad
umax = ${input[5]} / wad
sspeed = ${input[6]} / wad
gspeed = ${input[7]} / wad
a = ${input[0]} / wad
b = ${input[1]} / wad
umax = ${input[2]} / wad
unat = ${input[3]} / wad
sspeed = ${input[4]} / wad
gspeed = ${input[5]} / wad
ufloating = ${input[6]} / wad
uglobal = ${input[7]} / wad
r = a / (umax - ufloating) + b
Expand Down
Loading

0 comments on commit 1da95b3

Please sign in to comment.