Skip to main content

DAppControlTemplate

The DAppControlTemplate is the most abstract contract in the Atlas Protocol's dApp integration hierarchy. It defines essential internal virtual functions that form the foundation for dApp modules. The DAppControl contract, which inherits from DAppControlTemplate, introduces external functions that wrap these abstract internal functions and apply necessary modifiers for access control and execution phase management.

The contract inherits from AtlasErrors.

Constants

ConstantTypeValueDescription
DEFAULT_SOLVER_GAS_LIMITuint321_000_000Default gas limit for solver operations.

Constructor

constructor() { }

The constructor is intentionally left empty as DAppControlTemplate is an abstract contract.

Virtual Functions

_preOpsCall

function _preOpsCall(UserOperation calldata) internal virtual returns (bytes memory)

Description

Executed before processing a UserOperation. Allows dApps to perform preliminary operations or checks.

Parameters

NameTypeDescription
(Unnamed)UserOperationThe user operation being processed.

Return Values

NameTypeDescription
(Unnamed)bytesData to be passed to subsequent execution phases.

_checkUserOperation

function _checkUserOperation(UserOperation memory) internal virtual

Description

Validates the integrity and correctness of a UserOperation.

Parameters

NameTypeDescription
(Unnamed)UserOperationThe user operation to validate.

_allocateValueCall

function _allocateValueCall(address bidToken, uint256 bidAmount, bytes calldata data) internal virtual

Description

Allocates value based on the outcome of a SolverOperation.

Parameters

NameTypeDescription
bidTokenaddressAddress of the token used for the bid.
bidAmountuint256Amount of the bid.
databytesAdditional data required for allocation.

_preSolverCall

function _preSolverCall(SolverOperation calldata, bytes calldata) internal virtual

Description

Executed before a solver performs its operation.

Parameters

NameTypeDescription
(Unnamed)SolverOperationThe solver operation being executed.
(Unnamed)bytesData returned from the preOps call.

_postSolverCall

function _postSolverCall(SolverOperation calldata, bytes calldata) internal virtual

Description

Executed after a solver completes its operation.

Parameters

NameTypeDescription
(Unnamed)SolverOperationThe solver operation that was executed.
(Unnamed)bytesData returned from the solver's execution.

_postOpsCall

function _postOpsCall(bool, bytes calldata) internal virtual

Description

Executed after all user and solver operations within a metacall transaction are completed.

Parameters

NameTypeDescription
(Unnamed)boolIndicates if a winning SolverOperation was successful.
(Unnamed)bytesData returned from the previous call phase.

Getters & Helpers

getBidFormat

function getBidFormat(UserOperation calldata userOp) public view virtual returns (address bidToken)

Description

Retrieves the expected bid token format for a given user operation.

getBidValue

function getBidValue(SolverOperation calldata solverOp) public view virtual returns (uint256)

Description

Retrieves the bid value associated with a specific solver operation.

getSolverGasLimit

function getSolverGasLimit() public view virtual returns (uint32)

Description

Retrieves the gas limit set for solver operations.

Error Handling

The contract utilizes custom errors inherited from AtlasErrors:

  • AtlasErrors.NotImplemented()
  • Other custom errors from AtlasErrors based on specific implementation needs.