Polygon FastLane
  • What is Polygon FastLane?
    • Overview
    • Design Principles
    • Components
    • Component Diagram
  • Getting Started as a Validator
    • Getting Started as a Validator
    • Connecting to a FastLane Sentry Node
      • Finding Your Enode Address & Peer ID
      • Adding FastLane as a Static Peer
    • Patching Your Sentry Nodes With The FastLane Patch
      • Installing from source
        • Patch Download
        • Patch Installation
      • Installing from packages
  • Withdrawing Validator Revenue
    • Validator Vault
      • Connect an Eligible Wallet
      • Revenue Redemption (withdrawal)
  • Searcher Guides
    • Getting Started as a Searcher
      • Solver Call Data
      • Submission Methods
      • Migration Guide for Searchers
    • Bundles (Backruns)
      • Bundle Format
      • Bid Submission
      • Bundle Requirements
      • Full Example
      • Subscribe Events
    • 4337 Bundles Integration Guide
      • Overview
      • How it works
      • RPC Reference
      • Examples
    • Searcher Contract Integration
      • Safety Considerations
      • atlasSolverCall
      • Direct Implementation
      • Proxy Implementation
      • Solver Concepts
      • Altas Bonding Concept
      • Bond atlETH
      • Estimating Solver Gas Charges
    • Addresses & Endpoints
    • Helpers
    • Common Mistakes
    • Atlas SDK's
  • Tools and Analytics
    • FastLane Bundle Explorer
      • Features Overview
      • Key Components
      • Usage Example
      • Error Codes & Troubleshooting
  • Key Concepts
    • Transaction Encoding
  • INFRASTRUCTURE
    • Health Status Endpoint
  • Reference
    • Relay JSON-RPC API
    • Relay REST API
    • Glossary of Terms
Powered by GitBook
On this page
  • Solver Interface
  • Important Modifiers
  • 1. safetyFirst Modifier:
  • 2. payBids Modifier:
  1. Searcher Guides
  2. Searcher Contract Integration

atlasSolverCall

PreviousSafety ConsiderationsNextDirect Implementation

Last updated 6 months ago

Solver Interface

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

See ()

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

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

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

Uses for secure token transfers

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

Example Solver Repository
SolverBase
SafeTransferLib
SolverBase