More price functions for Token-Bonding Curves

This update is from Aventus Protocol Foundation – Medium

Following last week’s article, written by Alexandre Pinto, the author of by Wilson Lau, where the following function is derived (in general terms):

Despite the logarithm in the exponent, this can still be rewritten as


which falls exactly in the previous case of the reserved supply.

But there is also a second formula that is another kettle of fish, and introduces a whole new shape:

There are 5 different parameters here, which complicate things a little. We can rewrite the above like this:

which is not an immediate improvement but clarifies something: the dominant term here is of the form

which, once it turns positive, is a function that grows extremely slow. For reference, it turns 1 for

it is 2 for

and it turns 3 for

Given this rate of growth, for most practical applications it can probably be considered a constant, which places the above price formula in the company of a more boring class of function like

But this happens only after x turns smooth. It is a wholly different affair for small values of x, where the price function plunges almost vertically (depending on the choice of constants), until turning around and emulating a simple power function. This initial drop in value may not be suitable for normal market incentives, so study your curve well before implementing one, and in particular have an idea of the maximum and minimum range of supply the market is going to work. Here is an example of 3 curves of this type:

Exponential Functions

The last example introduced the possibility of using the variable in the exponent (albeit tempered by a double logarithm function). This opens the door to the simple but dramatic exponential function. On the surface, its graph is similar to power functions of exponent larger than 1 and for positive variable. When the variable is negative, these functions are radically different: the exponential function will seem to hug the horizontal axis, being almost a horizontal line, but the power functions will be a symmetric of the positive side of the graph: if the exponent’s numerator is even, it will be symmetric around the y-axis; if it is odd, it will be symmetric around the origin point. Another difference is that the power functions pass through the origin of the chart, and a vanilla exponential function does not. But with a little tweaking, we can write an exponential that does, eg:

Despite the similarities, the exponential function is NOT like a power function: it grows much, much faster than any polynomial function (for large enough x). An example of this is in the next figure, that shows the exact same functions as above for modest, but larger, values of supply (up to 20). See how the exponential function takes off in relation to the others.

The exponential function has a very simple integral, and we can easily check that it does not produce a constant ratio. Below, I list a generic exponential price function, the corresponding reserve and the calculation of the reserve ratio.

The reserve ratio is

which shows this varies with the supply, and so is not constant.

Logarithmic Functions

The logarithmic function is like the mirror of the exponential function. While the exponential function grows very fast and approximates a vertical curve, the logarithmic function grows very slowly, and instead approximates a horizontal.

The next figure shows a comparison of the logarithmic function with power functions of exponents

Their approximate shapes are similar, and one could think the logarithmic function (in a dashed line) to be just of the same type as the power functions. It does overtake two of the others, and from this small example it looks like it could dominate them. However, this is short lived behaviour. The truth is that as S tends to infinity, the logarithmic function grows slower and slower and slower, until it is overtaken by all other power functions.

The graph below shows the same functions in the vicinity of S= 90000 where the log function is already the smallest of the bunch.

The integral of

is more complicated than the previous ones:

Potential drawbacks of this function include the necessity to implement a logarithmic function, since this is not available in solidity off the shelf. It also is not easy to generalise the above function itself by increasing the degree of


which includes a trigonometric function in the integral. Higher exponents don’t even have a closed integral formula.

Negative Exponential

An interesting alternative to the logarithm function may be the negative exponential. Unlike the logarithm, which grows indefinitely and tends to infinitely (albeit at a very slow pace), the negative exponential has a true horizontal asymptote, meaning that it will approximate a true horizontal function and never go over a limit value. For example:

approximates the maximum value C. The rise of the function is steep for

and the passage to the near-horizontal regime is almost abrupt. To make the rise softer, we can make a much smaller, as long as it is still positive.

The integral (and therefore the reserve) is not complicated:

Here is an example graph:


In this long post, I have gone over several possible price functions for Token-Bonding Curves (TBC), and talked a little about their properties and how to compute their integral. The choice of function should primarily be dictated by the desired incentive, possibly by sketching a chart with the desired behaviour and then identifying a function close to it.

Importantly, any choice must then be validated according to the ease or difficulty of implementing the necessary functions. In a TBC, we want both to sell and buy tokens from the curve. We only need to compute the integral of the price function if we want to sell or buy a given number of tokens, but if we want to buy or sell tokens equivalent to a given amount of the reserve currency, then we need the inverse function of this integral.

To ease on the maths (which is already rather heavy) I have not given any of these inverse functions. This is a bigger challenge than it seems on the surface. For example, the inverse of the reserve for a function in the section “Positive initial price” would involve solving a polynomial equation of the kind

which for high values of k is not straightforward.

The exponential functions would not pose much of a problem, nor would the simpler function in “Quasi-polynomial function types”. The second kind in this section, however, would be very hard to solve analytically for both the reserve and its inverse. This also applies to the inverse of the reserve for a logarithmic function. Finally, even the negative exponential reserve is not easy to invert.

This makes it difficult to use most of the functions in this list in a TBC where we want to specify a currency value instead of the number of tokens to buy or sell (which is common in financial markets), but it is possible to provide a market that does not include the former. This is more similar to the material world, where many markets only work that way: we usually don’t buy 20$ worth of apples or meat, but rather look for a specified quantity or weight.

About the Author

Alex is a software engineer at Aventus, working on the blockchain engineering team. He has 20 years of experience working in technology, completing a PhD in Computer Science as well as a post-doctorate in Cryptography. As part of his research, Alex has published papers on Kolmogorov Complexity, Cryptography, Database Anonymization and Code Obfuscation.

Alex also spent seven years lecturing at the University Institute of Maia, including directing the degree programmes for BSc Computer Science and Information Systems and Software.

This article was originally posted on his blog.

More price functions for Token-Bonding Curves was originally published in Aventus Protocol Foundation on Medium, where people are continuing the conversation by highlighting and responding to this story.

Powered by WPeMatico