Giter VIP home page Giter VIP logo

ethereum-dex-prices-service's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ethereum-dex-prices-service's Issues

Introduce new "metadata" field to the result data

Currently, all of the DEX classes return a result object to every query. It matches the following structure:

result = {
        exchangeName: String,
        totalPrice: Number | null,
        tokenAmount: Number
        tokenSymbol: String,
        avgPrice: Number | null,
        timestamp: Number,
        error: String | null,
      }

This structure doesn't always tell the full story when it comes to price and expectations. For example, the prices reported by the Bancor API are subject to slippage. That slippage isn't reflected at all anywhere in the library. While a user won't experience slippage every time they execute a trade, they should certainly be aware of the possibility. To handle these kinds of non-deterministic details, I am proposing a "metadata" field be added to the result object. This is where we can store useful details about each DEX to help users and developers make more informed decisions when analyzing price data generated from this library.

Discussion: Support of the Standard Relayer API (Contract Addresses vs. Symbols)

While skimming through the available 0x relayers to get a better idea of what exchanges may be possible to be supported, I noticed that the 0x schema for order books actually returns asks and bids in terms of the maker and taker address, not by the resolved symbol. Example:
https://github.com/0xProject/standard-relayer-api/blob/master/http/v2.md#get-v2orderbook

Are there plans to support exchanges that use the 0x SRA? This would require the ability to pass in a contract address as an alternative to a symbol. On a similar note, it raises the question of asset resolution. For example, if a user passes ABC, there currently aren't any checks to ensure that ABC actually corresponds to the same assets. Given the goal of supporting any asset on any exchange, I see a couple paths off the top of my head:

1a) For major exchanges, keep a hard-coded mapping of symbol -> contract address if it's easily identifiable (ZRX, AST, BNB, etc.)
1b) Only support exchanges that provide tokens included in the "supported assets" mapping
2) Only support exchanges that allow retrieval of order books with contract addresses

And the potential issues:

1a) This obviously has a scaling problem and also brings up issues if contracts are redeployed
1b) This limits the amount of exchanges and assets available unless they're manually maintained in 1a
2) This allows for more flexibility in the sense that I could provide any address and if it shows up in an exchange we know that it's the same asset across exchanges but it limits consumers to knowing the address for the token contract, which they may not. Similar to 1b, this limits the amount of exchanges that could be supported.

Just some things that crossed my mind while looking around. Interested to get some feedback. :)

Add support for The Ocean

The Ocean is a 0x relayer. Their API allows for retrieval of orderbook info behind unauthenticated, rate-limited endpoints: https://docs.theocean.trade/#rate-limit

A client is also provided if you want some wrapper functions for interacting with the API:
https://docs.theocean.trade/#order-book-3

Based on some of the other examples, I think these are the two endpoints that will be useful:

Server Crashing due to timeout

Frequently crashes after running for several hour with this error:
Error: WebSocket is not open: readyState 2 (CLOSING)
at WebSocket.ping (/home/jake/ethereum-dex-prices-service/node_modules/ws/lib/websocket.js:257:19)
at Timeout.interval.setInterval [as _onTimeout] (/home/jake/ethereum-dex-prices-service/exchanges/AirSwap.js:182:18)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)

Add support for EthFinex

EthFinex has a trustless API that could easily be implemented in this library https://trustless.ethfinex.com

Requirements:

  • Create an EthFinex class that inherits from the OrderBookExchange class and implements the EthFinex API correctly
  • It should be called as part of the main() routine

Add unit tests for Uniswap

To ensure the library is functioning properly, unit tests should be included for Uniswap. Since this exchange uses the token metadata provided as part of the library as well as the ethers library, we should think about creating a mock module for ethers as there would be some reusability across the Airswap and Bancor tests as well. Consideration should be given to available test tools related to the ethers library if any exist.

Add support for Uniswap

This one looks like it will be a bit more challenging since there is no HTTP API available. The docs are here for anyone who wants to give it a shot: https://docs.uniswap.io/

@conlan on Twitter is working on an HTTP API that will make it much easier.

Until then you can pull all the NewExchange events from the factory:
0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95

Or use getExchange() functions on the factory:
https://docs.uniswap.io/frontend-integration/connect-to-uniswap

or

https://github.com/Uniswap/uniswap-info/blob/master/src/constants/Uniswap.js#L4

Add support for ForkDelta

API docs: https://github.com/forkdelta/backend-replacement/tree/master/docs/api

Requirements:

  • It should extend the OrderBookExchange class
  • It should implement the _createCanonicalOrderBook order book method and return an order book matching the canonical order book schema
// canonical order book example

    const exampleBook = {
      asks: [
        { amount: '100', price: '0.005', lotAmount: '100', lotPrice: '0.5' },
        { amount: '200', price: '0.006', lotAmount: '300', lotPrice: '1.7' },
        { amount: '300', price: '0.007', lotAmount: '600', lotPrice: '3.8' },
      ],
      bids: [
        { amount: '100', price: '0.004', lotAmount: '100', lotPrice: '0.4' },
        { amount: '200', price: '0.003', lotAmount: '300', lotPrice: '1.0' },
        { amount: '300', price: '0.002', lotAmount: '600', lotPrice: '1.6' },
      ],
    }

cli.js require(main) error

Just a small bug that is probably resolved in next release.
After following the instructions form the Quickstart, the cli.js command fails.
yarn search buy 500 ETH
The issue is coming from the import in cli.js.
const { main } = require('../main')
As there is no main file, replacing with below fixed the issue.
const { main } = require('../index')

Eth2Dai closed

Eth2Dai now changed on Oasis.
New address: 0x8018280076d7fA2cAa1147e441352E8a89e1DDbe

Refactor Ethfinex class

The Ethfinex class is no longer returning price data when queried. It seems that some changes may have been made to the underlying API in the last 6-9 months. They have also rebranded to https://deversifi.com

To do:

  • Investigate API changes and refactor class to restore functionality
  • Change branding to reflect their new site "deversifi"

DEXes APIs

Hi there!,

@grahamperich my name is Elio and I am the admin of inDEX (https://github.com/distribuyed/index). inDEX is a comprehensive list of decentralized exchanges of cryptocurrencies, tokens, derivatives and futures, their protocols, and other resources.

I do not have the time neither skills to collaborate as much as I would like with your project, but if it is helpful, I can help you by indicating DEXes with API that you can use for your project.

For example, the last I found:

DEX URL API
TOKENMON https://tokenmom.com https://docs.tokenmom.com/#introduction

Thanks a lot in advance and congratulations for the project!

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.