This project is a submission to the Open DeFi Hackathon.
Build a Twitter bot that tweets when a Synthetix Protocol trade occurs over a certain value threshold.
Extra features:
- Include Cross-asset Swaps on Curve
- Include large short positions
- Insert your creative idea here!
Concerning data collection, all data is queried from TheGraph API (Synthethix Exchanges subgraph) using the gql. The query details can be found in the source code.
For Cross-asset Swaps on Curve, the data is collected from TheGraph API (Blocklytics Curve subgraph). The prices are converted to USD using cryptocompare.
The EtherScan API is used to validate that the retrieved Swaps (from the subgraph) are actual Cross-Asset Swaps. This is done by matching the retrieved hashes to the Vyper Contract.
For the Short positions, the data is collected from TheGraph API (Synthethix Shorts subgraph). The prices are converted to USD using cryptocompare and pycoingecko for sETH and sBTC.
I have opted to create a simple, well-structured Python solution using tweepy. The bot is up and running at https://twitter.com/synthweetix-trades.
It queries TheGraph every 5min (can be easily configured) to fetch all exchanges since the last pull. When the exchange value is larger than a set threshold (default is $250,000), a tweet is sent. An additional threshold is introduced to optionally send an eye catcher line with the tweet (default is $1,000,000).
Preview
Name | Description | Default |
---|---|---|
CONFIGURATION | Configuration to run (development , production or cronjob ) |
development |
TWITTER_CONSUMER_KEY | Twitter Consumer Key | '' |
TWITTER_CONSUMER_SECRET | Twitter Consumer Secret | '' |
TWITTER_ACCESS_TOKEN | Twitter OAuth Access Token | '' |
TWITTER_ACCESS_SECRET | Twitter OAuth Access Secret | '' |
ETHERSCAN_API_KEY | EtherScan API Key (used for Cross-Asset Swap validation) | '' |
TRADE_VALUE_THRESHOLD | Trade Value Threshold (in USD) | 250000 |
SHORT_POSITION_VALUE_THRESHOLD | Threshold used for Short Positions (in USD) | 100000 |
EYE_CATCHER_THRESHOLD | Threshold (in USD) used to add additional eye catcher lines | 1000000 |
Application is deployed on Heroku using a CronJob
clock: python main.py
Note: Scale up the process when deploying for the first time using the Heroki CLI
heroku ps:scale clock=1
Dockerfile has been included for deployment using Docker