The State of Aave V3 Liquidations in Optimism
1. Introduction
Most of this analysis was forked by this dashboard by modifying the query to Optimism chain. Insights are being made by cross-chain analysis.
1.1. Brief Overview of Optimism
Optimism is a Layer 2 scaling solution for Ethereum that aims to enhance the speed and reduce the cost of transactions on the network. It utilizes a technology called Optimistic Rollups, which allows for faster transaction processing by bundling multiple transactions together and submitting them to the Ethereum blockchain as a single transaction. This approach not only improves scalability but also maintains the security of the Ethereum network.
1.2. Brief Importance of lending protocols in DeFi
Lending protocols on Optimism play a vital role in enhancing the platform's liquidity and providing users with borrowing options. They contribute to the growth of the decentralized finance (DeFi) ecosystem by offering competitive incentives and facilitating transactions.
2.4. Liquidation mechanism
2.4.1. Liquidation thresholds
The liquidation threshold is when the user has a health factor below 1. The health factor is calculated on the Pool contracts by considering the all user supply and borrow amount. Officially, there is one Pool contract per chain and version of the Aave protocol.
To calculate the health index is calculated by getting the user's total collateral balance (in ETH) multiplied by the liquidation threshold percentage for all the user's outstanding assets, divided by the user's total borrow balance across all reserves (in ETH). This means that the tokens that you borrow and supply your health index impact your health index.
2.4.2. Liquidation interface
The liquidation interface happens on the Pool contract or L2Pool if the liquidation is being made on layer two. The two interfaces are a bit different.
The interface for liquidations on the Pool contract is defined below. The collateral and debt addresses represent what token will be liquidated and what token will used for it. The liquidator must have the debtToCover amount to perform the liquidation (or use a flash loan). It is possible to use debtToCover equal to uint(-1) to liquidate as much as possible.
function liquidationCall(address collateral, address debt, address user, uint256 debtToCover, bool receiveAToken)
For the liquidation on the L2Pool the interface requires the same inputs but encoded into two bytes32 arguments. Check this document for more details.
function liquidationCall(bytes32 args1, bytes32 args2) external
2.4.3. Liquidation incentives
If the health index of the user falls below 1, half of the user's position can be liquidated. If it falls below 0.95, all of its positions can be liquidated.
On the liquidation, the tokens are sold at a discount. This discount is different for each token and is defined by Aave governance.
4.4. Liquidators examples
- dkirsche/aave-liquidator: TS liquidation bot integrated on Aave V2 that checks unhealthy positions using subgraph to be monitored. Also, this reference includes Solidity smart contracts to perform liquidations using flash loans.
- yuichiroaoki/aaveV2-liquidation-example: Set of smart contracts to facilitate liquidations using Balancer Vault flash loans and using Uniswap V3 for swaps.
- ialberquilla/aave-liquidation: Simple Aave liquidation JS call reference. It uses user funds to perform the liquidation and doesn't make any swap.
- aave/aave-sandbox: Setup environment to replicate Aave markets in a forked network to facilitate liquidation bots tests.
4.3 Liquidation liquidity
To pay the debt on the liquidation, there are two main options:
- Use self-funds;
- Request a flash loan and repay on the same block.
The usage of flash loans is possible due to the liquidation discount of the token and the liquidation interface being completely on chain and atomic. In addition, Uniswap V3 implemented an interface where users could add a callback data on their swap to be executed by the msg.sender after receiving the buy amount and after paying the swap. Some liquidator bots are using this for liquidation since you can use the swap buy amount to pay the debt and then use the liquidated tokens to pay the swap.
Comparing the flash loans on Optimism and Ethereum is possible to see that Uniswap v3 and Balancer v2 were the most used flash loan platforms. On Ethereum there are significantly more bots were the flash loan wasn't detected.
Note: Maybe there are flash loans that weren't detected or misclassified since we had to create a set of rules to classify them. For more details read the query.
4. Liquidation Technical Considerations
4.1. Liquidation MEV
In a competitive market, multiple bots will monitor the positions near the liquidation threshold to liquidate them as soon as possible. If the position is big enough, multiple bots will try to liquidated on the first block that is possible, and bribe the block builder with a big priority gas fee and ethereum transfers. Usually, this cost is the biggest on chain fee to perform a liquidation.
Bellow, you can check that the fee paid to the block builder increases with the liquidation value on Ethereum. On Optimism this pattern isn't so clear.
Note: All axis in both plots are in log scale.
4.2. Liquidators and builders' relationship
Both plots on the side represent how the number of liquidations and their value are distributed among the miners on the top 10 liquidators of Ethereum. To make the data easier to interpret, we removed all miners where their contribution to the liquidator was below 1% in value.
In both plots, it is possible to see that some liquidators had a strong relationship with one miner. This might represent a way to workaround the fee MEV issue represented above.
3.4. Liquidation in time
Looking at all-time liquidations, is possible to see that they already happened more liquidations on Optimism but they are smaller in value since the total liquidated value on Ethereum is significantly bigger.
Looking into last year's liquidations, it is possible to see that liquidation count and value follow a similar pattern on both chains. This happens because, on each market crash, a large amount of positions can be liquidated.
2.2 Tokens and their roles
On Ethereum, the most deposited token is DAI - it makes up over 70% of all deposits. However, on Optimism, the WETH is the most popular token for deposits and its share is smaller. The top three tokens on Optimism add up to more than 70% of all deposits. For borrowing, the most popular token is the same on both Ethereum and Optimism. BNB is the second most borrowed token on Optimism, but it's not available on Ethereum.
3.3. Liquidators competition
It is possible a similar distribution of the liquidators who won the liquidation on both chains. This is indicative that both chains have a highly competitive liquidation market.
2. Overview
2.1. Aave V3 introduction
Aave differentiates itself through uncollateralized flash loans, interest rate switching between stable and variable, multi-asset collateral support, and credit delegation for undercollateralized borrowing. The protocol employs dynamic risk parameters, utilizes a decentralized governance model via AAVE tokens, and implements liquidity mining incentives to optimize capital efficiency and user participation.
Comparing the Optimism total market size with Ethereum it is possible to see that it is significantly smaller and the ratio between the indicators is similar.
3.2 Tokens involved
Comparing the tokens involved in the liquidations of Ethereum and Optimism is possible to observe some similarities.
First, the top debt and collateral tokens types are the same. For collateral, the non-stable tokens (WETH, WBTC, WBNB, etc) are the ones more involved in liquidations. However, for the debt tokens, the USD stable tokens are on the top.
Also, the distributions have similarities in the percentage of the top tokens. For the collateral and debt, both chains have the top 1 with nearly 50% and the top 2 with more than 20%.
3. Liquidation data
3.1. Liquidation market
Unlike the market size analysis, in which Optimism was just 1 percent of Ethereum's size, there are weeks in which the liquidation number and debt amount on Optimism are similar or larger.
3.5 Liquidation Log
For analysis and monitoring reasons, you can check the tables on the side for the latest liquidations on both chains.
For performance reasons, just the last month of liquidations is being queried.