Skip to main content

Sorter

The Sorter contract in the Atlas Protocol is responsible for evaluating and organizing solver bids within a metacall transaction. By assessing the eligibility and bid amounts of solvers, the Sorter ensures that the most qualified and competitive solvers are selected for execution, thereby enhancing the protocol's efficiency and fairness.

State Variables

VariableTypeVisibilityDescription
ATLASIAtlaspublicImmutable instance of the Atlas protocol.
VERIFICATIONIAtlasVerificationpublicImmutable instance of the Atlas verification contract.

Structs

SortingData

FieldTypeDescription
amountuint256The bid amount associated with a solver operation.
validboolIndicates whether the solver operation is eligible.

Constructor

constructor(address _atlas)

Description

Initializes the Sorter contract by setting the immutable ATLAS and VERIFICATION instances.

Parameters

NameTypeDescription
_atlasaddressAddress of the deployed Atlas protocol contract.

External Functions

sortBids

function sortBids(
UserOperation calldata userOp,
SolverOperation[] calldata solverOps
) external view returns (SolverOperation[] memory)

Description

Processes and sorts solver bids based on their eligibility and bid amounts.

Parameters

NameTypeDescription
userOpUserOperationThe user operation containing user and dApp details.
solverOpsSolverOperation[]Array of solver operations to be evaluated and sorted.

Return Values

NameTypeDescription
solverOpsSortedSolverOperation[]Array of sorted and eligible solver operations.

Requirements

  • None explicitly stated. Invalid solver operations are handled internally.

Usage Notes

  • Filters out invalid solver operations.
  • Sorts eligible solvers in descending order of their bid amounts.
  • Prioritizes the highest bidders.

Error Handling

The Sorter contract leverages the underlying AtlasErrors for consistent and efficient error reporting. Common scenarios include:

  • Invalid Solver Operations
  • Bid Format Mismatch
  • Insufficient Bonded Funds