Tokenlon just launched. Now, here is a technical post on how Tokenlon works under the hood. Try on tokenlon.im/instant.
Tokenlon decentralized exchange based on 0x protocol sets new standards, designed to give you a final price before you trade. 🐉
In short, Tokenlon is built to be:
- Fast to trade: As off-chain quotations present final prices
- Easy to use: As the user sees what he gets, using one-click interface
- Affordable: As ERC20 tokens are sent out via gasless transactions
- More secure: No deposit/withdrawal necessary as tokens go wallet-to-wallet via trustless swap
Challenges with current DEXs
There’s a couple of different DEX models. The biggest one, IDEX, asks the user to deposit tokens into their accounts, which takes time and involves cost.
Uniswap - which recently has been growing in popularity - offers prices completely based on on-chain logic. A model that is susceptible to front-running.
Kyber Network - the other big DEX - is largely using market makers that provide periodic price updates, but only a final price after a user’s commitment to a trade.
Any user of either Uniswap and Kyber does not know the final price one gets from a trade before committing to the trade.
With Tokenlon, on the other hand, Tokenlon aim to solve all 3 of those issues. Let’s dive into the how below.
How does Tokenlon work?
A token swap on Tokenlon
Let’s walk through one trade on the new Tokenlon.
Receive real price updates
As soon as you enter a trading pair and amount, market makers compete on providing you with the best price - updated every 4 seconds.
If you are selling an ERC20 token, you are asked to set allowance for the specific token the time you trade it.
Trade with price-security
Clicking on ‘trade’ then triggers the market maker signing an order with the tokens already held in reserve. Tokenlon then forwards your signed order to the 0x contract.
With the transaction mined on the Ethereum blockchain, your tokens are available in your wallet. The whole process takes ~15 second, one block.
As soon as you click the trade button, you can be very certain of that trade being settled on-chain. Why? Tokenlon’s architecture eliminates front-running.
Say goodbye to front-running
As mentioned above, other exchanges such as Uniswap are prone to frontrunning in a way that — especially for large trades — give you a big slippage or failed trades.
Trading on Tokenlon, however, prevents those outcomes. How?
First, no other trader is able to accept your order, as the order itself specifies the taker as a transactionHash.
The Tokenlon Exchange contract will then verify you as the taker of this specific offer, preventing other blockchain users (including Tokenlon users) from frontrunning the trade.
The TokenlonExchange contract calls the 0x contract for settlement, with the specified UserProxy contract as the taker.
Therefore, miners are also not able to front run a trade.
Therefore, as soon as you click the trade button, you are very certain that the trade will be executed. Trading doesn’t fail.
Trusted on-chain settlement & free transactions
Furthermore, even if trades would fail you wouldn’t lose your tokens as can happen when you deposit tokens on an exchange - no matter if centralized or decentralized.
Since 0x contract offers trustless on-chain settlement, your trade will be finalized with either both tokens having changed their owner or nothing happening at all. You won’t lose your token in the swap process.
Last, Tokenlon offers gasless transactions. Tokenlon incentivises the end users by broadcasting their orders (except ETH sell orders) for them, offering gas free transactions.
If you would like to try Tokenlon, check it out in imToken or at tokenlon.im/instant