This repo contains smart contracts, mocks and a test suite showcasing how to automate the execution (or casting) of auto liquidations in MakerDAO Vaults using InstaDapp DSAs and Gelato. The condition/recipe can be easily transformed and adapted to use other user proxy wallets (e.g DSProxy). There's also an UI provided to simulate the execution (Only ETH simulated in UI atm).
- Install deps:
npm install
- Set
ALCHEMY_API_KEY
in.env
file. - Compile SC:
npm run compile
- Generate types of already deployed contracts used:
npm run typechain:deployed
npm run test
- [extra] -
npm run test:gas
(executes a mock to get an overview of gas usage)
To run the app smoothly a hardhat node must be running, using mainnet forking.
- Run the node:
npm run mainnet:fork https://eth-mainnet.alchemyapi.io/v2/<ALCHEMY_API_KEY>
- With the node running deploy the condition and connectors:
npm run deploy:connectorsAndCondition
Then:
- Navigate to the app folder:
cd app
- Install deps:
npm install
- Build the app:
npm run build
- Start the app:
npm run start
Trouble shooting: If you are having trouble sending txs to the node, check the the node logs, it may be complaining about nonces. You may need to override the nonce on MetaMask.
The motto is very simple. We provide a task to Gelato via DSA to auto liquidate the position if the underlined condition is met. Flash loans are used to automate the process, Uniswap is used to exchange tokens and the fees are paid with the collateralized token. There's no need of pre-payment with ETH or any other token, fees will be paid at execution with the collateralized token.
In this flow are used several existent DSA connectors and are introduced new ones, such as ConnectorAutoLiquidation and ConditionMakerVaultUnsafe (originally taken from here). See graph of both below.