This repo demostrates how a liquidation strategy works on Aave V2 Ethereum Mainnet using foundry.
1. Install foundry, if you haven't already.
Run the following command.
git clone https://github.com/yuichiroaoki/aaveV2-liquidation-example.git
You can get one from Alchemy website for free.
Run the following command.
forge build
Replace <your alchemy rpc url>
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.
forge test -vv --fork-url <your alchemy rpc 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 999477489095341547
Test result: ok. 4 passed; 0 failed; finished in 6.29ms
- https://etherscan.io/tx/0x6e808425bffd8aa53c9cb190251907d494fc6883ea32062d9cc80434a0b1cd84
- https://eigenphi.io/ethereum/liquidation/tx/0x6e808425bffd8aa53c9cb190251907d494fc6883ea32062d9cc80434a0b1cd84
- https://phalcon.blocksec.com/tx/eth/0x6e808425bffd8aa53c9cb190251907d494fc6883ea32062d9cc80434a0b1cd84