This document defines the Snapshot Module for the CMTA Token specification.
Warning:
This module was not audited during the audit made by ABDK and it is no longer imported by default inside the CMTAT.
If you want to add this module, you have to uncomment the specific lines "SnapshotModule" inside the file
CMTAT_BASE.sol
.Be warned that this module may possibly contain security flaws.
[TOC]
In relation to distributions or the exercise of rights attached to tokenized securities, it is necessary to determine the number of tokens held by certain users at a certain point in time to allow issuers to carry out certain corporate actions such as dividend or interest payments.
Such moments are generally referred to in practice as the "record date" or the "record time" (i.e. the time that is relevant to determine the eligibility of security holders for the relevant corporate action).
The snapshot functions to determine the number of tokens recorded on the various ledger addresses at a specific point in time and to use that information to carry out transactions on-chain.
Symbol | Meaning |
---|---|
🛑 | Function can modify state |
💵 | Function is payable |
File Name | SHA-1 Hash |
---|---|
./modules/wrapper/optional/SnapshotModule.sol | 940a05eeea32027baf3142c0c736e9679cb846ca |
Contract | Type | Bases | ||
---|---|---|---|---|
└ | Function Name | Visibility | Mutability | Modifiers |
SnapshotModule | Implementation | SnapshotModuleInternal, AuthorizationModule | ||
└ | __SnasphotModule_init | Internal 🔒 | 🛑 | onlyInitializing |
└ | __SnasphotModule_init_unchained | Internal 🔒 | 🛑 | onlyInitializing |
└ | scheduleSnapshot | Public ❗️ | 🛑 | onlyRole |
└ | scheduleSnapshotNotOptimized | Public ❗️ | 🛑 | onlyRole |
└ | rescheduleSnapshot | Public ❗️ | 🛑 | onlyRole |
└ | unscheduleLastSnapshot | Public ❗️ | 🛑 | onlyRole |
└ | unscheduleSnapshotNotOptimized | Public ❗️ | 🛑 | onlyRole |
File Name | SHA-1 Hash |
---|---|
./modules/internal/SnapshotModuleInternal.sol | 83cd7e3cd8b99c665c628f97ab37391f9dce07c1 |
Contract | Type | Bases | ||
---|---|---|---|---|
└ | Function Name | Visibility | Mutability | Modifiers |
SnapshotModuleInternal | Implementation | ERC20Upgradeable | ||
└ | __Snapshot_init | Internal 🔒 | 🛑 | onlyInitializing |
└ | __Snapshot_init_unchained | Internal 🔒 | 🛑 | onlyInitializing |
└ | _scheduleSnapshot | Internal 🔒 | 🛑 | |
└ | _scheduleSnapshotNotOptimized | Internal 🔒 | 🛑 | |
└ | _rescheduleSnapshot | Internal 🔒 | 🛑 | |
└ | _unscheduleLastSnapshot | Internal 🔒 | 🛑 | |
└ | _unscheduleSnapshotNotOptimized | Internal 🔒 | 🛑 | |
└ | getNextSnapshots | Public ❗️ | NO❗️ | |
└ | getAllSnapshots | Public ❗️ | NO❗️ | |
└ | snapshotBalanceOf | Public ❗️ | NO❗️ | |
└ | snapshotTotalSupply | Public ❗️ | NO❗️ | |
└ | _beforeTokenTransfer | Internal 🔒 | 🛑 | |
└ | _valueAt | Private 🔐 | ||
└ | _updateAccountSnapshot | Private 🔐 | 🛑 | |
└ | _updateTotalSupplySnapshot | Private 🔐 | 🛑 | |
└ | _updateSnapshot | Private 🔐 | 🛑 | |
└ | _setCurrentSnapshot | Internal 🔒 | 🛑 | |
└ | _lastSnapshot | Private 🔐 | ||
└ | _findScheduledSnapshotIndex | Private 🔐 | ||
└ | _findScheduledMostRecentPastSnapshot | Private 🔐 |
This section describes the Ethereum API of the Snapshot Module.
function scheduleSnapshot(uint256 time)
public onlyRole(SNAPSHOOTER_ROLE)
Schedule a snapshot at the given time
specified as a number of seconds since epoch.
Time has to be greater that the current time and the latest scheduled snapshot. There have to be no other already created snapshots at this time. Only authorized users are allowed to call this function.
function scheduleSnapshotNotOptimized(uint256 time)
public onlyRole(SNAPSHOOTER_ROLE)
Schedule a snapshot at the given time
specified as a number of seconds since epoch.
Time has to be greater that the current time. There have to be no other already created snapshots at this time. Only authorized users are allowed to call this function.
This function is not optimized because it moves all snapshots situated before it one position to the right.
function rescheduleSnapshot(uint256 oldTime,uint256 newTime)
public onlyRole(SNAPSHOOTER_ROLE)
Reschedule the scheduled, but not yet created snapshot with the given oldTime
to be created at the given newTime
specified as a number of seconds since epoch.
The newTime
cannot be before the time of the previous scheduled, but not yet created snapshot, or after the time of the next scheduled snapshot.
The function returns the original time
the snapshot was scheduled at.
Only authorized users are allowed to call this function.
function unscheduleLastSnapshot(uint256 time)
public onlyRole(SNAPSHOOTER_ROLE)
Cancel creation of the scheduled, but not yet created snapshot with the given time
.
There should not be any other snapshots scheduled after this one.
Only authorized users are allowed to call this function.
function unscheduleSnapshotNotOptimized(uint256 time)
public onlyRole(SNAPSHOOTER_ROLE)
Cancel creation of the scheduled, but not yet created snapshot with the given time
.
This function is not optimized because it moves all snapshots situated after it one position to the left
Only authorized users are allowed to call this function.
function getNextSnapshots()
public view
returns (uint256[] memory)
Return the next scheduled snapshots
function getAllSnapshots()
public view
returns (uint256[] memory)
Return all snapshots (past and future)
function snapshotTotalSupply(uint256 time)
public view
returns (uint256)
Return the total number of token in circulation at the time when the snapshot with the given time
was created.
function snapshotBalanceOf(uint256 time,address owner)
public view
returns (uint256)
Return the number of tokens owned by the given owner
at the time when the snapshot with the given time
was created.
event SnapshotSchedule(uint256 indexed oldTime, uint256 indexed newTime)
Emitted when the snapshot with the specified oldTime
was scheduled or rescheduled at the specified newTime
.
event SnapshotUnschedule(uint256 indexed time)
Emitted when the scheduled snapshot with the specified time
was cancelled.