Skip to content

Instantly share code, notes, and snippets.

@Dexaran
Last active April 13, 2024 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dexaran/8556c6f63d9968e7e293980d7ddd1b23 to your computer and use it in GitHub Desktop.
Save Dexaran/8556c6f63d9968e7e293980d7ddd1b23 to your computer and use it in GitHub Desktop.

Dex223 development report (4/4/2024)

This article is a development report of a Dex223 decentralized exchange.

We’re building an exchange to speed up adoption of the ERC-223 token standard. ERC-223 was created to solve a security problem in the older ERC-20 standard. Security issue of ERC-20 caused $200M losses on Ethereum in 2023.

Take a look at other Dex223 development reports.

Legal details finalized & exchange listing documents are ready

This month we've received the necessary legal data (privacy policies for our web services, protocol terms of use etc.) and established a Dex223 DAO LLC which would help us to apply for exchange listings in the future.

We have already agreed on a listing with BitMart as soon as the ICO round will be finished. It would be a huge step for the ecosystem if ERC-223 versions of existing ERC-20 tokens would be available for trading on some centralized exchanges and this was part of a deal with BitMart. Therefore we will soon see ERC-223 USDT tradeable on CEX.

Core Smart-contracts

Core smart-contracts of Dex223 were finalized. You can find them here:

Basic level of the ERC-223 support in Uniswap is already implemented. One remaining major improvement which is still pending is the implementation of the "merged liquidity" i.e. a feature that would allow two different versions of one token (ERC-20 one and ERC-223 one) created via Token Converter to be merged in one liquidity pool. This is a cumbersome task so it is likely that it will be completed after the basic margin trading implementation.

Dex223 implementation & testnet deployment

As it can be seen in our previous report we were mostly finalizing the conceptions during February. During March we started the development and finished the basic implementation of the exchange prototype already.

There are Dex223 test contracts on Sepolia testnet:

We are starting the implementation of the basic margin trading and we expect to have a fully functional prototype of the exchange at the end of April. Also, the UI should allow for test trading in the coming weeks.

  • (done) Updating libraries
  • (done) Finalizing ERC-223 workflow concepts
  • (done) Basic support of ERC-223 in Router and NonfungiblePositionManager: swaps and adding liquidity with ERC-223 tokens without approval() transaction
  • (done) Routerless single swap implementation in a Pool contract
  • (in progress) Auto-listing contracts
  • (in progress) Lending & Margin trading implementation
  • Merged ERC-20 & ERC-223 liquidity

ERC-223 & Gas Fees

Initially we were stating that ERC-223 support will allow us to reduce the gas costs of swaps by approximately 15%. Well, the testing results demonstrated that in some specific cases we can reduce the swap costs by up to 40% which is huge!

There is a fundamental difference between how to deposit ERC-20 and ERC-223 tokens to a smart-contract. In case of ERC-20 a user needs to "authorize" the contract to pull the tokens from the users's address first, then the user must tell the contract "hey, take my tokens and do something". These are two different transactions for ERC-20.

In case of ERC-223 the user can simply send the tokens to the destination smart-contract and tell it "do something" in the same transaction.

Also, Uniswap V3 implements a special contract called "Router" that processes the swaps. On the other hand, when you make a swap, you ultimately need to reach the smart-contract that stores the assets you want to receive - and this is a Pool smart-contract i.e. if you want to swap TokenA for TokenB then the A-B-Pool is the place where both tokens A and B are held. In case of Uniswap V3 a user can't directly contact the Pool and tell it to swap one token for another due to security reasons related to ERC-20 workflows. In case of Dex223 it is safe to swap tokens directly via the Pool which allows us to eliminate an intermediary from the process and therefore reduce the gas costs.

Routing. So what is the purpose of this "Router" contract? Well, it allows a user to swap tokens via multiple trading pairs. Imagine that you want to sell 10000 BTC on the market. It would impact the price severely if you will just dump these in one trading pair and you will end up selling at a much lower price than you could. It would be a good idea to find pairs with the best liquidity and sell your BTC to this pairs. This is exactly what the Router does.

It is important to note that the advantages of ERC-223 apply to certain specific cases. The most benefit is achieved for the first-time swap of a token without routing!

You can find a few transaction examples below.

ERC-20 Swap (150K gas in total)

A user needs to wait for the "approve" transaction to complete first. It is not possible to perform any further actions before this transaction completes.

ERC-223 Swap (115K gas in total)

A single transaction, no waiting delays.

Adding ERC-223 Liquidity (465K gas in total)

Adding ERC-20 Liquidity (566K gas in total)

UI

You can browse the state of the UI templates here: https://www.figma.com/file/euVeT6nAhnD55JUktI1WGr/%F0%9F%94%84-DEX223-Exchange-%F0%9F%94%84-(Copy)?type=design&node-id=2460%3A62488&mode=design&t=mwquP6ESFxyCvrku-1

We've made significant progress on finalizing the UI templates and currently the "Liquidity adding" and "Swap" pages are finished. We have brought the pages to a general style and are now polishing the details. "Margin trading" page is not yet ready but it will requite us to finalize the smart-contracts first (which is currently in progress). Auto-listing is partially completed.

Another major change that we did in the UI is the support of the "double standard" tokens. We are now planning to integrate the tokens created via the Token Converter natively in order to establish a new paradigm "Now every token is available in two versions on Ethereum mainnet: ERC-20 and ERC-223". Here are few example of the rework:

Old Swap page

Old_Swap

New Swap page

New_Swap

Old Liquidity page

Old_Liquidity

New Liquidity page

New_Liquidity

Old Account management

Old_Account_tab

New Account management

New_Account_tab

If you have any wishes or feature requests feel free to submit them in the comments to thig github gist or via our telegram channel.

Introducing a whole new "Trust score" system

We implemented a new trust score systems that will automatically calculate the value for every token displayable in the user's interface. This system is purely UI-based and it's just comparing the token lists. The main purpose of this system is to protect user from an obvious scam. For example if the user is going to swap some token USDT for a token called "USDC" but there is another token called USDC with a different contract address and the other USDC is listed in more token lists and (most importantly) it is listed in the default token list while the one the user is going to trade is not. This raises a big red flag indicating that the pseudo-USDC can be a scam token and we need to highlight it.

Trust_rating

ERC-223: Token Converter update

There was a small but important update to the Token Converter which is basically related to the live ERC-223 implementation. There was a lot of debates on whether the native currency can be transferred with the token in one transaction or not. As of now - we decided to focus on the implementation that allows the native currency (ETH on Ethereum) to be paid alongside token.

This will allow us to make it possible to deposit liquidity of ERC-223 token and native currency in one transaction potentially lowering the gas costs.

https://github.com/Dexaran/TokenStandardConverter/commit/082ee1f06c8dbb5ae996d02019a765bb488a88d1

@DrMordoMD
Copy link

Looks good! Keep up the good work!

@ghiocel30
Copy link

Dexaran ,migliore nel mondo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment