mev-toolkit/keeperDAO/docs-notes.md
2022-03-27 18:46:15 +01:00

12 KiB

KeeperDAO notes


KeeperDAO uses the power of Coordination to create more efficient markets by capturing and recycling MEV to the users and protocols that create it.


KeeperDAO is a decentralised and coordinated Keeper commonwealth making the Ethereum network more egalitarian, profitable, and secure for all the actors involved.



Core Products


The Hiding Game

  • Gasless limit order system that sources liquidity from all means supported by KeeperDAO Keepers.
  • If a user's order creates a MEV opportunity, the user will be reward with a share of the MEV profits in the form of ROOK.

The Hiding Vault

A generalized liquidation-mitigation lending and borrowing NFT product.

  • The first platform supported by Hiding Vaults is Compound Finance.
  • Using a Hiding Vault mitigates both the risks and the impacts of the liquidation of users using Compound Finance.
  • If a user's position is liquidated, the user will be reimbursed with a share of the liquidation profits in the form of ROOK.

Liquidity Pools

  • KeeperDAO offer five single-asset LP that yield ROOK tokens (ETH, WETH, USDC, renBTC, and DAI): users earn ROOK rewards based on the number of ROOK rewards allocated to the pool each quarter.


MEV


How the blockchain works

  • Each block in the blockchain contains a list of transactions in a particular order, enconding a sequence of updates to the blockchain sate (world state).
  • Anyone can broadcast a transaction to the network, which means that the transaction is public. A broadcast is a request. In order for that request to be carried out, someone must place the transaction in a block and add the block to the blockchain.
  • Anyone can listen for transactions being broadcast and gather them into a list. In order to a turn a list into a block, it needs to be validated. Validation creats a mathematical (cryptographic) proof that the state changes are consistent.
  • In a proof-of-work blockchain, block producers are miners. In a proof-of-stake blockchain, they are validators.
  • The act of converting a transaction into a block is called settlement. The process of block production is called settlement layer or consensus layer.

Arbritage opportunity

  • Results from a difference in prices between the same asset, listed on different DEXes.
  • A transaction that makes the right swaps along the right arbritage route will end up with profit.

Keepers

  • Bots that observe Ethereum, and other blockchains, to faciliate sorts of transactions, such as arbitrage, liquidations, auctions.
  • Automated agents that survey the state of the blockchain and compute all the different possibilitie in order to identifty transactions that can create profit.
  • Once Keepers have identified a valuable transaction, they will broadcast that to the network. Other keepers can copy and broadcast the same transaction with themselves as the originators.
  • MEV arises from the problem of "how can a keeper ensure that they are the one who gets a transaction settled first?
  • Keepers compete with each other in a zero-sum game, transforming Ethereum into a highly zero-sum game.
  • Inside KeeperDAO, keepers don't need to compete - but coordinate and capture on-chain profits efficiently. DeFi users, protocols, market makers can bring their activity to KeeperDAO and gain a portion of the profits as a reward.

Maximal extractable value

  • Refers to profit that can be extracted from a transaction from the transaction originator needing priority or control over the ordering of that transacion in a block (the arbitrage has 45 WETH of MEV).
  • As may of 2021, around $3-4mil of MEV is being captured daily.
  • MEV exists on any blockchain and layers where there is a party responsible for transaction ordering (eg. validators, rollup providers).
  • Extracted MEV = Successful MEV transactions + Successful MEV transactions gas fees + Failed MEV transactions gas fees

➡️ While it seems simple, MEV poses risks not only to the user but also to the consensus layer itself. The reorganisation of blocks, the reordering of transactions, and — even momentarily — the censorship of transactions can have profound impacts on the blockchain and breaks the assumptions of many applications.

➡️ Because block producers are able to prioritize transactions with higher gas fees, a bidding war between bots (who either try to arbitrage or front-run) can occur. This hurts ordinary users and DeFi platforms, because these bidding wars drive up gas fees (Priority Gas Auctions) and cause slippage and failed transactions

MEV strategies

  • Common MEV strategies are front-running, back-running, and sandwiching.
  • MEV should accrue to the originator of the transaction, or of the transactions or protocols that create the MEV in the first place.
  • Using KeeperDAO's coordination layer, we can capture and recycle the MEV before it can be extracted.



KeeperDAO Coordination Game


  • First protocol that allows generalized MEV to be internalized at the application layer, protecting users and protocols from negative externalities, reducing the total MEV available at the consensus layer, and ensuring that less value overall is being extracted from markets and protocols by miners and validators.

  • Design a comprehensive syste that can flexibly capture a wide variety of application-layer transaction flow, creating posiive-feedback flywheel that aggregates and re-distributes MEV among participants in a way that increases overall netwoek and market efficiency.


Screen Shot 2022-03-27 at 5 07 33 PM

Coordination lifecycle outline

  1. Keepers buy ROOK and stake it in the Coordinator smart contract. Keepers pend staked ROOK bidding on the right to execute transactions in the Coordination Game.
  2. Keepers watch incoming transactions, and search for the best way to profitably execute them.
  3. When an opportunity is discovered, Keepers initiate a sub-second just-in-time auction that will decide who gets the right-of-way to execute the transaction. In the auction, Keepers place bids using their staked ROOK from (1).
  4. The Coordinator Auction Module prevents Keepers from grim triggering each other during the auction, by balancing both upward and downward bid pressure to discover the fair value of the profit opportunity.
  5. The Coordinator greenlights the winner of the auction, leaving them free to broadcast the transaction and collect the profit they discovered, while fulfilling the request of the user who originated the transaction.
  6. Upon execution of the transaction, the bid that the winning Keeper paid to win the auction is distributed based on the image in the ROOK bid.

Screen Shot 2022-03-27 at 6 05 38 PM

Hiding Book


Screen Shot 2022-03-27 at 6 12 10 PM
  • Off-chain orderbook that hosts virtualized orders only filable by KeeperDAO keepers: single-connection access to the entire spectrum of on-chain and off-chain liquidity.
  • The hiding book can act as an order relay, or a virtual mempool.
  • Integrating the hiding book offers imit orders for dapps with benefits like ROOK rewards, MEV protection, and access to KeeperDAO's keepers.

Auctions

  • Keepers place a bid with the Coordinator, which is a JSON payload that includes: a signed bid commitment over the staked ROOK payment channel, the unique identifier of the user trade(s) being filler, the keeper's credentials, etc.
{
   "bids":[
      {
         "auctionId":"0x1234",
         ....
      },
      {
         "auctionId":"0x5678",
         ....
      }
   ],
   "type":"bid"
}

Auction life cycle

  • binding:

    • all auctions are identified by an auctionID.
    • an auction begins with the first keeper bid on an auctionID
    • the auction is locked into this state where any bids received for this auctionID are competing against each other for greenlight
    • last not more than a few seconds
  • greenlight:

    • once a keeper is greenlit to faciliate user trade, the coordinator waits a period of blocks for the keeper to mine their transaction
    • during this time, the auctionID remains locked
  • release:

    • once the lock ends, a new auction can begin

Reputation

  • KeeperDAO uses a proprietary reputation algorithm that's a simple scoring system based on actions performed by keepers.
  • reputation values are fed to the coordinator's greenlight algorithm to help select the winnter of an auction

Greenlight algorithm

  • bid quantity (the higher the better)
  • reputation
  • randomness
  • fill quantity (larger fill quantities)
  • staked ROOK quantity (the more the best)



How Market Makers benefit


  • KeeperDAO provides arbitrage as a service (using the Rook Network)

  • KeeperDAO is the most convenient, secure, and profitable network for on-chain market makers:

      1. one single integration to access all DeFi and CeFi liquidity: orders will be arbitraged against KeeperDAO users, other market makers, Uniswap, Curve, Balancer, Bancor, Binance, etc...
      1. KeeperDAO provides market makers with three different profit mechanisms: i) capture spreads or hedge fills, ii) earn arbitrage rewards in ROOK on every trade, 3) weekly pilot program rewards
  • Before KeeperDAO, DeFi asked market makers to execute their own trades, meaning they had to navigate gas, fees, liquidity, bridging, routing, L2s, settlements, MEV.


Screen Shot 2022-03-27 at 8 58 52 PM

MM integration guide




Running a Keeper


Example keeper bot technicuqes

  • DeFi arbitrage, cross the user with Uniswap or other on-chain DEX
  • CeFi arbitrage, cross the user with Coinbase, etc
  • Liquidation facilitation
  • Front running, tailgating, etc.
  • Keepers can also fill a user's order

Screen Shot 2022-03-27 at 9 24 22 PM

Keeper bot architecture

  • a keeper bot: 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 web sockets noting the specific order/liquidation. The coordinator prevents gas auctions and bad behaviors, and broadcast the winner of the auction letting the greenlit keeper know they can take the order/liquidation. The keeper can then capture the arbitrage or MEV they way they like (mempool, flashbots, eden, miningdao, etc).
  • Coordinator http server: keepers provide and gather critical info from this server (must register their addresss with the coordinator)
  • HidingBook http server: the orderbook containing user order only fillable by whitelisted KeeperDAO keepers.
  • 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 know when the order is filled or expired.