Collateral Auction Flash Swaps
Lightning fast bidding in collateral auctions
Overview
Normally, the collateral auction-keeper 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 geb-keeper-flash-proxy 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:
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.
Caveats
Flash swaps are only supported for collateral auctions.
auction-keeper will not do flash swaps on critical SAFEs with saviours. Read more about saviours here.
Possible errors
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 SAFEEngine.
Last updated