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.

Constants​

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);

Returns

NameTypeDescription
<none>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
_bytes32The id of the source side of the renewal (the position being closed).
_bytes32The id of the target side of the renewal (the position being entered).
renewalPeriodStartuint256The renewal period start timestamp (the policy computes the elapsed time internally).
_addressThe position owner being renewed (the offer maker in the make-on-behalf flow).
_addressThe Midnight.take taker, forwarded from isRatified.
_uint256The source market maturity (0 for Blue to Midnight migrations).
_uint256The target market maturity (0 for Midnight to Blue exits).
_boolThe renewed user's side in the trade, derived from the migration direction.

Returns

NameTypeDescription
<none>uint256The 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);

Returns

NameTypeDescription
knotsuint256[]
valuesuint256[]

_getPoint​

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

Parameters

NameTypeDescription
iuint256

Returns

NameTypeDescription
<none>PackedRatePoint