Giter Club home page Giter Club logo

synthweetix-trades's Introduction

Synthweetix - Twitter Bot for Synthetix High Roller Trades

This project is a submission to the Open DeFi Hackathon.

Challenge description

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!

Solution

Data collection

Trades

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.

Cross-asset Swaps on Curve

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.

Short positions

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.

Twitter bot

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

trade cross-asset swap

Deployment

Configuration

Environment variables

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

Heroku

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

Docker

Dockerfile has been included for deployment using Docker

synthweetix-trades's People

Contributors

pimoens avatar

Stargazers

KIM SEUNGWOO avatar

Watchers

 avatar

Forkers

ripples3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.