uTrade V2 Overview

uTrade V2 is an Automated Market Maker (AMM) utilizing Unifi Protocol's non-custodial, interoperable smart contracts operating on multiple blockchains. uTrade V2 is maintained by the Unifi Protocol team, and acts as a working proof-of concept trading platform for harnessing multi-chain swaps and liquidity mining to power UNIFI, Unifi’s Global Governance Token.

What is an Automated Market Maker?

An Automated Market Maker, or AMM, is a method of pricing assets in a decentralized way algorithmically instead of an order book of buy and sell orders. In other words, there is always buy and sell orders available, allowing users to trade as close to the quoted price as liquidity will allow. Market making is present in most asset classes. However, the innovation of automated market making is particular useful in cryptocurrency trading.

  • Tokens can lack significant liquidity. Trading on a traditional exchange requires somebody willing to be on the other end of the trade. AMMs ease this by having always-available liquidity at a price determined algorithmically.

  • Decentralized AMMs allow for users to maintain custody of their funds. Centralized exchanges offer a single point of attack for hackers. With AMMs, users are able to keep the funds in their own wallets and maintain their own private keys when trading.

  • Accessibility. If the liquidity is there, anybody is able to utilize it.

  • Decentralized AMMs are open and trustless. Many are open-source, and allow anybody to build their own dApps, bots, and more on top of a market.

  • In providing liquidity, small investors are able to generate returns previously reserved for large, highly-capitalized firms.

How do Automated Market Makers work?

Automated Market Makers utilize a series of smart contracts to allows any user to trade, provide liquidity, or even create their own market. Automated Market Makers are generally used by two types of market participants, traders and liquidity providers.

Traders

Traders who buy and sell cryptocurrency utilize automated market makers due to their always available liquidity, instant accessibility, open nature of verifiable on-chain trades, the ability to maintain individual custody of funds, and so much more. But how does it work under the hood? What determines the price and how is this liquidity always available? Each liquidity pool is managed by a smart contract that contains two tokens to make up a pair. The tokens are priced using a constant formula of x * y = k. In this equation, x and y represent a pair's reserve balances. In other words, x and y are the amount of each token in the smart contract. These change any time liquidity is utilized in a trade. However, k, the product of multiplying x and y remains constant during a trade. This allows for the ratio, or price, to shift dynamically based on how much liquidity is being utilized for a trade, therefore there is always liquidity available. The x * y = k formula dictates the ratio, or price, when trading. The greater the amount of liquidity in a pool, the less price movement that occurs during a trade. This price movement is known as slippage - the amount of difference between the current ratio or price, and the ratio or price that will be executed based on the trade size. The lower the value of the order, the less slippage a trader will incur. Let's say a liquidity pool consists of 200 USDT and 2 BNB. This sets the ratio or price at 100 USDT for 1 BNB. If Gene buys 3 USDT worth of BNB, Gene will pay very close to the 100 USDT per BNB ratio. However, if Gene buys 75 USDT of BNB, the ratio will significantly move, resulting in Gene paying far more than 100 USDT per BNB.

Liquidity Providers

Any user is able to reap the rewards of AMMs by providing liquidity. On uTrade, these rewards are in the form of UP tokens. UP is a token backed by that blockchain's selected base token, and is the backbone of uTrade's rewards for liquidity providers. UP is redeemable at anytime for the base tokens backing it. For example, UPbnb is backed by BNB and can be redeemed for BNB instantly. There is also a secondary market on uTrade V2 to sell UP to other traders. The redeem value of UP as measured in the number of base tokens. This redeem value can only stay the same or increase. A portion of trading fees are used to increase the redeem value of UP each time more UP is minted. UP is minted by fees at a rate that matches its redeem value, meaning the mint rate declines as the redeem value increases. UP awarded to liquidity providers can be retained for time to take advantage of the rising redeem value, or redeemed for the underlying base tokens. Now, let's say liquidity is added to a pair, how does this effect the x + y = k equation? The x and y values, representing the two assets that make up the liquidity pool, will be added at the current ratio or price. This in turn, adjusts the k value. For example, if x = 200 USDT and y = 2 BNB, k would equal 400. If Genette adds their liquidity of 100 USDT and 1 BNB to the pair, k would equal 900. Therefore, higher value trades will be possible without as significant price slippage. This works out well for traders as it allows them to make larger trades, and also beneficial for liquidity providers, as larger liquidity pools tend to have more of their liquidity utilized, resulting in more volume and trading fees.

Architecture of uTrade V2

uTrade V2 builds upon the Uniswap's smart contract architecture by utilizing the unique tokenomics of UNIFI and UP. For further details on each contract, as well as breakdowns of each function contained within, consult the documentation for each chain.

Controller

The Unifi Controller is responsible for the setting the variables of UP minting on individual pairs as well as updating the redeem value of UP tokens globally.

ERC-20

UnifiERC20.sol essentially ports the properties of ERC-20 tokens to Unifi LP Tokens, or uTokens. An example of this in practice would be the 'approve' transaction before a token is sent.

Factory

The uTrade V2 Factory contract creates an LP token for any pairs listed on uTrade V2, and indexes them for easy retrieval. In addition, it can return the address of the LP token based on a call of the addresses of the two tokens that make up the liquidity pool.

Pair

UnifiPair.sol is responsible for many of the functionalities of liquidity pool tokens and UP tokens. First, it is responsible for the issuing and burning of Liquidity Pool Tokens (uTokens). In addition, it allows for direct reads of the reserves and ratio of the liquidity pool, as well as swaps. Lastly, it is where UP claims are processed.

Router

The uTrade V2 Router is the 'brain' of uTrade. The router finds the optimal path for exchanging one token for another. Whenever a trade is made, your wallet sends funds to the router address. The router will then carry out as many transactions as necessary to acquire the desired token. The router also handles adding liquidity to liquidity pools, and sending the corresponding LP tokens to liquidity providers.

Single Liquidity Wrapper

Unique to uTrade, the Single Liquidity Wrapper allows one BEP-20 token to be converted into a LP pool. For example, BUSD can be added using the wrapper to supply liquidity for a BUSD / WBNB pair. The additional functionality from this wrapper simplifies applications such as compounding or fee-on-transfer additions to liquidity pools.

Further Reading

To learn more about how liquidity rewards are calculated, view the Liquidity Rewards Explained. To learn more about the individual contracts, including source code, parameters, and live addresses, navigate to the chain you wish to explore.

Last updated