GithubHelp home page GithubHelp logo

isabella232 / uniswap-price-feed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from makerdao/uniswap-price-feed

0.0 0.0 0.0 35 KB

License: GNU Affero General Public License v3.0

Shell 10.54% Python 89.46%

uniswap-price-feed's Introduction

uniswap-price-feed

This repository contains a standalone service for publishing Uniswap prices over Websockets.

Rationale

This service facilitates distribution of real-time Uniswap prices to keeper bots from the market-maker-keeper https://github.com/makerdao/market-maker-keeper repository. Prices are retrieved from chain every second. The average of last 60 prices are reported to subscribed clients.

Installation

This project uses Python 3.6.6 and requires virtualenv to be installed.

In order to clone the project and install required third-party packages please execute:

git clone https://github.com/makerdao/uniswap-price-feed.git
cd uniswap-price-feed
git submodule update --init --recursive
./install.sh

Running

usage: uniswap-price-feed [-h] [--rpc-host RPC_HOST] [--rpc-port RPC_PORT]
                          [--rpc-timeout RPC_TIMEOUT]
                          [--http-address HTTP_ADDRESS]
                          [--http-port HTTP_PORT]
                          [--base-exchange-address BASE_EXCHANGE_ADDRESS]
                          [--base-token-symbol BASE_TOKEN_SYMBOL]
                          [--base-token-address BASE_TOKEN_ADDRESS]
                          --quote-exchange-address QUOTE_EXCHANGE_ADDRESS
                          --quote-token-symbol QUOTE_TOKEN_SYMBOL
                          --quote-token-address QUOTE_TOKEN_ADDRESS
                          [--report-time REPORT_TIME]
                          [--ro-account RO_ACCOUNT]

optional arguments:
  -h, --help            show this help message and exit
  --rpc-host RPC_HOST   JSON-RPC host (default: `localhost')
  --rpc-port RPC_PORT   JSON-RPC port (default: `8545')
  --rpc-timeout RPC_TIMEOUT
                        JSON-RPC timeout (in seconds, default: 10)
  --http-address HTTP_ADDRESS
                        Address of the Uniswap Price Feed
  --http-port HTTP_PORT
                        Port of the Uniswap Price Feed
  --base-exchange-address BASE_EXCHANGE_ADDRESS
                        Address of the Uniswap Exchange
  --base-token-symbol BASE_TOKEN_SYMBOL
                        Token symbol
  --base-token-address BASE_TOKEN_ADDRESS
                        Token address
  --quote-exchange-address QUOTE_EXCHANGE_ADDRESS
                        Address of the Quote Uniswap Exchange
  --quote-token-symbol QUOTE_TOKEN_SYMBOL
                        Quote Token symbol
  --quote-token-address QUOTE_TOKEN_ADDRESS
                        Quote Token address
  --report-time REPORT_TIME
                        Time interval to report price
  --ro-account RO_ACCOUNT
                        Credentials of the read-only user (format:
                        username:password)

Sample scripts

  • ETH-DAI price feed (e.g. pass --price-feed command line argument to keeper bot as ws://user:readonly@localhost:7777/price/ETH-DAI/socket)
bin/uniswap-price-feed \
    --quote-exchange-address 0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14 \
    --quote-token-symbol DAI \
    --quote-token-address 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359 \
    --ro-account user:readonly
  • MKR-DAI price feed (e.g. pass --price-feed command line argument to keeper bot as ws://user:readonly@localhost:7778/price/MKR-DAI/socket):
bin/uniswap-price-feed \
    --base-exchange-address 0x2C4Bd064b998838076fa341A83d007FC2FA50957 \
    --base-token-symbol MKR \
    --base-token-address 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2 \
    --quote-exchange-address 0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14 \
    --quote-token-symbol DAI \
    --quote-token-address 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359 \
    --ro-account user:readonly \
    --http-port 7778 \
    --report-time 2

API

The primary and only entity this service operates on is feed. Each feed is effectively a stream of timestamped records. Timestamps never go back and it is always guaranteed that new records will be added 'after' the existing ones. This simplification makes feed streams consumption much easier for clients.

Each record is represented throughout the service as a JSON structure with two fields: timestamp and data. The first one is a UNIX epoch timestamp represented as a number (either integer or floating-point). The latter can be basically anything. Sample record may look as follows:

{
    "data": {
        "price": 173.03457395327663
    },
    "timestamp": 1571747588
}

All endpoints require and support only HTTP Basic authentication. Only one type of credentials is supported at the moment: (--ro-account) gives read-only access to the feeds.

ws://<service-location>/price/<feed-name>/socket

Opens a new socket subscription to a feed. Each new subscriber will immediately receive the last record from the feed, and will be promptly sent any new records posted by producer(s). Subscribers can assume that timestamps of records received over the WebSocket will always increase.

This is a receive-only WebSocket. Any messages sent by consumers to the service will be ignored.

uniswap-price-feed's People

Contributors

grandizzy avatar

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.