Aave V2 Liquidation Example

Example code for a liquidation strategy on Aave V2 Ethereum Mainnet using foundry

yuichiro aoki
Coinmonks
Published in
3 min readOct 23, 2022

--

Liquidation Contract

The tutorial repo is here.

Foundry

Foundry is a smart contract development tool like Hardhat, Truffle, etc. It’s known for fast compilation/testing time and probably because it’s written in Rust while Hardhat is in Typescript. Also, with foundry you write tests with solidity, so maybe foundry will become a go-to dev tool for new developers just because you only have to learn solidity.

Aave V2 Liquidation

Basically, when someone’s borrowing asset market value exceeds a certain threshold of their collateral market value, you can get their collateral assets with a fixed discount if you repay their borrowing assets. This kind of liquidation opportunity happens right after a price oracle updates.

For Aave, when someone’s health factor goes below 1, you can a liquidation call. Now Aave has V3, but not on the Ethereum Mainnet. You can find many liquidation transactions on EigenPhi website. Usually, there are fewer liquidation opportunities than arbitrage or sandwich ones because it needs relatively huge price volatility and lending protocols warn users not to liquidate their positions on web UI.

--

--