Inspiration
This is my first foray into the blockchain technology space, and I wanted a short term, well-scoped project as an excuse to learn more about chainlink, ethereum, and smart contracts. As I was watching the introduction videos of the virtual hackathon, I heard the representative from DODO talk about their sponsor bounty for a twitter bot that live-tweets price advantages for the DODO exchange. I thought this sounded like a perfect project to learn about interfacing with smart contract price feeds. But I also wanted to expand the project to something more than just a twitter bot -- I wanted to collect the historical price data from the different exchanges and tabulate some of the statistics of the price differences. So I looked into implementing an analysis dashboard using streamlit to construct an interactive historical price edge data app. As a bonus, I wanted the price data to be backed up regularly to a decentralized file server, so I implemented one using IPFS, and addressed the content to a constant name using its IPNS feature.
What it does
The PETA-Bot has 4 main components:
- Twitter Bot
- Analysis Dashboard
- Price Query Data API
- Data Storage Interface to IPFS
All 4 components rely on accumulating data from the Price Query Data API. This component uses python Web3.py to query smart contracts on the mainnet from chainlink and DODO. This data is then sent to two places (i) the twitter bot, and (ii), the data storage interface. If DODO has a price edge compared with chainlink for the particular currency pair, then the twitter bot will live-tweet the price advantage percentage, along with the raw prices from the two sources. The data storage interface receives the price query data regardless of which exchange has a price advantage. The data storage interface then pulls up a database using the python pandas library and appends the new data row to the dataframe. This updated dataframe is then pushed to a local csv file. Then, periodically, the set of local csv files containing historical price data is pushed to the decentralized IPFS under a common IPNS name. The analysis dashboard is an interactive tool used to check current and past price edge data. It was built using the python streamlit framework, and provides an interactive view of the distribution of price advantage data.
How we built it
Used Tweepy library for interfacing with twitter API. Used Streamlit for building the analysis dashboard. Used Web3.py, along with an infura account to query the price data using price feeds from chainlink and midprice quote data from the DODO mainnet smart contracts. As a backend, used IPFS to store the price history data.
Challenges we ran into
Got initial twitter developer account locked due to violating twitter rules (although they never told me which rules I violated... :)
I assume it had to do with how often my twitter bot was tweeting. I adjusted this rate as an input to the twitter bot python function, but have yet to hear back from twitter support.
When I first wanted to store files on the IPFS, I ran into the issue that files are addressed by their hash, which necessarily changes if the file is updated. But looking more into the IPFS website, I found their solution to this problem using IPNS - which ties a changeable file hash to a constant name address hash. That way, whenever the local files need to be backed up on IPFS, I can run the command to link the new file hash to the constant IPNS name hash.
Accomplishments that we're proud of
Iām glad to have been able to incorporate web3 smart contract querying, IPFS data storage, and the streamlit framework.
What we learned
I learned how to call smart contracts using web3, in particular the web3.py library. I also figured out how to interface with IPFS, how to add directories, and how to update the directory but keep the same name hash using IPNS. Finally, I got experience with making a twitter bot, the twitter api, and with building analysis dashboards using streamlit.
What's next for PETA-Bot
The principle can be extended to other exchanges beyond just Chainlink and DODO, as long as the other exchanges have price feeds accessible through a smart contract. The analysis tool could help with finding arbitrage opportunities among these exchanges.

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