Introducing Parallel Swap

Or simply put, better prices.

1. Context

Today, only the most liquid pools benefit from trading activities. At least it is true for traders who execute through our user interface.

For example, REF <> wNEAR pair has today 107 pools. Only one pool, ID number 79, with today the most value locked, is used to execute swaps. As a result, for each pair, only Liquidity Providers in the most liquid pool generate trading fee revenue.

2. Problem

New Liquidity Providers (LPs) are pushed to ‘comply’ with the swap fee initially set for the pool, wiping out the advantages of our Customizable LP fee per pool. Depending on the pair, LPs might want to offer a higher or lower swap fee rate.

For traders, executing through the most liquid pools does not guarantee the best prices. Depending on trade size and number of non-empty pools for the same pair, better prices could be sourced via multiple pools.

3. Parallel Swap

The Parallel Swap is an algorithm to optimize a swap of two tokens. For a given swap-in amount of Token A, the algorithm maximizes the swap-out value of Token B, taking into account the liquidity and swap fees of the various A-B liquidity pools.

For example, if someone wants to swap 10 Token A for Token B, and that there are 5 A-B equally distributed liquidity pools, it is expected that the swap transaction will contain 5 swap actions, taking advantage of all liquidity and ultimately creating a win-win situation:

  • Traders: best prices
  • LPs: fairer model (vs winner-takes-all market)

4. Implementation

Ref has been working in collaboration with the winning team of the OpenDeFi Hackathon. The implementation is the following phase of the original winning submission.

Now in the testing phase, we hope to deploy the feature very soon. Happening behing the scenes, the Parallel Swap will create a better user experience by sourcing better prices and by distributing swap fee revenue through a fairer model.

1 Like

Nice try, we will be much better.