What Is a Keeper Bot in DeFi?
A keeper bot is the unglamorous backbone of most serious DeFi protocols. Without keepers, lending markets would fill with zombie positions, options would expire unsettled, and yield vaults would sit idle. Understanding what a keeper bot does — and why protocols need them — is essential for anyone who wants to understand how DeFi actually functions at a mechanical level.
In traditional finance, clearinghouses and prime brokers handle margin calls and settlement. DeFi has no clearinghouse. Keeper bots fill that gap. They're off-chain programs (or increasingly on-chain agents) that watch for trigger conditions on smart contracts and call specific functions when those conditions are met, earning a fee for their trouble.
Core Functions of a Keeper Bot
Keeper bots serve different roles depending on the protocol. The main categories:
Liquidation keepers — Monitor lending protocols like Aave or Compound for positions where the collateral ratio drops below the liquidation threshold. When a position becomes undercollateralized, the keeper calls the liquidation function, repays a portion of the debt, and receives the collateral at a discount (the "liquidation bonus," typically 5–10%).
Oracle update keepers — Push fresh price data onto the chain on a scheduled or deviation-triggered basis. Chainlink's decentralized oracle network uses node operators performing this function at scale. See the Oracle Network Reliability comparison for how different networks handle this.
Vault harvest keepers — Trigger the harvest() function on yield aggregator vaults (like those built on Yearn Finance's architecture) to compound accumulated rewards back into the strategy. Without regular harvesting, yields decay.
Auction and settlement keepers — Settle expired options, trigger Dutch auctions in liquidation systems (like MakerDAO's Liquidations 2.0), or close positions in structured product vaults.
How a Keeper Bot Works: A Simple Example
Imagine a lending protocol where ETH is posted as collateral against a stablecoin loan. The protocol requires a 150% collateralization ratio. ETH drops 20% overnight.
- The keeper bot polls the protocol every few blocks (or subscribes to on-chain events)
- It detects a position at 148% collateralization — below threshold
- It calls
liquidate(positionId, repayAmount) - The smart contract transfers discounted collateral to the keeper's wallet
- The keeper repays the debt and pockets the spread
That's it. Simple in concept. Brutal in competition.
The Economics: Why Anyone Runs a Keeper
Keeper bots aren't charity work. They're profit-seeking programs. The incentive structure varies:
| Protocol Type | Keeper Incentive | Typical Margin |
|---|---|---|
| Lending liquidation | Liquidation bonus (5–15%) | High during volatility |
| Vault harvesting | Portion of harvest fee | Low, consistent |
| Oracle updates | Fixed call reward | Thin, high volume |
| Options settlement | Settlement fee | Variable |
During volatile markets — think March 2020 or the LUNA collapse in May 2022 — liquidation keepers can generate significant returns. I've seen well-positioned bots extract six figures in a single volatile session. But the competition is fierce. Most protocols have dozens of competing keepers, and MEV dynamics mean the fastest bot usually wins.
Warning: Running a liquidation keeper without proper gas optimization is a way to lose money. A keeper that calls a function 10 seconds too late — after a competitor — has paid gas for nothing.
Keeper Bots vs. MEV Bots: What's the Difference?
This distinction confuses a lot of people. Here's the practical split:
- Keeper bots perform protocol-specified maintenance functions. The protocol wants them to exist and pays them to act. They're operating within the intended design.
- MEV bots extract value through strategies the protocol didn't explicitly design for — sandwiching trades, backrunning arbitrage, front-running large swaps.
The line blurs in practice. A liquidation keeper can also be an MEV bot if it uses flashbots bundles to front-run other liquidators. Many sophisticated keeper operations do exactly this.
The Chainlink Automation Network (Formerly Keepers)
Chainlink's Automation network (rebranded from "Chainlink Keepers" in 2023) provides a decentralized keeper infrastructure that protocols can plug into directly. Instead of relying on a single operator running a bot, Chainlink Automation uses a decentralized network of nodes to watch conditions and trigger calls. Protocols register upkeeps and fund them with LINK tokens. It removes single-point-of-failure risk from keeper infrastructure — relevant for any protocol where missed calls have real financial consequences. See Chainlink Automation documentation for implementation specifics.
Risks and Failure Modes
Don't romanticize keeper bots. Several failure modes matter:
Gas price spikes — During congestion events, keeper profitability collapses if the liquidation bonus doesn't exceed gas costs. Keepers went unprofitable briefly during the 2021 NFT gas wars.
Oracle latency — A keeper acting on stale price data might attempt a liquidation that's no longer valid, wasting gas. This is why keeper bots typically consume data from multiple sources.
Competition and latency races — In practice, most liquidation opportunities on major protocols get claimed within 1–3 blocks. Without co-location or flashbots access, smaller operators struggle to compete.
Smart contract bugs — A keeper faithfully calling a buggy contract function can accelerate losses. Review smart contract vulnerabilities in DeFi protocols before building keeper infrastructure around any protocol.
Building a Keeper: What It Actually Requires
Running a basic keeper isn't as hard as most tutorials make it sound. A functional liquidation keeper needs:
- A node connection (Infura, Alchemy, or self-hosted)
- A wallet with sufficient gas reserves
- Logic to monitor the target protocol's state (events or polling)
- A transaction manager that handles gas pricing, retries, and nonce management
- Monitoring and alerting (a silent keeper that fails is a liability)
The agent-based trading systems analysis covers how automated systems like keepers perform across different market conditions — directly relevant if you're thinking about when keeper economics make sense to pursue.
Keeper bots aren't exotic. They're infrastructure. Every major DeFi protocol depends on them, and most retail users never think about them once.