PythInterestRateOracle
Inherits: IInterestRateOracle
Title: PythInterestRateOracle
Author: SocksNFlops
The PythInterestRateOracle contract is a contract that tracks the interest rate of US treasuries to determine the interest rate for new Mortgages being originated.
State Variables
PERCENT_DECIMALS
The number of decimals for percentages
int8 public constant PERCENT_DECIMALS = 2
BPS_DECIMALS
The number of decimals for basis points
int8 public constant BPS_DECIMALS = 4
MAX_CONFIDENCE_BPS
The maximum confidence in basis points
uint32 public constant MAX_CONFIDENCE_BPS = 100
MAX_AGE
The maximum age of a price in seconds
uint32 public constant MAX_AGE = 60 seconds
THREE_YEAR_PYTH_PRICE_ID
The Pyth price ID for 3-year US treasuries
bytes32 public constant THREE_YEAR_PYTH_PRICE_ID = 0x25ac38864cd1802a9441e82d4b3e0a4eed9938a1849b8d2dcd788e631e3b288c
FIVE_YEAR_PYTH_PRICE_ID
The Pyth price ID for 5-year US treasuries
bytes32 public constant FIVE_YEAR_PYTH_PRICE_ID = 0x7d220b081152db0d74a93d3ce383c61d0ec5250c6dd2b2cdb2d1e4b8919e1a6e
PAYMENT_PLAN_SPREAD
The spread for mortgages with a payment plan
uint16 public constant PAYMENT_PLAN_SPREAD = 100
NO_PAYMENT_PLAN_SPREAD
The spread for mortgages without a payment plan
uint16 public constant NO_PAYMENT_PLAN_SPREAD = 200
pyth
The Pyth contract
IPyth public immutable pyth
Functions
constructor
Constructor
constructor(address pyth_) ;
Parameters
| Name | Type | Description |
|---|---|---|
pyth_ | address | The address of the Pyth contract |
interestRate
Returns the interest rate (in basis points) for a given total periods and amortization status
2x the 3-year treasury yield + 100 BPS spread (for mortgages with a payment plan)
2x the 3-year treasury yield + 200 BPS spread (for mortgages without a payment plan)
function interestRate(uint8 totalPeriods, bool hasPaymentPlan) external view override returns (uint16 rate);
Parameters
| Name | Type | Description |
|---|---|---|
totalPeriods | uint8 | The total number of periods for the mortgage |
hasPaymentPlan | bool | Whether the mortgage has a payment plan |
Returns
| Name | Type | Description |
|---|---|---|
rate | uint16 | The interest rate |
Errors
MaxAgeExceeded
The error thrown when the age of a price is greater than the maximum age
error MaxAgeExceeded(uint256 age, uint256 maxAge);
Parameters
| Name | Type | Description |
|---|---|---|
age | uint256 | The age of the price |
maxAge | uint256 | The maximum age |
MaxConfidenceExceeded
The error thrown when the confidence of a price is greater than the maximum confidence
error MaxConfidenceExceeded(uint256 confidence, uint256 maxConfidence);
Parameters
| Name | Type | Description |
|---|---|---|
confidence | uint256 | The confidence of the price |
maxConfidence | uint256 | The maximum confidence |
InvalidTotalPeriods
The error thrown when the total periods are invalid and not supported by the InterestRateOracle
error InvalidTotalPeriods(uint8 totalPeriods);
Parameters
| Name | Type | Description |
|---|---|---|
totalPeriods | uint8 | The total periods |