Getting Started

Decentralized Finance (DeFi) is a term that describes financial products and services built on public blockchains.

One example of a DeFi product is a decentralized exchange (DEX). A DEX is a peer to peer marketplace where crypto transactions are completed directly between traders using a smart contract. The opposite of this is a centralized exchange (CEX) where crypto transactions are completed between a third party and traders.

Unlike traditional exchanges, DEXs allow users to swap assets without third parties facilitating the transaction or taking control of funds.

Decentralization and Self-Custodial:

Unlike centralized organizations that operate CEXs, the DEX operates on a decentralized network, with no single organization controlling the exchange.

Decentralization has two main advantages:

  1. The smart contracts that make the DEX cannot be changed once deployed, meaning no one can change the rules.
  2. Funds are completely self-custodial. You always remain in control of your assets. No third party can take them.


Transparency
:

DEXs are more transparent than centralized exchanges. Not only is all the code open source and publicly available, but the DEX operates on public blockchains where all transactions and smart contract interactions are recorded on a transparent and immutable ledger.

Anyone can access and verify these transactions, ensuring transparency and accountability.


Greater accessibility
:

Another benefit of the DEX is greater accessibility. Anyone can trade any token or create a market for any token.

In this way, DEXs are more accessible to a wider range of users, including those who may not have access to traditional banking services.

The DEX protocol enables crypto trades without the reliance on a centralized intermediary. The protocol achieves this through decentralization, liquidity pools, and automated market maker.

Decentralized

The DEX is an open source peer-to-peer decentralized exchange.

Immutable, persistent, non-upgradable smart contracts on the Ethereum blockchain define the DEX. This makes the protocol censorship resistant, secure, and self-custodial.

The protocol’s services are open for public use. No one has the ability to restrict who can or cannot use them. The result is anyone can swap tokens, list a token, or provide liquidity in a pool to earn fees.

Liquidity pools

Liquidity pools are token pairs stored in a DEX pool contract. They allow users to swap against the tokens within a pool.

These pools rely on users for funding. Users create market liquidity by providing token pairs to a pool.

To incentivize pooling liquidity, there is compensation for liquidity providers. 

Automated Market Maker

This smart contract manages liquidity pools. It allows for automated and permissionless token swaps. It is also known as an AMM or a Constant Function Market Maker.

The AMM analyzes a token pairs’ supply and demand within a liquidity pool. This is how the AMM determines the real time value of a token, and provides efficient token prices for each swap.

This system replaces the traditional order book used by centralized exchanges. Instead, users interact with the liquidity pool using the AMM.

You can connect a wallet to the DEX using a desktop browser with Metamask plugin or mobile browser on Metamask app.

To connect your wallet to DEX:

  1. Select the “Connect” icon.
  2. Only the Metamask wallet is supported, other wallets are under development.
  3. Your wallet will be prompted to approve the connection. Once approved your wallet will be connected!

You are able to disconnect your wallet from DEX.

To disconnect your wallet from DEX:

  1. Open your portfolio by selecting your wallet icon in the top right corner.
  2. Select the Disconnect Wallet icon.
  3. Select “Disconnect”.
  4. You have now disconnected from DEX.

Token prices are determined by the amount of each token in a pool.

The liquidity pool contract maintains a constant using the following function: x*y=k.

  • x = token0
  • y = token1
  • k = constant

Liquidity pools on the DEX require that the pool price is a constant K.

During each swap, a certain amount of one token x is removed from the pool for an amount of the other token y. To maintain k, the balances held by the smart contract are adjusted, which changes the price.

Network costs are determined by supply and demand of miners.

When there is a lot of traffic on a network (high volume of transactions), the network cost is higher. When there is low traffic on the network (low volume of transactions) the network cost is lower.

You can check the current network costs on Ethereum and average fees by time of day here: Etherscan Gas Tracker

Swapping

To swap tokens on DEX follow these steps:

  1. Open DEX and connect your wallet. Then select the token drop-down.
  2. Search for and select the token you wish to swap. You can browse the token list or search for a token by name or contract address.
  3. Now you have to select the token you want to swap for. Select the token drop-down.
  4. Search for and select the token you wish to swap for. You can browse the token list or search for a token by name or contract address.
  5. Enter the amount you would like to swap, receive, or select the “Max” option.
  6. The “Max” option automatically inputs the total amount of the token you have available in your wallet for swapping.
  7. Select “Swap”.
  8. Review the swap details, and then select “Confirm Swap”.
  9. In your wallet, approve spending for the token you are swapping.
  10. This will require a network cost. If this is your first time swapping the token with the DEX, then you’ll need to approve the token in order to trade it. See “What is an approval transaction”.

  11. In your wallet, sign the message. This transaction will not require a network cost.

  12. In your wallet, confirm the swap. This transaction requires network costs.

  13. Once confirmed, your swap is submitted to the blockchain and is pending.

  14. You will see “Swap success” and a green checkmark on screen when the transaction is successfully completed.

  15. You have now successfully swapped with DEX! To view your swap on Etherscan, you can select “View on Explorer”.

  1. The first time you swap or add liquidity, you have to approve the token to be swapped. This gives the DEX permission to swap that token from your wallet.

    The approval transaction allows the DEX permission to swap the token you granted approval for from your wallet. You have to complete an approval transaction for every token you want to swap using the DEX.

    Here a guide on how to complete an approval transaction:

    1. Enter your swap details.

       

    2. Select “Approve and swap”.

       

    3. In your wallet, approve DEX to access the token you are swapping. This transaction requires network costs.

      Your wallet may require you to enter the number of tokens you want to approve. Please enter a number that is greater than or equal to the amount of tokens you are swapping.

       

    4. In your wallet, allow the token to be used for swapping. This transaction requires network costs.

       

    5. In your wallet, confirm the swap. This transaction requires network costs.

       

    6. Once the swap is confirmed, the transaction is submitted to the blockchain (pending).

       

    7. You will see “Swap success” and a green checkmark on screen when the transaction is successfully completed.

       

    This token approval lasts for 30 days. After 30 days, the token approval will expire and the token will have to be approved again.

    However, this approval is completed with a signature request. An approval signature does not have network costs.

Price Slippage is the change in token price caused by the total movement of the market.

Price Slippage is shown as the difference between the price you expect to receive after swapping vs what you actually receive after the swap is complete.

However, you can always enter your own desired slippage for a swap.

How to change the slippage in the swap settings:

  1. Select the settings icon.

     

  2. Select the slippage drop-down.

     

  3. Here you can choose  slippage tolerance.

Note: If your slippage is set too low, your transaction may revert or fail.

If your slippage is set too high then you may get less tokens than expected when swapping.

For example, if your slippage is set to 25% then you may receive 25% less tokens that what is shown to you in the swap preview.

Liquidity

A liquidity pool is group of tokens that are locked in a smart contract and used for trading between assets on a decentralized exchange (DEX).

In traditional finance, liquidity is organized using a central limit order book where buyers and sellers create orders (trade) organized by price and demand.

The DEX takes a different approach, using an Automatic Market Maker (AMM) to replace the traditional order book method with a liquidity pool of two assets, where the price is determined by an AMM.

These pooled tokens are provided by liquidity providers (LPs) who receive an LP token in exchange for providing liquidity.

The DEX AMM sets prices for liquidity pools using the mathematical formula x*y=k.

Prices are determined by the amount of each token in a pool, with x and y representing the two tokens in a liquidity pool. 

It is important to evaluate the liquidity available in a pool before swapping. A pool with low liquidity will not give you an optimal price, and could potentially result in a loss.

To evaluate the liquidity available in a liquidity pool, visit https://oqopo.org/dex/#/pool and search for the pool or token you would like to swap.

A Liquidity Provider (LP) fee is applied to all swaps when using the Uniswap Protocol.

The LP fee is taken from the input token.

The liquidity provider fees are distributed to liquidity providers as a reward for supplying tokens to the liquidity pool.

The liquidity provider fee is paid proportionally to all liquidity providers who have an active liquidity position. Liquidity providers who have a position outside of the price range at that moment will not earn fees.

Liquidity provider fees are paid entirely to the liquidity providers. DEX does not receive these fees.

fee tier is the percentage of the liquidity provider fee that swaps pay when swapping.

When providing liquidity you will receive your 50% of the collected fees. These get shared equally with all the liquidity providers in the pool.

When providing liquidity on the DEX:

  • DEX has the 0.5% fee tier.
  • The fees are auto compounded into the liquidity pool. This means for every swap the fee will go back into the pool, increasing the value of your position.
  • When removing DEX liquidity positions, Fees are collected with the liquidity.

To add liquidity to the DEX:

  1. Open the DEX and connect to the network you want to add liquidity on. Next, select the “Pools” to open the Pools page.

     

     

  2. Select “Create pair”.

     

  3. Select the token drop-down.

     

  4. Select the token you want to add liquidity for.

    Note: When adding liquidity, you can select any pair of BEP-20 tokens.

     

  5. Next, select the second token. Select the token drop-down.

     

  6. Select the second token you want to add liquidity for.

     

  7. Enter the amount of tokens you want to deposit into the liquidity pool, or select “Max” for the maximum amount of tokens.

     

  8. Select “Approve”, then in your wallet allow your tokens to be used for providing liquidity. This transaction has network costs.

     

  9. Select “Supply”.

     

  10. Review the liquidity position details, then select “Supply”.

     

  11. In your wallet, confirm the transaction. This transaction has network costs.

     

  12. To view the pending transaction select “View on BSCscan”. Otherwise, select “Close”.

     

  13. A confirmation notification will appear once the transaction is complete.

     

  14. Once completed, you can view and manage your liquidity position from the DEX pool page.

     

When removing liquidity from the DEX, you will remove your liquidity position and collect earned fees in the same transaction.

To remove liquidity from DEX:

  1. Open the DEX and connect to the network you want to add liquidity on. Next, select the “Pools” to open the Pools page.

     

     

  2. Find the position you want to remove and select “Manage”.

     

  3. Select “Remove”.

     

  4. Review the details of your liquidity position. Then enter the percentage amount that you would like to remove.

    Note: if your liquidity position includes ETH, you will see the option to “Remove as WETH”.

    Selecting this means you receive WETH in place of ETH when removing liquidity.

     

  5. Select “Approve” then sign the transaction in your wallet. This does not have a network cost.

     

  6. Select “Remove”.

     

  7. Select “Confirm”.

     

  8. In your wallet, confirm the transaction.

     

  9. To view the pending transaction select “View on Etherscan or BSCscan”. Otherwise, select “Close”.

     

  10. A notification will appear once the transaction is complete.

     

Impermanent Loss (IL) is when the prices of the two tokens diverge. This happens while the liquidity position is active, resulting in a loss of the liquidity position value.

Liquidity pools on the DEX require that the pool has a constant k. The k represents the liquidity that has been provided.

The smart contract for the liquidity pool maintains a constant using the following function: x*y=k

  • x = token0
  • y = token1
  • k = constant

During each swap, an amount of one token is removed from the pool for an amount of the other token. To maintain k, the balances held by the smart contract are adjusted during the swap.

These prices also diverge through other pools and exchanges. As a result of the divergence in prices, the liquidity balance also changes.

The price may or may not return to the price you provided liquidity at. If it doesn’t return to the original price that you provided, this is considered impermanent loss.