Keeper Architecture
All Keepers have several things in common, they facilitate user actions (trades, liquidations, etc) within the Rook ecosystem, they connect to the HidingBook to learn about user activity, and they submit bids to the Coordinator to gain the rights to facilitate trade for the user and capture MEV. There are a variety of techniques for going about this. Some Keepers may specialize in one specific technique, while other Keepers may cast a wider net and use a variety of techniques.
- DeFi arbitrage, cross the user with Uniswap or another on-chain DEX
- CeFi arbitrage, cross the user with Coinbase or another centralized service
- Liquidation facilitation
- Liquidate something, and facilitate trade through the user
- Liquidate the user, and facilitate trade through another source
- Front running, tailgating, etc, including the user somewhere in the trade
- Keepers can also just fill a user's order outright
.png?alt=media&token=10e6ffd1-f9cd-46dc-95e4-3653741ec3ae)
DeFi example
In this example, a DeFi based Keeper bot can facilitate user trade using an on-chain smart contract that they operate. They also have an off-chain bot that connects to the HidingBook and Coordinator. The off-chain bot drives the on-chain contract. They can cross user orders with DEXs like Uniswap, and broadcast their transactions to Ethereum mempool or services like Flashbots.
.png?alt=media&token=94622ed5-e90e-46cd-b6d0-228e69c95bab)
CeFi example
In this example, a CeFi based Keeper bot can facilitate user trade themselves directly, and can also rebalance or hedge using off-chain exchanges like Binance or even OTC desks. Their off-chain bot connects to the HidingBook and Coordinator. They can broadcast their transactions to Ethereum mempool or services like Flashbots.
- A Keeper bot
- A bot built and operated by the Keeper. This is integrated with the Coordinator and HidingBook components
- Coordinator WebSocket server
- Keepers connect and communicate with the Coordinator using this server. When they find arbitrage, they place a bid via WebSockets noting the specific order/liquidation/etc they wish to fill. The Coordinator prevents gas auctions and other bad behaviors. The Coordinator will broadcast the winner of the auction letting the greenlit Keeper know to take the order/liquidation/etc. The Keeper can then capture the arbitrage or MEV any way they'd like, i.e., mempool, Flashbots, Eden, MiningDAO, etc.
- Coordinator HTTP server
- Keepers provide and gather critical information to and from this server. Keepers must stay up to date on the payment channel between the Keeper and the coordinator. They also must register their addresses with the Coordinator so the Coordinator can whitelist them appropriately. Keepers can also gather general useful information to help optimize profitability or review historic auctions.
- HidingBook HTTP server
- The orderbook containing user orders only fillable by whitelisted Rook Keepers. Keepers can get orders, learn about supported tokens, etc so they can scan the crypto space searching for MEV and ways to facilitate trade for users.
- HidingBook WebSocket server
- Keepers listen to real time order update events using this endpoint. This ensures they get orders as soon as they are posted, and they know as soon as an order is filled or expired.
Last modified 10mo ago