Since the meteoric rise of DeFi last year we have many options to exchange tokens using several decentralised exchanges built straight onto the block chain. They work great and have been a massive boon to the fledgling DeFi industry. UniSwap could even be called the spider in the DeFi web. All is not well however, and the issue I wish to address here is that DeFi is basically becoming too expensive to use for the general public. The native Ethereum token ETH has risen tremendously in price and on top of that the gas price on the network has risen due to congestion. Moreover, the fees that most DEXs charge is in the order of 0.3% of the trade value which is just quite expensive. These high trading costs have become such a problem it’s starting to damage the growth of the DeFi ecosystem. Thus, I believe there is space in the market for an Ethereum based exchange that competes on cost. That is to say, an exchange which allows users to swap tokens at lower gas fees and lower exchange fees. To put it simply: I believe the DeFi community wants and deserves a lean, mean swapping machine.
The value proposition of a low cost exchange
So why don’t we just build a DEX that has low fees? Sure, the customers who do swaps and the arbitrageurs would welcome such an exchange, but how can we convince the liquidity providers (LPs) to commit their capital to provide liquidity if the fees (which provide their revenue) are drastically reduced? There is only one answer that makes sense: by having the exchange turn over significantly higher volume per unit of liquidity. This is the objective of DeFi Plaza; To provide an exchange which offers such favourable conditions to its user base that it will generate more than enough volume to compensate the LPs for the lower level of fees.
Although there are many different fee levels being charged for DeFi trades, the benchmark level is set by UniSwap at 0.3% for dissimilar tokens. Off-chain centralized exchange fees are typically in the order of 0.1% of the trade value for everyday customers. The DeFi Plaza will go live with a fee level of 0.1% for 120 trading pairs between 16 of the largest and most liquid tokens on the Ethereum DeFi ecosystem. Consider below the fee for a trade from ETH to LINK on one of the various Ethereum main net exchanges:
A note on capital efficiency
So how could we get away with charging so much lower fees than the competition? The answer is by drastically increasing the efficiency of the deployed capital. To understand how this works, consider the history of UniSwap. In UniSwap v1, the capital would be allocated in pairs with ETH. In other words each token would be tradable against ETH. If we want to go from LINK to say DAI, internally UniSwap would trade your LINK with ETH and then that ETH with DAI incurring extra high gas costs and higher fees.
With UniSwap v2 came the ability to create pools between two arbitrary tokens directly, such that for popular trading pairs the hop to ETH can be avoided. This increases capital efficiency with respect to UniSwap v1. For UniSwap v3 the main improvement is ‘concentrated liquidity’, which is a high-tech engineering marvel that aims to further dramatically increase capital efficiency.
Concentrated liquidity allows you to earn N times the fees in exchange for suffering N times the impermanent loss. Also, when the price ratio moves outside of your configured bounds you completely stop earning fees but still rack up more impermanent loss. To prevent that from happening you need to rebase the ranges, which requires realising the impermanent loss. This makes liquidity providing a bit like options trading. If you guess the trading range correctly you can make good money. If not, you’re in for some losses instead. I’ve not been able to get data on the actual performance distribution of individual LPs, but I doubt that for dissimilar tokens they’re doing significantly better than with v2. And at least as important, for dissimilar tokens the default pair fee is still 0.3% and the high complexity means that the gas costs have only gone up. For end-users v2 is simply the superior product as for them it achieves the same thing at lower cost.
What would really fundamentally improve capital efficiency is to extrapolate the line that was set from UniSwap v1 to UniSwap v2. Where v2 would allow arbitrary pairs of tokens, I would have expected v3 to allow arbitrary pools of tokens. With multi-token pools, each token can be used to trade against all the other tokens in the pool. Balancer has done pioneering work in this domain, focussing on the imbalanced pairings and pools.
DeFi Plaza is a multi-token exchange, which lists 16 tokens. Since each token can be traded against every other token, this creates 120 unique trading pairs. The tokens that have been selected to be listed include the highest volume and most liquid tokens in DeFi. Thus, for 16 units of liquidity we enable 120 trading pairs, where pair based exchanges require 2 units of liquidity to enable 1 trading pair. This creates a fundamental improvement of a factor 15 in capital efficiency with no real downside.
If the market validates my hypothesis, pair based exchanges are now essentially obsolete for established, high volume tokens.
What about L2 solutions?
An argument is made that by moving volume to L2 implementations like Polygon, we can unload the main chain and lower transaction costs. However, L2 solutions suffer from several disadvantages that make me consider them work arounds rather than actual solutions:
- L2 breaks composability. DeFi is about an ecosystem of assets and dApps which can interact without friction in a single transaction. By moving to L2 this feature is broken and thus in the long run it simply won’t work.
- L2 introduces new security risks. For Bitcoin and Ethereum we have ample experience with the proven PoW security mechanism. The robustness of the security protocols and features of L2s still need to be proven.
- L2 introduces serious friction in the form of time and/or money to move assets back and forth.
- L2 breaks auditability. Things become much harder to keep track of when it is moved between chains.
While some users may not have any issues with waiting for 7 days to move funds on/off an L2 network, I don’t consider this an acceptable solution. In the long run, something is needed that solves the scalability and composability problem in the L1 (check out Radix), but in the short run I think the Ethereum ecosystem needs something that allows us to do swaps on Ethereum L1 at a lower cost point for both network costs and swapping fees.
Improving gas efficiency
During periods of network congestion the gas costs are a major factor in overall DeFi transaction costs. With the DeFi Plaza implementation an effort was made to save as much gas as reasonably possible in the actual execution of individual transactions. The primary focus for these savings are the end-user facing functions for swapping, liquidity add/remove as well as (un)staking transactions. Savings were mainly achieved in the following places:
- Everything in a single contract. Without a router there are fewer external contract calls, saving gas. And because all liquidity is in one big pot direct swaps between any two listed token become possible saving gas as well as fees.
- ETH not WETH: Using WETH makes the code cleaner and more generic, but it comes at the expense of additional gas costs. So I chose to make some ugly code to avoid the wrapping token to save some gas.
- Mappings over Arrays. It may not be pretty or convenient, but if it’s gas efficient I’m still doing it.
- No flash loan functionality. Flash loans are great, but enabling them requires additional complexity. For DeFi Plaza v1 I’ve decided they’re not core to the mission. Future versions may see flash loans enabled.
- Use variable packing where possible to minimise reads and especially writes to/from the blockchain.
- Minimising the amount of function calls to the bare minimum. Especially external calls.
It’s difficult to do a fair comparison of gas costs by simply looking at historic transactions as there is significant variation depending on whether there are new variables stored or gas rebates due to variables being reset to zero. Thus, I’ve run an experiment in a controlled environment (a forked main net) to enable a like for like comparison for a token swap for one of the most popular tokens in DeFi. See below the gas used in a swap transaction from to ETH→LINK, with no extra gas charges/rebates for storage changes.
DeFi Plaza is significantly leaner on gas than the competition, and the ETH to LINK example is actually quite favourable to the competition as they all have direct ETH-LINK pools (save for Bancor which has to go via BNT). If a swap needs to touch multiple pairs to complete the gas fees increase rapidly as can be seen from the Bancor example. For example, should we want to exchange LINK for MATIC, then the gas costs for DeFi Plaza remains low while in pair based exchanges it would increase dramatically as they don’t typically have LINK to MATIC pairs available.
For liquidity add/remove, as well as for staking transaction similar gas savings have been achieved. I’ll present comparison graphs in a separate Medium post as this one is plenty long already.
Managing a high volume, high liquidity exchange
To generate most value for all its users, the exchange should attract as much liquidity and trade volume as possible. Thus, the tokens initially listed include those projects that are likely to generate the highest DEX liquidity and trading volumes. For technical reasons the contract is hard coded to have 16 listed tokens, including ETH itself. If DeFi Plaza is successful, simply being listed here would drive up demand and trading volumes for any token similar to how S&P 500 inclusion drives demand for stocks on the NYSE.
DeFi Plaza will start with a single DEX, listing the most liquid and high volume tokens ERC20 tokens. If the market shows an appetite for this type of DEX, I anticipate that there will be a MidCap and SmallCap (MoonShot) exchange as well. These need separate exchanges as within an index the liquidity per token balances out to the same dollar value through arbitrage. If smaller projects were to be included into the primary exchange they would cause a drag on liquidity for the whole exchange. Optimum fee levels may be different since liquidity and volume will be lower there.
Fees on the exchange will start at 0.1% but can be configured anywhere between 0–100%. It’s unlikely that 0.1% is the optimal fee for the exchange, and I intend to explore the impact of changing the fee on the performance of the DEX. Balancer has already implemented variable fees based which are largely based on volatility. I’d propose dynamic fees based on market share of trading volume. This requires targeted experimentation with the level of fees. Once the exchange has been up and running for a while without code issues and the community has organised, the process of fee optimisation will be started.
Which gives us a nice segue into governance. Yes, DeFi Plaza will introduce a governance token called DFP (sorry Andre). This is a real product, which should be supplying real revenue. Once it has gained sufficient momentum in the marketplace it should be able to sustain itself without demand driven by a liquidity program. However, a governance token is a proven method to gather momentum, as well as helping achieve some secondary goals:
1) To recover cost of development and deployment to the team.
2) To provide an ongoing incentive for the team to further improve the product.
3) To allow a lively community to form around the project with decision making power over the direction. It is fully intended to phase over from dev control to community control as soon as the project has a community powerful and trusted enough to carry the project forward. There is a real need to make collective decisions, since choices around which tokens to list and which fee structure to use are real knobs to steer both LP revenue and risk profile.
4) To reward early adopters for their trust in the platform and their help with making it grow. I deeply believe that the project needs to be designed such that it can stand on its own and be an attractive product even when there are no liquidity incentives in the future. However, as the platform still needs to be proven there is a need to bootstrap liquidity and supplying a governance token liquidity reward is a proven method to achieve that even in a high risk (we test in production) environment.
The governance token will be used as means for the community to vote on the direction of the project. Which tokens to (un)list, which exchanges to launch, fee structures, collaborations, etcetera.
The governance token is a fixed supply token which can be mined by staking the exchange index liquidity token XDP1. Over a period of one year all 100MM will be released. At launch, there will be 1MM (1%) loaded onto the exchange as bootstrapping liquidity. A further 4MM (4%) is unlocked to recover development and deployment costs. 5MM (5%) are granted as a founder reward which is locked for 1 year to incentivise continued commitment to the project. 5MM (5%) of the tokens are reserved for a community multisig wallet to be spent in whichever way the community believes furthers the interests of the project. The other 85MM (85%) of the tokens are available for the community members as liquidity rewards.
The 90% of tokens that are allocated to the community are released over a period of 1 year, following a quadratic curve that is designed to taper off smoothly towards zero release rate at the end of the program. The total governance token amount in circulation including all allocations and their release is shown below.
The roll-out of DeFi Plaza
DeFi Plaza is live. You can find it at https://www.DeFiPlaza.net
The exchange is completely live. Liquidity can be added and LP index tokens can already be staked. Governance token distribution starts on Saturday June 26th at 16:00 UTC. Initial APR is ±1000%, which may change as it depends on the price of the DFP token on the DEX. This is a grassroots project. No marketing, no influencers, no ads, no nothing. DeFi Plaza depends on word of mouth to draw attention to the project. As I think it should be.
The exchange is here: https://www.defiplaza.net
The smart contract for the exchange is here.
The smart contract for the governance token staking is here.
There’s a telegram group at https://t.me/defiplaza
There’s a Twitter account at https://twitter.com/defiplaza
A word of caution & disclaimer
This project is an AMM experiment by a random guy from the internet. Nothing more, nothing less. Though I did my absolute best to make a secure and efficient exchange, there could be scenarios that I missed in testing. Thus, the real test of the concept is in production. The code is unaudited. It’s just me testing on my machine. And I’m not a professional coder, I’m an engineer. But I guess if you don’t constantly experience a sense of dread and impending doom while working on a project, you’re not using Solidity right.
Anyway, the message I want to convey is that this project should be considered very high risk. It’s not unlikely we’ll have to migrate the whole thing over to a new version down the line. Maybe even multiple times. It could cost transaction fees. It may even be worse because despite my best efforts it’s entirely possible that there are exploits lurking in the code. Stripping to the core helps reduce the attack vectors, but it’s still Solidity so who’s to say for sure, really?
Please review the code carefully and let me know if you find anything and/or forward it to people who can review it for us. I’ve seeded the DEX with a good chunk of my own net worth to show my personal confidence & commitment. And I’ve set up the liquidity rewards release curve to reflect the increased risk to early liquidity providers. Still, I take no responsibility whatsoever for any losses that you may incur when engaging with the DEX.
Who are you?
Hi, I’m Jazzer, some random guy from the internet. I’ve been active in the crypto community for quite some time, mostly as a moderator in the Radix community.
Why u no share your personal details?
It doesn’t matter who we are. What matters is our plan.. Nobody cared who I was until I put out the DEX.. Basically I’m not sharing my personal details because they’re personal. I appreciate some privacy, it would be nice if you respect that. Thanks.
Why DeFi Plaza?
Basically because I think the Ethereum ecosystem deserves a low cost DEX, and it’s something that I just want to use myself. It is my personal expectation that the long term future of DeFi lies outside of Ethereum for technical reasons. Several teams are working on solving the problems that need to be solved, and myself I’m a big fan of the global scale DeFi enabling tech that Radix is rolling out. Unfortunately it will be a while longer until we can enjoy its full benefits. It is my hope that in the meantime DeFi Plaza can squeeze a few extra miles out of DeFi on Ethereum L1.
You’re from Radix? Is this project connected to Radix in any way?
No. It is just me. I did this. Don’t go bother the guys at Radix because of DeFi Plaza. They have a project to carry over the finish line. The Radix main net goes live next week. Leave them alone please.
This exchange looks conceptually similar to Behodler.
DeFi Plaza is inspired by the single contract exchange concept I encountered with Behodler. However, upon closer inspection Behodler is not a low cost exchange. It’s more of a multilayer thriftcoin liquidity experiment with (imo) totally unsustainable logarithmic bonding curve economics. Unfortunately, their team waved away my concerns on the matter. Thus, I basically set out to build from scratch what I believed Behodler to be when I first heard about it.
Do you have a white paper?
Aint nobody got time fo’ that. Also, I believe white papers are for fundamentally new tech. There isn’t much new tech here, it’s mostly combining bits and pieces of things that are already out there, stripping it to the core, optimising the implementation and choosing a different low cost operating philosophy.
Your software architecture sucks!
I know, it’s to save gas.
Why don’t you use factories or proxy patterns?
Because that would cause more gas usage.
Your code is ugly.
I know, but it saves gas.
Also, I’m an amateur. ;)