Arbitraging Chicken Bonds’ Stability Pool for Fun and Profit

Yaron Velner
B.Protocol
Published in
3 min readNov 9, 2022

The Chicken Bonds protocol integrated B.Protocol’s Backstop Automated Market Maker (B.AMM) to manage its LUSD stability pool deposits. The motivation for the integration is two-folds. First: the B.AMM increases the stability pool capital efficiency and can support higher liquidation volume over time (e.g., see here). Second: The B.AMM auto-compounds the liquidation proceeds and the LQTY rewards, and offloads these core algorithmic components from the Chicken Bonds protocol.

At its core, the auto-compounding process relies on arbitrage bots who supply LUSD in return for a discounted price ETH or LQTY.

In this post, we explain how bots could arbitrage the B.AMM, and present an open source smart contract to facilitate such an arbitrage.

Buying discounted ETH

Every liquidation in the Liquity protocol takes some LUSD from the stability pool, and gives some ETH in return. The B.AMM offers the ETH for sale, in return to LUSD. The ETH is offered with a varying discount over chainlink market price, where the discount depends on the quantity of ETH that is available for sale. The bigger the quantity is, the higher the discount. The reader can find more technical details on the discount formula here.

How to arbitrage?

B.AMM address (Ethereum mainnet):

Price query function: getSwapEthAmount(uint lusdQty)

Swap function: swap(uint lusdAmount, uint minEthReturn, address dest)

Arbitrage bot smart contract reference:

  • Deployed address: 0x12c60B3170Fb43E6A8f8ba2d843621c19324329E
  • Arbitrage function: swap(uint ethQty, address bamm)
  • ethQty: the amount of ETH to buy in the arbitrage
  • bamm: the B.AMM address that is used in the arbitrage

A potential backend implementation would be to call the swap function offchain with various sizes, and to execute a tx when it is not expected to revert. The backend can also be implemented with Gelato.

Buying discounted LQTY

For long durations, the amount of ETH liquidations is typically much bigger than the amount of LQTY yield. However, the LQTY yield stream is more continuous, and thus an arbitrage is expected to be executed multiple times per week.

The B.AMM sells the LQTY according to a 24 hours Uniswap TWAP oracle. And thus, arbitrage prices are expected whenever the 24 hours TWAP price is lower than the current LQTY price.

How to arbitrage?

LQTY seller address (Ethereum mainnet):

Price query function: getSwapGemAmount(uint lusdQty)

Swap function: swap(uint lusdAmount, uint minGemReturn, address dest)

Arbitrage bot smart contract reference:

  • Deployed address: 0xf9a0e641c98f964b1c732661fab9d5b96af28d49
  • Arbitrage function: swap(uint lqtyQty, address reserve, address lqtyDest, uint minLqtyProfit)
  • lqtyQty: the amount of LQTY to buy in the arbitrage
  • reserve: should be set to 0x4f73ad319193320ED20eeFAEFb8F30B89b05b8B6
  • lqtyDest: the arbitrage generates LQTY profit, and sends the excess LQTY to the specified address
  • minLqtyProfit: the minimum acceptable arbitrage profit

A potential backend implementation would be to call the swap function offchain with various sizes, and to execute a tx when it is not expected to revert. The backend can also be implemented with Gelato.

Tips and Tricks

The reference arbitrage bot is suboptimal in (at least) two aspects:

  1. It buys LUSD with USDT or USDC only on Curve Finance, and ignores other LUSD liquidity sources, such as Uniswap v3.
  2. It sells LQTY only to ETH, and ignores other liquidity sources, e.g., LQTY/WBTC reserves on uniswap.

Improving the above, could improve both the gas consumption and the trade profitability.

Disclaimer

The reference bot code comes with no warranty. Using the bots does not require any funds, however gas fees could be lost in the event of unsuccessful arbitrage. Users should set reasonable gas prices when using the bots.

About B.Protocol

B.Protocol is building a Backstop DeFi primitive, unlocking higher capital efficiency in the ecosystem. By democratizing liquidation systems it shifts MEV and bot profits to the hands of the community.

Lending platforms that integrate with B.Protocol democratize their liquidation system, provide a stronger safety net to their lenders, and enable higher collateral factors for its borrowers.

With B.Protocol, anyone can participate in the lucrative business of liquidations, tapping into the $1B/Year market of DeFi liquidations, on its growth path to the $100B/Year of liquidations made in CeFi.

Website, Docs, Discord, Twitter, YouTube, Reddit, Forum, GitHub

--

--