SafetyBits
The SafetyBits
library provides utility functions and constants for managing and interpreting safety-related flags within the Atlas Protocol. It defines constants that represent safe transfer states and offers functions to manipulate and encode context information based on execution phases. This library is essential for ensuring that transfers and operations adhere to the protocol's safety requirements during various execution phases.
State Variables
Constants
Constant Name | Type | Description |
---|---|---|
SAFE_USER_TRANSFER | uint8 | Flags indicating that no user transfers are allowed during specific execution phases. |
SAFE_DAPP_TRANSFER | uint8 | Flags indicating that no DApp transfers are allowed during specific execution phases. |
Constant Definitions:
// NOTE: No user transfers allowed during AllocateValue
uint8 internal constant SAFE_USER_TRANSFER = uint8(
1 << (uint8(ExecutionPhase.PreOps)) | 1 << (uint8(ExecutionPhase.UserOperation))
| 1 << (uint8(ExecutionPhase.PreSolver)) | 1 << (uint8(ExecutionPhase.PostSolver))
| 1 << (uint8(ExecutionPhase.PostOps))
);
// NOTE: No Dapp transfers allowed during UserOperation
uint8 internal constant SAFE_DAPP_TRANSFER = uint8(
1 << (uint8(ExecutionPhase.PreOps)) | 1 << (uint8(ExecutionPhase.PreSolver))
| 1 << (uint8(ExecutionPhase.PostSolver)) | 1 << (uint8(ExecutionPhase.AllocateValue))
| 1 << (uint8(ExecutionPhase.PostOps))
);
Functions
setAndPack
function setAndPack(Context memory self, ExecutionPhase phase) internal pure returns (bytes memory packedCtx)
Description
The setAndPack
function updates the execution phase within the provided Context
structure and encodes the context information into a packed bytes format. This packed context is used for efficient storage and transmission of context-related data during protocol operations.
Parameters
Name | Type | Description |
---|---|---|
self | Context memory | The context structure to be updated and packed. |
phase | ExecutionPhase | The current execution phase to set within the context. |
Return Values
Name | Type | Description |
---|---|---|
packedCtx | bytes memory | The packed bytes representation of the updated context. |