Skip to main content

CallBits

The CallBits library provides utility functions and constants for encoding and decoding call configurations within the Atlas Protocol. It facilitates the management of various execution phase flags by encoding them into a compact uint32 format and decoding them back into a structured CallConfig object. This library is essential for ensuring that calls adhere to the protocol's safety and operational requirements during different execution phases.

State Variables

Constants

Constant NameTypeDescription
_ONEuint32Represents the value 1 used for bit shifting operations.

Functions

buildCallConfig

function buildCallConfig(address control) internal view returns (uint32 callConfig)

Description

Retrieves the call configuration from the specified DAppControl contract. This configuration determines the behavior and restrictions of calls within different execution phases.

Parameters

NameTypeDescription
controladdressThe address of the DAppControl contract.

Returns

NameTypeDescription
callConfiguint32The encoded call configuration flags.

encodeCallConfig

function encodeCallConfig(CallConfig memory callConfig) internal pure returns (uint32 encodedCallConfig)

Description

Encodes a CallConfig struct into a uint32 representation by setting specific bits corresponding to each configuration flag.

Parameters

NameTypeDescription
callConfigCallConfig memoryThe call configuration struct containing various flags.

Returns

NameTypeDescription
encodedCallConfiguint32The encoded call configuration as a uint32 value.

decodeCallConfig

function decodeCallConfig(uint32 encodedCallConfig) internal pure returns (CallConfig memory callConfig)

Description

Decodes a uint32 encoded call configuration back into a CallConfig struct by extracting each flag based on its bit position.

Parameters

NameTypeDescription
encodedCallConfiguint32The encoded call configuration to decode.

Returns

NameTypeDescription
callConfigCallConfig memoryThe decoded call configuration struct.

Getter Functions

The following functions are used to check specific flags in the call configuration. Each function takes a uint32 callConfig as input and returns a bool indicating whether the specific flag is set in the configuration.

needsSequentialUserNonces

function needsSequentialUserNonces(uint32 callConfig) internal pure returns (bool sequential)
Description

Determines if sequential user nonces are required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
sequentialbooltrue if sequential user nonces are required.

needsSequentialDAppNonces

function needsSequentialDAppNonces(uint32 callConfig) internal pure returns (bool sequential)
Description

Determines if sequential DApp nonces are required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
sequentialbooltrue if sequential DApp nonces are required.

needsPreOpsCall

function needsPreOpsCall(uint32 callConfig) internal pure returns (bool needsPreOps)
Description

Determines if a pre-operations call is required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
needsPreOpsbooltrue if a pre-operations call is required.

needsPreOpsReturnData

function needsPreOpsReturnData(uint32 callConfig) internal pure returns (bool needsReturnData)
Description

Determines if return data from pre-operations calls should be tracked based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
needsReturnDatabooltrue if return data from pre-operations calls should be tracked.

needsUserReturnData

function needsUserReturnData(uint32 callConfig) internal pure returns (bool needsReturnData)
Description

Determines if return data from user operations should be tracked based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
needsReturnDatabooltrue if return data from user operations should be tracked.

needsDelegateUser

function needsDelegateUser(uint32 callConfig) internal pure returns (bool delegateUser)
Description

Determines if user delegation is required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
delegateUserbooltrue if user delegation is required.

needsPreSolverCall

function needsPreSolverCall(uint32 callConfig) internal pure returns (bool needsPreSolver)
Description

Determines if a pre-solver call is required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
needsPreSolverbooltrue if a pre-solver call is required.

needsPostSolverCall

function needsPostSolverCall(uint32 callConfig) internal pure returns (bool needsPostSolver)
Description

Determines if a post-solver call is required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
needsPostSolverbooltrue if a post-solver call is required.

needsPostOpsCall

function needsPostOpsCall(uint32 callConfig) internal pure returns (bool needsPostOps)
Description

Determines if a post-operations call is required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
needsPostOpsbooltrue if a post-operations call is required.

allowsZeroSolvers

function allowsZeroSolvers(uint32 callConfig) internal pure returns (bool zeroSolvers)
Description

Determines if zero solvers are allowed based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
zeroSolversbooltrue if zero solvers are allowed.

allowsReuseUserOps

function allowsReuseUserOps(uint32 callConfig) internal pure returns (bool reuseUserOp)
Description

Determines if user operations can be reused based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
reuseUserOpbooltrue if user operations can be reused.

allowsUserAuctioneer

function allowsUserAuctioneer(uint32 callConfig) internal pure returns (bool userAuctioneer)
Description

Determines if a user auctioneer is allowed based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
userAuctioneerbooltrue if user auctioneer is allowed.

allowsSolverAuctioneer

function allowsSolverAuctioneer(uint32 callConfig) internal pure returns (bool solverAuctioneer)
Description

Determines if a solver auctioneer is allowed based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
solverAuctioneerbooltrue if solver auctioneer is allowed.

allowsUnknownAuctioneer

function allowsUnknownAuctioneer(uint32 callConfig) internal pure returns (bool unknownAuctioneer)
Description

Determines if an unknown auctioneer is allowed based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
unknownAuctioneerbooltrue if unknown auctioneer is allowed.

verifyCallChainHash

function verifyCallChainHash(uint32 callConfig) internal pure returns (bool verify)
Description

Determines if the call chain hash verification is required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
NameTypeDescription
verifybooltrue if call chain hash verification is required.

forwardReturnData

function forwardReturnData(uint32 callConfig) internal pure returns (bool)
Description

Determines if return data should be forwarded based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
TypeDescription
booltrue if return data should be forwarded.

needsFulfillment

function needsFulfillment(uint32 callConfig) internal pure returns (bool)
Description

Determines if fulfillment is required based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
TypeDescription
booltrue if fulfillment is required.

allowsTrustedOpHash

function allowsTrustedOpHash(uint32 callConfig) internal pure returns (bool)
Description

Determines if a trusted operation hash is allowed based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
TypeDescription
booltrue if trusted operation hash is allowed.

invertsBidValue

function invertsBidValue(uint32 callConfig) internal pure returns (bool)
Description

Determines if the bid value should be inverted based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
TypeDescription
booltrue if bid value should be inverted.

exPostBids

function exPostBids(uint32 callConfig) internal pure returns (bool)
Description

Determines if ex-post bids are enabled based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
TypeDescription
booltrue if ex-post bids are enabled.

allowAllocateValueFailure

function allowAllocateValueFailure(uint32 callConfig) internal pure returns (bool)
Description

Determines if failures during value allocation are allowed based on the call configuration.

Parameters
NameTypeDescription
callConfiguint32The encoded call configuration flags.
Returns
TypeDescription
booltrue if allocation value failures are allowed.