Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuichiroaoki/aavev2-liquidation-example
Aave V2 Liquidation Example on Ethereum Mainnet
https://github.com/yuichiroaoki/aavev2-liquidation-example
blockchain cryptocurrency ethereum flashloan foundry liquidation mev solidity
Last synced: 2 months ago
JSON representation
Aave V2 Liquidation Example on Ethereum Mainnet
- Host: GitHub
- URL: https://github.com/yuichiroaoki/aavev2-liquidation-example
- Owner: yuichiroaoki
- Created: 2022-10-23T05:59:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-23T10:50:59.000Z (about 2 years ago)
- Last Synced: 2023-03-03T22:44:05.685Z (almost 2 years ago)
- Topics: blockchain, cryptocurrency, ethereum, flashloan, foundry, liquidation, mev, solidity
- Language: Solidity
- Homepage: https://yuichiroaoki.medium.com/aave-v2-liquidation-example-162de8436ff5
- Size: 11.7 KB
- Stars: 15
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Aave V2 Liquidation Example
This repo demostrates how a liquidation strategy works on Aave V2 Ethereum Mainnet using foundry.
## Installation and Setup
### 1. Install [foundry](https://book.getfoundry.sh/getting-started/installation), if you haven't already.
### 2. Clone This Repo
Run the following command.
```console
git clone https://github.com/yuichiroaoki/aaveV2-liquidation-example.git
```## Demo
### 1. Get Ethereum Mainnet RPC URL
You can get one from [Alchemy website](https://alchemy.com/?r=33851811-6ecf-40c3-a36d-d0452dda8634) for free.### 2. Compile Smart Contracts
Run the following command.
```console
forge build
```### 3. Execute a Liquidation Call 🔥
Replace `` with the Ethereum Mainnet RPC URL you get from step 1 and run the following command. This will run test/Liquidation.t.sol, a test contract for src/Liquidation.sol on the Ethereum Mainnet fork network on your local machine.
```bash
forge test -vv --fork-url --fork-block-number 15780157 --mp test/Liquidation.t.sol
```Expected Outputs
```
Running 4 tests for test/Liquidation.t.sol:LiquidationTest
[PASS] testCollateralAsset() (gas: 10099)
[PASS] testDebtBalance() (gas: 10061)
[PASS] testFlashloan() (gas: 727761)
Logs:
Earned 25916384485813682 MKR[PASS] testHealthFactor() (gas: 157336)
Logs:
health factor 999477489095341547Test result: ok. 4 passed; 0 failed; finished in 6.29ms
```## References
[AaveV2 Docs](https://docs.aave.com/developers/v/2.0/guides/liquidations) / [GitHub](https://github.com/aave/protocol-v2)
### Transaction Details
- https://etherscan.io/tx/0x6e808425bffd8aa53c9cb190251907d494fc6883ea32062d9cc80434a0b1cd84
- https://eigenphi.io/ethereum/liquidation/tx/0x6e808425bffd8aa53c9cb190251907d494fc6883ea32062d9cc80434a0b1cd84
- https://phalcon.blocksec.com/tx/eth/0x6e808425bffd8aa53c9cb190251907d494fc6883ea32062d9cc80434a0b1cd84