GEB Docs
  • Introduction to GEB
  • Community Resources
  • FLX Mechanics
  • FAQ
  • RAI
    • RAI Use-Cases
    • Multi-chain RAI
    • RAI Integrations
  • The Money God League
    • Intro to The League
  • Ungovernance
    • Governance Minimization Guide
  • Risk
    • GEB Risks
    • PID Failure Modes & Responses
  • Incentives
    • RAI Uniswap V2 Mint + LP Incentives Program
    • RAI Uniswap V3 Mint + LP Incentives Program (Inactive)
    • FLX Staking
    • RAI / ETH Uniswap V3 Oracle LP Incentives Program
  • Contract Variables Translation
    • Core Contracts Naming Transition
    • Governance Contracts Naming Transition
    • SAFE Management Contract Naming Transition
  • System Contracts
    • Core Module
      • SAFE Engine
      • Liquidation Engine
      • Accounting Engine
    • Auction Module
      • English Collateral Auction House
      • Fixed Discount Collateral Auction House
      • Increasing Discount Collateral Auction House
      • Debt Auction House
      • Surplus Auction House
    • Oracle Module
      • Oracle Relayer
      • Medianizer
        • DSValue
        • Governance Led Median
        • Chainlink Median
        • Uniswap V2 Median
      • FSM
        • Oracle Security Module
        • Dampened Security Module
        • FSM Governance Interface
    • Token Module
      • Token Adapters
      • System Coin
      • Protocol Token
      • Protocol Token Authority
      • Protocol Token Printing Permissions
    • Money Market Module
      • Tax Collector
    • Sustainability Module
      • Stability Fee Treasury
      • FSM Wrapper
      • Increasing Treasury Reimbursement
      • Mandatory Fixed Treasury Reimbursement
      • Increasing Reward Relayer
    • Automation Module
      • Collateral Auction Throttler
      • Single Spot Debt Ceiling Setter
      • ESM Threshold Setter
    • Governance Module
      • DSPause
    • Shutdown Module
      • Global Settlement
      • ESM
  • Proxy Infrastructure
    • DSProxy
    • Proxy Registry
  • Helper Contracts
    • SAFE Manager
  • GEB.js
    • Getting Started
    • Global Settlement Guide
    • API Reference
      • Geb
      • Safe
      • Proxy Actions
      • Geb Admin
  • APIs
    • API Endpoints
  • Pyflex
    • Getting Started
      • Configuration
      • GEB Basics
    • SAFE Management
      • Opening a SAFE
      • Closing a SAFE
    • Numerics
  • Keepers
    • Keeper Overview
    • Collateral Auction Keeper
      • Running in Docker
      • Running on a Host
      • Liquidations & Collateral Auctions
      • Collateral Auction Flash Swaps
    • Debt Auction Keeper
      • Running in Docker
      • Running on a Host
    • Staked Token Auction Keeper
      • Running in Docker
      • Running on a Host
    • Surplus Auction Keeper
      • Running in Docker
      • Running on a Host
    • Bidding Models
  • Liquidation Protection
    • SAFE Protection
    • Liquidation Protection Guide
    • Uni-V2 RAI/ETH Savior Details
    • Curve V1 Savior Details
Powered by GitBook
On this page
  • Overview
  • Details
  • Uniswap Pools Used for Bidding
  • Configuration
  • Flash Swaps in Action
  • Caveats
  • Possible errors

Was this helpful?

  1. Keepers
  2. Collateral Auction Keeper

Collateral Auction Flash Swaps

Lightning fast bidding in collateral auctions

PreviousLiquidations & Collateral AuctionsNextDebt Auction Keeper

Last updated 3 years ago

Was this helpful?

Overview

Normally, the collateral uses system coins to bid in fixed discount collateral auctions. A keeper operator must acquire system coins to be prepared for future collateral auctions. With collateral auction flash swaps, this is no longer necessary.

The auction-keeper can be configured to use Uniswap v2 or v3 flash swaps when bidding in collateral auctions. This allows the keeper to participate in collateral auctions with no upfront capital other than gas costs to execute the transaction.

Details

The collateral auction-keeper performs flash swaps using the contracts.

The flash proxy is used by the auction-keeper to:

1) Liquidate an underwater SAFE, start a new collateral auction and bid by calling liquidateAndSettleSAFE

or

2) Bid in existing auctions by calling settleAuction

Uniswap Pools Used for Bidding

Configuration

You can enable flashswaps using the --flash-swaps flag when starting a collateral auction-keeper.

You can also specify multiple pools that the keeper loops through when trying to bid in an auction. You do this using the --flash-swap-pools flag. For example:

--flash-swap-pools eth-v2, dai-v3, usdc-v3, eth-v3

If a flash swap for a specific pool fails, the next in order will be tried.

The default order is dai-v3, eth-v2, usdc-v3, eth-v3.

Flash Swaps in Action

Below is a log output from an auction-keeper started with the --flash-swap and --flash-swap-pools usdc-v3,dai-v3,eth-v2,eth-v3 flags.

First, the auction-keeper finds two undercollateralized SAFEs and successfully calls liquidateAndSettleSAFE using the usdc-v3 flash proxy. The second SAFE is a large one so the call fails due to lack of liquidity in the RAI/USDC Uniswap v3 pool. The auction-keeper then successfully uses the RAI/DAI Uniswap v3 flash-proxy to liquidate the large SAFE.

Finally, the auction-keeper finds a third ciritcal SAFE and successfully uses the RAI/USDC Uniswap v3 flash proxy to liquidateAndSettleSAFE.

2021-08-26 14:25:18,258 INFO     Keeper connected to RPC connection http://172.31.46.114:8545
2021-08-26 14:25:18,259 INFO     Keeper operating as 0xdD1693BD8E306eCfDbe41D246562fc4109f871f8
2021-08-26 14:25:18,289 INFO     Executing keeper startup logic
2021-08-26 14:25:19,375 INFO     Keeper will not settle auctions
2021-08-26 14:25:19,375 INFO     Keeper will perform the following operation(s) in parallel:
2021-08-26 14:25:19,375 INFO     --> Check all safes and start new auctions if any critical safes need to be liquidated
2021-08-26 14:25:19,375 INFO     --> Check all auctions being monitored and evaluate bidding opportunity every 4.0 seconds
2021-08-26 14:25:19,375 INFO     *** When Keeper is settling/bidding, the initial evaluation of auctions will likely take > 45 minutes without setting a lower boundary via '--min-auction' ***
2021-08-26 14:25:19,375 INFO     *** When Keeper is starting auctions, initializing safe history may take > 30 minutes without using Graph via `--graph-endpoints` ***
2021-08-26 14:25:19,378 INFO     Keeper will use Node gas price (currently 2.0 Gwei, changes over time) with initial multiplier 1.0 and will multiply by 1.125 every 42s to a maximum of 2000.0 Gwei for transactions and bids unless model instructs otherwise
2021-08-26 14:25:19,658 INFO     Watching for new blocks
2021-08-26 14:25:19,664 INFO     Started 2 timer(s)
2021-08-26 14:25:20,750 INFO     Getting safe mods from https://api.thegraph.com/subgraphs/name/reflexer-labs/rai-kovan
2021-08-26 14:25:20,752 INFO     Fetching safe modes from https://api.thegraph.com/subgraphs/name/reflexer-labs/rai-kovan
2021-08-26 14:25:42,418 INFO     Using usdc-v3 flash swap to liquidate and settle safe 0xA0be17B5C408aaFF03e0E3434de199F6df94fFC7
2021-08-26 14:25:42,946 INFO     Sent transaction GebETHKeeperFlashProxy('0x8a8970c74Ca60c954b32D1015D4563908eB798Fd').liquidateAndSettleSAFE('0xA0be17B5C408aaFF03e0E3434de199F6df94fFC7') with nonce=4964, gas=2000000, gas_price=2000000000 (tx_hash=0xdf19ae2f76def32a3c797ef51b614ddf6b680ad38ecbe3910b154a4c4228eb0f)
2021-08-26 14:25:44,423 INFO     Transaction GebETHKeeperFlashProxy('0x8a8970c74Ca60c954b32D1015D4563908eB798Fd').liquidateAndSettleSAFE('0xA0be17B5C408aaFF03e0E3434de199F6df94fFC7') was successful (tx_hash=0xdf19ae2f76def32a3c797ef51b614ddf6b680ad38ecbe3910b154a4c4228eb0f)
2021-08-26 14:25:44,519 INFO     Using usdc-v3 flash swap to liquidate and settle safe 0xa46B5d01326d858856396fb80bD06654ED64770f
2021-08-26 14:25:44,820 WARNING  Transaction GebETHKeeperFlashProxy('0x8a8970c74Ca60c954b32D1015D4563908eB798Fd').liquidateAndSettleSAFE('0xa46B5d01326d858856396fb80bD06654ED64770f') will fail, refusing to send (execution reverted: failed bidding)
2021-08-26 14:25:44,821 WARNING  flash swap liquidate and settle with pool usdc-v3 failed.
2021-08-26 14:25:44,821 INFO     Using dai-v3 flash swap to liquidate and settle safe 0xa46B5d01326d858856396fb80bD06654ED64770f
2021-08-26 14:25:45,223 INFO     Sent transaction GebETHKeeperFlashProxy('0x26232B7Fe0dD0Ade6192Bd69438dBEc424EF7a59').liquidateAndSettleSAFE('0xa46B5d01326d858856396fb80bD06654ED64770f') with nonce=4965, gas=2000000, gas_price=2000000000 (tx_hash=0xb4c177c114874ee267a8e2d47a3bd075936372996eeebbf3caf1decb881f2737)
2021-08-26 14:25:52,724 INFO     Transaction GebETHKeeperFlashProxy('0x26232B7Fe0dD0Ade6192Bd69438dBEc424EF7a59').liquidateAndSettleSAFE('0xa46B5d01326d858856396fb80bD06654ED64770f') was successful (tx_hash=0xb4c177c114874ee267a8e2d47a3bd075936372996eeebbf3caf1decb881f2737)
2021-08-26 14:25:53,171 INFO     Using usdc-v3 flash swap to liquidate and settle safe 0x20aE373C782b03925413a394EE620A4BF2828a60
2021-08-26 14:25:53,744 INFO     Sent transaction GebETHKeeperFlashProxy('0x8a8970c74Ca60c954b32D1015D4563908eB798Fd').liquidateAndSettleSAFE('0x20aE373C782b03925413a394EE620A4BF2828a60') with nonce=4966, gas=2000000, gas_price=2000000000 (tx_hash=0xf4d45385753219c5a9a7fb28f7d60e0e4b4d42eb05d8d65f50deb09308cfd1ba)
2021-08-26 14:25:56,851 INFO     Transaction GebETHKeeperFlashProxy('0x8a8970c74Ca60c954b32D1015D4563908eB798Fd').liquidateAndSettleSAFE('0x20aE373C782b03925413a394EE620A4BF2828a60') was successful (tx_hash=0xf4d45385753219c5a9a7fb28f7d60e0e4b4d42eb05d8d65f50deb09308cfd1ba)

Caveats

  • Flash swaps are only supported for collateral auctions.

Possible errors

auction-keeper will not do flash swaps on critical SAFEs with saviours. Read more about saviours .

When liquidity is too low, calls to flash proxys will revert or run out of gas. In this case, the auction-keeper will try to use the next Uniswap pool specified in --flash-swap-pools. In the unlikely case where all calls fail (none of the pools have enough liquidity), the auction-keeper can be restarted without --flash-swap to bid normally using the keeper’s system coin balance inside the .

auction-keeper
geb-keeper-flash-proxy
RAI/DAI Uniswap V3
RAI/ETH Uniswap V2
RAI/USDC Uniswap V3
RAI/ETH Uniswap V3
here
SAFEEngine