atlasSolverCall

Solver Interface

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

See (Example Solver Repository)

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

solverOpFrom

address

The address initiating the solver operation.

executionEnvironment

address

The address of the Execution Environment.

bidToken

address

The token used for bidding; use zero address to indicate POL

bidAmount

uint256

The amount of tokens bid in wei

solverOpData

bytes

The data associated with the solver operation.

extraReturnData

bytes

Additional data to return after execution.

payable

-

Indicates that ether can be sent with the call (if any).

The bidAmount will have to be transferred at the end of the solver call to the executionEnvironment address. We provide opinionated modifiers which can be easily used to get started.

Important Modifiers

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

1. safetyFirst Modifier:

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:

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 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.

Last updated