Skip to main content

IKpis

Asset Tokenization Studio Team

IKpis

Interface for recording and querying time-series KPI data associated with a project address.

Each data point is keyed by (project, date). Dates must fall within the token's configured min/max date window. Adding a data point for an already-registered date reverts with KpiDataAlreadyExists.

Methods​

addKpiData​

function addKpiData(uint256 _date, uint256 _value, address _project) external nonpayable

Records a KPI data point for _project at _date.

Reverts with InvalidDate if _date is outside the allowed window, or with KpiDataAlreadyExists if a value has already been recorded for this (project, date) pair.

Parameters​

NameTypeDescription
_dateuint256Unix timestamp for the data point.
_valueuint256KPI value to record.
_projectaddressAddress of the project the data point belongs to.

getLatestKpiData​

function getLatestKpiData(uint256 _from, uint256 _to, address _project) external view returns (uint256 value_, bool exists_)

Returns the most recent KPI value for _project within [_from, _to].

Reverts with InvalidDateRange if _from > _to.

Parameters​

NameTypeDescription
_fromuint256Start of the search window (Unix timestamp, inclusive).
_touint256End of the search window (Unix timestamp, inclusive).
_projectaddressAddress of the project to query.

Returns​

NameTypeDescription
value_uint256The latest KPI value found in the range, or 0 if none.
exists_booltrue if at least one data point exists within the range.

getMinDate​

function getMinDate() external view returns (uint256 minDate_)

Returns the earliest valid date for KPI data points on this token.

Returns​

NameTypeDescription
minDate_uint256The configured minimum date (Unix timestamp).

initializeKpis​

function initializeKpis() external nonpayable

Initialises the KPI capability on the token.

Callable once; subsequent calls revert with FacetAlreadyRegistered. Requires DEFAULT_ADMIN_ROLE. Called by the factory during deployment.

isCheckPointDate​

function isCheckPointDate(uint256 _date, address _project) external view returns (bool exists_)

Checks whether a KPI data point exists for _project at exactly _date.

Parameters​

NameTypeDescription
_dateuint256Unix timestamp to look up.
_projectaddressAddress of the project to query.

Returns​

NameTypeDescription
exists_booltrue if a data point is registered for (project, date).

Events​

KpiDataAdded​

event KpiDataAdded(address indexed project, uint256 date, uint256 value)

Emitted when a new KPI data point is recorded.

Parameters​

NameTypeDescription
project indexedaddressAddress of the project the data point belongs to.
dateuint256Unix timestamp identifying the data point.
valueuint256KPI value recorded at date.

KpisInitialized​

event KpisInitialized()

Emitted once when the KPI capability is initialised on a token.

Fires exclusively from initializeKpis.

Errors​

InvalidDate​

error InvalidDate(uint256 providedDate, uint256 minDate, uint256 maxDate)

Thrown when _date falls outside the token's allowed [minDate, maxDate] window.

Parameters​

NameTypeDescription
providedDateuint256The date supplied by the caller.
minDateuint256Lower bound of the valid date range.
maxDateuint256Upper bound of the valid date range.

InvalidDateRange​

error InvalidDateRange(uint256 fromDate, uint256 toDate)

Thrown when the supplied date range is invalid (e.g. fromDate > toDate).

Parameters​

NameTypeDescription
fromDateuint256Start of the requested range.
toDateuint256End of the requested range.

KpiDataAlreadyExists​

error KpiDataAlreadyExists(uint256 date)

Thrown when a KPI data point already exists for the given date and project.

Parameters​

NameTypeDescription
dateuint256The duplicate date supplied by the caller.