Swap API liquidity management

Take a peek under the hood of how we manage Swap API’s liquidity portfolio.

Published on
May 18, 2023
Under the Hood
Swap API liquidity management

Swap API sources liquidity from over 100 decentralized exchanges, which can easily be accessed through a single endpoint. That’s the deepest liquidity out there.

Similar to managing nodes or other layers of infrastructure, managing liquidity sources is a piece of the infrastructure stack that is incredibly important to the success of your app. Missteps in sourcing liquidity can manifest in poor experiences for users, weak pricing, lack of token coverage, and increased slippage.

At 0x, we have a team dedicated to managing liquidity, ensuring that we onboard and offboard the right sources to deliver the most value to users. We manage the overhead and allow you to focus on building what matters: your product. 

Let's take a peek under the hood of how we manage Swap API’s liquidity portfolio.

Why is liquidity management important?

Why is it important that we actively manage our liquidity portfolio? Public liquidity, by nature, is an open resource. As such, it’s important that 0x offers the most competitive liquidity portfolio in terms of pricing and coverage. The higher performing, diverse portfolio that we offer, the more value we can deliver to users.

Ultimately, we curate liquidity based on the value that can be passed on to users. We continuously monitor and benchmark our performance to deliver the best product possible.

Our liquidity management framework:

  1. Discovery: Programmatically discover new valuable liquidity sources.
  2. Decision: Should the new liquidity sources be aggregated or not?
  3. Performance Assessment: Continuous assessment of what value a source is adding to the system.
  4. Offboarding: When a source dries up, we remove it from the system to maintain scalability.

Let’s dive a little deeper into each one.

Discovery

There are hundreds upon hundreds of liquidity sources spread across the 8 chains that we support. Given the sheer number of liquidity sources in the ecosystem, how do we find the highest value sources for our users? The first step is discovering which high-quality sources aren’t currently integrated.

The first method we utilize is automated discovery. We’ve developed two internal bots that continuously report the top sources on each chain that Swap API supports. The first is our Discovery Bot. This bots ping DeFi Llama and checks, out of all the liquidity sources they index, which ones we don’t have. We run these reports on a weekly basis. Our second bot is a Curve Pools bot. In Curve, pools can be spun up on a weekly basis. Staying up-to-date on these pools manually is next to impossible, so automating this process allows us to flag high liquidity pools.

Second is community input. We also identify new sources through our Liquidity Integration Form, where devs and projects can manually submit liquidity sources to us. Finally, our Liquidity Integration Team continually monitors the ecosystem through social media to keep an eye out for new projects and liquidity providers.

Decision Framework

We’ve now taken a galaxy of liquidity sources and narrowed it down to a short list of potential liquidity sources. Once we have a sense of potential new liquidity sources that Swap API is not currently aggregating, the question becomes: should these new sources be in our portfolio or not? 

When we vet new liquidity sources we measure two fundamental aspects: Pricing and Coverage. Will this source provide a price improvement compared to our existing sources or does this source provide access to tokens that we are currently not supporting.

We utilize a simple decision framework, an impact-effort matrix, which is based on some foundational parameters.

Impact

Pricing: is it improving pricing for specific pairs we already have a market for in our existing portfolio?

Coverage: is it providing liquidity for a market we’ve never had, i.e. new tokens that our existing portfolio doesn’t have coverage for?

Effort

Dev time: some integrations require one day and some can require up to one month

If the source requires low effort and is high impact, integration will be prioritized. If it requires high effort and is low impact, integration is deprioritized.

Performance Assessment

Once a new source has been added to our portfolio, we closely monitor both post-integration performance alongside how our portfolio is performing overall. This includes monitoring coverage and volume for relevant token pairs at the source level and for chains at the portfolio level.

Why is this important? We need to have a benchmark for how we’re performing against the rest of the ecosystem. This also allows us to be intentional about how we spend our resources. For instance, do we need to focus on improving our sources on BNB Chain vs Avalanche?

Offboarding

Our strategic approach to liquidity will always be quality over quantity.

As we add new sources, we are also adding complexity to our infrastructure. We can not continue increasing our portfolio infinitely because it doesn’t scale. For that reason, it’s important to remove dry liquidity sources. Offboarding sources allows us to maintain an efficient and high performing portfolio.

If we find that a given source is underperforming, an assessment is made whether it should be removed from the portfolio. The parameters we use in determining if a source should be offboarded are 7 day volume, 30 day volume, and 6 month volume.

Start building with Swap API today

One integration with 0x unlocks thousands of tokens on the most popular blockchains and aggregated liquidity from 100+ AMMs and private market makers. Swap makes it easy for teams, big and small, to tap into deep DEX liquidity, reducing infrastructure overhead so that you can focus on what matters: your product.

Ready to start building? Check out our guide below to get started with Swap API.