funded

Maladex: Algorithmic Swaps Protocol

$50,000.00 Received
$50,000.00 Requested
Ideascale logo View on ideascale
Community Review Results (1 reviewers)
Addresses Challenge
Feasibility
Auditability
解决方案

Maladex算法自动做市(AAMM)健全和高资本效率的并发协议,动态调整市场。

Problem:

提议的Cardano DEX模型是低效的:资本效率低,无常损耗高,而且容易在并发性上挣扎。

Yes Votes:
₳ 392,129,925
No Votes:
₳ 4,979,460
Votes Cast:
2334

This proposal was approved and funded by the Cardano Community via Project F6: Scale-UP Cardano's DeFi Ecosystem Catalyst funding round.

  • download
  • download
  • download

Detailed Plan

ヾ(^∇^)

<u>Glossary</u>

We start by introducing a series of concepts important for decentralised market making. We suggest that you read it first, as on top of being dictionary of terms used throughout the proposal, information about those terms that you might not be aware of (e.g. did you know that money can be thought of as energy when modelling financial markets)?

Liquidity - ease of exchanging one asset for the other without affecting the asset price, at the perceived current market value. Naturally the most liquid asset is fiat currency, for instance USD can be exchanged for many assets around the world, it is used in international settlements, and the payments performed by individual organisations, regardless how large do not affect the price of USD.

Model - mathematical description / definition of system, e.g. liquidity model defining how liquidity pool models market dynamics in the response to trades. However, even a poor model can be used for the purpose of modelling, but it will suffer from many inefficiencies (lagging behind the actual state, being too sensitive / having too high inertia, etc.). All CFMM AMM are poor liquidity models (see below for definition of AMM and CFMM).

AMM - automated market maker; a liquidity definition as a supply formula enabling automatic (autonomous - without the presence of maker) trades, preserving certain properties such as path independence (the execution price is not depending on the history of transactions), and for trading without any active interaction from the maker party (makers provide assets into the liquidity pool which are then managed based on pool model / formula).

CFMM (constant-function market maker) - AMM model using constant function; the most famous example is Uniswap v1/v2 model of x * y = const.

Maker - party providing liquidity to the market (pool); i.e. making the market (making it possible for trades to execute).

Taker - party exchanging on the market (e.g. swapping token X for Y).

Quantitative Finance - scientific field using mathematical and statistical modelling for the purpose of investment management. Quant finance enables modelling of complex stochastic (random processes) and building efficient models and accurate predictions. Quant finance is used heavily in traditional finance in modelling markets, managing risk, making both automated and manual investment decisions, to name a few.

DEX (decentralised exchange) - non-custodial exchange executing trades on-chain.

TradFi - traditional finance.

Account Model - a model used by ETH and a lot of other smart contract blockchains, where the global state is shared, and all operations are applied sequentially, one after the other based on tips, giving the rise of front-running, and other exploits or MEV.

Front-Running - refers to using the knowledge of submitted orders, to tip the exchange / protocol, with the aim to insert your order (based on existing information) ahead of other orders, in order to capitalise on this knowledge. For instance, spot a whale swap, tip the protocol to insert transactions before in the block, buy at the cheaper price, allow the whale order to move the market (whale pays more for the order), tip for 2nd order to be placed after the whale order, sell immediately for higher price.

EUTxO Model - accounting model used by Cardano where all assets are stored in EUTxOs (boxes) that can be spent either using private key (e.g. wallet transactions) and (Plutus) script (private key and script are locked on the box). The wallet balance is the sum of all EUTxOs that the wallet can spend. In the EUTxO model each EUTxO has to be spent when used, hence can be only used once per block (20s).

Concurrency "Issue" - a consequence of applying account based models to EUTxO model putting the entire pool liquidity into one EUTxO leading to either requiring an off-chain sequencer to build transaction blocks (but at the cost of centralisation) or to being able to perform only one transaction per block (as each EUTxO can be only spent once per block and to be used each EUTxO must be spent). "Issue" is quoted, since this is a design fallacy rather than the EUTxO model issue, which simply requires a different approach, and to architect concurrency into the protocol itself.

Arbitrage - exploiting the market inefficiency between trading venues (exchanges); in the most simple case of the arbitrage, let's say ADA is priced at $3 at exchange A and at $2.95 at exchange B. The arbitrage bot will find this information and will attempt to buy ADA at exchange B for $2.95 and sell it immediately at exchange A at $0.05 profit per ADA. The act of arbitraging moves the price, as after the execution, the price at the exchange B will be higher (e.g. $2.98) due to purchasing the discounted ADA, and on exchange A it will be cheaper due to selling it (e.g. $2.98). As long as there is a price difference between exchanges, so that when these trades are executed they are more profitable than the execution cost, arbitrage is possible. Arbitrage leads to all exchanges being arbitrage converging on the central limit value (true market sentiment from the aggregated exchanges) of the asset price. The arbitrageur earns profits by buying at discount from exchange B and selling at the premium at exchange A, hence both exchange B sellers and exchange A are the source of income for the arbitrage bot, and are "victim" of the market inefficiency (in reality they are not victims, but simply prone to be scalped this way). Finally, the mentioned example is the most basic case of arbitrage (pure arbitrage), there are multitude of arbitrage styles, including statistical, where arbitrage is based on the market movement predictions and the average expectation of reward <https://en.wikipedia.org/wiki/Arbitrage#Types> . Arbitrage leads to efficient price discovery, but at the cost of market participants (both takers and makers).

Slippage - difference between the expected price of a trade and the price at which the trade is executed. In the AMM model, slippage occurs due to not large enough liquidity compared to the amount of assets being swapped.

MoneyEnergy - when modelling financial systems you can think of money as a unit of energy, same as in physics, we can think of kinetic, potential, and other energies, energy is potential to perform a certain amount of work. We can think of money in the same way, money has potential to be applied in the market from lending to businesses developing novel ideas, increasing market efficiency by providing liquidity to exchanges, creating information flow via arbitrage and financial analysis and research, to utilising available information to maximise returns given a specified risk appetite. However, energy can be applied in many ways, if we choose a very inefficient way to do something (e.g. growing tomatoes in a completely dark underground bunker we will expend a lot of energy) when we can put it in a greenhouse or even on a balcony and make much more energy efficient use. Same in the capital markets, efficient models lead to high money utility (energy well spent towards productive work), and productive work is the work that usually is associated with the rewards (e.g. business borrowing money will pay it with interest). Therefore, an efficiently allocated liquidity will work very well even with low total value locked and respond quickly to the changing market dynamics, bringing higher rewards per unit of capital.

Capital Efficiency - each task has many ways of being performed, one way will consume more resources (energy, time, etc.) than the other, hence the way which consumes less resources and achieves the same result is more efficient. The more efficient use of capital the better generated returns, the better user experience, and the better reflected the actual state of the market.

Efficient Market Hypothesis (Market Efficiency) - a hypothesis stating that the prices in the market reflect all the information available. In practice it is rarely true, a straightforward example is Dogecoin raise to top 10 and firmly remaining there based on a series of Tweet without without anything behind them, and even rebuttal from the Dogecoin development team itself, and market ignoring this information, and irrationally valuating Dogecoin at the higher price. This definitely does not reflect the fundamental information available in the market, and is an extreme case of market inefficiency. In traditional finance, such an overvalued company would be shorted and the research would be published showing its shortcomings, and people would evaluate validity of the study. If an asset would be severely undervalued, a leverage or long options would be bought magnifying significantly the potential returns from the efficient use of information. Under the Efficient Market Hypothesis, an asset would be priced at what they truly are worth and there would be very little difference in the asset prices between exchanges. However, to the contrary, market inefficiency is such a commonly occurring phenomenon that there is a whole field of study dedicated to measuring it and adjusting trading strategies based on it, but most of the time the inefficiencies take root from lack of information flow between exchanges (e.g. via arbitrage) and irrational decision making (modelled well by behavioural investing). But, this is not a problem without solution, it is merely the result of the environment emerging from inefficiencies of the exchanges and irrationality of the actors in the market.

Impermanent Loss - loss of capital when compared to HODLing due to inherent flaws of liquidity pool formula. The worst offenders are ironically the most popular family of constant-product pools such as Uniswap's v1/v2 x * y = const. It occurs when providing a pair of assets into a liquidity pool, as the rations of x and y change in the pool and the more the prices diverge, the bigger the impermanent loss. At some point, around the 20-50% threshold (the range is large due to inherent typical crypto volatility), actually holding the 2 separate assets outside of the pool would have been a better investment. It is even made worse by incentivisation by yield farming to create the most negatively correlated pools there are possible (completely deflationary crypto such as ADA and completely inflationary fiat such as USD). Those two assets will naturally diverge and create the impermanent loss, in a sense out of the gecko the deposited funds have a sizeable hole in the bucket through which the total value of the funds you deposited leaks. … it is even made worse by many DEXes being either only concerned with increasing the amount of transactions (in order to obtain more fees from transactions) to being completely oblivious to this obvious mathematical fact (DEXes are generally built without regard to quantitative modelling).

<u>Problem & Solution</u>

All established liquidity models, including those being currently developed by DEXes on Cardano, do not model markets well (see model, market efficiency, and impermanent loss in the glossary for more info) leading to low capital efficiency (expenditure of large amount of energy compared to the total value locked) and have inherent scaling limit due to global memory (akin to Ethereum accounting model) architecture.

What are the roots of the capital efficiency challenge?

<u>1. Minting sound liquidity pools.</u>

Challenge:

It is very important for the market maker to pick assets to put into a liquidity pool that, given the pool model, will minimise any potential losses while maximising the exposure to money marketing opportunities. Hence, one wants a pair that is frequently exchanged, but at the same one that is able to maintain its inherent value over time, a property that emerges from the specific assets in the pool and the model of liquidity that the pool uses.

In the majority of cases, simple CFMMs such as x * y = const and naive creation of negatively correlated pairs deteriorates the total pool value. The worst offenders are stablecoin in pair with cryptos. Stablecoins are by nature inflationary and crypto is in its nature deflationary. This means that the liquidity pool from day one is a bucket with a hole at the bottom through which your total rewards (rewards from providing liquidity and liquidity locked in the pool) deteriorate or in good case maintain current value (but then what is the point of providing liquidity).

The naive trend following on Cardano has now multitude of DEXes focusing on stablecoins and related liquidity pairs, while the only valuable role of stablecoin is to bridge traditional finance in which we live every day with the world of crypto. Once the bridge is crossed there is very little reason to do anything with the fiat, maybe perhaps except in rare conditions of very soundly designed stablecoins such as Djed which compensates swap of floatable for stable, but in the case of Djed it makes only sense to collateralise Djed with ADA, not to create liquidity pool of Djed fiat and crypto.

Solution:

Provide observation and orientation using on-chain and external data, to provide telemetry when creating or seeding a pool that helps to visualise the capital efficiency and the risks involved (e.g. automatically alert if the pair reserves are negatively or weakly correlated). This way market makers will be able to make much more sound decisions. What is more, we plan to reward the most sounded liquidity nodes with platform tokens (to further incentivize sound decision making).

<u>2. Capital efficient pool models.</u>

Challenge:

Currently, the most predominant liquidity pool models such as CFMM and among them x * y = const are extremely capital inefficient.

In x * y = const and other CFMMs, liquidity is provided equally across the entire liquidity space defined by all (x, y) on the supply curve. This means that there's the same amount of energy reserved for the liquidity to be provided in the least likely scenario (e.g. ADA going to 0 and USD to infinity) as in the most likely scenario (i..e the current trading price). This is incredibly wasteful, and what is worse leads to an unnatural market model.

All prices, given the space is continuous enough, are naturally of geometric nature. Continuous means lack of sudden jumps from one price to another, in practice all markets are jumpy, but to be considered continuous under this definition the jumps have to be small relative to each other (an example of non-continuous markets are exotics such as NFTs).

What does it mean for the price to be geometric? It means that it follows the Wiener process (1-dimensional GBM - Generalised Brownian Motion):

- https://en.wikipedia.org/wiki/Wiener_process ,

- https://en.wikipedia.org/wiki/Geometric_Brownian_motion .

The reason for all prices to be geometric in nature is the relationship between ratios and logarithm, and ratios being how we express dynamic systems (in relation to itself).

Unfortunately, majority of market making formulas have a constant form such as x * y = const or similar, leading to incredible inefficiency in the pool price discovery process. Given, you can model any process iteratively with the worst model, given a step is small enough, it will eventually converge, but in practice it gives rise to such issues as

- slippage - the execution moving the price significantly leading in overpaying for the transaction;

- inertia - pool unable to update its price due to the astronomic size of total value locked having single trades with very little effect on the price expressed by the pool,

- unnecessary expenditure of energy - a lot of energy is wasted where it is not needed (impossible scenarios) and much longer process to converge on the actual price. Yes, arbitrage bots fulfil here a role of price balancer between exchanges, but there is significant lack of arbitrage between any different assets than BTC and ETH. People who exchange cryptocurrency constantly are for sure aware of sometimes gross discrepancies between prices for such liquid assets as for instance Cardano on different exchanges.

Solution:

Perform study of cryptocurrency asset types and families of quantitative models to express the automated liquidity. Provide a rich family of quantitative models for minting liquidity pools with information on what is the ideal pool in a given case and its parameterization. Allow for dynamic on-chain update of the liquidity pool parameters.

<u>3. Liquidity fragmentation and concurrency.</u>

Challenge:

The recent concurrency "issue" controversy only further proved that the majority of blockchain devs think of liquidity pools in very simplistic terms. It is easiest to design a pool with global memory, but then in the case of EUTxO account model it leads to 1 transaction per block (20s), or in case of optimisation running into memory issues (16kB per transaction and 65kB per block).

Solution:

All this issue, while actually EUTxO if utilised correctly leads to a series of very desirable naturally emerging properties. If one shifts from a monolithic blocks of liquidity to fragmented nodes reflecting separate market making decisions, that naturally leads to emergence of geometric pricing models.

Uniswap v3, by introduction of concentrated liquidity and indexes observed the same. People specify liquidity in the ranges they think are good market making ranges and provide liquidity only within this range. As result, from all concentrated liquidity a geometric pricing model emerges.

It is a natural consequence of aggregation of multiple samples each allowing for individual expression of market sentiment. It is due to CTL (Central Limit Theorem: https://en.wikipedia.org/wiki/Central_limit_theorem ) which states that given a large enough set of random samples, a normal distribution naturally emerges.

Therefore, by fragmenting the liquidity into separate nodes all kinds of geometric distributions naturally emerge giving very efficient and market reflective pricing and liquidity models.

When combined with Maladex liquidity scripting language, it allows for expression of all kinds of market sentiments, and hence for an emergence of true market distribution. Maker orders in the liquidity pool express their belief of the market, and given a large enough sample it starts to naturally reflect the entire real market belief.

Hence, not only is there no concurrency issue, if we deal with this extremely complex routing and graph order formation, but it leads to some very desirable properties.

Concurrency still needs to be built into the system, but this is a routing algorithm for block EUTxO graphs.

<u>4. Efficient price discovery via arbitrage.</u>

Challenge:

Information about the makers and takers of asset prices is spread across multiple exchanges. This leads to such gross discrepancies as the 3rd largest crypto (by the market cap) having even sometimes 10-20 cents difference between exchanges. This gets only more extreme for smaller cap coins, as while Bitcoin, Ethereum, and to a lesser extent Cardano are actively arbitraged, the smaller caps are deemed not worthy of running arbitrage and hustle.

This creates a segmented markets between exchanges and lack of information flow. Arbitrage is a useful and necessary information exchange mechanism, and leads to efficient price discovery and convergence to the same price +/- delta delays on participating exchanges.

Solution:

On exchange A one asset might cost $3.00, while on exchange B $2.96. This obviously is a pure arbitrage opportunity - we can buy asset on the exchange B at the discounted price of $2.96 and sell it immediately on exchange A for the premium of $0.04 per unit (for the price $3.00 each).

After such arbitrage operation the assets on both exchanges A and B will now cost $2.98 and there won't be any more arbitrage opportunity, until the prices between exchanges diverge again.

This is not only lucrative to perform such arbitrage, but also leads to increased market efficiency - information from across all different exchanges is exchanged between exchanges leading to establishment of one geometric centric price (in the above example $2.98);

In the EUTxO and script validation mechanism model such arbitrage can be incorporated into a liquidity protocol, which we plan on doing. It will put market makers in the role of performing additional transactions (and earning additional fees), for takers it will provide market efficient price on Maladex reflecting the true market price at given time, and for the other applications it will provide invaluable on-chain price Oracle not approximating the true price, but having on-chain arbitrage proof of it. Such on-chain price Oracle does not have any lag meaning it is much more efficient than any other on-chain price Oracles (it is the optimal state), only subject to lack of liquidity not allowing for convergence of price in the market.

<u>5. Expressiveness of liquidity protocol - Maladex scripting language.</u>

Challenge:

All exchanges, even the most sophisticated centralised ones, offer a very limited number of order types.

For DEXes, usually only either CFMM AMM akin to x * y = const or limit orders.

CFMM AMM has disadvantage of all the introduced market inefficiencies, while limit orders on DEXes often leads to trading pairs without limit orders to execute against, or exploitation of the phenomena by creation of spoof orders (small order to execute at the good market price and significantly off one inserted upon the small order consumption to catch anyone executing using market price orders).

This limited number of ways to express makers' and takers' intentions and beliefs in the market leads to 2 things:

- a lot of manual work and monitoring to the market conditions, in case of some professional traders, even setting multiple alarms at night to check the market conditions;

- inability to express dynamic conditions such as, when the price starts to rise quickly, buy back, when the price starts dropping, quickly sell, create limit order, execute limit order not at once, but in a range over time, perform simple market order, provide liquidity of given parameterization, etc.

Solution:

Design Maladex own order scripting language allowing to express complex market sentiments and to allow for contract composition. This is akin to the idea described by Simon Peyton Jones et al. in <https://www.cs.tufts.edu/~nr/cs257/archive/simon-peyton-jones/contracts.pdf> . Using this scripting language, define the most commonly used order types (market, limit, liquidity pool, etc.), and allow for access to the scripting language.

<u>Founder</u>

Jarek - the founder and lead developer of Maladex experience:

- Master of Informatics from the University of Edinburgh (where Phil Wadler and Aggelos Kiayias research and teach) with specialisation in concurrent and distributed systems, functional programming, and formal methods.

- Quantitative Finance master equivalent degree from CQF (the bespoke industry degree).

- Head of Platforms in an international bank leading 3 teams, architecting and building complex financial systems.

- Citadel Securities (the #1 market market in the world) where I worked on designing and building a novel approach to market making.

- Microsoft Research where I worked on designing and implementation of highly scalable (cluster) machine learning algorithms used in Microsoft Office and Windows analytics (processing exabytes of data).

- Experienced Haskell developer, used Haskell multiple times in both personal and commercial applications, active participant of Haskell conferences and hackathons.

- Completed Plutus Pioneer program 1st cohort and got NFT to prove it.

I believe that my experience gives me the unique ability to combine all 3 intersections - advanced mathematical financial modelling, building scalable concurrent protocols which EUTxO requires, and many years of coding experience.

<u>About Us</u>

We operate stake pool (ticker MAL):

- <https://pooltool.io/pool/261789e4d39000aa333495d4dbe850708a7fe7a996011a6be98060db/> ,

- <https://adapools.org/pool/261789e4d39000aa333495d4dbe850708a7fe7a996011a6be98060db> .

We are engaged in the community promoting Cardano, answering questions (of all types, not only related to our project, including how to implement concurrency in EUTxO).

<u>Funding</u>

Total: $50,000

This project should receive significantly more founding due to its complexity and everything involved in delivering it, but we are conscious of other more popular projects applying in the same category (dcSpark, Minswap, and Indigo), and from experience in fund 5, we know that it is foremost popularity contest, hence we tapped down the amount to be able to receive the funding, if we made the list 4th (after those 3 projects).

This is a minimal funding possible to perform this work and we might need to apply in the future for additional funding (from audit to expanding any of the outlined concepts further).

Breakdown:

- 320 hours research and quantitative modelling of AAMM protocol, publication write up

- 320 engineering hours implementation and testing

- 80 engineering hours front-end design

Average price per hour $70 incl. VAT and tax.

<u>Personal Funds Contribution</u>

I have been building this project already since April 2021 and applied unsuccessfully for funding in fund 5: https://cardano.ideascale.com/a/dtd/DEX-Cardano-Decentralized-Exchange/352819-48088 .

To be able to continue the work, I have put $50,000 of my own funds toward the project, of which only part has been spent thus far.

I have spent money for hiring graphic designer who created a lot of custom art for us, I have employed developers via Upwork, and paid for the infrastructure (over $2k per month) which hosts private Cardano testnet, current website, MAL stake pool, and much more, paid for marketing, and many single time expenses.

At the same time, I had multiple parties from VCs to private investors reach out asking to invest significant portion of the funds in the project. However, thus far we did not take any of those offers as one of the goals of our project is economic decentralisation (fair and wide distribution of the tokens in the community).

Thus far I have spent akin to $20-25k on the project development. To be clear, this is money I am never getting back as I do not receive any tokens, etc. allocation for it, we have got only fixed supply of tokens for the team (20%) which will be vested over the many years that project is being build. This means that I have got a lot of skin in the game, and the reasons I am working on this projects, which are the ideals I believe in.

<u>Features</u>

We have got a unique and refreshing approach to DeFi.

For full description check our site: <https://maladex.com/#features> .

But, to outline our approach in the case of AAMM protocol:

- capital efficiency - we make the best use of all funds locked, your funds are generating more revenue, and as the taker you find better prices.

- risk control - we build risk control mechanisms into the protocol.

- research and new frontiers - we push the frontier of the entire DeFi ecosystem forward, and we do it on Cardano.

- powerful tokenomics - we have got one token for all our projects, and check how much we work on at <https://maladex.com/#roadmap> , and we not only have fair launch, we plan on distributing the token to the wide community to engage everything in the protocol and its decentralisation via the shared ownership.

- one of a kind team - people with experience akin to our are not interested in DeFi because their day to day job pay exceedingly well and they are surrounded by some of the brightest minds in the industry, we however base our decisions on the goals of decentralisation and wide access to means of increasing financial wealth (hence financial revolution), we put our hearts into the project because we want DeFi as the concept to be successful and Cardano as a blockchain, and we build the future in which we want to live ourselves.

<u>Definition of Success</u>

1 month: collect on-chain telemetry, categorise financial assets, apply stochastic modelling, design fragmented liquidity model, write draft white paper

3 months: publish AAMM research paper, implement the protocol in Plutus and Haskell, testnet evaluation, stress and performance testing

6 months: launch AAMM swap protocol.

12 months: establish a new industry standard of market making proving the superiority of EUTxO model and pushing DeFi ecosystem and how we think about designing DeFi protocols to a next level.

You can read more about our project roadmap that goes beyond AAMM on our site: https://maladex.com/#roadmap.

Expected launch date: Q4 2021 / Q1 2022.

社区顾问评论 (1)

Comments

Monthly Reports

close

Playlist

  • EP2: epoch_length

    Authored by: Darlington Kofa

    3分钟24秒
    Darlington Kofa
  • EP1: 'd' parameter

    Authored by: Darlington Kofa

    4分钟3秒
    Darlington Kofa
  • EP3: key_deposit

    Authored by: Darlington Kofa

    3分钟48秒
    Darlington Kofa
  • EP4: epoch_no

    Authored by: Darlington Kofa

    2分钟16秒
    Darlington Kofa
  • EP5: max_block_size

    Authored by: Darlington Kofa

    3分钟14秒
    Darlington Kofa
  • EP6: pool_deposit

    Authored by: Darlington Kofa

    3分钟19秒
    Darlington Kofa
  • EP7: max_tx_size

    Authored by: Darlington Kofa

    4分钟59秒
    Darlington Kofa
0:00
/
~0:00