Hatcher
Inherits: Administrable, Freezable, IHatcher
Author: mortimr @ Kiln
This contract provides all the utilities to handle the administration and its transfer
Unstructured Storage Friendly.
In general, regarding the fixes, try to always perform atomic actions to apply them.
When using regular fixes, it's already the case.
When using global fixes, try to wrap multiple actions in one tx/bundle to create the global fix and apply it on required instances.
When removing a global fix, keep in mind that the action can be front runned and the fix that should be removed would be applied.
The hatcher can be frozen by the admin. Once frozen, no more upgrade, pausing or fixing is allowed.
If frozen and paused, a cub will be unpaused.
If frozen and pending fixes are still there, they will be applied to cubs that haven't applied them.
If frozen, pending fixes cannot be removed.
Initial progress and cub progress can get updated by the admin. This means a fix can be applied twice if progress is decreased.
State Variables
$pauser
Unstructured Storage Helper for hatcher.pauser.
Holds the pauser address.
Slot: keccak256(bytes("hatcher.pauser")) - 1
types.Address internal constant $pauser =
types.Address.wrap(0x67ad2ba345683ea58e6dcc49f12611548bc3a5b2c8c753edc1878aa0a76c3ce2);
$implementation
Unstructured Storage Helper for hatcher.implementation.
Holds the common implementation used by all the cubs.
Slot: keccak256(bytes("hatcher.implementation")) - 1
types.Address internal constant $implementation =
types.Address.wrap(0x5822215992e9fc50486d8256024d96ad28d5ca5cb787840aef51159121dccd9d);
$initialProgress
Unstructured Storage Helper for hatcher.initialProgress.
Holds the initial progress value given to all new cubs.
Supersedes the progress of old cubs if the value is higher than their progress.
Slot: keccak256(bytes("hatcher.initialProgress")) - 1
types.Uint256 internal constant $initialProgress =
types.Uint256.wrap(0x4a267ea82c1f4624b3dc08ad19614228bbdeee20d07eb9966d67c16d39550d77);
$fixProgresses
Unstructured Storage Helper for hatcher.fixProgresses.
Holds the value of the fix progress of every cub.
Type: mapping (address => uint256)
Slot: keccak256(bytes("hatcher.fixProgresses")) - 1
types.Mapping internal constant $fixProgresses =
types.Mapping.wrap(0xa7208bf4db7440ac9388b234d45a5b207976f0fc12d31bf9eaa80e4e2fc0d57c);
$pauseStatus
Unstructured Storage Helper for hatcher.pauseStatus.
Holds the pause status of every cub.
Type: mapping (address => bool)
Slot: keccak256(bytes("hatcher.pauseStatus")) - 1
types.Mapping internal constant $pauseStatus =
types.Mapping.wrap(0xd0ad769ee84b03ff353d2cb4c134ab25db1f330b56357f28eadc5b28c2f88991);
$globalPauseStatus
Unstructured Storage Helper for hatcher.globalPauseStatus.
Holds the global pause status.
Slot: keccak256(bytes("hatcher.globalPauseStatus")) - 1
types.Bool internal constant $globalPauseStatus =
types.Bool.wrap(0x798f8d9ad9ed68e65653cd13b4f27162f01222155b56622ae81337e4888e20c0);
$fixes
Unstructured Storage Helper for hatcher.fixes.
Holds the array of global fixes.
Slot: keccak256(bytes("hatcher.fixes")) - 1
types.Array internal constant $fixes =
types.Array.wrap(0xa8612761e880b1989e2ad0bb2c51004fad089f897b1cd8dc3dbfeae33493df55);
$creationSalt
Unstructured Storage Helper for hatcher.initialProgress.
Holds the create2 salt.
Slot: keccak256(bytes("hatcher.creationSalt")) - 1
types.Uint256 internal constant $creationSalt =
types.Uint256.wrap(0x7b4670a3a88a40c4de314967df154b504cc215cbd280a064c677342c49c2759d);
Functions
onlyAdminOrPauser
Only allows admin or pauser to perform the call.
modifier onlyAdminOrPauser();
implementation
Retrieve the common implementation.
function implementation() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | implementationAddress Address of the common implementation |
status
Retrieve cub status details.
function status(address cub) external view returns (address, bool, bool);
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | The address of the cub to fetch the status of |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | implementationAddress The current implementation address to use |
<none> | bool | hasFixes True if there are fixes to apply |
<none> | bool | isPaused True if the system is paused globally or the calling cub is paused |
initialProgress
Retrieve the initial progress.
This value is the starting progress value for all new cubs
function initialProgress() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | currentInitialProgress The initial progress |
progress
Retrieve the current progress of a specific cub.
function progress(address cub) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | Address of the cub |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | currentProgress The current progress of the cub |
globalPaused
Retrieve the global pause status.
function globalPaused() external view returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | isGlobalPaused True if globally paused |
paused
Retrieve a cub pause status.
function paused(address cub) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | Address of the cub |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | isPaused True if paused |
pauser
Retrieve the address of the pauser.
function pauser() external view returns (address);
fixes
Retrieve a cub's global fixes that need to be applied, taking its progress into account.
function fixes(address cub) external view returns (address[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | Address of the cub |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | fixesAddresses An array of addresses that implement fixes |
globalFixes
Retrieve the raw list of global fixes.
This method is not view because it reads the fixes from storage.
function globalFixes() external pure returns (address[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | globalFixesAddresses An array of addresses that implement the global fixes |
nextHatch
Retrieve the address of the next hatched cub.
function nextHatch() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | nextHatchedCub The address of the next cub |
frozen
Retrieve the freeze status.
function frozen() external view returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if frozen |
freezeTime
Retrieve the timestamp when the freeze happens.
function freezeTime() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The freeze timestamp |
hatch
Creates a new cub.
function hatch(bytes calldata cdata) external virtual onlyAdmin returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
cdata | bytes | The calldata to use for the initial atomic call |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | cubAddress The address of the new cub |
hatch
Creates a new cub.
function hatch() external virtual onlyAdmin returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | cubAddress The address of the new cub |
commitFixes
Sets the progress of the caller to the current global fixes array length.
function commitFixes() external;
setPauser
Sets the address of the pauser.
function setPauser(address newPauser) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newPauser | address | Address of the new pauser |
applyFixToCubs
Apply a fix to several cubs.
function applyFixToCubs(address fixer, address[] calldata cubs) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
fixer | address | Fixer contract implementing the fix |
cubs | address[] | List of cubs to apply the fix on |
applyFixesToCub
Apply several fixes to one cub.
function applyFixesToCub(address cub, address[] calldata fixers) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | The cub to apply the fixes on |
fixers | address[] | List of fixer contracts implementing the fixes |
registerGlobalFix
Register a new global fix for cubs to call asynchronously.
function registerGlobalFix(address fixer) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
fixer | address | Address of the fixer implementing the fix |
deleteGlobalFix
Deletes a global fix from the array.
function deleteGlobalFix(uint256 index) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | Index of the global fix to remove |
upgradeTo
Upgrades the common implementation address.
function upgradeTo(address newImplementation) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | Address of the new common implementation |
upgradeToAndChangeInitialProgress
Upgrades the common implementation address and the initial progress value.
function upgradeToAndChangeInitialProgress(address newImplementation, uint256 initialProgress_)
external
notFrozen
onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | Address of the new common implementation |
initialProgress_ | uint256 | The new initial progress value |
setInitialProgress
Sets the initial progress value.
function setInitialProgress(uint256 initialProgress_) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
initialProgress_ | uint256 | The new initial progress value |
setCubProgress
Sets the progress of a cub.
function setCubProgress(address cub, uint256 newProgress) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | Address of the cub |
newProgress | uint256 | New progress value |
pauseCubs
Pauses a set of cubs.
function pauseCubs(address[] calldata cubs) external notFrozen onlyAdminOrPauser;
Parameters
| Name | Type | Description |
|---|---|---|
cubs | address[] | List of cubs to pause |
unpauseCubs
Unpauses a set of cubs.
function unpauseCubs(address[] calldata cubs) external notFrozen onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
cubs | address[] | List of cubs to unpause |
globalPause
Pauses all the cubs of the system.
function globalPause() external notFrozen onlyAdminOrPauser;
globalUnpause
Unpauses all the cubs of the system.
If a cub was specifically paused, this method won't unpause it
function globalUnpause() external notFrozen onlyAdmin;
freeze
Sets the freeze timestamp.
function freeze(uint256 freezeTimeout) external;
Parameters
| Name | Type | Description |
|---|---|---|
freezeTimeout | uint256 | The timeout to add to current timestamp before freeze happens |
cancelFreeze
Cancels the freezing procedure.
function cancelFreeze() external;
_setPauser
Internal utility to set the pauser address.
function _setPauser(address newPauser) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newPauser | address | Address of the new pauser |
_setImplementation
Internal utility to change the common implementation.
Reverts if the new implementation is not a contract.
function _setImplementation(address newImplementation) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | Address of the new implementation |
_nextHatch
Internal utility to retrieve the address of the next deployed Cub.
function _nextHatch() internal view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of the next cub |
_hatch
Internal utility to create a new Cub.
The provided cdata is used to perform an atomic call upon contract creation.
function _hatch(bytes memory cdata) internal returns (address cub);
Parameters
| Name | Type | Description |
|---|---|---|
cdata | bytes | The calldata to use for the atomic creation call |
_pause
Internal utility to pause a cub.
function _pause(address cub) internal;
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | The cub to pause |
_unpause
Internal utility to unpause a cub.
function _unpause(address cub) internal;
Parameters
| Name | Type | Description |
|---|---|---|
cub | address | The cub to unpause |
_setInitialProgress
Internal utility to set the initial cub progress.
This value defines where the new cubs should start applying fixes from the global fix array.
This value supersedes existing cub progresses if the progress is lower than this value.
function _setInitialProgress(uint256 initialProgress_) internal;
Parameters
| Name | Type | Description |
|---|---|---|
initialProgress_ | uint256 | New initial progress |
_getFreezer
Internal utility to retrieve the address of the freezer.
function _getFreezer() internal view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of the freezer |