The End of Fragmentation

Astroport
9 min readAug 31, 2023

Introduction

Neutron is leading the growth of the Atom Economic Zone (AEZ) by driving liquidity from around the Cosmos and beyond it into ICS Chains. An advanced DEX that supports the needs and wants of traders and market makers is a key primitive to fulfil that mission.

The proposed merger between Neutron and Duality is exciting because it would give Neutron access to one of the most advanced liquidity primitives in the market, as well as an excellent team of researchers and developers to keep optimising it going forward.

In the wake of this proposal, some have asked how Astroport fits into this vision. Astroport contributors see Astroport and Duality as perfect complements and the teams have already been working closely on crafting a vision for what they believe can be the most advanced liquidity infrastructure in the market.

This blog post describes that vision.

‍Astroport the Aggregator, and Duality the Infrastructure

Duality provides advanced market primitives for managing liquidity, allowing market makers to recreate almost any strategy, from expiring limit orders to AMM-like range orders. However, as with CLOBs and Uni v3, these tools are mostly suited to sophisticated market-makers. Research has repeatedly shown that the vast majority of active LPs lose money. As a result, these advanced primitives tend to become centralised around a small number of large market-makers. If any of these entities run into trouble, on-chain liquidity can rapidly collapse. This is a lesson that Serum DEX learnt the hard way on Solana when Alameda went bankrupt.

For AMMs to deliver on their promise of democratising and decentralising liquidity provision, sophisticated market-making strategies must be transposed into smart contracts and made accessible to anyone. Failing to do so, this industry would have achieved nothing but to recreate the existing system on blockchain rails, with many of its vulnerabilities and dependencies.

Astroport’s many pool types are the perfect complement to Duality’s liquidity primitives. Their logic can be encoded into vaults that simplify liquidity management and can be incentivized by protocols. In particular, Astroport’s specific pools for LSTs, weighted pools, and concentrated liquidity strategies can be compiled and run on top of Duality, without recreating complicated trading logic each time. This combines the best of both worlds: aggregating liquidity from sophisticated, active market-makers as well as decentralised, passive strategies into a single venue.

An Astroport integration with Duality is a massive win-win for the Neutron ecosystem. Liquidity deployed on Duality protects Neutron from liquidity fragmentation. It reduces the ecosystem’s reliance on complex, expensive order aggregation and routing. Astroport LPs in turn receive more order flow from the network effects of traders using Duality. Aggregated liquidity results in better execution for traders. The entire ecosystem benefits from more robust, decentralised liquidity.

The rest of this piece will describe the general approach through which Astroport’s automated strategies compile their liquidity onto Duality. It will also provide examples of products which embody the powerful synergies between the projects.

‍Discretization

Liquidity inside AMMs is generally represented by a continuous function or invariant that describes how LP inventory can change. When viewed as a function of price, this liquidity appears as a smoother version of what one might see on a traditional orderbook:

On Duality, on the other hand, liquidity is split into distinct “bins” called “ticks”. Each tick contains all of the liquidity available at a certain price. To represent continuous liquidity in these bins, it must be discretized at some resolution. There are various ways to do this, with the two most straightforward ways being “equal height” or “equal width” bins:

In the “Equal height” representation, each bin represents the same amount of liquidity, which must be placed in the proper price bin as defined by the underlying invariant. Whereas, in “equal width” representations, each bin represents the amount of liquidity available at a particular price, with the prices spaced evenly apart.

Equal width requires inverting the mathematical functions representing Astroport’s invariant, while equal height bins can re-use the logic that’s used today to fulfill trades (i.e., if Alice trades X amount of token0, how much of token1 would she receive?). As such, equal height is preferred.

The algorithm for transforming an AMM into discrete chunks of liquidity of equal height is given by the following formula:

Given an order size increment ‘x’ (i.e. our equal “height”)

For each bin ‘n’

  • Calculate cumulative price for bins 1…n:
  • Place liquidity for bin n at price p_n, such that:

Strategies on Neutron Duality

In addition to the standard X * Y = K and stableswap pool types, the following new pool types can be created to provide additional benefits to Neutron’s specific use cases.

Weighted Pools

Neutron is an attractive L1 for DAOs and projects to launch governance tokens and staking derivatives on. Using Duality, Astroport can create products that meet the needs of these projects and DAOs.

Typically, DAOs have lots of capital denominated in their own token, but very little capital that could be paired with these tokens to enter into LP positions.

In these scenarios, pools that allow protocols to provide liquidity in other weights than 50–50 are popular, as they lower the non-token capital requirements of bootstrapping liquidity. Astroport already features this pool type, which is used in its LBP product. An integration with Duality would allow protocols to provide liquidity without requiring traders to change venues or use value-extracting aggregators. Simply by trading on Duality, traders would have access to this protocol-provided liquidity.

Liquid Staking Token Pools

LSTs are an extremely popular product in Cosmos, and Neutron has a number of features that make it an attractive home for protocols to launch LSTs. The price of liquid staked tokens tends to be close to that of the underlying token. For that reason, LST liquidity has typically been deployed in stableswap-style AMMs.

However, this approach faces two significant limitations: firstly, the opposing forces of the redemption rate and unbonding discount gradually gouge the price away from 1:1, unbalancing traditional stableswaps. Secondly, LPs in these pools are generally underexposed to the yield of the LST, since half their liquidity is in the non-yielding base token.

By combining Astroport and Duality’s capabilities, it is possible to create a new stableswap pool type that solves both of these issues. A first enhancement would factor in the redemption rate and an unbonding discount modelled as a zero-coupon bond to center liquidity closer to where market participants should price it. This is similar to “metastable” swaps which have been proposed before, with the addition of the unbonding discount factor.

A second enhancement would aim to solve the LPs’ underexposure to LST yield as half of their liquidity sits in the native asset. Borrowing ideas from Balancer-style weighted pools, the stableswap formula can be modified to target a particular ratio of LST to base token (e.g., 70% LST). In such a pool, when the pool is “balanced” with respect to the redemption rate and unbonding discount, LPs can expect to be 70% exposed to the LST, as opposed to only 50%. This weight-adjusted version of the stableswap uses the following invariant, where w_1 and w_2 are the weights of the token and always sum to 1:

This new pool type can have its liquidity placed into Duality to bolster the market for LSTs and provide backstop liquidity that exists alongside traditional orderbook-style active market makers. To the author’s knowledge, this vault product would be the first of its kind in the industry, and the most efficient LST stableswap pool available anywhere.

‍PCL Vaults

Passive Concentrated Liquidity improves upon the capital efficiency of xy=k-style pools by concentrating liquidity near the current price. They rely on a variable fee to protect LPs during times of high volatility. In this way, they are akin to traditional CLOB market makers, and provide LPs with a sophisticated market-making strategy while maintaining the benefits of passive UX.

Duality’s on-chain order types are expressive enough for Astroport to deploy liquidity in a way that recreates the inner workings of PCL pools. As with the integrations above, placing the liquidity on Duality’s order book has a dual benefit for Astroport LPs and the Neutron ecosystem: increased order flow and reduced liquidity fragmentation.

‍Implementation considerations for PCL on Duality

For simple AMMs, such as the traditional X*Y=K invariant, the amount of liquidity in each bin need only change when users add or remove liquidity from the pool. Trading against this liquidity does not require additional liquidity placement calculations. Using Duality’s own fee mechanism, reimplementing the fixed fees used by these pool types is trivial.

PCL, on the other hand, introduces two specific challenges: liquidity repegging, and dynamic fees. In PCL, the pool keeps track of an internal moving average of the pool’s price. If the price moves away from where the liquidity is concentrated, the pool may rebalance to move liquidity closer to the true price of the asset and to provide better liquidity depth to traders. This repegging operation would require a recalculation of the discretization algorithm, and a redeployment of liquidity into new bins.

Since this operation must be triggered from trades that occur on Duality, the repegging logic must be run sufficiently often to provide optimal liquidity to traders and remain competitive with other non-passive liquidity. There are a few proposed methods to trigger this logic:

  • Off-chain infrastructure: A bot monitors the chain, and sends an explicit transaction to run the repegging logic when appropriate.
  • BeginBlocker / EndBlocker logic: A method on the PCL contract is called at the beginning or end of every block, and the repegging logic can be run if trades have occurred
  • Hooks: Each completed trade against duality triggers a hook that runs the repegging logic on the PCL pool
  • Tick-crossing: A specialised hook that only runs when a tick is crossed

In addition to repegging liquidity, PCL uses a dynamic fee that adjusts based on recent trading activity. The fee increases as a way to combat toxic arbitrage flow, and results in overall higher profits for LPs when compared with fixed-fee counterparts. Duality does allow for arbitrary per-position fees, but for PCL there needs to be a way to adjust the fee dynamically in response to trading activity.

By using non-reversible liquidity (a.k.a. one-way liquidity), a PCL vault could ensure that liquidity is not accidentally offered to traders at too attractive a price. After liquidity is ‘taken’ by a trader, a trade in the opposite direction in the same bin wouldn’t be possible until the vault has had a chance to properly price the trade and recalculate the discrete bins. Alternatively, fees for existing positions could be updated to reflect new fees resulting from this trade. Either way, this recalculation of fees or bins would need to be triggered by one of the above methods, in a similar manner to the repegging logic.

Conclusion

Through xy=k, stableswap, weighted, LST, and PCL pools, Astroport will offer highly efficient pool types for all LPs (whether DAOs or retail) and for all tokens (whether stablecoins, volatile or LST). With this passive liquidity being compiled onto Duality’s liquidity book and aggregated alongside liquidity from active market-makers, Neutron will offer passive liquidity providers any strategy imaginable.

This blog post only scratches the surface of the design space at hand. Enabling leveraged token exposure via mechanisms such as GMX-style oracle pools is another interesting potential to be explored.

Contributors at all three projects hope this blog post conveys their excitement and inspires and elicits feedback from the community.

Follow Astroport on Twitter and subscribe to the Astroport email newsletter to get the latest alerts from the mothership.

DISCLAIMER

Remember, Astroport, Injective, Neutron, Sei, and Terra are experimental technologies. This article does not constitute investment advice and is subject to and limited by the Astroport disclaimers, which you should review before interacting with the protocol.

--

--

Astroport

An automated, decentralised exchange protocol on the Terra blockchain. http://astroport.fi