The-Wary-One / self-repaying-ens

A dapp that use a Alchemix's user account to automatically renew ENS names

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Self Repaying ENS

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.

🌍 Overview

The Self Repaying ENS is a smart contract written in Solidity that uses:

🧐 How to use

⚠ Prerequisites:

  • Register a ENS name
  • Deposit enough funds to the alETH AlchemistV2 contract to cover renewals fees

To subscribe to the Self Repayins ENS renewal service for a name:

  1. Allow the SelfRepayingENS contract to mint enough alETH debt to cover multiple renewals by calling alchemistV2.approveMint().
  2. Subscribe to the SRENS service for a name by calling srens.subscribe(<name>). Use the multicall 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 calling srens.checker(). You can get your taskId by calling srens.getTaskId(<your address>)
  • SRENS tries to get the lower renewal price by limiting the allowed gasprice. You can get the maximum gasprice limit for a name by calling srens.getVariableMaxGasPrice(<name>). For more information on the gasprice limit formula, checkout the srens._getVariableMaxGasPrice() comments
  • Once srens.checker() returns true for a name, Gelato tells SRENS to renew it by calling srens.renew()
  • To renew it, SRENS mint enough alETH debt to pay for the renewal and Gelato fees in ETH by calling SelfRepayingETH.borrowSelfRepayingETHFrom(<your address>, <amount>) then it calls ETHRegistrarController.renew()

To unsubscribe to the Self Repaying ENS renewal service for a name:

  1. unsubscribe to the SRENS service for a name by calling srens.unsubscribe(<name>). Use the multicall feature to subscribe or unsubscribe for multiple names

Voila ! 🥳 That’s it for the user actions.

🚚 How to install

⚠ Prerequisites:

Clone this repository and install the dependencies

git clone git@github.com:The-Wary-One/self-repaying-ens.git
mkdir self-repaying-ens
forge install

👷 How to test

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

🏃 How to run locally

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. 🥳

About

A dapp that use a Alchemix's user account to automatically renew ENS names

License:The Unlicense


Languages

Language:Solidity 87.8%Language:Shell 12.2%