RegularTimeInterval

The RegularTimeInterval execution module enables recurring execution of jobs in a fixed time interval. The input bytes to the onCreateJob function should follow the structure:

uint32 cooldown;
uint40 initialExecutionTime;

cooldown specifies the number of seconds between when the job can be executed. The initialExecutionTime value is the UNIX time in seconds when the job can be executed from the first time. If initialExecutionTime <= block.timestamp, block.timestamp becomes the initial time of execution and the job will be executed immediately.

The contract stores information about each job in a public mapping from job indices to Params structs:

struct Params {
    uint40 lastExecution;
    uint32 cooldown;
}

The lastExecution field is the UNIX time in seconds of when the last execution opened. Initially it will be set to initialExecutionTime - cooldown, unless initialExecutionTime <= block.timestamp, then it is set to block.timestamp. The lastExecution value is updated every time the job is executed and there are always cooldown seconds between each value of lastExecution.

Warning: The onCreateJob function will revert if cooldown < _executionWindow.

Warning: lastExecution is not necessarily the last timestamp the job was executed. To get an exact timestamp of when the job is executed, you can listen for the JobExecuted event emitted by the JobRegistry contract.

Last updated