Lock-Ups
For smart contracts that represent securities, it is beneficial to provide an option for an "early-sale" or "pre-sale" of security tokens. This means that tokens can be purchased by investors at a lower price, but cannot be sold or transferred for a specified period of time. To facilitate this, lock-ups have been added to the smart contract.
Tokens can be locked for a predetermined period.
Investors can see the locked tokens in their balance but cannot transfer them until the lock-up period ends.
Lock-ups are an optional feature that can be enabled or disabled. The authority to toggle Lock-ups is assigned to the Super Admin role.
When Lock-ups are disabled, the information regarding locked tokens remains intact, but the contract no longer checks this parameter during token transfers.
Information about locked tokens is stored in the PersonalInfo
struct for each address. This is a dynamic array consisting of pairs of data: 1 - the timestamp when tokens can be unlocked, and 2 - the amount of tokens locked until that timestamp.
Tokens can only be locked by the Financial Manager role and will only be unlocked after the period specified during the locking process. There is no option to unlock them earlier.
The Process of Locking Tokens
Technically, locking tokens involves writing a pair (timestamp, amount) to the PersonalInfo
of the account. The smart contract checks this array whenever the address attempts to transfer tokens, and if tokens are locked, they cannot be moved.
Tokens can be locked at the time of their distribution. When the Financial Manager sends tokens to the investor’s address from the Corporate Treasury using the
transferFromTreasuryLockedTokens()
function, the specified amount of tokens will be sent and locked simultaneously. (This function cannot be called if Lock-ups are disabled)Tokens can also be locked when they are already in the user’s balance. In this case, the Financial Manager uses the
lockUpTokensOnAddress()
function. (This function cannot be called if Lock-ups are disabled)This function has a special feature! It checks the available balance of the address (total token balance minus already locked tokens), compares it with the amount to be locked, and if the available balance is less than the amount to lock, only the available tokens will be locked.
Information About Locked Tokens of an Address
Using the standard balanceOf()
function will not show if there are locked tokens in an account. It will only display the total token balance.
To find out information about locked tokens, you can use:
getListOfLockUps(address _account)
to see the complete list of (timestamp, amount) pairs.getAmountOfLockedTokens(address _account)
to see the total amount of locked tokens (this information is also included ingetUserData(address _account)
).
How Do Tokens Unlock?
Any function that includes the internal _transfer()
function (such as transfer
, transferFrom
, transferFromTreasuryLockedTokens
, replacementOfCorporateTreasury
) uses the _beforeTokenTransfer(_from, _amount)
hook to check the amount of locked tokens associated with an address. If locked tokens exist, the transfer will be prevented.
After the transfer, the _afterTokenTransfer(_from)
hook updates the array of locked tokens.
The updateDataOfLockedTokensOf()
function removes the lock-up entry if the unlocking timestamp has passed, thus freeing the locked tokens and allowing them to be transferred.
Additionally, note that the updateDataOfLockedTokensOf()
function is public and can be called at any time by any user without restrictions. This will update the list of locked pairs and unlock tokens as their respective timestamps are reached.
Last updated