Skip to content

Schedule Checkpoint (Automation)

Satyam Agrawal edited this page Feb 10, 2020 · 1 revision

Schedule Checkpoint Module

Introduced in 3.1.0
Contract name ScheduleCheckpoint
Compatible ST Protocol version range ^3.0.0
Type Checkpoint Module & Transfer Manager

How it works

Schedule Checkpoint Module:

Many organizations vetted to provide regular dividends for their investors. To facilitate the dividends mechanism a checkpoint is needed to collect the snapshot of the balances of the investors, Using this module issuer can easily schedule future checkpoints creation data so they don't need to worry to wakeup at night and create a checkpoint at a particular time to deliver the fair dividends to their investors. This module not only useful for the dividend use case only it will also help for the frequent voting use case as well. In short, every use case which depends on the checkpoint can leverage this module automation features.

DISCLAIMER: PENDING FOR AUDIT

Key functionalities (as defined in the Smart Contract)

Transfer Verification

  • There are no checks in the executeTransfer() function related to transfer data. For every transfer, this module will return Result.NA.
  • In every transfer _update() function is being called to check whether the next checkpoint creation time is passed or not if yes then it will create a new checkpoint and update the next checkpoint creation time according the frequency given.

Add Schedule

This function allows issuers to create a schedule by providing certain details that will be used to schedule the creation of dividends. By providing FrequencyUnit like SECONDS, DAYS, WEEKS, MONTHS, QUATER, YEARS & _frequency issuer can provide the details of "how frequent checkpoint will be created?" eg. If the frequency unit is WEEKS and frequency is 3, it means every 3 weeks new schedule will be created.

Note- Issuer can only be allowed to create the MAXIMUM 10 schedule.

    /**
     * @notice adds a new schedule for checkpoints
     * @param _name name of the new schedule (must be unused)
     * @param _startTime start time of the schedule (first checkpoint)
     * @param _endTime End time of the schedule
     * @param _frequency How frequent checkpoint will being created
     * @param _frequencyUnit Unit of frequency i.e If issuer puts _frequency = 10
     * & frequency unit is DAYS then it means every 10 day frequency new checkpoint will be created
     */
   function addSchedule(bytes32 _name, uint256 _startTime, uint256 _endTime, uint256 _frequency, FrequencyUnit _frequencyUnit) withPerm(OPERATOR) external

Remove schedule

This function allows the issuer to remove the schedule.

    /**
     * @notice removes a schedule for checkpoints
     * @param _name name of the schedule to be removed
     */
    function removeSchedule(bytes32 _name) withPerm(OPERATOR) external

Modify Schedule EndTime

This function allows the issuer to change the end time of the schedule, every other detail of a schedule is non-changeable.

    /**
     * @notice Used to modify the end time of the schedule
     * @dev new endtime can be set as 0 or any value greater than now.
     * @param _name Name of the schedule that need to modify
     * @param _newEndTime New end time of the schedule
     */
    function modifyScheduleEndTime(bytes32 _name, uint256 _newEndTime) withPerm(OPERATOR) external

Manually Update

This feature can be used to manually update the createNextCheckpointAt of a given schedule. It can be used to reduce the gas cost of the transfers.

    /**
     * @notice manually triggers update outside of transfer request for named schedule (can be used to reduce user gas costs)
     * @param _name name of the schedule
     */
    function update(bytes32 _name) withPerm(OPERATOR) external

Manually update all

This will update every schedule createNextCheckpointAt

     /**
      * @notice manually triggers update outside of transfer request for all schedules (can be used to reduce user gas costs)
      */
    function updateAll() withPerm(OPERATOR) external

Get Schedule details

This function gives the details of the schedule by providing the name of schedule.

    /**
     * @notice gets schedule details
     * @param  name name of the schedule.
     * @return name Name of the schedule
     * @return startTime Unix timestamps at which schedule of creating the checkpoint will start
     * @return endTime Unix timestamps at which schedule of creation the checkpoint will stop
     * @return createNextCheckpointAt Unix timestamp at which next checkpoint will be created
     * @return frequency Frequency at which checkpoint has been created
     * @return frequencyUnit Unit of frequency
     * @return checkpointIds List of checkpoint Ids that been created in the schedule
     * @return timestamps List of unix timestamp at which checkpoints have been created
     * @return periods List of periods covered
     * @return totalPeriods Total periods covered 
     */
   function getSchedule(bytes32 _name) external view returns(
      bytes32 name,
      uint256 startTime,
      uint256 endTime,
      uint256 createNextCheckpointAt,
      uint256 frequency,
      FrequencyUnit frequencyUnit,
      uint256[] memory checkpointIds,
      uint256[] memory timestamps,
      uint256[] memory periods,
      uint256 totalPeriods
  )
Clone this wiki locally