Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Compound’s interest-rate model constants to reflect post-Merge Ethereum’s ~12s target block time so that per-block accrual matches governance-intended APRs going forward (addresses over-accrual caused by assuming 15s blocks / 2,102,400 blocks/year).
Changes:
- Update
blocksPerYearfrom2,102,400to2,628,000in core interest rate models (JumpRateModel,WhitePaperInterestRateModel,BaseJumpRateModelV2). - Update
DAIInterestRateModelV3to assumeSECONDS_PER_BLOCK = 12instead of 15. - Update JS tests and scenario “Value” helpers to use the new blocks/year conversion factor.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Tokens/cTokenTest.js | Updates per-block-to-APR assertions to use 2,628,000 blocks/year. |
| tests/Models/InterestRateModelTest.js | Updates test helper constant blocksPerYear to 2,628,000. |
| tests/Models/DAIInterestRateModelTest.js | Updates blocksPerYear constant (but expected-rate helpers still hardcode 15s/block; see comment). |
| scenario/src/Value/InterestRateModelValue.ts | Updates borrow-rate display scaling to 2,628,000 blocks/year. |
| scenario/src/Value/CTokenValue.ts | Updates borrow-rate display scaling to 2,628,000 blocks/year. |
| contracts/WhitePaperInterestRateModel.sol | Updates blocksPerYear constant to 2,628,000. |
| contracts/JumpRateModel.sol | Updates blocksPerYear constant to 2,628,000. |
| contracts/DAIInterestRateModelV3.sol | Updates SECONDS_PER_BLOCK to 12 for DAI-specific rate math. |
| contracts/BaseJumpRateModelV2.sol | Updates blocksPerYear constant to 2,628,000 for V2 models. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } = require('../Utils/Compound'); | ||
|
|
||
| const blocksPerYear = 2102400; | ||
| const blocksPerYear = 2628000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
All interest-rate models hardcode a 15-second block time
(
blocksPerYear = 2102400, DAISECONDS_PER_BLOCK = 15). Post-Merge Ethereumtargets ~12s blocks (~2,628,000 blocks/year).
Impact
CToken.accrueInterestaccrues interest per block. With blocks arriving~25% faster than assumed, the effective annual rate =
configured APR × (2,628,000 / 2,102,400) = ×1.25. Borrowers are overcharged
and suppliers over-earn ~25% versus the rate governance intended, on every
market using these models. Matches #230.
Fix
blocksPerYear2102400 → 2628000 inJumpRateModel,WhitePaperInterestRateModel,BaseJumpRateModelV2.SECONDS_PER_BLOCK15 → 12 inDAIInterestRateModelV3.(
InterestRateModelTest.js,DAIInterestRateModelTest.js,cTokenTest.js,CTokenValue.ts,InterestRateModelValue.ts).Validation
Executed the patched
JumpRateModelandJumpRateModelV2under Foundry:blocksPerYear() == 2628000,getBorrowRateper-block value round-trips to theintended APR, and the old constant is shown to over-accrue by 25%. 2/2 pass.
Caveats
deployments. Live markets need a redeploy + governance migration (or a
compensating APR re-tune).
current Node; that build breakage is pre-existing and out of scope here.