Skip to content

Latest commit

 

History

History
145 lines (88 loc) · 12.5 KB

2. How to Solana — Chapter 2: Overview of DEX & AMM.md

File metadata and controls

145 lines (88 loc) · 12.5 KB

How to Solana — Chapter 2: Overview of DEX & AMM


Primitive I: Decentralized Exchange — DEX

Objectives: Global Access to Markets | Non-Custodial Commerce | Transparent & Trustless Trade

The Decentralized Exchange (DEX), is a novel form of permissionless commerce that has come into prominence, over recent years. Primarily, DEXes enable traders to transact across financial markets, without relinquishing ownership of their funds. During the primordial iterations of the DEX financial primitive (2017–2018), decentralized exchanges exclusively operated through standalone buy/sell orderbooks. Often due to insufficient liquidity and a primitive UI/UX experience, these orderbooks were not sufficiently practical to satisfy the functional demands of mainstream traders & investors.

As a nascent financial primitive, DEXes lagged behind, in both adoption and disruption, for years after inception. Most traders simply lacked any practical thesis for conducting transactions on anything other than a centralized exchange (CEX), therefore the broader ecosystem was relegated to only a few thousand enthusiasts & early adopters. However, after years of quiet development, an innovative alternative to the standalone orderbook model, known as Automated Market Makers (AMMs) emerged as the second fundamental primitive for practical, permissionless commerce.

Primitive II: Automated Market Makers — AMM

Objectives: 24/7 Liquidity | Stable Buy & Sell Spreads | Transparent & Universal MM Incentives

The scope of Uniswap Labs’ first working AMM model (K = x*y) cannot be understated in the history of DeFi, as the working application of liquidity pools instantaneously made standalone orderbook DEXes, on both Ethereum (Etherdelta, IDEX) and other chains (Bitshares, Waves, Cryptobridge) obsolete, almost overnight. Uniswap was a truly revolutionary addition to the future of DeFi, and demonstrated the legitimacy and potential of the DEX/AMM financial primitive as the bedrock for transparent, trustless commerce. Solana’s current DEX/AMM infrastructure and prospective DeFi product suite stands on the shoulders of invaluable contributions by the Ethereum Foundation, Uniswap Labs, & the greater DeFi community.

Solana’s high-throughput, low-latency, processing capabilities provide the means for a vast suite of sophisticated AMM applications for decentralized operations, such as high-frequency trading, central limit order books(CLOB), derivatives, cloud computing, and cloud storage. These financial instruments and Web3 interfaces are rapidly being built on Solana, with seamless scaling to support over 1 billion user accounts on a single state machine.

Solana DEX/AMM Suite I: Raydium

Raydium is an on-chain order book and automated market maker (AMM) that enables lightning-fast trades, shared liquidity and new features for earning yield. Initially offered as a standalone DEX/AMM product, Raydium offers a suite of services to its users such as launchpads, accelerators, and yield farming.

Note: Currently, there are two supported operations for trading on Raydium. Users can transact through the Orderbook (Trading tab) or through the AMM (Swap tab).

Documentation: https://raydium.gitbook.io/raydium/
How to use Raydium: https://raydium.gitbook.io/raydium/

Swapping:

  1. Access Raydium via raydium.io, and click on the Swap tab.

2. As one can see from the image above, Raydium will ask users to connect a wallet before conducting a token swap. Click Connect on the top right button above, it will pop out a menu to select your wallet.

3. Select a desired wallet and connect to Raydium. Once the tab has recorded a public address, the user now has access to Raydium’s entire product suite.

Note: We recommend using either Phantom or Sollet for Web3 integration , as they are currently the most supported and adopted within the greater Solana ecosystem.

4. Select the token to be sold in the top slot, and the token to be bought in the bottom slot.

5. Insert a desired quantity, and observe the terms of the “Minimum Received” and the “Price Impact” values.

6. After confirming that the user’s selected slippage tolerance < price impact, the swap will execute once acted upon. If all displayed conditions are acceptable, click swap.

Limit Order Trading

Pre-specified price limit orders are another trading operation supported by the Raydium DEX/AMM, with real-time price feed updates from Serum’s underlying orderbook data.

1. Click the Trading tab on the Raydium dashboard to access Limit Orders for both buy & sell side operations.

Note: The orderbook feed will display critical data such as bid/ask spreads, real-time order flow updates, and recent on-chain trades.

2. Select a supported trading pair for an asset that the user has already deposited and settled on the Raydium interface. If the trading pair is not listed on the front-end, it is also possible to add a custom market for existing Raydium.

3.Insert desired limit order price (less than highest bid and greater than highest ask).

4. Insert desired size as either a positive real number value or as a percentage of relevant asset holdings.

Note: In this example, a limit buy of 10 SOL at $170 you be executed if/when SOL drops to $170, and should not be made above a market price of $170/SOL.

5. Click LIMIT BUY SOL and approve the transaction on your web wallet. That’s it. Repeat the same steps for Buying/Selling other tokens for a specified price on Raydium.

Solana DEX/AMM Suite II: Serum

Serumhttps://dex.projectserum.com/

Documentation Guide: https://docs.projectserum.com/guides/trade-on-serum-dex-1

  • Serum is a protocol and ecosystem that brings unprecedented speed and low transaction costs to decentralized finance. It is built on Solana and is completely permissionless. Ecosystem partners can compose with Serum’s on-chain central limit order book to share liquidity and power markets-based features for institutional and retail users.
  • Serum’s on-chain central limit order book and matching engine provides liquidity and price-time-priority matching to traders and composing projects. Users benefit from this exchange model through the ability to choose the price, size and direction of their trades. Composable protocols are extensively supported by Serum’s existing architecture, bootstrapped liquidity, and matching service.
  • Users can access Serum directly for pairs that are not available on Raydium. For example Saber (SBR) is not available on Raydium, but users are able to trade it on Serum.
  • Serum’s Web3 interface also follows a standard integration procedure. Users will first connect their wallet, and then enter desired price and tokens quantities for buy/sell side execution.

  • Serum’s UI/UX for limit order trading should feel quite familiar for Raydium users.

Solana DEX/AMM Suite III: Orca

Orcahttps://www.orca.so/

  • Orca is a relatively new, yet promising addition to the Solana ecosystem. Orca’s interface focuses on simple, straightforward UI/UX design to onboard users unfamiliar with both Solana & DeFi operations. Orca can offer casual, curious users an intuitive introduction to Solana, without sacrificing any of the backend, technical efficiency that experienced Raydium & Serum users have come to expect.
  • Orca’s DEX/AMM trading operations are all accessible from the Exchange tab on the homepage.
  • Swapping on Orca is possible with two differing inputs: numbers & words. The former is similar to Raydium/Serum. Swapping between two existing pairs requires a single input for desired quantity. Click swap, approve the transaction, and watch it confirm in milliseconds.


  • The second method requires users to write out a desired transaction into the search bar located above the swapping function ( e.g “24 USDC to orca). Orca will then proceed to register this input through its front-end and offer back suggestions which can be acted upon as on-chain trading operations. After clicking through, Orca will fill in the inputs for the user’s selected swap, and if the terms are acceptable to the user, the user will be able to click “Exchange” to commence the swap.

Supplementary Resource: Additional step-by-step examples regarding web3 integration for DEX/AMM protocols can be found in published How to Defi book, written by Coingecko.

Reference Protocols — DEX & AMM

Mainnet Products:

  1. Serum [Mainnet][Solana]: Essential Solana DEX orderbook primitive which allows for trading of all SPL tokens with near-instantaneous price feed updates.
  2. Raydium [Mainnet][Solana]: First Solana AMM with fully decentralized central limit orderbooks.
  3. Orca [Mainnet][Solana]:DEX/AMM with intuitive, straightforward UI/UX that also features collectibles, high yield SPL-Stablecoin pools, and YF mechanics.
  4. Mango Markets [Mainnet][Solana]: Decentralized Trading Platform with spot and margin trading (up to 5x) with Serum-derived orderbook data.
  5. Mercurial [Mainnet][Solana]: Multi-token stablecoin swapper with minimal slippage.
  6. Bonfida [Mainnet][Solana] : Full product suite for critical solana infrastructure such as perpetual swaps, trading bots, token vesting, and naming services.
  7. Saber [Mainnet][Solana, Cross-Chain]: Solana’s leading cross-chain stablecoin and wrapped assets exchange for large, low-slippage stablecoin swaps

Pre-launch & Conceptual Products:

  1. 1Sol [Devnet][Solana,Cross-Chain]:Interoperable DEX aggregator on Solana. Comparable to 1inch.
  2. Nerve Finance [BSC Mainnet][Solana Devnet]: AMM launched on BSC for low slippage trading of primarily stablecoins and other pegged assets (gold, euro, etc.)
  3. Solster Finance [Devnet][Solana]: Launchpad for Initial Dex Offerings (IDOs) seeking to provide decentralized lottery and KYC services for whitelisted token sales.
  4. Hydraswap [Devnet][Solana]: AMM leveraging Pyth’s real-time oracle feeds to offer a CEX-like experience for liquidity providers (no IL, negligible slippage) and a native cross-chain bridge.
  5. Coinmeca [Proof-of-Concept][Solana,Ethereum]: Hybrid CEX/DEX architecture with a high-speed interoperable exchange. IDO first on Ethereum as ERC-20 before transitioning to SPL token model
  6. IdentitySwap [Proof-of-Concept][Solana]: AMM bypassing traditional KYC/AML norms with decentralized identity (based on Civic’s product).