Skip to content

fix(irm): assume 12s blocks post-Merge, not 15s - #310

Open
PrazwalR wants to merge 1 commit into
compound-finance:masterfrom
PrazwalR:fix/irm-blocks-per-year-12s
Open

PrazwalR wants to merge 1 commit into
compound-finance:masterfrom
PrazwalR:fix/irm-blocks-per-year-12s

Conversation

@PrazwalR

@PrazwalR PrazwalR commented Jul 1, 2026

Copy link
Copy Markdown

Problem

All interest-rate models hardcode a 15-second block time
(blocksPerYear = 2102400, DAI SECONDS_PER_BLOCK = 15). Post-Merge Ethereum
targets ~12s blocks (~2,628,000 blocks/year).

Impact

CToken.accrueInterest accrues 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

  • blocksPerYear 2102400 → 2628000 in JumpRateModel,
    WhitePaperInterestRateModel, BaseJumpRateModelV2.
  • SECONDS_PER_BLOCK 15 → 12 in DAIInterestRateModelV3.
  • Update test/scenario helpers that encode the same 15s assumption
    (InterestRateModelTest.js, DAIInterestRateModelTest.js, cTokenTest.js,
    CTokenValue.ts, InterestRateModelValue.ts).

Validation

Executed the patched JumpRateModel and JumpRateModelV2 under Foundry:
blocksPerYear() == 2628000, getBorrowRate per-block value round-trips to the
intended APR, and the old constant is shown to over-accrue by 25%. 2/2 pass.

Caveats

  • Deployed rate-model contracts are immutable; this corrects future
    deployments. Live markets need a redeploy + governance migration (or a
    compensating APR re-tune).
  • The repo's legacy JS test toolchain (eth-saddle/ganache) does not build on
    current Node; that build breakage is pre-existing and out of scope here.

Copilot AI review requested due to automatic review settings July 1, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 blocksPerYear from 2,102,400 to 2,628,000 in core interest rate models (JumpRateModel, WhitePaperInterestRateModel, BaseJumpRateModelV2).
  • Update DAIInterestRateModelV3 to assume SECONDS_PER_BLOCK = 12 instead 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;
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.

2 participants