--- tags: dAMM --- # Multi-asset market making ## Introduction Multi-asset market making (MAMM) consists in managing inventories with more than two assets. One important benefit of MAMM compared to two-asset market making is *capital efficiency*. For example, instead of managing an ETH/USDC and WBTC/USDC strategy, a single ETH/USDC/WBTC strategy economizes on USDC capital. In the AMM space, Balancer allows users to create pools with up to eight assets, user-defined weights, and customizable swap fees. The multi-asset invariant is a generalization of the Uni V2 two-asset AMM pool. For example with three assets, the invariant is: $$ x^a y^b z^c = k $$ with $a$, $b$, $c \in (0,1)$ the respective portfolio share of each asset in the pool and $a+b+c=1$. Another advantage is *diversification*. Volatility and inventory risks can be mitigated by spreading risk across many assets. This is only possible under proper conditions though. Balancer type AMM pools do not incorporate stop-loss mechanisms. If the price of one of the tokens goes to zero, so does the entire pool. A third benefit is *index management*, the possibility to manage a portfolio which tracks a basket of assets representative of an asset class. Thematic index funds include blue-chip index funds, "growth assets" funds, NFT-related funds, ... In decentralized finance, two major index management protocols, [Indexed Finance](https://ndxfi.medium.com/introducing-indexed-finance-ndx-5d91137bde29) and [Powerpool](https://medium.com/powerpool/dynamic-amm-as-a-solution-for-decentralized-smart-indexes-b0aaf036f64d), use a fork of the multi-asset Balancer AMM to manage the funds. The leader in the sector, [indexcoop](https://indexcoop.com/), manages six index funds including the Defi Pulse Index which has \$250m of TVL. Curve proposes a three-asset AMM pool tricrypto2, composed of ETH, WBTC and USDT and has \$866m of TVL on Ethereum. The Table proposes a typology of AMMs and market making strategies (with contrarian portfolio weights referring to weights varying to opposite price direction): | | Two assets | More than two assets | | -------- | -------- | -------- | | Constant weights | Uni V2, Kelly | Balancer, Curve 3-crypto, index management, | | Contrarian weights | Uni V3, market making | Multi-asset MM, Curve tricrypto2| This note shows how a [discrete AMM](https://hackmd.io/@pre-vert/smm) could manage a multi-asset pool and implement a market making strategy. ## Model There are $n$ assets $X_i$ and 1 numeraire $Z$ or "cash", $n$ prices $p_i$ and $n$ price states: $$ s_i = \dfrac{p_{i,max}-p_i}{p_{i,max} - p_{i,min}} \; \in [0,1] $$ Let $p=(p_1,...,p_n)$ and $s=(s_1,...,s_n) \in [0,1]^n$ be the price and price state vectors, and $\omega_i(s) \in [0,1]$ the share of $X_i$ in MM's portfolio: $$ \omega_i(p) = \dfrac{p_ix_i}{\sum_{j=1}^n p_jx_j + z} $$ The general strategy consists in targeting inventories (and posting asks and bids of acording size) by making the shares track a well-chosen function of price states: $$ \omega_i(p) = g_i(s) $$ for all assets $i=1,...,n$, with $g_i$: $[0,1] \rightarrow [0,1]$. MM's portfolio share in cash is the residual share: $$ g_z(s) = 1 - \sum_i g_i(s) $$ In the following, $s_{-i}$ is the vector of all price states but asset $i$'s, and $s=a$ means that all price states are equal to $a$. ## Properties $g_i(s)$ must satisfy four properties: :::info 1. If the price of $X_i$ hits its upper bound, its share is zero: $$ g_i(s_i=0,s_{-i}) = 0 \; \forall s_{-i} \in [0,1]^{n-1} $$ ::: :::info 2. The lower the price of asset $i$ or the higher the price of other assets in the portfolio, the higher share of $i$ in the inventory: - $\dfrac{\partial g_i}{\partial s_i} (s) \geq 0$ $\; \forall s_{-i} \in [0,1]^{n-1}$ - $\dfrac{\partial g_i}{\partial s_{j}} (s) \leq 0$ $\; \forall j\neq i$ , $\; \forall s_{-j} \in [0,1]^{n-1}$ ::: :::info 3. If the price of $X_i$ reaches its lower bound while other prices hit their upper bound, its share is $100\%$: $$ g_i(s_i=1,s_{-i}=0)= 1 $$ ::: :::info 4. If all prices reach their lower bound ($s_j = 1 \; \forall j$), the portfolio has 0 cash: $$ g_z(s=1)= 0 $$ ::: Property 1 implies that the MM is all in cash if all prices reach their upper bound: $g_z(s=0)= 1$. Also, define the shares $\alpha_i$ by $g_i(s=1) = \alpha_i \, \forall i=1,...,n$. Property 4 implies $$ \sum_{j=1}^n \alpha_j = 1 $$ Although assets' actual shares widely fluctuate with price vector, we need to give a sense to how much a MM invests in each asset relatively to other ones. For instance, in a ETH/WBTC portfolio with USDC as cash, is the MM exposed 50/50 to ETH and WBTC or 60/40? Portfolio weights $\alpha_j$ provides this information in the notional situation in which all prices have reached their parametric lower bound. ## Functionals :::success Portfolio shares as a function of price states satisfy properties 1 to 4: $$ g_i(s) = \phi_i(s_i) \big( 1 - \sum_{j \neq i} \alpha_j \phi_j(s_j) \big) $$ with $\phi_i'(.) \geq 0$, $\phi_i(0) = 0$ and $\phi_i(1) = 1$. ::: The share of cash is the residual capital: $$ g_z(s) = 1 - \sum_{i=1}^n \Big( \phi_i(s_i) \big( 1 - \sum_{j \neq i} \alpha_j \phi_j(s_j) \big) \Big) $$ ## Examples ### One asset With one asset plus cash, the strategy boils down to the [one asset strategy](https://hackmd.io/@pre-vert/smm): $$ g_1(s) = \phi_1(s_1) $$ with $\alpha_1 = 1$. <!--This is also the case if all other prices reach their maximum since the market maker (temporarily) manages a two asset fund. --> ### Two assets With two assets, MM's portfolio shares are: \begin{align} g_1(s) &= \phi_1(s_1) ( 1 - \alpha_2 \phi_2(s_2)) \\ g_2(s) &= \phi_2(s_2) ( 1 - \alpha_1 \phi_1(s_1) \\ g_z(s) &= 1 - g_1(s) - g_2(s) \\ &= 1 - \phi_1(s_1) - \phi_2(s_2) + \phi_1(s_1) \phi_2(s_2) \end{align} We check that - $g_z(s_1,s_2)=1$ if $s_1 = s_2 = 0$ (all in cash if the two prices hit their upper limit) - $g_z(s_1,s_2)=0$ if $s_1 = s_2 = 1$ (all in $X_1$ and $X_2$ if the two prices reach their lower limit). Furthermore: - the share of cash is always non-negative: $$ g_z(s) = \big( 1 - \phi_1(s_1) \big) \big( 1 - \phi_2(s_2) \big) $$ - if the price of one of the two tokens increases ($s_j$ decreases), the share of cash increases: $$ \dfrac{\partial g_z}{\partial s_i} (s_1,s_2) = \phi_i'(s_i)(\phi_j(s_j) - 1) \leq 0 $$ ## More than two assets When the price of one of the $n$ assets varies, the share of cash changes according to: \begin{aligned} \dfrac{\partial g_z}{\partial s_i} (s) &= \phi_i'(s_i) \Big( \sum_{j \neq i} \alpha_j \phi_j(s_j) - 1 + \alpha_i \sum_{j \neq i} \phi_j(s_j)\Big) \\ &= \phi_i'(s_i) \Big( \sum_{j \neq i} (\alpha_j + \alpha_i) \phi_j(s_j) - 1 \Big) \end{aligned} A higher price $i$ reduces the demand for asset $i$, but also increases the demand for all other assets. The net effect on the demand for cash is ambiguous, contrary to the two asset case. As a consequence, a zero demand for cash when all asset prices are at their lower bound is not necessarily a minimum. To see it, let us start from $s=1$ for all assets implying $g_z(s)=0$, and \begin{aligned} \dfrac{\partial g_z}{\partial s_i} (s=1) &= \phi_i'(1) \Big( \sum_{j \neq i} (\alpha_j + \alpha_i) - 1 \Big) \\ &= \phi_i'(1) (n-2) \alpha_i \end{aligned} The derivative is zero in the two-asset case ($n=2$), and positive with more than two assets. This implies that the demand for cash decreases and becomes negative in this particular case. A negative share of cash is met by borrowing asset $z$ from the lending protocol in which the MM has deposited its inventory and by buying assets $j \neq i$ with the borrowed amount. ## Inventory risk diversification Managing a multi-asset portfolio instead of a two-asset portfolio not only reduces volatility risk but also inventory risk. In a two-asset potfolio with fixed price range, the potfolio is 100% in one asset when the price is out of range. Market making is still possible in this case with more than two assets. Suppose that asset $k$ belonging to the pool has a price falling below $p_{i,min}$, meaning $s_k = 1$ and $\phi_k(1) = 1$. Its share in the pool is: $$ g_k(1) = 1 - \sum_{j \neq i} \alpha_j \phi_j(s_j) $$ which is less than 100%. Other assets' shares are $$ g_i(s) = \phi_i(s_i) \big( 1 - \alpha_k - \sum_{j \neq i,k} \alpha_j \phi_j(s_j) \big) $$ This is a notable difference with multi-asset Balancer pools in which all other assets are drained out of the pool and the pool's value converges to zero when one asset falls to zero. At the other end, if asset $k$ has a price rising above $p_{i,max}$, its share in the pool is zero ($\phi_k(0) = 0$). But it is still possible for the market maker to operate with $n$ assets ($n-1$ volatile assets and cash). ## Simulations Two market making strategies are compared with holding. The $1 \times 3$ strategy is the linear three-asset model with $\phi_i(s)=s$: \begin{align} g_1(s_1,s_2) &= s_1 ( 1 - \alpha_2 s_2) \\ g_2(s_1,s_2) &= s_2 ( 1 - \alpha_1 s_1) \\ g_z(s_1,s_2) &= 1 - s_1 - s_2 + s_1 s_2 \end{align} The market maker manages a unified inventory with the two assets and cash. The $2 \times 2$ strategy consists in managing two separate inventories, one with asset $1$ and cash, the other with asset $2$ and cash according to the formula: \begin{align} g_1(s_1) &= s_1 \\ g_2(s_2) &= s_2 \\ \end{align} Price sequences are simulated based on the data generating process: \begin{align} p_{1,t} &= \rho_1 p_{1,t-1} + (1-\rho_1) \bar{p} + \omega \epsilon_{1,t} + (1-\omega) \epsilon_{2,t} \\ p_{2,t} &= \rho_2 p_{2,t-1} + (1-\rho_2) \bar{p} + \omega \epsilon_{2,t} + (1-\omega) \epsilon_{1,t} \end{align} Parameters $\rho_1, \rho_2 \in (0,1)$ measure time auto-correlation of the two price series. Price cross-correlation is controlled by $\omega$. It is positive for $[0.5,1]$, minimum for $\omega=1$ and maximum for $\omega=0.5$. <!--It is negative negative for $[-0.5,0]$, minimum for $\omega=0$ and maximum for $\omega=0.5$. --> 100 sequences of 500 prices are generated. For each sequence, the market maker starts with 1 unit of wealth and uses either the $2 \times 2$ strategy in which the unit is equally split at the start between the two inventories, or the $1 \times 3$ strategy. Execution prices are spaced from each other by +/-10%. Baseline calibration: :::info - $p_{min}=1$, $p_{max}=5$, $\bar{p}=3$ - $\alpha_1 = \alpha_2 = 0.5$ - $\epsilon_{1}$, $\epsilon_{1}$ follow $N(0,0.1)$ - $\rho_1 = \rho_2 = 0.997$ - $\omega=0.85$ ::: Examples of generated price sequences for the two assets: ![](https://i.imgur.com/eJTjw61.png) Ratios of terminal wealths with and without rebalancing for the $2 \times 2$ strategy (blue points) and the $1 \times 3$ strategy (orange triangles): ![](https://i.imgur.com/OnuByCY.png =480x275) Both strategies dominate on average the holding strategy (ratio > 1). Holding is outperformed in 86% of price sequences if the $2 \times 2$ strategy is used, and in 95 % if the $1 \times 3$ strategy is applied. The $1 \times 3$ strategy gives better returns on average than the $2 \times 2$ strategy but also displays a bit more downside risk. Ratios of terminal wealth with and without rebalancing: | | Min | Quartile 1 | Median | Mean | Quartile 3 | Max | | :---: | ----: | --------: | ------: | ----: | ------: | ---: | | $2 \times 2$ | 0.899 | 1.054 | 1.105 | 1.092 | 1.147 | 1.248 | | $1 \times 3$ | 0.737 | 1.133 | 1.206 | 1.188 | 1.255 | 1.816 | The $1 \times 3$ strategy is both more profitable and more risky than the $2 \times 2$ one. This remains true when the coefficient $\omega$ measuring the degree of price cross-correlation varies from 0.5 (perfect correlation) to 1 (no correlation). Median ratios of terminal wealth with and without rebalancing for various values of price cross-correlation: | $\omega$ | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 | | :------: | --- | --- | --- | --- | --- | --- | | $2 \times 2$ Med |1.083|1.084|1.087|1.100|1.113|1.132| | $1 \times 3$ Med |1.068|1.134|1.151|1.174|1.221|1.269| | Difference |0.015|0.050|0.064|0.074|0.108|0.137| The lower the price cross-correlation ($\omega$ close to $1$), the more profitable the two strategies compared to holding, but also the more profitable the $1 \times 3$ compared to the $2 \times 2$ one. To understand the last result, suppose a low cross-correlation between the two assets and that asset $1$ is close to its minimum and asset $2$ to its maximum. If the two inventories are segregated, the market maker would like to have more cash to buy additional asset $1$ and has plenty of cash sitting in his inventory in the asset $2$ market. The $1 \times 3$ strategy mutualizes the need for cash and is more efficient in those situations. Minimum and maximum ratios of terminal wealth with and without rebalancing for various values of price cross-correlation: | $\omega$ | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 | | :------: | --- | --- | --- | --- | --- | --- | | $2 \times 2$ Min |0.857|0.855|0.882|0.885|0.820|0.685| | $2 \times 2$ Max |1.169|1.190|1.222|1.226|1.255|1.281| | $1 \times 3$ Min |0.839|0.887|0.904|0.851|0.582|0.289| | $1 \times 3$ Max |1.141|1.233|1.302|1.535|2.172|2.874| The lower the price cross-correlation, the more risky. *Many thanks to Weijia Wang and Vincent Danos for great comments on earlier versions.* <!-- | $\omega$ | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 | | :------: | --- | --- | --- | --- | --- | --- | | 2x2 Min |0.857|0.855|0.882|0.885|0.820|0.685| | 2x2 Q1 |1.038|1.035|1.044|1.051|1.056|1.062| | 2x2 Med |1.083|1.084|1.087|1.100|1.113|1.132| | 2x2 Q3 |1.106|1.111|1.116|1.137|1.158|1.182| | 2x2 Max |1.169|1.190|1.222|1.226|1.255|1.281| | 1x3 Min |0.839|0.887|0.904|0.851|0.582|0.289| | 1x3 Q1 |1.031|1.083|1.095|1.120|1.125|1.155| | 1x3 Med |1.068|1.134|1.151|1.174|1.221|1.269| | 1x3 Q3 |1.090|1.155|1.178|1.221|1.278|1.361| | 1x3 Max |1.141|1.233|1.302|1.535|2.172|2.874| Since $$ \alpha_i + \sum_{j \neq i} \alpha_j \phi_j(s_j) \leq 1 $$ $$ g_i(s) = \phi_i(s_i) \big( 1 - \sum_{j \neq i} \alpha_j \phi_j(s_j) \big) \geq \alpha_i \phi_i(s_i) $$ $$ g_z(s) = 1 - \sum_{i=1}^n \Big( \phi_i(s_i) \big( 1 - \sum_{j \neq i} \alpha_j \phi_j(s_j) \big) \Big) $$ $$ g_z(s) = 1 - \sum_{i=1}^n \phi_i(s_i) + \sum_{i=1}^n \phi_i(s_i) \sum_{j \neq i} \alpha_j \phi_j(s_j) $$ - $\phi(s_X,0) \in [0,1]$ (when the price of Y reaches its upper bound, the share of X is between zero and one) - $\phi(s_X,1) \in [0,1]$ (when the price of Y reaches its lower bound, the share of X is between zero and one) - $\phi(s_X,1) \in [0,1]$ (when the price of Y reaches its lower bound, the share of X is between zero and one)