Inspiration

A stable coin that includes in its peg the value of the fiat coin plus inflation on a given period of time does not exist right now. This coin would protect investor against inflation giving at the same time benefit of stability. in order to achieve this kind of coin an oracle that reports actual accumulated inflation since a given moment is needed. And this is the objective for this hackathon: to build an oracle that informs smart contracts accumulated inflation of dollar since a given date.

What it does

The oracle given a date in past, returns accumulated inflation of dollar since that date.

How we built it

We took advantage of chainlinks "any apy". Consulted the api data.nasdaq.com. The smart contract was deployed on kovan. An external adapter was build that consolidate the array that returns nasdaq.

Challenges we ran into

Previous api tried did not worked in my hands. Some Node/ jobs published Get > Uint256 were not functional, and this was tricky to understand (thanks ljonas from Translucent) . The external adapter was neither easy for me as i m not proficient in javascript, but finally succeded in local and docker

Accomplishments that we're proud of

Being able to have a working smart contract in kovan that reports inflation of last month. An external adapter that recovers internal array of the response of the api and calculates accumulated inflation since a given data was built and works in lcoal and in docker. (Heroku upload does not finish to be functional so it could not be incorporated on contract shown) This particular line from the external adapter capture the internal array and consolidate the accumulated inflation (index.js 55): reply = response.data.dataset_data.data.map(x => x[1]).reduce( (p, c) => p *(1+ c/100/12), 1).

What we learned

Improved remix, hardhat, solidity, javascrpt. Learn to build an oracle with any api from Chainlink, Learned to build an external adapter. Learn a lot working alone Learn to ask for help in discord. Began to learn other technologies through hackaton videos that i have not implemented yet (foundry, moralis, etc) First time i make a video and upload it to youtube. It is longer than what you ask, please bypass the part where I compile the contract.

What's next for Oracle for an historical stable coin.

To finish debugging the external adapter in heroku . To build a coin similar to cUSD in Celo network, using this oracle as a peg (or a similar one as Chainlink is not yet available in Celo)

Built With

Share this project:

Updates

posted an update

Manage to debug the external adapter on Heroku now works!

curl --silent -X POST -H "content-type:application/json" "https://evening-forest-80004.herokuapp.com" --data '{"id": 0, "data": { "start_date": "2005-01-01"}}' | jq -r .result 1.480891171443743

curl --silent -X POST -H "content-type:application/json" "https://evening-forest-80004.herokuapp.com" --data '{"id": 0, "data": { "start_date": "2000-01-01"}}' | jq -r .result 1.6818745805741342

Changing the start_date returns the accumulated us dollar inflation since then

Log in or sign up for Devpost to join the conversation.