ContinuousIndexing

Git Source

Inherits: IContinuousIndexing

Author: M^0 Labs

State Variables

latestIndex

The latest updated index.

uint128 public latestIndex;

_latestRate

The latest updated rate.

uint32 internal _latestRate;

latestUpdateTimestamp

The latest timestamp when the index was updated.

uint40 public latestUpdateTimestamp;

Functions

constructor

Constructs the ContinuousIndexing contract.

constructor();

updateIndex

Updates the latest index and latest accrual time in storage.

function updateIndex() public virtual returns (uint128 currentIndex_);

Returns

NameTypeDescription

currentIndex_

uint128

index The new stored index for computing present amounts from principal amounts.

currentIndex

The current index that would be written to storage if updateIndex is called.

function currentIndex() public view virtual returns (uint128);

_getPrincipalAmountRoundedDown

Returns the principal amount (rounded down) given the present amount, using the current index.

function _getPrincipalAmountRoundedDown(uint240 presentAmount_) internal view returns (uint112);

Parameters

NameTypeDescription

presentAmount_

uint240

The present amount.

Returns

NameTypeDescription

<none>

uint112

The principal amount rounded down.

_getPrincipalAmountRoundedUp

Returns the principal amount (rounded up) given the present amount and an index.

function _getPrincipalAmountRoundedUp(uint240 presentAmount_) internal view returns (uint112);

Parameters

NameTypeDescription

presentAmount_

uint240

The present amount.

Returns

NameTypeDescription

<none>

uint112

The principal amount rounded up.

_getPresentAmountRoundedDown

Returns the present amount (rounded down) given the principal amount and an index.

function _getPresentAmountRoundedDown(uint112 principalAmount_, uint128 index_) internal pure returns (uint240);

Parameters

NameTypeDescription

principalAmount_

uint112

The principal amount.

index_

uint128

An index.

Returns

NameTypeDescription

<none>

uint240

The present amount rounded down.

_getPresentAmountRoundedUp

Returns the present amount (rounded up) given the principal amount and an index.

function _getPresentAmountRoundedUp(uint112 principalAmount_, uint128 index_) internal pure returns (uint240);

Parameters

NameTypeDescription

principalAmount_

uint112

The principal amount.

index_

uint128

An index.

Returns

NameTypeDescription

<none>

uint240

The present amount rounded up.

_getPrincipalAmountRoundedDown

Returns the principal amount given the present amount, using the current index.

function _getPrincipalAmountRoundedDown(uint240 presentAmount_, uint128 index_) internal pure returns (uint112);

Parameters

NameTypeDescription

presentAmount_

uint240

The present amount.

index_

uint128

An index.

Returns

NameTypeDescription

<none>

uint112

The principal amount rounded down.

_getPrincipalAmountRoundedUp

Returns the principal amount given the present amount, using the current index.

function _getPrincipalAmountRoundedUp(uint240 presentAmount_, uint128 index_) internal pure returns (uint112);

Parameters

NameTypeDescription

presentAmount_

uint240

The present amount.

index_

uint128

An index.

Returns

NameTypeDescription

<none>

uint112

The principal amount rounded up.

_rate

To be overridden by the inheriting contract to return the current rate.

function _rate() internal view virtual returns (uint32);

Copyright 2024 M^0 Foundation