> For the complete documentation index, see [llms.txt](https://fastlane-labs.gitbook.io/polygon-fastlane/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fastlane-labs.gitbook.io/polygon-fastlane/searcher-guides/searcher-contract-integration/solver-concepts.md).

# Solver Concepts

This guide provides an overview of developing Solver contracts within the FastLane Protocol ecosystem. Solvers are essential components that execute operations and can submit bids in relation to opportunity transactions. If a solver’s bid wins the backrun auction, it will be executed immediately after the referenced transaction.

## Core Concepts

#### EIP-712 Signed Messages

Searchers submit their solutions to the FastLane Protocol via [EIP-712](https://eips.ethereum.org/EIPS/eip-712) signed messages. This standard ensures secure and verifiable communication between searchers and the protocol, allowing for off-chain data signing and on-chain verification.

#### Auction Type: Searcher Bundles (Backrun Auctions)

FastLane supports one type of auction:

* **Searcher Bundles (Backrun Auctions)**: These auctions enable searchers to submit backrunning opportunities by providing transaction bundles that can capture value from other transactions in the block.

#### Solver Interface[^1]

Searchers need to implement the following interface in their smart contracts:

```solidity
interface ISolverContract {
    function atlasSolverCall(
        address solverOpFrom,
        address executionEnvironment,
        address bidToken,
        uint256 bidAmount,
        bytes calldata solverOpData,
        bytes calldata extraReturnData
    )
        external
        payable;
}
```

This interface defines the `atlasSolverCall` function, which is the entry point for the FastLane Protocol to interact with the searcher's contract.

### Sequential Diagram of the Solver

The following diagram illustrates the key interactions between the Searcher, DAppContract, FastLane Protocol, and SolverContract components in the FastLane Protocol ecosystem:

{% @mermaid/diagram content="sequenceDiagram
participant Searcher
participant DAppContract
participant Atlas
participant SolverContract

```
Searcher->>Atlas: Submit EIP-712 Signed Message
Atlas->>DAppContract: Execute Operation
DAppContract->>Atlas: Return Operation Result
Atlas->>SolverContract: Call atlasSolverCall
SolverContract-->>Atlas: Return Execution Result
Atlas-->>Searcher: Confirm Execution" %}
```

### Helper Base Contracts

The FastLane Protocol provides helper base contracts that developers can inherit from to streamline the creation of Solvers.

#### SolverBase

`SolverBase` is a foundational contract for Solvers designed to handle:

* Safety checks
* Bid payment processing
* Escrow reconciliation

**Important Modifiers**

The `SolverBase` contract includes important modifiers that you should utilize in your `atlasSolverCall` function implementation:

1\. `safetyFirst` Modifier:

```solidity
modifier safetyFirst(address executionEnvironment, address solverOpFrom) {
    if (msg.sender != _atlas) revert InvalidEntry();
    if (solverOpFrom != _owner) revert InvalidCaller();

    _;

    uint256 shortfall = IAtlas(_atlas).shortfall();

    if (shortfall < msg.value) shortfall = 0;
    else shortfall -= msg.value;

    if (msg.value > address(this).balance) {
        IWETH9(WETH_ADDRESS).withdraw(msg.value - address(this).balance);
    }

    IAtlas(_atlas).reconcile{ value: msg.value }(shortfall);
}
```

This modifier:

* Ensures that only the Atlas contract can call the function
* Verifies that the solver operation is from the authorized owner
* Handles any shortfall in the Atlas contract after the main function execution
* Unwraps WETH if necessary to cover the msg.value
* Reconciles the shortfall with the Atlas contract

2\. `payBids` Modifier:

```solidity
modifier payBids(address executionEnvironment, address bidToken, uint256 bidAmount) {
    _;

    if (bidToken == address(0)) {
        // Pay bid in ETH
        if (bidAmount > address(this).balance) {
            IWETH9(WETH_ADDRESS).withdraw(bidAmount - address(this).balance);
        }
        SafeTransferLib.safeTransferETH(executionEnvironment, bidAmount);
    } else {
        // Pay bid in ERC20 (bidToken)
        SafeTransferLib.safeTransfer(bidToken, executionEnvironment, bidAmount);
    }
}
```

This modifier:

* Handles the payment of the solver's bid to the Execution Environment
* Supports payments in both POL (Native) and ERC20 tokens
* Unwraps WETH if necessary to cover ETH payments
* Uses [`SafeTransferLib`](https://github.com/Vectorized/solady/blob/main/src/utils/SafeTransferLib.sol) for secure token transfers

When inheriting from `SolverBase`, it's crucial to use these modifiers correctly in your `atlasSolverCall` function implementation to ensure proper security checks and bid payments.

[^1]:


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://fastlane-labs.gitbook.io/polygon-fastlane/searcher-guides/searcher-contract-integration/solver-concepts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
