Skip to main content

StaticRatePolicy

Git Source - Generated with forge doc

Inherits: IInterestRatePolicy

Title: StaticRatePolicy

A configurable N-point rate policy.

Stores the rate curve as immutable packed rate points embedded in the bytecode.

The constructor does not validate its inputs: rates and durations must have the same length (1 to 8) and durations must be strictly increasing.

State Variables​

lastIndex​

uint256 internal immutable lastIndex

rp0​

PackedRatePoint public immutable rp0

rp1​

PackedRatePoint public immutable rp1

rp2​

PackedRatePoint public immutable rp2

rp3​

PackedRatePoint public immutable rp3

rp4​

PackedRatePoint public immutable rp4

rp5​

PackedRatePoint public immutable rp5

rp6​

PackedRatePoint public immutable rp6

rp7​

PackedRatePoint public immutable rp7

Functions​

constructor​

constructor(uint128[] memory rates, uint128[] memory durations) ;

Parameters

NameTypeDescription
ratesuint128[]The rates per second, in WAD.
durationsuint128[]The durations in seconds (must be strictly increasing).

numPoints​

Returns the number of rate points in the policy.

function numPoints() external view returns (uint256);

getRate​

Returns the interest rate for the given renewal context.

function getRate(bytes32, bytes32, uint256 renewalPeriodStart, address, address, uint256, uint256, bool)
public
view
virtual
override
returns (uint256);

Parameters

NameTypeDescription
<none>bytes32
<none>bytes32
renewalPeriodStartuint256The renewal period start timestamp (the policy computes the elapsed time internally).
<none>address
<none>address
<none>uint256
<none>uint256
<none>bool

Returns

NameTypeDescription
<none>uint256rate The interpolated rate per second in WAD at the given elapsed time.

_loadCurve​

Materializes the bytecode-immutable rate points into parallel (knots, values) arrays.

function _loadCurve() internal view returns (uint256[] memory knots, uint256[] memory values);

_getPoint​

function _getPoint(uint256 i) private view returns (PackedRatePoint);