weedEXDecentralized on-chain subcurrency exchange with relays.

weedex
weedEX is an open source decentralized exchange on the PUFFScoin blockchain, intended to act as an initial marketplace for tokenized assets, designed to be application agnostic and extendable to allow communication through smart contract interaction with dApps running on the PUFFScoin network as well as allow for direct peer-to-peer transactions.

Cryptocurrency exchanges are often the first taste of altcoin trading that the general public experiences. They permit users to trade one cryptocurrency for another, engaging in speculation or investment into projects. Some of the more established exchanges also offer their users the ability to purchase Bitcoin and other cryptocurrencies directly with fiat currencies. While the stated ideals espoused by the vast majority of cryptocurrency projects that exists tend to lean towards the importance of decentralizing wealth models, taking back control of our assets, data, and privacy. Unfortunately, the exchanges within which the majority of cryptocurrency transactions actually occur are very centralized.

Many of these “third-party” exchanges are actually very safe to use, but there still exists that caveat, users of third-party exchanges DO NOT control the private keys to their funds. The brief history of cryptocurrency is fraught with examples of third-party exchanges that have had vulnerabilities exposed by hackers and lost millions of dollars worth of user funds, or have deliberately been involved in thefts from customers. Because third-party exchanges simply act as active escrow for their clients, their systems are not “on-chain” and transactions are not recorded on the blockchain.

There are innumerable stories of exchanges that have failed due to security breaches, unsafe storage of user information, or simple mismanagement resulting in the loss of user funds, many times in the hundreds of millions of dollars. Some exchanges have been exposed as Ponzi schemes or were involved in outright thefts of user funds. While court cases have proceeded, creditors in many of these cases are still waiting for even a proportion of their lost funds.

A platform acting as a “decentralized exchange” (DEX) where users private keys are never exposed, assets remain under the user’s control at all times and transactions are directly peer-to-peer will reduce a great deal of those risks and allow the disruptive expectation behind cryptocurrency to remove third-party limitations in value transfer in a meaningful way.

weedEX, the decentralized exchange deployed on the PUFFScoin blockchain, and maintained by the PUFFScoin Core team, will aim to provide this capability atop the PUFFSnet, providing relay throughputs to Bitcoin, Litecoin and others, as well as providing a marketplace for on-chain ERC20 compliant tokens. Support has not yet been built to provide cross-chain interaction for ERC20 tokens users may support on the Ethereum blockchain, but we are looking into smart contract ideas originally brought forth by the Digix gold-standard token for a malleable token balance, which may allow for tokens to build support by communicating through relays and sidechains and possess interactive qualities or callable functions across chains, at higher fees.

CENTRALIZED VS. DECENTRALIZED EXCHANGES

THE RISKS OF CENTRALIZED EXCHANGES

Centralized exchanges are platforms enabling cryptocurrency traders to buy, sell and exchange digital assets against other cryptocurrencies or fiat money. There are several hundred different third-party exchanges available presently, although the trade volume is greatly consolidated to the top five exchanges, each of which sees an average of over USD$1 billion in transactions daily. These exchanges do serve a very important part in the success of any cryptocurrency project, and oftentimes there is a great deal of competition involved to have an altcoin listed on an exchange.

The main problems with centralized cryptocurrency exchanges remain the same sorts of issues that have plagued the industry since its inception. Lack of security, from outside or inside interests, puts user’s funds at risk of loss and theft. Market liquidity, difficult to build on smaller exchanges, is divided onto a handful of leading marketplaces. Certainly, they can be targets of market manipulation, “pump-and-dump” market collusion, DDOS attacks and other schemes. They can suffer hardware failures and latency issues.

Fees associated with trades and withdrawals from exchange wallets are generally opaque and can become prohibitively high. The user base tends to be less educated regarding safe practice techniques involved with cryptocurrency, and less than scrupulous exchange operators will permit even the most evident “scam coins” listing for a fee. In the end, it truly becomes a buyer beware situation, excepting that in the majority of cases, users don’t own the private keys to their exchange wallet, and leaves users in a state of required trust in the service provider, many of whom act as anonymous actors.

Governmental intervention, or interference, is also an issue facing many centralized exchanges, and user data collected by these exchanges – including the largest operations – has been forfeit to taxation services in several countries.

LIMITATIONS OF DECENTRALIZED EXCHANGES

Decentralized cryptocurrency exchanges differ from their centralized counterparts most specifically in that users remain in control of their own assets, and that the critical functions of the trade engine are built as blockchain operations. Because all active nodes of the parent blockchain are involved in ensuring the consensus of the transaction, there is no single point of failure. Furthermore, as weedEX will operate under the open source policy, permitting users to build the necessary application architecture to run a copy of weedEX locally on their own system.

Distributed applications such as weedEX will have limitations as they are introduced. Issues such as blockchain bloat derived from high volumes of transactions and network congestion during token sales have been experienced on Ethereum. Transactions require blockchain verification which necessarily causes a delay between order and completion. Direct fiat integration to the blockchain has very few decentralized accessible options. Liquidity of the market becomes a very transitory experience and building market fungibility through mass adoption of the platform ecosystem is a long process.

Furthermore, “full decentralization” is not quite possible as portions of the exchange infrastructure, such as the orderbook, may need to remain off-chain or hosted through third-party services. As mentioned previously, cross-chain interoperability remains a challenge, although relays exist in open source development that will allow weedEX to host and maintain those services to other digital assets as they are available. Tokens built with equivalent smart contract code on autonomous EVM blockchains are not interchangeable across block-chains.

Gas costs for transaction verification may be slow to adapt when congestion occurs, which may lead to further trade completion delays. Further, as the orderbook resides directly upon the blockchain, traders must expend gas (transaction fees) for each posting, modification or cancellation of an order. While a single change to a trader’s market position may be minimal, frequent adjustments in response to market condition evolution may become excessive.

Regardless, a move towards decentralized exchanges is inevitable, although a hybridization of service is likely to become the new normal in the near future.

HYBRID DECENTRALIZATION

Part of the business plan enumerated in the 2018 PUFFScoin roadmap is to purchase rights to a white-label cryptocurrency solution, enabling not only simple fiat gateways but trade against a PUFFS base pairing for other cryptocannabis projects, environmentally conscious or humanitarian blockchain enterprises. While this project will be a form of centralized exchange, with the PUFFScoin Core development group, and its parent company The Leafy Cauldron Apothecary governing it, the intention is to integrate the proprietary exchange as deeply as possible with weedEX, providing a thoroughfare to a larger representation in the cryptosphere for those projects.

While imperfect, decentralized exchanges can provide stronger security guarantees to end users since there is no longer a central authority which can be hacked, there is no longer need to trust exchange providers not to run away with customer funds, and intrusive government regulatory environments can be avoided if users maintain as pseudonymous identity as possible.

THE weedEX PROTOCOL

weedEX

weedEX will facilitate a decentralized environment for PUFFScoin users to buy, sell or trade on-chain tokens as well as independent cryptocurrencies to which a light client relay may be constructed. To prevent excessive fees mounting for active traders, but remain as decentralized as possible upon launch, will operate the exchange dynamics through off-chain order book relays that channel trade settlement on-chain.

Direct peer-to-peer orders are placed when the “Author” approves the weedEX smart contract to access their balance of TOKENx, creating a trade order to exchange TOKENx for TOKENy at the desired exchange rate, appends an expiration point for the order beyond which the order cannot be filled by separate actors. This order is cryptographically signed by the Author’s private key.

The market order is then broadcast, there are a variety of mediums available for this action including through Whisper. Orders are simply data packets which are stored in hexadecimal form. They can be sent, off-chain, through email, social media messaging or other similar services. “Suitors“, users who view the order on whatever medium and agree to fill the order specifications, approve the weedEX smart contract to access their balance of TOKENy, submitting the original signed order released by the Maker to weedEX. The weedEX smart contract will authenticate the Author’s cryptographic signature, verifies that the expiration date for the order has not passed, and then transfers the assets between the two parties at the agreed upon exchange rate. Direct peer-to-peer exchange in this manner can be a direct and private exchange with the weedEX smart contract providing trustless escrow for both participants, with the Suitor paying the gas costs to announce the transaction for inclusion on the PUFFScoin blockchain.

Because orders are “broadcast”, any user may participate with the decentralization of process by acting as an exchange, maintaining public (or private) order-books, and levying transaction fees on the resultant market liquidity they create. These “Ferrymen” expedite the market exchange mechanism by generating and hosting the order-book. They do not execute the trades themselves, the open order simply adds in two parameters from the peer-to-peer transaction method. The asset exchange itself is still performed by the weedEX smart contract directly between the Author and Suitor.

The Ferryman sets a fee schedule, along with the PUFFScoin address to which those fees will be sent to. The order Maker may broadcast an open order to the Relayer’s hosted order book, setting fees which satisfy the Ferryman’s criteria. This order is updated onto the hosted order book, which can be fulfilled by anyone who submits the Maker’s order to the weedEX smart contract. This experience will be designed with a front-end web application that will as closely approximate the typical exchange interface as possible.

The PUFFScoin Core development group will host a Ferryman on the PUFFScoin home page with a 1% fee schedule. Fees collected through trades executed through the PUFFScoin Ferryman will be set towards a wallet address registered to Weed for Good, a California-based non-profit which provides free or low-cost cannabis to clients suffering from terminal illnesses.

The weedEX exchange protocols are codified within a PUFFScoin resident smart contract with a public address and maintain no additional costs to users beyond the standard gas costs, which are sent to the Veterans Endowment. An order fulfillment will cost the Suitor an average 90000 gas (see Gas) to broadcast to the blockchain correctly. References to previously fulfilled orders are indexed within the contract to prevent multiple fulfillments of a single order. Orders can be partially filled by market participants, which will allow multiple partial commitments, the balance of available tokens from the available total offered balance deducted and indexed.

Unfilled orders which have not expired can be canceled by the Author. This function will cost the Author the standard gas associated with the transaction and is intended as a fallback mechanism against market manipulation.

weedX TOKEN

To create the incentive for third-party agents to participate in the weedEX and overall PUFFScoin economy while presenting a standard rate for fee transmittal across the weedEX infrastructure, we will use the WEEDx token primarily as the denomination payable to Ferryman service providers. The WEEDx token may also be used in the process of decentralized governance for the overall weedEX protocol.

The suite of contracts is designed to be modular so that an upgrade to the functions of one aspect of service will not require the base exchange smart contract to require redeployment, which could lead to network disruptions or an invalidation of current orders, forcing each market participant to approve the new smart contract to access their token assets marked as in escrow by the contract pending trade.

A weedEX token registry will also be launched, managing a list of PUFFScoin resident tokens that may be associated with the exchange protocol, including their contract address and JSON files. Market participants will be able to query the registry to independently verify token contract addresses. As this service will require “trust” to provide accurate information, some oversight will be necessary to ensure information included in the registry is accurate. It is the hope that the emergent weedEX decentralized governance mechanism will eventually take over that task alongside approvals of modular service updates.

Use of the PUFFScoin DNS will enable Authors, Suitors, and Ferrymen to be identified by .puffs addresses, rather than by account or contract address.

weedEX will be launched during the first quarter of PUFFScoin operation, with full user guides, public API and public contract address and source.