Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return early linear adaptation zero #88

Merged
merged 3 commits into from
Nov 16, 2023

Conversation

MathisGD
Copy link
Contributor

No description provided.

@MathisGD MathisGD self-assigned this Nov 16, 2023
Copy link
Contributor

@Rubilmax Rubilmax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it!
I would not indent all the code in the else branch though if using early returns (we're indenting twice for no reason)

Copy link
Contributor

@QGarchery QGarchery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, and the test for it is in #80 here :

function testRateAfterUtilizationTargetNoPing(uint256 elapsed) public {
elapsed = bound(elapsed, 0, type(uint48).max);
Market memory market;
market.totalSupplyAssets = 1 ether;
market.totalBorrowAssets = uint128(uint256(TARGET_UTILIZATION));
assertEq(irm.borrowRate(marketParams, market), uint256(INITIAL_RATE_AT_TARGET));
assertEq(irm.rateAtTarget(marketParams.id()), INITIAL_RATE_AT_TARGET);
market.lastUpdate = uint128(block.timestamp);
vm.warp(block.timestamp + elapsed);
irm.borrowRate(marketParams, market);
assertEq(irm.rateAtTarget(marketParams.id()), INITIAL_RATE_AT_TARGET);
}

src/SpeedJumpIrm.sol Outdated Show resolved Hide resolved
src/SpeedJumpIrm.sol Outdated Show resolved Hide resolved
@MathisGD
Copy link
Contributor Author

I'm fine with it! I would not indent all the code in the else branch though if using early returns (we're indenting twice for no reason)

I did it because the code is already like that (for when startBorrowRate==0)

@MathisGD MathisGD merged commit 0974005 into feat/riemann-avg Nov 16, 2023
3 checks passed
@MathisGD MathisGD deleted the feat/return-early-linearAdaptation-zero branch November 16, 2023 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants