ILM_PC_RecurringPayments_v1.sol

Git Source

Functions

getEpochLength

Returns the length of an epoch.

function getEpochLength() external view returns (uint epochLength);

Returns

Name
Type
Description

epochLength

uint256

Length of an epoch in a uint timestamp.

getRecurringPaymentInformation

Returns the RecurringPayment instance with id id.

function getRecurringPaymentInformation(uint id)
    external
    view
    returns (RecurringPayment memory);

Parameters

Name
Type
Description

id

uint256

The id of the RecurringPayment to return.

Returns

Name
Type
Description

<none>

RecurringPayment

RecurringPayment with id id.

listRecurringPaymentIds

Returns total list of RecurringPayment ids.

List is in ascending order.

function listRecurringPaymentIds() external view returns (uint[] memory);

Returns

Name
Type
Description

<none>

uint256[]

List of RecurringPayment ids.

getPreviousPaymentId

Returns the id of previous RecurringPayment.

function getPreviousPaymentId(uint id) external view returns (uint prevId);

Parameters

Name
Type
Description

id

uint256

The id of the RecurringPayment to return.

Returns

Name
Type
Description

prevId

uint256

The id of previous RecurringPayment.

isExistingRecurringPaymentId

Returns whether RecurringPayment with id id exists.

function isExistingRecurringPaymentId(uint id) external view returns (bool);

Parameters

Name
Type
Description

id

uint256

The id of the RecurringPayment to test.

Returns

Name
Type
Description

<none>

bool

True if RecurringPayment with id id exists, false otherwise.

getEpochFromTimestamp

Calculates the epoch from a given uint timestamp.

Calculation is: timestamp divided by epochLength.

function getEpochFromTimestamp(uint timestamp)
    external
    view
    returns (uint epoch);

Parameters

Name
Type
Description

timestamp

uint256

A timestamp in a uint format.

Returns

Name
Type
Description

epoch

uint256

Epoch in which timestamp belongs to.

getCurrentEpoch

Calculates the current epoch.

Calculation is: block.timestamp divided by epochLength.

function getCurrentEpoch() external view returns (uint epoch);

Returns

Name
Type
Description

epoch

uint256

Epoch in which current timestamp (block.timestamp) belongs to.

getFutureEpoch

Calculates a future epoch x epochs from now.

Calculation is: current epoch + X epochs in the future = futureEpoch.

function getFutureEpoch(uint xEpochsInTheFuture)
    external
    view
    returns (uint futureEpoch);

Parameters

Name
Type
Description

xEpochsInTheFuture

uint256

How many epochs from the current epoch.

Returns

Name
Type
Description

futureEpoch

uint256

Epoch in the future.

addRecurringPayment

Adds a recurring payment to the manager.

a new id is created for each Payment.

function addRecurringPayment(uint amount, uint startEpoch, address recipient)
    external
    returns (uint id);

Parameters

Name
Type
Description

amount

uint256

Amount of tokens send to the recipient address.

startEpoch

uint256

Epoch in which the payment starts. Use getEpochFromTimestamp() or getCurrentEpoch() to get the appropriate epoch.

recipient

address

Recipient address that should receive tokens.

Returns

Name
Type
Description

id

uint256

Id of the newly created recurring payment.

removeRecurringPayment

Removes a recurring Payment.

function removeRecurringPayment(uint prevId, uint id) external;

Parameters

Name
Type
Description

prevId

uint256

Id of the previous recurring payment in the payment list.

id

uint256

Id of the recurring payment that is to be removed.

trigger

Triggers the start of the due payments for all recurring payment orders.

function trigger() external;

triggerFor

See trigger() but enables you to determine which ids you want to trigger payment ordes for.

this is to being able to bypass the unlikely event of having a runOutOfGas error for the normal trigger function.

function triggerFor(uint startId, uint endId) external;

Parameters

Name
Type
Description

startId

uint256

: id of start position of the recurring payments that should be triggered.

endId

uint256

: id of end position of the recurring payments that should be triggered.

Events

RecurringPaymentAdded

Event emitted when a new recurring payment added.

event RecurringPaymentAdded(
    uint indexed recurringPaymentId,
    uint amount,
    uint startEpoch,
    uint lastTriggeredEpoch,
    address recipient
);

Parameters

Name
Type
Description

recurringPaymentId

uint256

The id of the RecurringPayment.

amount

uint256

The amount of tokens that should be sent to the recipient address.

startEpoch

uint256

The epoch in which the payment starts.

lastTriggeredEpoch

uint256

The epoch in which the payment was last triggered.

recipient

address

The recipient address that should receive tokens.

RecurringPaymentRemoved

Event emitted when a recurring payment was removed.

event RecurringPaymentRemoved(uint indexed recurringPaymentId);

Parameters

Name
Type
Description

recurringPaymentId

uint256

The id of the RecurringPayment.

RecurringPaymentsTriggered

Event emitted when a recurring payment was triggered.

event RecurringPaymentsTriggered(uint indexed currentEpoch);

Parameters

Name
Type
Description

currentEpoch

uint256

The current epoch.

EpochLengthSet

Event emitted when the epoch length is set.

event EpochLengthSet(uint epochLength);

Parameters

Name
Type
Description

epochLength

uint256

The epoch length.

Errors

Module__LM_PC_RecurringPayments__InvalidRecurringPaymentId

Given RecurringPayment id is invalid.

error Module__LM_PC_RecurringPayments__InvalidRecurringPaymentId();

Module__LM_PC_RecurringPayments__InvalidStartEpoch

Start epoch cant be placed before the current epoch.

error Module__LM_PC_RecurringPayments__InvalidStartEpoch();

Module__LM_PC_RecurringPayments__InvalidEpochLength

Given EpochLength is invalid.

error Module__LM_PC_RecurringPayments__InvalidEpochLength();

Module__LM_PC_RecurringPayments__StartIdNotBeforeEndId

Given startId is not position before endId.

error Module__LM_PC_RecurringPayments__StartIdNotBeforeEndId();

Structs

RecurringPayment

Struct that holds the information of a RecurringPayment.

struct RecurringPayment {
    uint amount;
    uint startEpoch;
    uint lastTriggeredEpoch;
    address recipient;
}

Properties

Name
Type
Description

amount

uint256

The amount of tokens that will be paid out upon triggering the RecurringPayment.

startEpoch

uint256

The epoch in which the RecurringPayment should start.

lastTriggeredEpoch

uint256

When was the last epoch this RecurringPayment was triggered.

recipient

address

The recipient address that should receive tokens.

Last updated