Skip to main content
InterestRateModel is a pure library that turns pool utilization into a per-second borrow rate. It implements a kinked curve: a gentle slope up to the kink and a steep slope above it, so full utilization becomes expensive and liquidity returns to the pool. Stockline calls it during every accrual with the book’s IrmParams from RiskRegistry. The library has no external functions. InterestRateModel lets you:
  • Compute the per-second borrow rate for a given utilization and book
  • Round interest up so debt never accrues slower than the curve
  • Reject utilization above 100% or an invalid kink
InterestRateModel is a Solidity library. It is linked into the contracts that use it and has no address of its own. The source code is src/core/InterestRateModel.sol on GitHub. The ABI is /abis/InterestRateModel.json.

Pure functions

rate

Returns the per-second borrow rate for a utilization and a book’s curve. Below the kink the rate is baseRate + slopeBelowKink * u / kink. Above it the rate is baseRate + slopeBelowKink + slopeAboveKink * (u - kink) / (1 - kink). Reverts with UtilizationAboveWad above 1e18 and InvalidKink unless 0 < kink < 1e18.
Internal function. Divisions round up against the borrower. Parameters are already per-second; the library does not convert from APY.
Input parameters Return values

_mulDivUp

ceil(a * b / d). Borrow interest rounds against the borrower.
Input parameters Return values

Errors

UtilizationAboveWad

The utilization argument is above 1e18.

InvalidKink

The kink is 0 or 1e18 or more.