Run a Solver Bot

Solver bots (also called Matchers) are the backbone of Floe's intent matching system. They scan for compatible intents and execute matches, earning fees in the process.

What is a Solver?

Solvers are automated bots that:

  1. Monitor open lend and borrow intents

  2. Find compatible pairs based on matching criteria

  3. Execute the matchLoanIntents transaction

  4. Earn the matcher commission set by borrowers

Revenue Model

Solvers earn the matcher commission set by borrowers:

  • Typical range: 0.1% - 0.5% of loan amount

  • Paid from the loan proceeds at settlement

  • Example: 0.3% on a $10,000 loan = $30

Prerequisites

  • Node.js 18+

  • Base Mainnet RPC (Alchemy or Infura recommended)

  • Funded wallet with ETH for gas (we recommend at least 0.1 ETH for 200+ matches; a typical matchLoanIntents call costs 300-500k gas)

  • Capital for gas fees only (no loan capital needed)

Quick Setup

1. Clone the Repository

2. Configure Environment

Edit .env:

3. Run the Solver

Configuration Options

Variable
Description
Default

PRIVATE_KEY

Wallet private key for signing transactions

Required

RPC_URL

Base Mainnet RPC endpoint

Required

LOG_LEVEL

Logging verbosity (debug, info, warn, error)

info

MATCHING_INTERVAL_MS

How often to scan for matches (ms)

5000

MIN_PROFIT_THRESHOLD_BPS

Minimum profit to execute match (basis points)

10

GAS_PRICE_MULTIPLIER

Gas price buffer for faster inclusion

1.2

MAX_GAS_PRICE_GWEI

Maximum gas price to use

100

Matching Logic

Compatibility Requirements

For two intents to be matchable:

  1. Same Market: Both intents must be for the same loan/collateral pair

  2. Rate Compatible: borrower.maxInterestRate >= lender.minInterestRate

  3. LTV Compatible: borrower.minLtvBps + 800bps <= lender.maxLtvBps (the protocol requires an 8% gap between origination and liquidation LTV)

  4. Duration Compatible: borrower.duration <= lender.duration

  5. Amount Available: lender.remainingAmount >= borrower.amount

  6. Not Expired: Both intents must be within their validity period

LTV Gap Requirement

The protocol enforces an 8% minimum gap between:

  • Origination LTV (borrower's minLtvBps)

  • Liquidation LTV (lender's maxLtvBps)

Profitability Calculation

The solver only executes matches where:

Architecture

Components

  1. Indexer Client: Fetches open intents from Envio GraphQL

  2. Matching Engine: Finds compatible intent pairs

  3. Profitability Scorer: Calculates expected profit per match

  4. Executor: Submits transactions to the blockchain

Strategies

Greedy Strategy (Default)

Executes matches immediately when found, prioritizing by profit.

Optimal Strategy

Finds the globally optimal set of matches considering partial fills.

More complex but can extract more value when multiple matches are possible.

Monitoring

Logs

Metrics

The solver exposes metrics at /metrics (if enabled):

  • matches_executed_total: Total successful matches

  • matches_failed_total: Failed match attempts

  • profit_earned_total: Cumulative profit in USDC

  • gas_spent_total: Cumulative gas in ETH

Troubleshooting

"Transaction reverted"

Common causes:

  • Intent was already matched by another solver

  • Intent expired during execution

  • Insufficient gas price (front-run)

Solution: Increase GAS_PRICE_MULTIPLIER or reduce MATCHING_INTERVAL_MS

"No profitable matches found"

  • Market conditions may not have compatible intents

  • Your MIN_PROFIT_THRESHOLD_BPS may be too high

  • Check that indexer is synced

"RPC rate limited"

  • Switch to a dedicated RPC provider (Alchemy, Infura)

  • Increase MATCHING_INTERVAL_MS to reduce request frequency

Security Considerations

  1. Private Key Security

    • Never commit .env to version control

    • Consider using a hardware wallet or KMS

    • Use a dedicated wallet for the solver

  2. Gas Management

    • Set MAX_GAS_PRICE_GWEI to prevent excessive spending during network congestion

    • Monitor wallet balance for gas

  3. MEV Protection

    • Consider using Flashbots or private mempools for large matches

    • Front-running risk exists for high-value matches

Advanced: Custom Strategies

You can implement custom matching strategies by extending the base solver:

Economics Example

Next Steps

Last updated