Sitemap
Coinmonks

Coinmonks is a non-profit Crypto Educational Publication. Other Project — https://coincodecap.com/ & Email — gaurav@coincodecap.com

Member-only story

Aave V2 Liquidation Example

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

3 min readOct 23, 2022

--

Press enter or click to view image in full size
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.

--

--

yuichiro aoki
yuichiro aoki

Written by yuichiro aoki

Ethereum Enthusiast & Software Developer

Coinmonks
Coinmonks

Published in Coinmonks

Coinmonks is a non-profit Crypto Educational Publication. Other Project — https://coincodecap.com/ & Email — gaurav@coincodecap.com