- Moderator edit to add link to on-chain proposal: Mintscan - Chain explorer by COSMOSTATION
Hi Cosmonauts!
This document is the draft signal proposal to adopt the Liquidity Module(DeX) onto the Cosmos Hub. Please share the valuable thoughts and suggestions about the Liquidity Module!
The proposal will be submitted to the Cosmos Hub after two weeks(25th Feb) from today.
Thank you!
Proposal to Adopt the Liquidity Module onto the Cosmos Hub
Summary: Tendermint (https://tendermint.com) and B-Harvest (https://bharvest.io) have joined forces to produce and develop a Liquidity Module (GitHub - tendermint/liquidity: Cosmos SDK Liquidity module). This signal proposal is a Request For Comment to the ATOM community regarding the addition of this Liquidity Module into the Cosmos Hub source code.
By voting YES to this proposal, you will signal that you approve of having a DEX based on this specific Liquidity Module deployed on the Cosmos Hub.
2020: The Year of DeFi
For the crypto community, 2020 has been the year of DeFi. Websites like DeFi Pulse have recorded a transition from centralized, custodial exchanges onto DEXs like Uniswap. In September of last year, trading volume on Uniswap surpassed the trading volume on Coinbase for the first time. Throughout 2020, the total value locked (TVL) in Ethereum DeFi apps has risen from USD 0.7B to USD 23B.
How do we bring this activity to Cosmos? Our proposed solution is to do that through the Cosmos Hub, that will act as an Interchain router.
Cosmos & DeFi
In Cosmos, a diverse developer community has used the Cosmos SDK to build projects that currently secure over USD 22 billion in digital assets. A large number of these projects provide DeFi services. Gravity Bridge, by Althea, plans on bringing an ETH peg directly to the Cosmos Hub. Sovereign chains like Terra and Kava are providing IBC stable coins and synthetic assets. Ethermint is a fully compatible chain with Ethereum web3 tooling and allows developers to port Solidity contracts. Persistence is working on delivering asset-based lending assets to the interchain.
With Proposition 37, ATOM holders have voted to upgrade to Stargate, fulfilling the original Cosmos whitepaper from 2017. In the next proposal, ATOM holders will vote to enable IBC transfers. This proposition will allow native tokens to be transferred to and from IBC-compatible blockchains, fulfilling the promise of the internet of blockchains.
Why the Hub needs a DEX
For the Cosmos Hub to function as an interchain router, it needs to create incentives for users to transfer tokens. The most direct way is for the Hub to create liquidity for the greater interchain economy. Token holders need a trusted way to discover the prices of tokens, exchange tokens, and generate liquidity via pools. We think these services belong to the Hub. By adopting this DEX, ATOM holders will lay down the first, âsine qua nonâ component of a Hub-centric interoperable financial ecosystem that will provide all stakeholders with innumerable exciting opportunities.
What is the âLiquidity Moduleâ?
The Liquidity Module is a new Cosmos SDK module that allows the implementation of a token DEX on any Cosmos SDK based network. It will enable any user to create a liquidity pool with a pair of tokens, provide liquidity by depositing reserve tokens into the liquidity pool, and trade tokens using the liquidity pool.
How does it work?
Liquidity Module has two major distinctive characteristics:
- First, it combines a traditional order book based exchange system with a Uniswap-like AMM (Automated Market Maker) mechanism. This hybrid system deepens liquidity for the token swap marketplace.
- The second major characteristic of the Liquidity Module is batch-style swap execution. The order book accumulates incoming limit orders into a batch. It matches accumulated limit orders and orders from the liquidity pool at an equivalent swap price at each batch execution height. All limit orders in a batch are treated equally and executed at the same swap price. This mechanism minimizes front-running risk and sub-second latency competition, thereby protecting ordinary traders.
Proposed fee structure
Liquidity providers earn fees through the creation of pools and the supply of tokens. The initial analysis proposes the following fee structure:
- Swap Fee Rate = 0.003 (0.3%)
- Pool Creation Fee = 100ATOM
An additional fee is charged on all withdrawals to protect pool investors from attack vectors and maintain pool stability. An appropriate rate could be 0.003 (0.3%)
All transactions incur a gas fee. Readers can find further details in the light paper.
Risk Management
Risk management is focused on two areas, code base and the model. These are mitigated through the following strategies:
Codebase Vulnerabilities
- Test Coverage Over 80%: Minimum criteria of test coverage for Liquidity Module is 80%.
- Extensive Simulation Tests: We conduct extensive simulation testing for core functionalities of the Liquidity Module.
- External Audit: an independent audit of the codebase is due to start shortly.
Economic Model Risk
- Economic Simulation with Agent-based Model: We conduct economic simulation on Liquidity Module with an agent-based model. The report will be published in early March.
- Testnets to assess pool performance
- Optionally a phased mainnet release with pools limited in size initially.
Node Performance
The Cosmos Hub is likely to experience an increased number of transactions coming from new features, such as IBC and DeX. Most new DeX transactions will be swap orders from different liquidity pools. Increased traffic on the Cosmos Hub could cause performance issues for blockchain nodes with less computational resources. It may also require tuning of genesis parameters. For example, an increase in block_size will allow for larger block space.
We have tested the performance of Liquidity Module by submitting many swap order transactions into the state machines. From our testing, with two cores, 8G RAM node specs, it concludes that,
- All transactions are well broadcasted and committed to the blockchain when the transaction-per-block rate is less than 400.
- When transaction per block is about 400, the average block time increased from 6.19s to 6.90s (0.71s increased).
- When transaction per block is higher than 400, the nodes started to lose a significant number of transactions.
To conclude, if there are frequently more than 400 swap order transactions in a block, it will be necessary for node operators and validators to review their hardware capacity.
Also, to allow an increased number of transactions within a block, we have to increase block_size as follows, assuming additional 1,000 swap order transactions in a block:
- max_bytes : 150,000 â 500,000 ( 350 bytes per 1 swap message )
- max_gas : 1,500,000 â 81,500,000 ( 80,000 gas per 1 swap message )
Mempool Policy
The sorting of transactions that are to be included in a block is primarily decided by the state machineâs mempool policy. In most AMMs, sorting of swap order transactions impacts significantly on their execution price. Hence fair sorting policy is very crucial. Our AMM does not prioritize swap order transactions based on transaction sorting in blocks thanks to our batch execution model. Every swap order transaction is treated equally, and the execution price is equivalent for all swap order transactions within a batch.
Next steps
The Liquidity Module code is due to be ready by mid-March. At this point, the code will enter the Quality Assurance phase.
Testing
As mentioned above, the team has performed extensive testing through test coverage, simulation (i.e. fuzzy testing), and performance testing. Economic testing is underway and will be completed at the beginning of March, before performing full integration testing and the launch of testnets for the community use soon after.
Review
Risk management already mentioned an external software assurance audit as an essential artifact. The process to select an auditor is underway. Once their recommendations are received, they will be implemented as needed.
At this point, a final governance proposal to upgrade Gaia (the state machine of the Cosmos Hub) to include the Liquidity Module will be raised.
Conclusion
The potential of the Cosmos Hub AMM is inspiring. With IBCâs asset transfer capability, it offers Cosmos Hub an opportunity to become the center of the interchain financial ecosystem.
Appendix: Pool Investment Opportunities
Assuming adoption of the Liquidity Module on the Cosmos Hub, ATOM holders will have an additional utility for ATOM to be invested in liquidity pools. The graph below is a theoretical analysis of a liquidity pool investment based on an ATOM/$STABLECOIN token pair.
Assumptions
- Annual percentage yield from swap fee distribution to liquidity pool investors is assumed to be 10%, 20%, 30%, 40% and 50% respectively.
- The average Atom price for a year is assumed to be the average of Atom prices at the beginning and end of the one year period.
- HODL APY: It assumes the investor holds 100% ATOM for one year period
Annual Percentage Yield (APY) Analysis
In the below graph, X-axis represents Atom price change after one year; Y-axis represents an annual percentage yield of the pool investment with each assumption. It suggests that the pool investment has a better risk-return profile for most scenarios, except for a sharp increase in ATOM price. The pool investment gives safer and more balanced profit opportunities than just holding the assets(HODL). In the case when ATOM price decreases, it provides some protection from significant loss.
The below data is produced by a simulation based on the assumptions above; therefore, it is NOT meant to be a reliable ROI forecast analysis and should NOT be taken as investment advice.