Bonding Curve for Swapping Stablecoins — A Theory Behind

Short Introduction to Bonding Curve

A bonding curve defines a mathematical relationship between the price of a token and other token parameters, mostly total supply. The basic idea is to define such a function so that as the more the token is supplied, the higher price of the token should be (otherwise there is no incentive to buy the token). An example of the bonding curve is as below (Bancor):

where ReserveTokenBalance is the number of reserve token in the pool, and ReserveRatio is a pre-defined constant.

Note that the function is a continuous price function, while to obtain the actual price to buy/sell some amount of the token, we need to take the integral of the price from pre-tokenSupply to post-tokenSupply after a trade.

Here is the short introduction, which is sufficient to describe the rest of the article, but if you are interested in more details in bonding curves, you could find more details in,supply%20of%20the%20token%20increases.

Bonding Curve for Swapping Stablecoins

When comes to swapping stablecoins, e.g., tokens USDC and USDT, we have prior information that both tokens should have the same intrinsic value and most of the trades should be 1:1. However, the actual price varies around 1:1, and sometimes due to some extreme events, the price may fluctuate a lot. The question now is that could we also use bonding curves to price stablecoins so that most of the time the trades are 1:1, while the price may vary if a large number of such token are sold/bought in the market?

To design such a curve, first of all, we need to determine the token parameter of the price function. Clearly, using total supply is a bad choice — total supply does not reflect the intrinsic value of the token. Instead, we use a pooled method and price a token using its percentage in the pool as the pricing parameter:

  • 1:1 trade is guaranteed if a token’s percentage is under a pre-defined value, or
  • the price of the token reduces if the token’s percentage exceeds the threshold.


Assuming we have a list of stablecoins with amounts [x_1, x_2, … , x_N] in the pool, so that S = sum(x_i). Furthermore, the liquidity providers that supply the tokens have S amount of sUSD — the LP token to buy/sell the stablecoins in the pool:

Buy LP tokens: A user can sell a stablecoin for sUSD by calling mint(), which will deposit x’ amount of a stablecoin k and return s’ sUSD back. s’ must <= x’, and If s’ < x’, x’ — s’ sUSD will be evenly distributed to existing LPs.

Sell LP tokens: A user can buy a stablecoin k with s amount of sUSD by calling redeem(), which will deposit s’ sUSD and return x’ amount of stablecoin k. x’ must <= s’, and if x’ < s’, s’ — x’ sUSD will be evenly distributed to existing LPs.

Bonding Curve for Buying LP Tokens

Similar to Bancor, let us define the curve as follows:

ContinuousLPTokenPrice = 1 if ContinousTokenPercentage_k < Weight_k or 1 + (ContinousTokenPercentage_k — Weight_k) / (1 — ContinousTokenPercentage_k)

where ContinousTokenPercentage_k = x_k / S, and Weight_k is the pre-defined threshold so that the swap between LP token (sUSD) and the stablecoin is 1:1, or if the threshold is exceeded, the LP token will be more expensive and the price grows to infinite if the percentage approaches 1.

The above graph shows the bonding curve with Weight_k = 0.5. To obtain the price of a swap, similar to Bancor, we could apply integral (the red part) to the bonding curve to calculate the area as the price of swap.

Bonding Curve for Selling LP Tokens

Selling LP tokens can be formulated as if a user wants to retrieve back x’ amount of stablecoin k, how much LP token the user should offer? This is a bit more complicated as the percentage of stablecoin k decreases, while all other stablecoins’ percentage increases, where the curve should account for. Let us define the curve as follows:

ContinunousLPTokenPrice = 1 + sum_{j \neq k} 0 if ContinousTokenPercentage_j < Weight_j or (ContinousTokenPercentage_j — Weight_j) / (1 — ContinousTokenPercentage_ — j)

The curve is very similar to the mint one, except that it uses all stablecoins’ percentages other than percentage kth stablecoin as a pricing parameter.

Special Case for Swapping a Stablecoin to Another

If a user wants to swap a stablecoin A to another B directly, one way is to use A to buy LP tokens and then sell the LP tokens for B sequentially, which will need all percentages of the stablecoins as pricing parameter. One observation is that, based on the model, the output amount of B must <= the input amount of A — this means that all tokens’ percentages will be decreased except A. As a result, we could only perform the bonding curve using stablecoin A’s percentage as pricing parameter, which can save a lot of gas cost (calculation and storage read).

The Experiment

We have implemented the idea of the bonding curve for swapping stablecoins and launch a testnet product at Besides the bonding curve, has the following unique features:

  • Extremely low gas fee with about 77k gas vs 127k gas of Curve (sPool)
  • One pool for all stablecoins (10+) without increasing the gas cost of gas fee — this prevents diverged liquidity of multiple pools.
  • Dynamic cash reserve algorithm for LPs to earn both interest and swap fee with low gas cost swapping.

If you are interested in it, you can find more details about the project at Welcome to join and provide valuable feedback.

About Smoothy:




A novel single pool liquidity protocol specialized in same backed assets with low-cost zero-slippage swapping and max interest earning.

Love podcasts or audiobooks? Learn on the go with our new app.

4 key takeaways from Sibos 2019

Cleaning Up The Chain Of Custody For Medical Implants With Blockchain

Joe Rogan Learns About Blockchain Technology With Dr. Ben Goertzel

Developing Ethereum smart contracts with the Truffle Suite including Web3

GovWorld X Babylons: Strategic Partnership Announcement

Experience crypto trading like never before — L2 ZK Rollup Architecture

[Project Spotlight] — DeepBrain Chain

Mobius Company Updates: March 7, 2018

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

A novel single pool liquidity protocol specialized in same backed assets with low-cost zero-slippage swapping and max interest earning.

More from Medium

A Discernment on Defi Yield Mechanisms

How To Know A Token Is Safe with COIN

Tracking and Analyzing Whale Wallets

Allbridge Partners with onXRP to Bring Stablecoin Assets to XRP Ledger