Generalized DEX

A new type of swappable DEX, which is gasless, feeless, debtless short-able, and extremely extensible to various logic

Running the project locally

If you want to test your project locally, you can use the following commands:

# Starts the replica, running in the background
dfx start --background

# Deploys your canisters to the replica and generates your candid interface
dfx deploy

Once the job completes, your application will be available at http://localhost:8000?canisterId={asset_canister_id}.

Additionally, if you are making frontend changes, you can start a development server with

npm start

Which will start a server at http://localhost:8080, proxying API requests to the replica at port 8000.

Note on frontend environment variables

If you are hosting frontend code somewhere without using DFX, you may need to make one of the following adjustments to ensure your project does not fetch the root key in production:

  • setNODE_ENV to production if you are using Webpack
  • use your own preferred method to replace process.env.NODE_ENV in the autogenerated declarations
  • Write your own createActor constructor

How It Works

The action of exchange can be divided into “deposit” and “withdrawal”. If a person deposits a product and withdraws a different product at the same price, the result for the person is the same as exchanging the product with someone else. The simple separation of the process makes this protocol very powerful. This is the core of how this protocol works.

The Exchange Protocol

Static Price Quote

Static Price Quote is the way to quote the price respective to every currency or token by the Universal Static Price. It works as “the quote currency of all” instead of exchanging at the price of every pair of derivatives. That enables “deposit” and “withdrawal” at the same price and at a different moment because prices are quoted by the price that is static over time. The Universal Static Price is stabler than any fiat currencies.

Rules

The rules of this exchange are very simple, which are:

  • An address can withdraw the amount of the value the address has deposited.

The deposited value is confirmed with whitelisted tokens or executed orders with non-whitelisted tokens. There are some limitaion on swapping minor tokens but thanks to the flexibility of this protocol, anyone can make applications that liquidate for trades of the tokens like adding liquidity providers or making the proxy address that regards the minor tokens as whitelisted ones.

No Liquidity Providers

There are no liquidity providers although there is a liquidity pool. What liquidates the pool is time lag between deposit and withdrawal. That sounds liquidity is lacking, however, it can be much more liquidated than other AMMs thanks to the flexibility and extensibility of this DEX. Examples that liquidate the pool are the followings:

  • Token issuance
  • Debtless short selling
  • Banking
  • This

Or other applications

Custom Token Offering

Custom token offering is one of the most powerful applications that users can build in this protocol. This is because pricing is customizable and the value can be stably backed by Universal Static Price.

The Pricing Protocol

Data From Third Parties

Price feeds, currency weights, and inflation rates are fetched or provided. Data from third parties will get much more secure in the future.

Price Adjustment

Prices are adjusted to control supplies and demands in the liquidity pool.

Non-Whitelisted Tokens

There would be malicious tokens that violate the pricing system. Users still can trade those tokens efficiently. This is because once the value of the counter tokens gets confirmed or the counter order is booked, the order for the non-whitelisted tokens is executed. Those are much more efficient than the conventional exchange because orders are booked irrespective of token pairs, moreover, prices and amounts of ordered tokens are bundled.

Universal Static Price (USP)

Universal Static Price (USP) is calculated to minimize the intrinsic change of its value from price feeds, currency weights, and inflation rates by applying the weighted average of value changes of major currencies.

Paper

GitHub

View Github