1.0.53 • Published 5 years ago

slpdex v1.0.53

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

SLPdex

SLPdex is a standardized protocol for trading SLP (Simple Ledger Protocol) tokens on the Bitcoin Cash framework. Anyone can spin up a node (or mini-exchange) and draw from the decentralized pool of liquidity. Nodes maintain themselves by collecing fees (0% to 5%) on every order posted or signed on their site. Users never have to put a private key on an exchange, and can even sign taker transactions from an offline machine.

The properties of SLP tokens that make them good for SPV verification also, coincidentally, make them awesome for a highly liquid decentralized exchange. SLPdex uses rotating signing, similar to CoinJoin, followed by a single settlement transaction. It is the first truly liquid (one-transaction-per-trade) decentralized bitcoin-based exchange. Its development was inspired by Ethereum's 0x, but it seems SLPdex comes together a bit more easily, thanks to the bitcoin's UTXO model.

After designing an awesome protocol like SLP, providing liquidity is the next stage to launching a thriving token ecosystem. Arbitrage traders and hedge funds will only trade on platforms where they have a chance to move money quickly and make a profit. The SLPdex API is being meticulously designed by a former high-frequency arbitrage trader, so it will be compliant with the data structures already in use by other centralized exchanges.

An SLPdex backend node can improve a custodial exchange's quality by providing a gigantic, shared pool of liquidity to draw from. The more open orders you have on your exchange, the more likely a traders will want to design algorithms to profit off them.

Unless you're a high-frequency trader who needs either 1) higher rate-limits and/or 2) to be first in line for trades, there is no token or extra fees for the underlying default protocol. It is "default" because nodes are free to set parameter fees for the protocol as they wish (although their orders risk being ignored by other nodes). It is our opinion that supporting liquidity is, in general, a good thing, and that token fees outside of preventing Sybil will actively harm the overrall network.

Installation

npm install --save slpdex

Details

This library has two modes. Some features may still be in development but should be out once we have feedback from the community. Please note there's only one SLP node right now, hosted by bitcoin.com. This is a central point of failure and should be solved by fundraising to run more SLP nodes. If you're interested in helping out buy some SLP tokens at slpdex.com.

  • Trader (Client): Offline Manual trader (very high security) You can use SLPDex to sign an existing order offline, protecting your private keys. Offline signing is only supported for taker transactions. To get started, download the repo to a USB disk, transfer it to a new computer. Drag and drop the "offline.html" file from the 'manual' directory into your web browser. Paste a maker order from an existing exchange here. Online Manual trader (high security): You can use SLPDex to post maker transactions. These transactions will be available for people to fill so long as you remain online. They require you to import your private key to a website running on your local machine. To get started, download the repo. Drag and drop the 'maker.html' from the 'manual' directory into your repo. Be sure to use a Chrome Incognito Window so that browser extensions won't be able to access your private key. DNS spoofing is not a risk here. Online Automated trader (high security): You can of course use SLPDex as a normal trading api. Since there aren't any docs yet, see the slpdex.postOrder command inside ./src/slpdex.js. Scrape tradeData using functions from slpdex.tradeData. Exchange trader (low security): DNS spoofing is a risk here. You can paste your private key into https://slpdex.com and use it there. However, people have already lost money from decentralized exchanges by DNS spoofing from doing exactly this, so only do this for small amounts.
  • Exchange Node: Primary: You can use SLPDex as your primary exchange's engine, filling and posting orders from it. Your users will need a private key. Backend: You can use SLPDex as your custodial exchange's backup engine, drawing liquidity from it whenever you need. Your exchange will benefit a lot from HFT traders. * Browser Client: SLPDex also builds for the browser, allowing you to use all of its functions directly in your user's web browser without having to go through an extra server.
  • In development: Badger Wallet / Electron Cash. Due to incompatibilities between software, right now you'll have to export a standard WIF private key from these softwares into one of the above methods. We think Badger Wallet will be open to providing the signing method needed for SLPdex. For electron cash, a plugin with the required partial-signing method already exists inside of a much more complex library here: https://github.com/cashshuffle/cashshuffle-electron-cash-plugin

If you just want a browser package, you should build and host your own version of slpdex. Using a CDN is dangerous. However, assuming you're only interested in the public tradeData endpoints, we're working on a CDN support for this use case.

Development

To get started, clone the repo, and run the example exchange node like so:

node exampleExchangeNode.js;

In another terminal, use the exampleClient:

node exampleClient.js;

You should peek at these files, and import your WIFs, tokenIds, and other parameters to suit your liking. You'll have to comb the src directory as well depending on what you're trying to do.

Adding SSL

SLPDex uses Nginx as a proxy-pass to a backend HTTP server. Nginx can be configured to inhibit DDOS at a much lower level than express. For this reason, this library will not support SSL right now.

Dependencies

GunDB

Running a decentralized peer to peer network should be difficult. GunDB is one of the easiest libraries ever, not just for p2p but across all of npm. You can learn more about it here: https://github.com/amark/gun#documentation .

SLP-sdk

SLP-sdk includes a web of dependencies like slpjs, BitBox, bitcoin-lib-cash, and other bitcoin-related libraries for signing and communicating SLP token transactions. I recommend you look at the example folder in their github repo for more information.

Compliance

Nothing on this page is legal advice. The SEC recently shut down EtherDelta, a decentralized Ethereum exchange: https://www.sec.gov/news/press-release/2018-258

In reading the SEC's judgement, it appears as though the founder of EtherDelta got into trouble for, among other things, 1) allowing to trade any project, even scams 2) allowing to trade voting tokens (DAOs), which may be a security, and 3) holding all pending transactions on a single centralized server.

The advantage of SLPDex is that although its back-end is decentralized, its front-end is centralized on a per-node basis. Any node can choose not only which fee to list, but which tokens to list, and the design of their site. You may want to check out your local regulations to see how they comply with these SEC statements.

Slpdex.com over-complies with all of these SEC statements.

For hire

If you're interested in having us set-up an exchange for you or your domain, i would greatly appreciate it. Currently considering offers for initial development, ongoing maintenence, and consultation. Your support not only helps devs who are forward about developing useful products, but will improve the great BCH ecosystem as a whole. You should do your own research as to what your expected returns may be as they will vary depending on the success of the ecosystem and your current cryptocurrency holdings.

Demo with orderbooks: staging.slpdex.com Inquiry e-mail: inquiries@slpdex.com