Skip to content

Commit

Permalink
✨ previewer: update utilizations and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sebipap authored and cruzdanilo committed Jan 25, 2024
1 parent 05edf4f commit c416594
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 33 deletions.
64 changes: 32 additions & 32 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: 1602514)
InterestRateModelTest:testFixedBorrowRate() (gas: 1602558)
InterestRateModelTest:testFloatingBorrowRate() (gas: 1595762)
InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 38815)
InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 38837)
MarketTest:testAccountLiquidityAdjustedDebt() (gas: 383489)
MarketTest:testAnotherUserRedeemWhenOwnerHasShortfall() (gas: 488711)
MarketTest:testAnotherUserWithdrawWhenOwnerHasShortfall() (gas: 476505)
Expand Down Expand Up @@ -242,29 +242,29 @@ PoolLibTest:testEarningsAccrual() (gas: 37660)
PoolLibTest:testEarningsDistribution() (gas: 29462)
PoolLibTest:testMaturityRangeLimit() (gas: 3761)
PoolLibTest:testMaturityRangeTooWide() (gas: 6858)
PreviewerTest:testAccountsReturningAccurateAmounts() (gas: 1204126)
PreviewerTest:testAccountsReturningUtilizationForDifferentMaturities() (gas: 3438833)
PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 808547)
PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 1699178)
PreviewerTest:testAccountsWithEmptyAccount() (gas: 657916)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 15064600)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 6955622)
PreviewerTest:testEmptyExactly() (gas: 5154358)
PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 652342)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 11143409)
PreviewerTest:testFixedPoolsA() (gas: 16304418)
PreviewerTest:testFixedPoolsChangingMaturityInTime() (gas: 1594622)
PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 12642785)
PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 13417537)
PreviewerTest:testFlexibleAvailableLiquidity() (gas: 14711376)
PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 3655752)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 10727568)
PreviewerTest:testFloatingRateAndUtilization() (gas: 976543)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 6224199)
PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2108094)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 9435512)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 10921675)
PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 8961070)
PreviewerTest:testAccountsReturningAccurateAmounts() (gas: 1212003)
PreviewerTest:testAccountsReturningUtilizationForDifferentMaturities() (gas: 3470635)
PreviewerTest:testAccountsWithAccountOnlyDeposit() (gas: 816418)
PreviewerTest:testAccountsWithAccountThatHasBalances() (gas: 1707069)
PreviewerTest:testAccountsWithEmptyAccount() (gas: 665789)
PreviewerTest:testAccountsWithIntermediateOperationsReturningAccurateAmounts() (gas: 15150280)
PreviewerTest:testActualTimeBeforeStartDistributionRewards() (gas: 6971490)
PreviewerTest:testEmptyExactly() (gas: 5162121)
PreviewerTest:testExactlyReturningInterestRateModelData() (gas: 660213)
PreviewerTest:testFixedAvailableLiquidityProjectingNewFloatingDebt() (gas: 11177147)
PreviewerTest:testFixedPoolsA() (gas: 16408515)
PreviewerTest:testFixedPoolsChangingMaturityInTime() (gas: 1618365)
PreviewerTest:testFixedPoolsRatesAndUtilizations() (gas: 12693684)
PreviewerTest:testFixedPoolsWithFloatingAssetsAverage() (gas: 13485868)
PreviewerTest:testFlexibleAvailableLiquidity() (gas: 14797279)
PreviewerTest:testFlexibleBorrowSharesAndAssets() (gas: 3695552)
PreviewerTest:testFloatingAvailableLiquidityProjectingNewFloatingDebt() (gas: 10761281)
PreviewerTest:testFloatingRateAndUtilization() (gas: 984415)
PreviewerTest:testJustUpdatedRewardRatesShouldStillReturnRate() (gas: 6232025)
PreviewerTest:testMaxBorrowAssetsCapacity() (gas: 2131892)
PreviewerTest:testMaxBorrowAssetsCapacityForAccountWithShortfall() (gas: 9452081)
PreviewerTest:testMaxBorrowAssetsCapacityPerMarket() (gas: 10955525)
PreviewerTest:testOraclePriceReturningAccurateValues() (gas: 8977639)
PreviewerTest:testPreviewBorrowAtAllMaturitiesReturningAccurateAmount() (gas: 3100617)
PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmount() (gas: 524155)
PreviewerTest:testPreviewBorrowAtMaturityReturningAccurateAmountWithIntermediateOperations() (gas: 1188807)
Expand Down Expand Up @@ -294,7 +294,7 @@ PreviewerTest:testPreviewRepayAtMaturityWithMaturedMaturity() (gas: 497212)
PreviewerTest:testPreviewRepayAtMaturityWithOneUnit() (gas: 500402)
PreviewerTest:testPreviewRepayAtMaturityWithSameTimestamp() (gas: 495601)
PreviewerTest:testPreviewRepayAtMaturityWithZeroAmount() (gas: 500469)
PreviewerTest:testPreviewValueInFixedOperations() (gas: 1976003)
PreviewerTest:testPreviewValueInFixedOperations() (gas: 1991823)
PreviewerTest:testPreviewWithdrawAtMaturityReturningAccurateAmount() (gas: 213181)
PreviewerTest:testPreviewWithdrawAtMaturityReturningAccurateAmountWithIntermediateOperations() (gas: 771711)
PreviewerTest:testPreviewWithdrawAtMaturityWithEmptyMaturity() (gas: 35276)
Expand All @@ -305,12 +305,12 @@ PreviewerTest:testPreviewWithdrawAtMaturityWithMaturedMaturity() (gas: 197612)
PreviewerTest:testPreviewWithdrawAtMaturityWithOneUnit() (gas: 220304)
PreviewerTest:testPreviewWithdrawAtMaturityWithSameTimestamp() (gas: 197628)
PreviewerTest:testPreviewWithdrawAtMaturityWithZeroAmount() (gas: 220350)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6181134)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 6386242)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 6140826)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 16911977)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 16160955)
PreviewerTest:testRewardsRateX() (gas: 7181853)
PreviewerTest:testReturnRewardAssetUsdPrice() (gas: 6196996)
PreviewerTest:testRewardsRateAfterDistributionEnd() (gas: 6394069)
PreviewerTest:testRewardsRateOnlyWithFixedBorrows() (gas: 6148654)
PreviewerTest:testRewardsRateWithDifferentRewardLengths() (gas: 16928968)
PreviewerTest:testRewardsRateWithMarketWithDifferentDecimals() (gas: 16194683)
PreviewerTest:testRewardsRateX() (gas: 7197650)
PriceFeedDoubleTest:testPriceFeedDoubleReturningAccurateDecimals() (gas: 433304)
PriceFeedDoubleTest:testPriceFeedDoubleReturningPrice() (gas: 26165)
PriceFeedDoubleTest:testPriceFeedDoubleWithActualOnChainValues() (gas: 30909)
Expand Down
20 changes: 19 additions & 1 deletion contracts/periphery/Previewer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ contract Previewer {
RewardRate[] rewardRates;
uint256 floatingBorrowRate;
uint256 floatingUtilization;
uint256 floatingAssets;
uint256 floatingDebt;
uint256 floatingBackupBorrowed;
uint256 floatingAvailableAssets;
uint256 totalFloatingBorrowAssets;
Expand Down Expand Up @@ -82,6 +84,13 @@ contract Previewer {
int256 curveB;
uint256 maxUtilization;
uint256 naturalUtilization;
int256 growthSpeed;
int256 sigmoidSpeed;
int256 spreadFactor;
int256 maturitySpeed;
int256 timePreference;
uint256 fixedAllocation;
uint256 maxRate;
}

struct FixedPosition {
Expand Down Expand Up @@ -144,7 +153,14 @@ contract Previewer {
curveA: irm.floatingCurveA(),
curveB: irm.floatingCurveB(),
maxUtilization: irm.floatingMaxUtilization(),
naturalUtilization: irm.naturalUtilization()
naturalUtilization: irm.naturalUtilization(),
growthSpeed: irm.growthSpeed(),
sigmoidSpeed: irm.sigmoidSpeed(),
spreadFactor: irm.spreadFactor(),
maturitySpeed: irm.maturitySpeed(),
timePreference: irm.timePreference(),
fixedAllocation: irm.fixedAllocation(),
maxRate: irm.maxRate()
}),
usdPrice: auditor.assetPrice(m.priceFeed).mulWadDown(basePrice),
penaltyRate: market.penaltyRate(),
Expand All @@ -156,6 +172,8 @@ contract Previewer {
floatingUtilization: market.floatingAssets() > 0
? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18)
: 0,
floatingAssets: market.floatingAssets(),
floatingDebt: market.floatingDebt(),
floatingBackupBorrowed: market.floatingBackupBorrowed(),
floatingAvailableAssets: floatingAvailableAssets(market),
totalFloatingBorrowAssets: market.totalFloatingBorrowAssets(),
Expand Down

0 comments on commit c416594

Please sign in to comment.