Skip to main content

Getting Started

This guide provides an overview of developing Solver contracts within the Atlas Protocol ecosystem. Solvers are essential components that execute operations, handle bid payments, and integrate decentralized applications (DApps) with the Atlas Protocol.

Developing a Solver

  1. Choose a Base Contract: Decide whether to inherit from SolverBase, SolverBaseInvertBid, or implement the ISolverContract interface from scratch based on your DAppControl's configuration.

  2. Implement the ISolverContract Interface: Override the atlasSolverCall function if using a base contract, or implement it as defined in the interface if starting from scratch.

  3. Handle SolverOperation Data: Within the atlasSolverCall function, parse and process the solverOpData to execute the intended operation. This data contains the details of the solver operation to be performed.

  4. Manage Bid Payments: Implement logic to handle bid payments as specified in the SolverOperation struct. If using a base contract like SolverBase, utilize the provided payBids modifier to handle bid payments automatically.

  5. Interact with the Execution Environment: The Execution Environment is primarily used for bid payments, which is handled automatically by the payBids modifier in SolverBase. Direct interaction with the Execution Environment from within the solver is limited. The executionEnvironment address is provided mainly for this payment process.

  6. Error Handling: Implement proper error handling and revert mechanisms to ensure the solver behaves correctly under various conditions. This includes handling potential failures in the solver's main logic and any interactions with external contracts.

  7. Gas Optimization: Optimize your solver's gas usage to remain competitive in the bidding process. This involves writing efficient code and minimizing unnecessary operations or storage updates.

Atlas Solver Execution Flow

1. Security First

  • Bond Validation: Ensures the solver is bonded with atlETH.
  • Signature Validation: Validates the signature for the solverOperation to confirm authenticity.

2. Execution

  • Atlas Call: Atlas initiates the process by calling the solver through atlasSolverCall.
  • MEV Strategy Execution: The solver executes its MEV strategy using the provided calldata.

Note: Solvers must implement the atlasSolverCall function to facilitate this interaction.

3. Payment

  • Bid Payment: The solver must pay the specified bidAmount back to Atlas.
  • Retry Mechanism: Atlas will attempt each solver in sequence until the bid is paid.

Best Practices

  • Thoroughly test your solver implementation using various scenarios and edge cases.
  • Implement security measures to protect against potential vulnerabilities.
  • Consider implementing modular designs to allow for easy upgrades and maintenance.
  • Document your solver's specific behavior and any unique features it offers.
  • When using base contracts, understand the provided modifiers and their implications.