Skip to content

Instantly share code, notes, and snippets.

@Dexaran
Last active June 5, 2024 02:07
Show Gist options
  • Save Dexaran/c671c41dde06856ca20493126f3bb56f to your computer and use it in GitHub Desktop.
Save Dexaran/c671c41dde06856ca20493126f3bb56f to your computer and use it in GitHub Desktop.

Dex223 development report (6/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.

Core smart-contracts

Source codes:

The implementation of the core Dex223 smart-contracts is finished. Currently we have a 'basic' version of the contracts ready and deployed on testnet (Sepolia). The contracts support both ERC-20 and ERC-223 standards, all the trading features, liquidity providing (in both standards) and fees claiming (also in both standards).

Merged liquidity concept is implemented.

The contracts are not fully optimized and we expect that it will take few iterations to fine-tune the system to optimize the GAS usage with the help of ERC-223.

You can interact with the contracts on Sepolia:

(POOL_INIT_CODE_HASH if you are planning to implement a custom router compatible with Dex223 pools: 0xeec262796ecc14445f5c61bc47690b549e0fb69dbc0b99b87ae5b61b9707cdf5)

Dex223 contracts have undergone a structural change compared to Uniswap. In Uniswap every Pool (a contract that actually holds tokens and performs "swap" and "liquidity" actions) actually implements the logic of all its features i.e. Uniswap V3 Pools are different contracts each with its own code but in fact they all copy-paste each others logic.

UNISWAP_struct

In Dex223 Pools do not implement logic but instead pull it from one library contract i.e. Dex223 Pools act as proxies. They only hold token balances and implement a minimal set of functions but the actual logic is stored in one contract that all pools connect to.

DEX223_struct

This update allows us to drastically reduce the costs of creating new pools (and listing new tokens as a consequence) in theory. However, calling a library contract from a pool may cost some gas which may entail the increase of operational costs. Our main priority is to optimize the cost of "swap" actions so we are trying to find a reasonable balance here.

Dex223 Prototype

As the smart-contract are already deployed on the testnet we are moving closer to the launch of a fully-functional prototype of the DEX. The basic version of the UI is almost finished and it is currently undergoing internal testing. We are planning to publish it in few days (as soon as the found bugs are fixed).

The initial version will work with the contracts deployed on Sepolia testnet. It will support basic trading features (swaps and liquidity providing) in both token standards. Shortly after the launch the auto-listing feature will be supported.

Margin trading will come mid July most likely.

The UI source codes will be published in few days under EthereumCommonwealth github organization.

Auto-listing contracts concept is finalized

The logic of auto-listing is completed and we already have a prototype smart-contract https://github.com/EthereumCommonwealth/Dex223-core/blob/41a1d0ac22763138e55e79d98b732a052e8105fe/Autolisting.sol

The basic auto-listing contract is supposed to become a template for all the future listing contracts.

Testnet prototype of the DEX will support free auto-listing contract initially, so you can list your testnet tokens automatically and they will appear in the test UI.

Most likely auto-listing implementation will be completed by mid June.

Margin trading concept has been finalized and the implementation of smart contracts has begun

Margin trading has been the most complex yet most anticipated feature of the DEX and now its actual implementation has begun. We can currently share some drafts of the UI. The whitepaper will be updated to include a proper documentation of the margin trading concept during June. We expect that the margin trading module will be finished in July-August.

Dex223 margin trading module will definitely be the most flexible implementation on the market. In Dex223 users will be allowed to create "lending orders" where they can specify the terms for lending their funds including: (1) maximum leverage, (2) allowed trading operations, (3) interest rates and some others. This means that as long as there are lenders who allow trading PEPE2.0 with 1000x leverage - it would be possible on Dex223. In fact what is possible and what is not is determined by the market, not the exchange dev team. Our goal is to provide a tool that traders can use without restrictions.

On the downside this places risks on the lenders (should someone allow trading some memcoin with 1000x leverage the chances of them losing funds in the process become non-zero) and overcomplicates the UI.

Margin trading will be discussed in detail in the next development report.

Screen_Lending_1

Screen_Lending_2

Screen_Lending_3

UI

The most important UI updates are connected with the margin trading implementation this month. As always it is possible to observe all the UI improvements in our Figma here:

https://www.figma.com/design/LUTEwFhYezZyhcudBV5FkG/%F0%9F%94%84-DEX223-Exchange-(Copy)?node-id=2460-62488&t=MdJOHu1Mx9VzXK7b-1

ERC-20 Losses Calculator

ERC20_Losses_UI_improvement

Live ERC-20 losses calculator will receive an update in the future. It's new design can be reviewed here https://www.figma.com/design/xIF7sfOBkdc0dx1e0mekCk/%F0%9F%A7%AE-ERC-20-losses-calculator-(Copy)?node-id=1-2&t=nkpHgPngn1I1awDI-1

As we are planning to give the ERC-20 issue more exposure it is becoming more important to represent it in a visually appealing way.

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