Skip to main content

Wombat—An Efficient Stableswap Algorithm

  • Conference paper
  • First Online:
Mathematical Research for Blockchain Economy (MARBLE 2022)

Abstract

Curve Finance invented the first stableswap-focused algorithm. However, its algorithm involves (1) solving complex polynomials and (2) requiring assets in the pool to have the same size of liquidity. This paper introduces a new stableswap algorithm–Wombat, to address these issues. Wombat uses a closed-form solution, so it is more gas efficient and adds the concept of asset-liability management to enable single-side liquidity provision, which increases capital efficiency. Furthermore, we derive efficient algorithms from calculating withdrawal or deposit fees as an arbitrage block. Wombat is named after the short-legged, muscular quadrupedal marsupials native to Australia. As Wombats are adaptable and habitat-tolerant animals, the invariant created is also adaptable and tolerant to liquidity changes.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 149.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 199.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 199.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Angeris, G., & Chitra, T. (2020). Improved price oracles: Constant function market makers. SSRN Electronic Journal.

    Google Scholar 

  2. Hayden, A. (2019). Uniswap birthday blog–v0.

    Google Scholar 

  3. Michael, E. (2019). stableswap–efficient mechanism for stablecoin liquidity.

    Google Scholar 

  4. Othman, A., Sandholm, T., Pennock, D. M., & Reeves, D. M. (2013). A practical liquidity-sensitive automated market maker. ACM Transactions on Economics and Computation (TEAC), 1(3), 1–25.

    Article  Google Scholar 

  5. Platypus Team. (2021). Platypus AMM technical specification.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Tony W. H. Wong .

Editor information

Editors and Affiliations

Appendices

A Screenshots of Uniswap and Curve

See Figs. 2 and 3.

Fig. 2
figure 2

Uniswap screenshot

Fig. 3
figure 3

Curve screenshot

B Proof of Theorem 2

Proof

If \(r^*=1\), then \(D=\left( \sum _{k\in \mathcal {T}}L_k\right) (1-A)\) by Eq. (5), \({r^*}'=1\) by Eq. (6), and \(D'=\left( \delta ^L_i+\sum _{k\in \mathcal {T}}L_k\right) (1-A)\) by Eq. (7). Hence, Eq. (8) becomes

$$\begin{aligned} (L_i+\delta ^L_i)\left( \frac{A_i+\delta ^A_i}{L_i+\delta ^L_i}-\frac{A(L_i+\delta ^L_i)}{A_i+\delta ^A_i}\right) +\sum _{k\in \mathcal {T}\setminus \{i\}}L_k\left( r_k-\frac{A}{r_k}\right)&=\left( \delta ^L_i+\sum _{k\in \mathcal {T}}L_k\right) (1-A)\nonumber \\ A_i+\delta ^A_i-\frac{A(L_i+\delta ^L_i)^2}{A_i+\delta ^A_i}+D-L_i\left( r_i-\frac{A}{r_i}\right)&=\delta ^L_i(1-A)+D\nonumber \\ \delta ^A_i-\frac{A(L_i+\delta ^L_i)^2}{A_i+\delta ^A_i}+\frac{AL_i^2}{A_i}&=\delta ^L_i(1-A). \end{aligned}$$
(13)

If \(\delta ^L_i<0\) and \(\delta ^A_i\ge 0\), then the left hand side (LHS) of Eq. (13) is positive while the right hand side (RHS) is negative, a contradiction. Similarly, if \(\delta ^L_i>0\) and \(\delta ^A_i\le 0\), then the LHS is negative while the RHS is positive, a contradiction again. Hence, \(\delta ^L_i\) and \(\delta ^A_i\) always share the same sign.

To compare \(\delta ^L_i\) and \(\delta ^A_i\), we first rewrite Eq. (9) as

$$\begin{aligned} b'&=\frac{1}{L_i+\delta ^L_i}\left( \left( \sum _{k\in \mathcal {T}}L_k\right) (1-A)-L_i\left( r_i-\frac{A}{r_i}\right) -\left( \delta ^L_i+\sum _{k\in \mathcal {T}}L_k\right) (1-A)\right) \\&=-\frac{1}{L_i+\delta ^L_i}\left( L_i\left( r_i-\frac{A}{r_i}\right) +\delta ^L_i(1-A)\right) . \end{aligned}$$

Therefore, Eq. (10) yields

$$\begin{aligned}&\delta ^A_i-\delta ^L_i\\&=\frac{-(L_i+\delta ^L_i)b'+\sqrt{\left( (L_i+\delta ^L_i)b'\right) ^2+4A(L_i+\delta ^L_i)^2}}{2}-L_ir_i-\delta ^L_i\\&=\frac{-L_i\left( r_i+\frac{A}{r_i}\right) -\delta ^L_i(1+A)+\sqrt{\left( L_i\left( r_i-\frac{A}{r_i}\right) +\delta ^L_i(1-A)\right) ^2+4A(L_i+\delta ^L_i)^2}}{2}. \end{aligned}$$

Note that

$$\begin{aligned} \left( r_i-\dfrac{A}{r_i}\right) ^2+4A=r_i^2-2A+\dfrac{A^2}{r_i^2}+4A=\left( r_i+\dfrac{A}{r_i}\right) ^2\end{aligned}$$

and

$$\begin{aligned} (1-A)^2+4A=1-2A+A^2+4A=(1+A)^2.\end{aligned}$$

Furthermore, by the AM-GM inequality, we have \(r_i+\dfrac{1}{r_i}\ge 2\), so

$$\begin{aligned} \left( r_i-\frac{A}{r_i}\right) (1-A)+4A&=r_i+\frac{A^2}{r_i}-A\left( r_i+\frac{1}{r_i}\right) +4A\\&\le r_i+\frac{A^2}{r_i}-A\left( r_i+\frac{1}{r_i}\right) +2A\left( r_i+\frac{1}{r_i}\right) \\&=\left( r_i+\frac{A}{r_i}\right) (1+A), \end{aligned}$$

where the equality holds if and only if \(r_i=1\). As a result,

$$\begin{aligned}&\left( L_i\left( r_i-\frac{A}{r_i}\right) +\delta ^L_i(1-A)\right) ^2+4A(L_i+\delta ^L_i)^2\\&=L_i^2\left( r_i-\frac{A}{r_i}\right) ^2+4AL_i^2+2L_i\left( r_i-\frac{A}{r_i}\right) \delta ^L_i(1-A)+8AL_i\delta ^L_i\\&\qquad +(\delta ^L_i)^2(1-A)^2+4A(\delta ^L_i)^2\\&=L_i^2\left( r_i+\frac{A}{r_i}\right) ^2+2L_i\delta ^L_i\left( \left( r_i-\frac{A}{r_i}\right) (1-A)+4A\right) +(\delta ^L_i)^2(1+A)^2. \end{aligned}$$

If \(\delta ^L_i<0\), then

$$\begin{aligned}&\sqrt{\left( L_i\left( r_i-\frac{A}{r_i}\right) +\delta ^L_i(1-A)\right) ^2+4A(L_i+\delta ^L_i)^2}\\&\ge \sqrt{L_i^2\left( r_i+\frac{A}{r_i}\right) ^2+2L_i\delta ^L_i\left( r_i+\frac{A}{r_i}\right) (1+A)+(\delta ^L_i)^2(1+A)^2}\\&=\left| L_i\left( r_i+\frac{A}{r_i}\right) +\delta ^L_i(1+A)\right| , \end{aligned}$$

so \(\delta ^A_i-\delta ^L_i\ge 0\), with the equality holds if and only if \(r_i=1\); if \(\delta ^L_i>0\), then

$$\begin{aligned}&\sqrt{\left( L_i\left( r_i-\frac{A}{r_i}\right) +\delta ^L_i(1-A)\right) ^2+4A(L_i+\delta ^L_i)^2}\\&\le \sqrt{L_i^2\left( r_i+\frac{A}{r_i}\right) ^2+2L_i\delta ^L_i\left( r_i+\frac{A}{r_i}\right) (1+A)+(\delta ^L_i)^2(1+A)^2}\\&=\left| L_i\left( r_i+\frac{A}{r_i}\right) +\delta ^L_i(1+A)\right| , \end{aligned}$$

so \(\delta ^A_i-\delta ^L_i\le 0\), again with the equality holds if and only if \(r_i=1\).

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Lie, J.H., Wong, T.W.H., Lee, A.Yt. (2023). Wombat—An Efficient Stableswap Algorithm. In: Pardalos, P., Kotsireas, I., Guo, Y., Knottenbelt, W. (eds) Mathematical Research for Blockchain Economy. MARBLE 2022. Lecture Notes in Operations Research. Springer, Cham. https://doi.org/10.1007/978-3-031-18679-0_13

Download citation

Publish with us

Policies and ethics