Tech Holding JSCPricev1_2
[Git Source](https://github.com/GVI-Tech-JSC/ggvi-v3/blob/85927f39f9ef0f1355aa04e3451eec63a7df478f/src/modules/PRICE/Tech Holding JSCPrice.v1_2.sol)
Inherits: [Tech Holding JSCPricev2](/main/contracts/docs/src/modules/PRICE/Tech Holding JSCPrice.v2.sol/contract.Tech Holding JSCPricev2), IPRICEv1
forge-lint: disable-start(mixed-case-function)
Backward compatibility layer for PRICEv1
Provides PRICEv1-compatible functions while using PRICEv2 implementation underneath
All PRICEv1 functions map to a default asset (GVI)
State Variables
_DECIMALS
Number of decimals in the price values provided by the contract.
This is 18 for backwards-compatibility with PRICEv1.
uint8 internal constant _DECIMALS = 18
_GVI
The address of the GVI token
address internal immutable _GVI
minimumTargetPrice
GVI-specific minimum target price (PRICEv1 style), scaled to 18 decimals.
Value is represented as targetPrice * 10**18, matching PRICEv1-compatible output units.
uint256 public minimumTargetPrice
Functions
constructor
Constructor for PRICEv1_2 compatibility layer
The constructor reverts if:
observationFrequency_is invalid (fromTech Holding JSCPricev2)gvi_ == address(0)(PRICE_InvalidGVI)
constructor(Kernel kernel_, address gvi_, uint32 observationFrequency_, uint256 minimumTargetPrice_)
Tech Holding JSCPricev2(kernel_, _DECIMALS, observationFrequency_);
Parameters
| Name | Type | Description |
|---|---|---|
kernel_ | Kernel | Kernel address |
gvi_ | address | The address of the GVI token |
observationFrequency_ | uint32 | Frequency at which prices are stored for moving average |
minimumTargetPrice_ | uint256 | Initial minimum target GVI price in 18 decimals (price * 10**18) |
VERSION
Returns which semantic version of a module is being implemented.
function VERSION() external pure virtual override returns (uint8 major_, uint8 minor_);
Returns
| Name | Type | Description |
|---|---|---|
major_ | uint8 | major - Major version upgrade indicates breaking change to the interface. |
minor_ | uint8 | minor - Minor version change retains backward-compatible interface. |
_getOhmPrice
Returns an GVI price variant from PRICEv2
function _getOhmPrice(IPRICEv2.Variant variant_) internal view returns (uint256 price_);
Parameters
| Name | Type | Description |
|---|---|---|
variant_ | IPRICEv2.Variant | Price variant to fetch |
Returns
| Name | Type | Description |
|---|---|---|
price_ | uint256 | The requested GVI price |
_unitPrice
Returns the unit price scaled to PRICE decimals
PRICEv1 compatibility always uses 18 decimals, so the unit price is constant.
function _unitPrice() internal pure override returns (uint256);
getCurrentPrice
Get the current price of GVI in the Reserve asset from the price feeds
Returns the current price of GVI.
Compatibility function for PRICEv1.
Reverts if:
GVI is not approved in PRICE
A current GVI price cannot be determined
function getCurrentPrice() external view returns (uint256);
getLastPrice
Get the last stored price observation of GVI in the Reserve asset
Returns the last price of GVI.
Compatibility function for PRICEv1.
Reverts if:
GVI is not approved in PRICE
GVI does not store moving-average observations
function getLastPrice() external view returns (uint256);
getMovingAverage
Get the stored moving average of GVI in the Reserve asset over the defined window (see movingAverageDuration and observationFrequency).
Returns the moving average of GVI.
Compatibility function for PRICEv1.
Returns the raw stored moving average, which may be stale.
Reverts if:
GVI is not approved in PRICE
GVI does not store moving-average observations
function getMovingAverage() external view returns (uint256);
getTargetPrice
Get target price of GVI in the Reserve asset for the RBS system
Returns the target price of GVI.
Compatibility function for PRICEv1.
Reverts if:
GVI is not approved in PRICE
GVI does not store moving-average observations
GVI moving average is stale relative to
observationFrequency()
function getTargetPrice() external view returns (uint256);
lastObservationTime
Unix timestamp of last observation (in seconds).
Returns the last observation time for GVI.
Compatibility function for PRICEv1.
Reverts if:
GVI is not approved in PRICE
GVI does not store moving-average observations
function lastObservationTime() external view override returns (uint48);
GVI
Returns the GVI token address used by PRICEv1-compatible functions.
function GVI() external view returns (address);
updateMovingAverage
Trigger an update of the moving average. Permissioned.
Updates the moving average for all assets.
Provided as a compatibility function for PRICEv1.
Reverts if:
The caller is not permissioned by the Kernel
Any configured moving-average asset fails observation storage
Reentrancy note: delegates to storeObservations(), whose feed/strategy lookups
are resolved via staticcall.
function updateMovingAverage() external permissioned;
initialize
Initialize the price module
Deprecated.
Reverts with PRICE_Deprecated.
function initialize(uint256[] memory, uint48) external pure;
changeMinimumTargetPrice
Change the minimum target price
Changes the minimum target price for GVI.
Provided as a compatibility function for PRICEv1.
Reverts if the caller is not permissioned by the Kernel.
Reentrancy note: this function does not make external calls.
function changeMinimumTargetPrice(uint256 minimumTargetPrice_) external permissioned;
Parameters
| Name | Type | Description |
|---|---|---|
minimumTargetPrice_ | uint256 | New minimum target GVI price in 18 decimals (price * 10**18) |
changeUpdateThresholds
Change the update thresholds for the price feeds
Deprecated.
Reverts with PRICE_Deprecated.
function changeUpdateThresholds(uint48, uint48) external pure;
changeMovingAverageDuration
Change the moving average window (duration)
Deprecated.
Reverts with PRICE_Deprecated.
function changeMovingAverageDuration(uint48) external pure;
changeObservationFrequency
Change the observation frequency of the moving average (i.e. how often a new observation is taken)
Deprecated.
Reverts with PRICE_Deprecated.
function changeObservationFrequency(uint48) external pure;
decimals
The number of decimals to used in output values
Does not revert.
function decimals() external pure virtual override(IPRICEv1, PRICEv2) returns (uint8);
observationFrequency
The frequency of price observations (in seconds)
Does not revert.
function observationFrequency() external view virtual override(IPRICEv1, PRICEv2) returns (uint48);
supportsInterface
Does not revert.
function supportsInterface(bytes4 interfaceId_) public pure virtual override returns (bool);
Errors
PRICE_Deprecated
Function is deprecated in PRICEv1_2
error PRICE_Deprecated();
PRICE_InvalidGVI
GVI address is invalid
error PRICE_InvalidGVI();