- Wallet to operate on the Massa blockchain. Currently, we can use MassaStation (official) or the Bearby browser extension. For convenience in taking screenshots, I’ll use Bearby. You can get it here: https://bearby.io/.
- Once a wallet is created, we need to get tokens for testing, which are valueless tokens on the test (buildnet) network. To obtain these tokens, we go to the Massa Discord: https://discord.gg/massa. Inside the Discord, access the “#buildernet-faucet” channel. Paste your wallet address there, and you’ll receive a certain amount of tokens for testing.
- Now, go to http://beta.dusa.io and log in with your Bearby wallet.
- At this point, we need the tokens used in the DEX. To get them, click on the Faucet 👛 button at the top of the page.
The note indicates that you’ll receive a set of tokens: USDC, USDT, WETH, and WBTC, and you can request funds from the faucet every 24 hours. By pressing mint, you sign the transaction that sends these tokens to your wallet. If there’s any error, check if Bearby is on the “Buildnet” mode by clicking the yellow circle in the top left corner of the Bearby extension.
- To use the new features of Limit Orders or Customizable Autonomous Liquidity, you need to exchange some MAS tokens for their “Wrapped” version, WMAS. The exchange rate is 1:1, so swap 400 MAS for 400 WMAS by clicking the Wrap button and confirming the transaction in Bearby:
- Now, you have everything you need to use the new features of the Dusa beta. Let’s get started!
Limit Orders are a type of token swap that occurs when certain conditions we set are met. This way, we can place a buy/sell order for a token when its price reaches a certain threshold. This is similar to orders in traditional markets (Stock Exchange) or centralized crypto markets (CEX). The difference is that these orders are stored and executed 100% “On Chain”, meaning it doesn’t depend on any operator (human or bot) for execution, nor on external “Off Chain” oracles to track prices, etc. This is possible thanks to the Autonomous Smart Contracts of Massa, as mentioned before.
(NOTE: On Chain means the entire process happens within the blockchain, significantly increasing the security and speed of operations.)
To create Limit Orders, use the “Limit” tab in the “Trade” section.
Let’s do an example to make it clearer. Let’s see how to place an order to buy WMAS with USDC when the price of WMAS drops to a certain value:
Imagine you want to exchange 10 USDC for WMAS. When you enter the quantity of 10 USDC, the protocol tells you:
- The current exchange rate is 1 WMAS = 5.058 USDC
- For this swap, you’ll get a minimum of 1.9769 WMAS
- It indicates that to place the Limit Order, you must set the price higher than the market price.
Let’s finish configuring our Limit Order. The swaps will be triggered if the price of 1 WMAS drops to 5 USDC, and we wait for this the next 24 hours or cancel it:
If the ratio drops to 1 WMAS = 5 USDC in the next 24 hours, the Limit Order will be executed, and we will get ≈ 2 WMAS for ours 10 USDC.
You might want to have information with the relationship with the other token in the pair, meaning having the ratio of how many WMAS is worth 1 USDC instead of how many USDC is worth one WMAS. To do this, click on the 🔁 button. Now, it indicates that the Limit Order will be executed if the ratio rises to 0.2 WMAS = 1 USDC.
In parentheses, in green, you can see the % by which the ratio between the two currencies must change for the operation to be executed, 3.04% at the time of this last screenshot.
Click on the “Place an order” button and sign the transaction to place the Limit Order.
Once confirmed, you can review it at the bottom of the screen:
We can see the order details:
- From which token to which token we will swap (USDC -> WMAS)
- The amount of the token we’re sending (10 USDC)
- The execution price (0.1996 WMAS per 1 USDC)
- The minimum amount of token you’ll get (1.99 WMAS)
- The deadline, after which the order is canceled (16/12/2023 18:35)
- We can cancel the order at any time by clicking the “Cancel order” button and signing that transaction.
It’s essential to remember that you still have an active price slippage, ensuring that minimum in the operation. You can modify it in the gear icon in the top right corner ⚙️, next to your wallet; by default, it’s at 0.05%.
This means that if, when the order is executed, if the price has changed more than 0.05% from the values on the website, the exchange won’t happen:
You can create as many Limit Orders as you want with any of the available currencies; they will be displayed at the bottom like this:
On Chain = More secure:
For the first time users have access to a fully decentralized Limit Order service with no offline dependencies. No need for bots/traders to query prices, execute smart contract calls etc., with a fully on chain website. These features take security to a new level, removing the frontend/backend risks that exist today (remember the recent bug with a Ledger web3 library…).
Entry point to new developments:
Other developers will be able to use Dusa services (such as Limited Orders) and build on top of them their own protocols and applications, minimizing costs and increasing the security of their products.
No opportunity cost:
Another advantage is that Limit Orders don’t block our liquidity. When we place a limit order we are simply authorizing the Dusa Autonomous Smart Contract to spend that amount of that particular token, so nothing is deducted from our balance. This is a great advantage as we can place the orders and still have our tokens available! We will be able to dispose of our liquidity while we wait for our buy/sell prices to be reached.