An Alchemix user can subscribe to the Self Repaying ENS service to automatically renew an expired ENS name. The renewal fee is paid by adding some self repaying debt to the user Alchemix account 🧙🪄💸. Winner project of Gitcoin’s Money Legos Hackaton 2022.
The Self Repaying ENS is a smart contract written in Solidity that uses:
- the Alchemix Protocol to manage users self repaying debt
- the Curve Protocol to exchange alETH and ETH
- the Ethereum Name System to manage the ENS names
- the Gelato Network to automate the smart contract actions
⚠ Prerequisites:
- Register a ENS name
- Deposit enough funds to the
alETH AlchemistV2
contract to cover renewals fees
- Allow the
SelfRepayingENS
contract to mint enoughalETH
debt to cover multiple renewals by callingalchemistV2.approveMint()
. - Subscribe to the
SRENS
service for a name by callingsrens.subscribe(<name>)
. Use themulticall
feature to subscribe or unsubscribe for multiple names
Voila ! 🥳 That’s it for the user actions.
This is where the automated actions start:
- Subscribing for the first time to the service creates a
Gelato
task that regularly checks if your names should be renewed by callingsrens.checker()
. You can get yourtaskId
by callingsrens.getTaskId(<your address>)
SRENS
tries to get the lower renewal price by limiting the allowedgasprice
. You can get the maximumgasprice
limit for a name by callingsrens.getVariableMaxGasPrice(<name>)
. For more information on thegasprice
limit formula, checkout thesrens._getVariableMaxGasPrice()
comments- Once
srens.checker()
returnstrue
for a name,Gelato
tellsSRENS
to renew it by callingsrens.renew()
- To renew it,
SRENS
mint enoughalETH
debt to pay for the renewal andGelato
fees inETH
by callingSelfRepayingETH.borrowSelfRepayingETHFrom(<your address>, <amount>)
then it callsETHRegistrarController.renew()
- unsubscribe to the
SRENS
service for a name by callingsrens.unsubscribe(<name>)
. Use themulticall
feature to subscribe or unsubscribe for multiple names
Voila ! 🥳 That’s it for the user actions.
⚠ Prerequisites:
Clone this repository and install the dependencies
git clone [email protected]:The-Wary-One/self-repaying-ens.git
mkdir self-repaying-ens
forge install
The tests needs to be run in a Mainnet fork. Set the environment variables with your API keys
cat .env.example > .env
vim .env
Run the tests
./test.sh
Set the environment variables with your API keys
cat .env.example > .env
vim .env
Start anvil as a Mainnet fork in a terminal
./tasks/start-fork-local.sh
Run the local setup task
./tasks/setup-env-local.sh
Now play with the app using the other tasks inside the tasks
directory. 🥳