Asset Freeze Mechanism
Token Freezes
The Token Freeze Mechanism acts as a measure, against fraudulent behavior. When the compliance contract detects activities it promptly freezes the tokens involved making them untransferable and unusable. The freeze remains in place for a duration and only legal intervention can lift it in certain situations.
We want to implement multi signature based algorithms to ensure no single party has the ability to decide about freezes.
Data Flow:
Fraud Detection:
The compliance contract detects a potential fraudulent activity associated with a specific token.
Token Freezing:
The token associated with the suspicious activity is frozen for a predefined duration.
During this freeze period, the token cannot be transferred or used in any operations.
Token Defrosting:
After the predefined duration, the token is automatically defrosted, making it usable again.
Alternatively, an external trigger (like legal intervention) can defrost the token.
Contract Structure:
Function Descriptions:
freezeToken
:
Purpose: Freezes a token for a specified duration.
Inputs:
tokenId
: The ID of the token to be frozen.freezeDuration
: Duration (in seconds) for which the token should remain frozen.
Outputs: Emits a
TokenFrozen
event with the token ID and freeze duration.Internal Operations: The function sets the
isFrozen
status of the token totrue
and calculates thefreezeEndTime
by adding thefreezeDuration
to the current block timestamp.
defrostToken
:
Purpose: Defrosts a frozen token after the freeze duration has passed.
Inputs:
tokenId
: The ID of the token to be defrosted.
Outputs: Emits a
TokenDefrosted
event with the token ID.Internal Operations: The function checks if the token is frozen and if the current time has surpassed the
freezeEndTime
. If both conditions are met, the token'sisFrozen
status is set tofalse
.
isTokenFrozen
:
Purpose: Checks if a token is currently frozen.
Inputs:
tokenId
: The ID of the token to check.
Outputs: Returns a boolean indicating if the token is frozen.
Mathematical and Logical Considerations:
Freeze Duration: The freeze duration is added to the current block timestamp to determine the
freezeEndTime
. This ensures a clear and immutable end time for the freeze.Automatic Defrosting: The system doesn't automatically defrost tokens once the freeze duration is over. Instead, the
isTokenFrozen
function considers tokens as defrosted if the current time surpasses thefreezeEndTime
, even if theirisFrozen
status remainstrue
. This design choice reduces unnecessary writes to the blockchain, saving gas.Safety Checks: The contract includes checks to prevent already frozen tokens from being frozen again and to ensure only tokens that have completed their freeze duration can be defrosted.
Last updated