A python implementation of an automated market maker (AMM) for a liquidity pool in DeFi. The market maker is a homotopy between a constant sum market maker (CSMM) and a constant product market maker (CPMM).
Automated market makers (AMMs) are used in the DeFi space to enforce desired liquidity characteristics of a token. For instance, a DeFi project may want its token always to be liquid, exponentially appreciating in value as its supply diminishes and therefore being impossible to buy out completely. A constant product marker maker is a straightforward solution for this. In the standard setting, this token would be placed in a liquidity pool along with another suitable token and an equation such as
If, instead, a limited supply is desired, a constant sum market maker with the equation
Here I describe and characterize an automated market maker arrived at by taking the geometric mean of a Constant Sum Market Maker (CSMM) and a Constant Product Market Maker (CPMM). Such a configuration gives an AMM that displays characteristics of both a CSMM and a CPMM (the CPMM is dominant). This is desirable since apart from liquidity, which a CPMM will always ensure, a CSMM will perform better by other crypto-economic metrics.
Given the present quantities of the currencies in the liquidity pool, the illustrations herein arrive at the immediate exchange rate between the currencies and the amount of one currency to exchange for some amount of the other (taking into consideration that the exchange rate changes marginally for each marginal amount of currency traded).
The characteristics considered are those that pertain to liquidity, particularly the configuration of the automated market maker (AMM) so that the pool is always liquid.