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
| Name | Type | Description |
|---|---|---|
rates | uint128[] | The rates per second, in WAD. |
durations | uint128[] | 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
| Name | Type | Description |
|---|---|---|
<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
| Name | Type | Description |
|---|---|---|
_ | bytes32 | The id of the source side of the renewal (the position being closed). |
_ | bytes32 | The id of the target side of the renewal (the position being entered). |
renewalPeriodStart | uint256 | The renewal period start timestamp (the policy computes the elapsed time internally). |
_ | address | The position owner being renewed (the offer maker in the make-on-behalf flow). |
_ | address | The Midnight.take taker, forwarded from isRatified. |
_ | uint256 | The source market maturity (0 for Blue to Midnight migrations). |
_ | uint256 | The target market maturity (0 for Midnight to Blue exits). |
_ | bool | The renewed user's side in the trade, derived from the migration direction. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | 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);
Returns
| Name | Type | Description |
|---|---|---|
knots | uint256[] | |
values | uint256[] |
_getPoint
function _getPoint(uint256 i) private view returns (PackedRatePoint);
Parameters
| Name | Type | Description |
|---|---|---|
i | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | PackedRatePoint |