Smart contracts and a Next.js front end for an Alchemix V2 self-repaying loan
helper. The Extender contract deposits collateral into Alchemix V2, mints
debt against the depositor's account, swaps the debt token for the underlying
on Curve, and forwards the proceeds to a chosen beneficiary.
⚠️ Unaudited, experimental software. Use at your own risk. This code moves real funds in DeFi protocols, has not been audited, and may contain bugs that result in total loss of funds. Do not use it with money you cannot afford to lose. No warranty of any kind is provided.
- Deposits DAI in Alchemix V2
- Mints alUSD from Alchemix V2
- Swaps alUSD for DAI on Curve
- Transfers DAI to a selected beneficiary
contracts/— Hardhat project with theExtendercontract, interfaces, tests and scripts.frontend/— Next.js dApp front end.
- Node.js 16+
- An Alchemy (or other archive RPC) API key for mainnet forking
Alchemix V2 only allows whitelisted contracts (regular EOAs are allowed) to interact with their contracts. For local development you must run against a mainnet fork and whitelist the deployed contract in the Alchemix whitelist.
cd contracts
npm install
cp .env.example .env # fill in ALCHEMY_API_KEY, DEPLOYER_MNEMONIC, etc.
npx hardhat compile
npx hardhat test # runs against a mainnet fork- Install the contract dependencies (
cd contracts && npm install). - Create the
.envfile from.env.exampleand fill in the variables (RPC key, deployer mnemonic, etc.). - Start a local forked node:
(see mainnet forking)
npx hardhat node
- Deploy the contract to localhost:
npx hardhat run scripts/deploy.js --network localhost
- Run
scripts/setup-for-front.json localhost to set the whitelist and other setup. - Configure the front end: in
frontend/, copy.env.sampleto.env.localand set the deployed contract address and RPC values. - Start the front end:
cd frontend npm install npm run dev - Open the app and enjoy :)
MIT — see SPDX headers in the source files.