Skip to content

santiellena/air-flatcoin-protocol

Repository files navigation

description
A flatcoin protocol that sets its price initially at one US dollar and then updates it daily given the daily inflation data.

Against Inflation Rate Protocol (AIR Protocol)

About

AIR protocol is a flatcoin protocol that sets its price initially at one US dollar and then updates it daily given the daily inflation data provided by Truflation (oracle working with Chainlink) and triggered by Chainlink Automation. This protocol intends to simulate the operation of MakerDao's DAI, only its peg is not fixed.

Air protocol architecture

Getting Started

Requirements:

First of all, install Make:

{% embed url="https://www.geeksforgeeks.org/how-to-install-make-on-ubuntu/" %}

Then, install Foundry:

{% embed url="https://github.com/crisgarner/awesome-foundry" %}

To use this code, you need to have installed foundry.

To check if you have it installed:

# In case you have it installed you will see the version
$ forge --version

Quickstart:

Install the necessary dependencies:

$ make install

Usage

Locally:

First of all, add anvil network to Metamask.

  1. Go to "Settings> Networks> Add a network> Add a network manually"

How to fill network data

  1. Switch to anvil network.

Now add your anvil account to Metamask:

I recommend using the following private key as account to avoid re configuring the environment:

0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

Example of adding an account

Then deploy the protocol to start interacting with it.

$ make deploy

Printed on the console you will find the following logs:

Logs example

Import the WETH contact as a token on Metamask:

Import a token example

You will immediately see you have balance because the "make deploy" command in addition to deploying the protocol, it minted some tokens for us.

Now, you need to import the AIR token to Metamask (same procedure but use the AIR Contract Address from the logs).

As we still don't have AIR tokens, we need to deposit some collateral to the engine to mint some.

Open the makefile file. There you will find the depositAndMint command. Use the logs to configure it:

Command before configuration

Execute the command:

$ make depositAndMint

Your balance on Metamask should be like this:

Metamask status after deposit and mint

Congrats! You have deployed the protocol and its testing components. Now you can start playing around with some other commands to see how the protocol behaves.

Thank you for taking the time to read and use the Anti Inflation Rate protocol!

Other commands to execute and try the protocol:

# Add collateral to your account to increase your health factor
$ make deposit 

# Mint some AIR into your account and decrease your health factor
$ make mint

# Burn some AIR to increase your health factor
$ make burn

# By asking the mock truflation contract the daily inflation
$ make increaseAirPrice

# Liquidate a user whose account has been created when the contract was deployed
$ make liquidate 

# Get your health factor account
$ make healthFactor

# Creates a second account in the protocol with a health factor of 1 (one)
# which is the limit before liquidation is available
$ make depositAndMintSecondAccount
  • Recommendation: Deposit a lot of WETH on the protocol so you can use it without breaking the health factor.

Testnet:

This option is not yet available through the command line.

Recommendations:

  • Try executing other commands to update AIR price by inflation, to liquidate a user, to mint some more tokens, etc.
  • Audit the protocol! This codebase probably has a couple of security issues I haven't find out.
  • Star the project! ⭐