MIP63: Maker Keeper Network implementation for the Chainlink Automation Network.
Maintains Maker protocol by poking oracles, liquidating vaults, managing the autoline, managing D3Ms, etc.
DssCronKeeper.sol
- Executes pending jobs from the Sequencer
- Triggers upkeep refunding when needed by calling
DssVestTopUp
- Registered as upkeep
DssVestTopUp.sol
- Withdraws accumulated DAI from the Vest
- Swaps DAI for LINK via Uniswap
- Transfers swapped LINK to the upkeep balance
graph TD
A(Chainlink Automation Network) -->|calls upkeep| B(KeeperRegistry)
B -->|checks and performs upkeep| C(DssCronKeeper)
C -->|triggers refund| D(DssVestTopUp)
C -->|runs jobs| E(DssCron)
D -->|withdraws DAI| F(NetworkPaymentAdapter)
D -->|checks upkeep balance / add funds| B
D -->|swaps DAI for LINK| H(Uniswap Router)
D -->|checks price for swap|I(Chainlink Price Feeds)
Clone the repo and install all dependencies.
git clone [email protected]:hackbg/chainlink-makerdao-automation.git
cd chainlink-makerdao-automation
git submodule init
git submodule update
npm install
Copy the .env.example
to .env
file and make sure you've set all of the following.
- Hardhat development environment
Name | Description |
---|---|
RPC_URL |
URL of a node |
PRIVATE_KEY |
Controls which account Hardhat uses |
ETHERSCAN_API_KEY |
Required to verify contract code on Etherscan |
DssCronKeeper
contract
Name | Description |
---|---|
SEQUENCER |
Address of Sequencer |
NETWORK_NAME |
Short name from the Sequencer network registry |
DssVestTopUp
contract
Name | Description |
---|---|
UPKEEP_ID |
Unique identifier of the registered upkeep for DssCronKeeper |
KEEPER_REGISTRY_V2_1 |
Address of KeeperRegistry V2.1 |
DAI_TOKEN |
Address of DAI token |
LINK_TOKEN |
Address of LINK token |
NETWORK_PAYMENT_ADAPTER |
Address of NetworkPaymentAdapter for the keeper network |
DAI_USD_PRICE_FEED |
Chainlink price feed for the DAI / USD pair |
LINK_USD_PRICE_FEED |
Chainlink price feed for the LINK / USD pair |
SWAP_ROUTER_V3 |
Address of Uniswap V3 Router |
SLIPPAGE_TOLERANCE_BPS |
Price slippage tolerance in basis points. Learn more here. |
UNISWAP_PATH |
Uniswap V3 path for swapping DAI for LINK. Example: DAI, 500, WETH, 3000, LINK . Learn more here. |
- End-to-end test environment (optional)
Name | Description |
---|---|
AUTOMATION_REGISTRAR_V2_1 |
Address of Automation Registrar V2.1 contract |
EOA_WITH_LINK |
Address of the Externally Owned Account (EOA) with at least 50 LINK balance before the block specified when running the tests on a fork. |
UNISWAP_V3_FACTORY |
Uniswap V3 Factory address |
NONFUNGIBLE_POSITION_MANAGER |
Uniswap V3 Nonfungible Position Manager address |
VOW |
Address of Vow |
Note: Example contract addresses are for Ethereum mainnet.
Run unit tests on the local Hardhat network.
npm test
For end-to-end testing.
npm run test:e2e
- Run the following to deploy
DssVestCronKeeper.sol
to a network configured in Hardhat config.
npx hardhat run scripts/deploy_keeper.ts --network <network>
Note: After successful deployment, the contract must be registered as new upkeep to start performing pending jobs.
- Then deploy
DssVestTopUp.sol
by running the following.
npx hardhat run scripts/deploy_topup.ts --network <network>
- Finally, to enable auto refunding of the
DssCronKeeper
upkeep, callsetUpkeepRefunder(address)
and pass the address of the deployedDssVestTopUp
contract.