Pause
Enables pausing all mint, burn, buy, sell, and transfer actions of an application
Purpose
The purpose of the pause rule is to allow developers to pause the entirety of an application for maintenance, security or any other reason. Pausing the application means that no transfer of tokens is allowed at any level (with the few exceptions listed in the Evaluation Exceptions section below).
Scope
This rule works at the application level which means that all tokens in the app will have no choice but to comply with this rule when active.
Data Structure
A pause rule is composed of 2 components:
- Pause Start (uint64): The timestamp where the pause rule starts.
- Pause Stop (uint64): The timestamp where the pause rule ends.
see PauseRule
Configuration and Enabling/Disabling
- This rule can only be configured in the protocol by a rule administrator.
- This rule can only be set in the asset handler by a rule administrator.
- This rule can only be activated/deactivated in the asset handler by a rule administrator.
- This rule can only be updated in the asset handler by a rule administrator.
Rule Evaluation
The rule will be evaluated with the following logic:
- The protocol’s rule processor retrieves all the pause rules stored in the data contract of the appManager.
- The processor loops through all these pause rules, and evaluates if current timestamp is greater or equal to
pauseStart
and less thanpauseStop
. If the condition is true for at least one rule, then the transaction reverts.
see ApplicationPauseProcessorFacet -> checkPauseRules
Evaluation Exceptions
- This rule doesn’t apply when a treasuryAccount address is in either the
from
or theto
side of the transaction. This doesn’t necessarily mean that if a treasury account is the one executing the transaction it will bypass the rule, unless the aforementioned condition is true.
Revert Message
The rule processor will revert with the following error if the rule check fails:
The selector for this error is 0x33385551
.
Create Function
Adding a pause rule is done through the function:
see AppManager
Parameters:
- _pauseStart (uint256): the Unix timestamp for the start of the paused period.
- _pauseStop (uint256): the Unix timestamp for the end of the paused period.
The add function will return the protocol ID of the rule.
This add function will also delete automatically any pause rule where the pauseStop
timestamp is less than current timestamp since this means that the rule has expired.
There is a default limit of 15 pause rules per application to avoid too much gas consumption during transactions.
Parameter Optionality:
There are no options for the parameters of this rule.
Parameter Validation:
The following validation will be carried out by the add function in order to ensure that these parameters are valid and make sense:
- The amount of rules won’t be greater than
MAX_RULES
. pauseStop
timestamp is greater thanpauseStart
.pauseStart
timestamp is greater than current timestamp.
see PauseRule
It is worth noting that this rule is special in the sense that it is not stored in the protocol but in the AppManager data contracts. Therefore, this rule doesn’t have an ID like the other rules. This fact also makes this rule unreachable by other applications.
see ProtocolApplicationHandler
Other Functions:
- In AppManager:
- Function to remove a rule:
- Function to activate/deactivate the rule:
- Function to get all rules:
- Function to clean expired rules:
- Function to remove a rule:
Return Data
This rule doesn’t return any data.
Data Recorded
This rule doesn’t require of any data to be recorded.
Events
- event AD1467_PauseRuleEvent(uint256 indexed pauseStart, uint256 indexed pauseStop, bool indexed add): emitted when:
- A pause rule has been added. In this case, the
add
field of the event will be true. - A pause rule has been removed. In this case, the
add
field of the event will be false.
- A pause rule has been added. In this case, the
Dependencies
This rule has no dependencies.