Peter De Roovere, IDLab-AIRO – Ghent University – imec, iGent Tower -
Technologiepark-Zwijnaarde 126, B-9052 Ghent, Belgium

# Dataset of Industrial Metal Objects

Peter De Roovere11affiliationmark:  Steven Moonen22affiliationmark:  Nick
Michiels22affiliationmark:  Francis wyffels11affiliationmark:
11affiliationmark:  IDLab-AIRO – Ghent University – imec
22affiliationmark:  Hasselt University – tUL – Flanders Make, Expertise Centre
for Digital Media<EMAIL_ADDRESS>
###### Abstract

We present a diverse dataset of industrial metal objects. These objects are
symmetric, textureless and highly reflective, leading to challenging
conditions not captured in existing datasets. Our dataset contains both real-
world and synthetic multi-view RGB images with 6D object pose labels. Real-
world data is obtained by recording multi-view images of scenes with varying
object shapes, materials, carriers, compositions and lighting conditions. This
results in over 30,000 images, accurately labelled using a new public tool.
Synthetic data is obtained by carefully simulating real-world conditions and
varying them in a controlled and realistic way. This leads to over 500,000
synthetic images. The close correspondence between synthetic and real-world
data, and controlled variations, will facilitate sim-to-real research. Our
dataset’s size and challenging nature will facilitate research on various
computer vision tasks involving reflective materials. The dataset and
accompanying resources are made available on the project website
https://pderoovere.github.io/dimo.

###### keywords:

sim-to-real, robotic manipulation, reflective materials, 6D object pose
estimation, industrial robotics

##  1 Introduction

Identifying objects and estimating their 6D poses are crucial aspects of many
robotics applications (Du et al., 2021). Manipulating physical objects
requires knowledge about their position and orientation. Estimating these
poses from image data is a longstanding problem, which remains an active area
of research (Rad and Lepetit, 2017; Xiang et al., 2018; Tekin et al., 2018; Li
et al., 2020; Zhou et al., 2019).

Existing object pose estimation datasets fail to capture important aspects of
real-world industrial use-cases. The Benchmark for 6D Object Pose Estimation
(BOP) (Hodan et al., 2018) unifies 12 datasets, of which the majority focus on
household objects. These objects are non-symmetric, with rich textures that
lead to distinct visual features. In contrast, most industrial objects are
symmetric and textureless. Material properties such as colour and reflectance
dominate their visual appearance. Other datasets do incorporate textureless
industrial objects (Hodan et al., 2017; Drost et al., 2017) but focus on
objects with limited reflectivity. However, reflective materials are
widespread. Most high precision machine components, for example, are made of
shiny metals. Existing depth sensors are unable to capture these parts
correctly. 6D pose estimation from RGB images is thus a fundamental problem
for reflective objects. This task is challenging, as these objects literally
reflect their surroundings, ambiguating their appearance. This leads to widely
varying visual appearances. A diverse dataset is needed to develop and
evaluate new solutions.

Figure 1: Side-by-side comparison of a real-world image (left) and its
synthetic counterpart (right).

As object pose labels are costly to obtain, synthetic data generation is a
promising approach to creating diverse pose estimation datasets. Recent
advances in computer graphics make it feasible to generate large amounts of
labelled data. This has been applied to pose estimation datasets (Denninger et
al., 2019; Kleeberger et al., 2019). However, the resulting images fail to
capture essential aspects of their real-world counterparts, like object
materials, scene compositions, lighting and camera viewpoints. Variations
between synthetic and real-world data can significantly hamper model
performance – the so-called _reality gap_ (Sünderhauf et al., 2018). A
proposed solution to the reality gap is domain randomization (Tobin et al.,
2017), in which parts of the data generation process are randomized. With
enough variability, real-world data may then appear to be just another
variation. However, generating _enough_ variability to envelope real-world
data points is non-trivial. Many variations are wasteful and can unnecessarily
increase the task difficulty (Hodan et al., 2019). This problem is amplified
for reflective objects, as their visual appearance is highly dependent on
their surroundings.

We present a diverse dataset of industrial, reflective objects with real-world
data and corresponding synthetic data with controlled variations. Scenes with
varying object shapes, materials, carriers, compositions, and lighting are
recorded with different cameras and from multiple viewpoints. Our dataset
consists of more than 30,000 real-world images labelled using a new open
source labeling tool. In addition, we generate over 500,000 synthetic images
by carefully mimicking real-world conditions and adding controlled variations
in object materials, compositions and lighting. We use modern physically-based
rendering techniques to simulate realistic reflections and procedurally
generate real-world artefacts like scratches.

Table 1: The different cameras used for capturing real-world image data. Camera | Lens | Type | Resolution
---|---|---|---
JAI GO-5000-PGE | KOWA LM12HC-V | RGB | $2560\times 2048$
mvBlueFOX3-2124rG-1112 | MV-O1218-10M-KO | Grayscale | $4064\times 3044$
RealSense L515 |  | RGB, LiDAR | $1920\times 1080$
RealSense D415 |  | RGB, Active IR Stereo | $1920\times 1080$

Our dataset will be of value to many different research problems. The close
correspondence between synthetic and real-world data, along with controlled
variations, will facilitate sim-to-real research. While many existing datasets
are insufficiently large (Du et al., 2021), the large number of labelled
images presented in this work can be used for training robust models. Our
dataset enables research on many important computer vision tasks involving
reflective objects. We focus our discussion on 6D object pose estimation,
which is at the root of many robotics use cases. However, our dataset also
applies to object detection, instance segmentation, novel view synthesis, 3D
reconstruction and active perception.

##  2 Methodology

We built a setup for easily collecting and labelling real-world data and
created a system for generating synthetic data by simulating real-world
conditions.

###  2.1 Real-world data

We use different camera sensors (Table 1) mounted on an industrial robot, to
capture multi-view images of diverse scenes. A custom-designed end-effector is
used to attach all cameras to a Fanuc M20ia robot, as shown in Figure 3. The
robot, with repeatability of 0.1mm, is used to accurately change camera
viewpoints. We further stabilize camera poses by cancelling backlash using the
Fanuc IRVBKLSH instruction. We calibrate all cameras using ChArUco targets,
undistort all images and perform hand-eye calibration (Tsai and Lenz, 1989).
We use high-precision aluminium-LDPE calibration targets with DICT_5x5
dictionary codes and 15mm wide checkers. ChArUco detection and calibration are
implemented using OpenCV (Bradski, 2000). Each scene is captured with every
camera from 13 different viewpoints. These viewpoints are spread out on a
hemisphere and oriented towards the center of the object carrier, as shown in
Figure 4.

Figure 2: Our set-up for collecting real-world images. We capture multi-view
images of diverse scenes using different camera sensors mounted on an
industrial robot. Figure 3: Different camera sensors are attached to the end-
effector of an industrial robot. Figure 4: Top-view visualisation of all 13
camera viewpoints. These viewpoints were spread out on a hemisphere, centred
around and oriented towards where objects are placed. Figure 5: Object
categories. We use objects of 6 categories, with different shapes and material
properties. Most objects (5a, 5b, 5c, 5d) are highly reflective and exhibit
real-world artefacts like scratches. For comparison, we also include less
reflective and textured objects (5e, 5f).

(a) Cylinder

(b) Small block

(c) Large block

(d) Shaft

(e) Red block

(f) Red cylinder

Diverse scenes are created by varying object shapes, materials, carriers,
compositions, and lighting. We use 6 object categories, shown in Figure 5,
with different shapes and material properties. Most objects (5a, 5b, 5c, 5d)
are highly reflective and exhibit real-world artefacts like scratches and saw
patterns. We also include less reflective (5e, 5f) and textured objects (5e)
for comparison. We use 3 object carriers, shown in Figure 6. Parts are stacked
in various compositions with different levels of occlusion. Lighting
conditions are varied by controlling Nanguan Luxpad 43 lights. These
variations lead to 600 scenes (Table 2) and 31,200 images (Table 3).

Figure 6: Objects are placed on 3 different types of carriers.

(a) Pallet

(b) Bin

(c) Cardboard

Table 2: Composition variations in real-world data. We use 6 object types. For each object type, we record 2 compositions with a single instance and 8 compositions with multiple instances (homogeneous). In addition, we create 40 compositions with objects of different types (heterogeneous). This leads to 100 different compositions.  Category | # Variations
---|---
Object types | $6$
Single object | $2$
Multiple objects (same type) | $8$
Homogeneous | $6\times(2+8)=60$
Heterogeneous | $40$
Compositions | $60+40=100$
Table 3: Scene variations in real-world data. All composition variants are recorded for each carrier (3) and lighting condition (2), resulting in 600 scene variations. Using 4 different cameras, each recording from 13 different viewpoints, this leads to 31,200 images. Category | # Variations
---|---
Compositions | $100$
Carriers | $3$
Lighting |  $2$ (light or dark)
Scenes | $100\times 3\times 2=600$
Camera’s | $4$
Viewpoints | $13$
Images | $600\times 4\times 13=31,200$

We carefully label all real-world data using a new open source tool. Precise
calibration and consistent camera viewpoints allow joint labelling of all
images of one scene. We developed a new open source tool to facilitate this
task, available at https://github.com/pderoovere/dimo-labeling. First, object
poses are estimated based on user-annotated correspondences between image
pixels and object model points. Next, object models are projected on each
image, allowing precise fine-tuning. All poses are defined relative to a
global coordinate system, ensuring multi-view consistency. To assess the
accuracy of our labelling pipeline, we manually label 10 synthetic scenes,
where exact ground-truth poses are available. We measure pose errors using
Maximum Symmetry-Aware Surface Distance (MSSD):

$e_{\text{MSSD}}=\text{min}_{\textbf{S}\in S_{O}}\text{max}_{\textbf{x}\in
V_{O}}\|\hat{\textbf{P}}\textbf{x}-\bar{\textbf{P}}\textbf{S}\textbf{x}\|_{2},$

with $\hat{\textbf{P}}$ the estimated pose, $\bar{\textbf{P}}$ the ground
truth pose, $S_{O}$ a set of symmetry transformations, and $V_{O}$ a set of
vertices of the object CAD model. We obtain an $e_{\text{MSSD}}$ of
$0.267\text{mm}$, demonstrating highly accurate manual annotations.

###  2.2 Synthetic data

Using a Unity project, we generate high-fidelity synthetic data. Real-world
conditions are carefully simulated. We adopt camera intrinsics and extrinsics,
and model objects and carriers. Environment maps of the different real-world
lighting conditions are created by combining bracketed images. We use a Rico
Theta S 360° camera to capture the environment with different exposures. The
resulting images are combined into a single HDRI environment map used to light
the virtual scene. We mimic real-world artefacts like scratches and saw
patterns by synthesizing textures from real-world images of example objects.
These images are relighted and cropped so they can be used as albedo textures.
A normal map is created by estimating normal vectors from these textures. A
texture synthesis algorithm is then used to create new variations of the
captured textures. This texture synthesis algorithm works in two steps. First,
random patches are taken from an example image. Next, to reduce seams between
copied patches, pixels search their neighbourhood for similar pixels and
update their value accordingly. This step is repeated multiple times, reducing
the radius of the neighbourhood with each turn, until the neighbourhood
consists of a single pixel. This procedure generates unique and realistic
appearances for every virtual object. Figure 7 shows a close-up of multiple
generated object textures. Our synthetic data generation setup leads to
synthetic images that strongly resemble their real-world counterparts.

Figure 7: Close up of a synthetic image. Our texture synthesis algorithm leads
to realistic object textures, exhibiting real-world artefacts like scratches
and saw patterns. The use of path tracing leads to realistic reflections.

A large amount of additional data is generated by varying object materials,
compositions and lighting. Object materials are generated using the texture
synthesis algorithm described before, using additional example images. We use
Unity’s physics engine to generate physically plausible object poses, starting
from random initialisations. Lighting is varied by randomly selecting an
environment map from a predefined set. Table 4 gives an overview of all
variations. Combining these variations leads to 42,600 scenes. To focus our
resources on generating environmental variations, we generate synthetic data
for 1 camera type (JAI GO-5000-PGE). In total, 553,800 images are generated.

Table 4: Synthetic variations of a real-world scene. First, each real-world scene is replicated by mimicking object poses and lighting conditions. Next, lighting conditions are varied while retaining object poses. Next, object poses are varied, while using the original lighting conditions. Finally, both lighting conditions and object poses are jointly varied. Object textures are regenerated for each recording. This leads to 71 synthetic variations for each real-world scene.  Pose | Lighting | # Variations
---|---|---
Original | Original | $1$
Original | Randomized | $15$
Randomized | Original | $15$
Randomized | Randomized | $40$
|  | 71

As we are in total control of the data generation process, labels are free.
Generating 1 scene takes 2 minutes using a NVIDIA GeForce 2080 Ti.

##  3 Dataset

Our dataset contains 31,200 images of 600 real-world scenes and 553,800 images
of 42,600 synthetic scenes, stored in a unified format. In addition to camera
intrinsics and extrinsics, object models and object pose labels, we store
information about the data generation process.

###  3.1 Format

We adopt and extend the BOP format (Hodan et al., 2018). The folder structure
is shown in Figure 8. All distances are recorded in mm. Matrices and vectors
are stored as flattened lists.

Figure 8: Folder structure of our dataset. Our dataset contains a subfolder
with object CAD models and subfolders for each camera (real and virtual).
These camera folders contain subfolders for each scene. Each scene folder
contains a subfolder with multi-view images and json files with accompanying
information. We adopt the BOP format and extend it (marked in red).

models contains object CAD models, stored in the PLY format. models_info.json
contains additional information about the size and symmetries of each object,
as shown in Listing 1. Each continuous symmetry is described by an axis and
offset value, each discrete symmetry by a transformation matrix. construction
contains technical drawings that can be used for manufacturing the parts.

Listing 1: models_info.json contains info about the CAD models.

⬇

{

"<object id>": {

"diameter": 300.0,

"min_x": -12.5,

"min_y": -12.5,

"min_z": -150.0,

"size_x": 25.0,

"size_y": 25.0

"size_z": 300.0,

"symmetries_continuous": [

{

"axis": <(3,)>,

"offset": <(3,)>

}, …

],

"symmetries_discrete": [

<(4,4)>, …

]

}, …

}

Scenes are organised by camera type (both real and virtual) and identified by
a unique id. Each scene is available for each camera. For real cameras, 13
images are available for each scene – one for each viewpoint. For virtual
cameras, 71 scenes are available for each real-world scene – 1 mimicking the
corresponding real conditions and 70 generated with varying conditions.

scene_camera.json contains camera intrinsics and extrinsics for each image, as
shown in Listing 2.

Listing 2: scene_camera.json contains camera intrinsics and extrinsics for
each image.

⬇

{

"<image id>": {

"cam_K": <(3,3)>,

"cam_R_c2w": <(4,4)>,

"cam_t_c2w": <(3,)>

}, …

}

Object poses are recorded in scene_gt.json and scene_gt_world.json, as shown
in Listing 3 and Listing 4. For each image, scene_gt.json contains objects
poses relative to the camera reference frame. As poses are consistent between
different viewpoints, we also record object poses in a shared global reference
frame (scene_gt_world.json).

scene_info.json contains information about the data generation process, as
presented in Listing 5. For each image, we record which lighting conditions
apply, which carrier is used, the type of composition (heterogeneous or
homogeneous) and camera viewpoint. This information allows selecting subsets
on the data based on specific variations.

Listing 3: scene_gt.json contains object poses (relative to the camera) for
each image.

⬇

{

"<image id>": [{

"cam_K": <(3,3)>,

"cam_R_m2c": <(4,4)>,

"cam_t_m2c": <(3,)>,

"obj_id": 2,

}, …]

}

Listing 4: scene_gt_world.json contains object poses (relative to a global
world reference). These poses are valid for all images.

⬇

{[

{

"cam_K": <(3,3)>,

"cam_R_m2w": <(4,4)>,

"cam_t_m2w": <(3,)>,

"obj_id": 2

}, …

]}

Listing 5: scene_info.json contains information about the data generation
process for each image.

⬇

{

"<image id>": {

"light": <lightmap_id>,

"carrier": <carrier_id>,

"parts": <0 (mix) | obj_id>,

"viewpoint" <viewpoint_id>,

}, …

}

Figure 9: Real-world image (left) and corresponding synthetic images with
varying lighting conditions.

###  3.2 Project website

The dataset is made available on the project website
https://pderoovere.github.io/dimo, along with a utility script for loading
data and information about the labeling tool.

##  4 Conclusion

We present a diverse dataset of industrial, reflective objects with both real-
world and synthetic data. Real-world data is obtained by recording multi-view
images of scenes with varying object shapes, materials, carriers, compositions
and lighting conditions. This leads to over 31,200 images, accurately labelled
using a new public tool. Synthetic data is obtained by carefully simulating
real-world conditions and varying environmental conditions in a controlled and
realistic way. This results in over 553,800 synthetic images. We hope our
dataset can facilitate both sim-to-real research and research on computer
vision tasks involving reflective objects.

We thank Cedric Verschueren and Hube Van Loey for their help in annotating
real-world data and RoboJob NV for their overall support.

The Authors declare that there is no conflict of interest.

The authors disclosed receipt of the following financial support for the
research, authorship, and/or publication of this article: this work was
supported by VLAIO Baekeland Mandate HBC.2019.2162.

## References

  * Bradski (2000) Bradski G (2000) The OpenCV Library.  _Dr. Dobb’s Journal of Software Tools_ .
  * Denninger et al. (2019) Denninger M, Sundermeyer M, Winkelbauer D, Zidan Y, Olefir D, Elbadrawy M, Lodhi A and Katam H (2019) Blenderproc.  _CoRR_ abs/1911.01911.  URL http://arxiv.org/abs/1911.01911.
  * Drost et al. (2017) Drost B, Ulrich M, Bergmann P, Härtinger P and Steger C (2017) Introducing mvtec ITODD - A dataset for 3d object recognition in industry.  In: _2017 IEEE International Conference on Computer Vision Workshops, ICCV Workshops 2017, Venice, Italy, October 22-29, 2017_. IEEE Computer Society, pp. 2200–2208.  10.1109/ICCVW.2017.257.  URL https://doi.org/10.1109/ICCVW.2017.257.
  * Du et al. (2021) Du G, Wang K, Lian S and Zhao K (2021) Vision-based robotic grasping from object localization, object pose estimation to grasp estimation for parallel grippers: a review.  _Artificial Intelligence Review_ 54(3): 1677–1734.  10.1007/s10462-020-09888-5.  URL https://doi.org/10.1007/s10462-020-09888-5.
  * Hodan et al. (2017) Hodan T, Haluza P, Obdrzálek S, Matas J, Lourakis MIA and Zabulis X (2017) T-LESS: an RGB-D dataset for 6d pose estimation of texture-less objects.  In: _2017 IEEE Winter Conference on Applications of Computer Vision, WACV 2017, Santa Rosa, CA, USA, March 24-31, 2017_. IEEE Computer Society, pp. 880–888.  10.1109/WACV.2017.103.  URL https://doi.org/10.1109/WACV.2017.103.
  * Hodan et al. (2018) Hodan T, Michel F, Brachmann E, Kehl W, Buch AG, Kraft D, Drost B, Vidal J, Ihrke S, Zabulis X, Sahin C, Manhardt F, Tombari F, Kim T, Matas J and Rother C (2018) BOP: benchmark for 6d object pose estimation.  In: Ferrari V, Hebert M, Sminchisescu C and Weiss Y (eds.) _Computer Vision - ECCV 2018 - 15th European Conference, Munich, Germany, September 8-14, 2018, Proceedings, Part X_ , _Lecture Notes in Computer Science_ , volume 11214. Springer, pp. 19–35.  10.1007/978-3-030-01249-6_2.  URL https://doi.org/10.1007/978-3-030-01249-6_2.
  * Hodan et al. (2019) Hodan T, Vineet V, Gal R, Shalev E, Hanzelka J, Connell T, Urbina P, Sinha SN and Guenter B (2019) Photorealistic image synthesis for object instance detection.  In: _2019 IEEE International Conference on Image Processing, ICIP 2019, Taipei, Taiwan, September 22-25, 2019_. IEEE, pp. 66–70.  10.1109/ICIP.2019.8803821.  URL https://doi.org/10.1109/ICIP.2019.8803821.
  * Kleeberger et al. (2019) Kleeberger K, Landgraf C and Huber MF (2019) Large-scale 6d object pose estimation dataset for industrial bin-picking.  In: _2019 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)_. IEEE, pp. 2573–2578.
  * Li et al. (2020) Li Y, Wang G, Ji X, Xiang Y and Fox D (2020) Deepim: Deep iterative matching for 6d pose estimation.  _International Journal of Computer Vision_ 128(3): 657–678.  10.1007/s11263-019-01250-9.  URL https://doi.org/10.1007/s11263-019-01250-9.
  * Rad and Lepetit (2017) Rad M and Lepetit V (2017) BB8: A scalable, accurate, robust to partial occlusion method for predicting the 3d poses of challenging objects without using depth.  In: _IEEE International Conference on Computer Vision, ICCV 2017, Venice, Italy, October 22-29, 2017_. IEEE Computer Society, pp. 3848–3856.  10.1109/ICCV.2017.413.  URL https://doi.org/10.1109/ICCV.2017.413.
  * Sünderhauf et al. (2018) Sünderhauf N, Brock O, Scheirer WJ, Hadsell R, Fox D, Leitner J, Upcroft B, Abbeel P, Burgard W, Milford M and Corke P (2018) The limits and potentials of deep learning for robotics.  _The International Journal of Robotics Research_ 37(4-5): 405–420.  10.1177/0278364918770733.  URL https://doi.org/10.1177/0278364918770733.
  * Tekin et al. (2018) Tekin B, Sinha SN and Fua P (2018) Real-time seamless single shot 6d object pose prediction.  In: _2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18-22, 2018_. Computer Vision Foundation / IEEE Computer Society, pp. 292–301.  10.1109/CVPR.2018.00038.  URL http://openaccess.thecvf.com/content_cvpr_2018/html/Tekin_Real-Time_Seamless_Single_CVPR_2018_paper.html.
  * Tobin et al. (2017) Tobin J, Fong R, Ray A, Schneider J, Zaremba W and Abbeel P (2017) Domain randomization for transferring deep neural networks from simulation to the real world.  In: _2017 IEEE/RSJ International Conference on Intelligent Robots and Systems, IROS 2017, Vancouver, BC, Canada, September 24-28, 2017_. IEEE, pp. 23–30.  10.1109/IROS.2017.8202133.  URL https://doi.org/10.1109/IROS.2017.8202133.
  * Tsai and Lenz (1989) Tsai RY and Lenz R (1989) A new technique for fully autonomous and efficient 3d robotics hand/eye calibration.  _IEEE Transactions on Robotics and Automation_ 5(3): 345–358.  10.1109/70.34770.  URL https://doi.org/10.1109/70.34770.
  * Xiang et al. (2018) Xiang Y, Schmidt T, Narayanan V and Fox D (2018) Posecnn: A convolutional neural network for 6d object pose estimation in cluttered scenes.  _Robotics: Science and Systems (RSS)_ .
  * Zhou et al. (2019) Zhou X, Wang D and Krähenbühl P (2019) Objects as points.  _CoRR_ abs/1904.07850.  URL http://arxiv.org/abs/1904.07850.


# Constant Power Root Market Makers

Mike Wu, Will McTighe
{mike<EMAIL_ADDRESS>
(February 2022)

###### Abstract

The paper introduces a new type of constant function market maker, the
constant power root market marker. We show that the constant sum (used by
mStable), constant product (used by Uniswap and Balancer), constant reserve
(HOLD-ing), and constant harmonic mean trading functions are special cases of
the constant power root trading function. We derive the value function for
liquidity providers, marginal price function, price impact function,
impermanent loss function, and greeks for constant power root market markers.
In particular, we find that as the power $q$ varies from the range of $-1$ to
$1$, the power root function interpolates between the harmonic ($q=-1$),
geometric ($q=0$), and arithmetic ($q=1$) means. This provides a toggle that
trades off between price slippage for traders and impermanent loss for
liquidity providers. As the power $q$ approaches 1, slippage is low and
impermanent loss is high. As $q$ approaches to -1, price slippage increases
and impermanent loss decreases.

##  1 Preface

This paper is part of an exploration of alternative approaches to AMM
curvature to incentivize trading and liquidity provision in specific use
cases. The goal of an efficient market is to provide the most liquidity at the
lowest price impact. In service of that goal, we had two initial hypotheses.
First, there is low liquidity for long tail assets in existing automated
market makers (AMMs) because it is unattractive for liquidity providers,
absent liquidity incentives. We hypothesized that greater curvature than the
constant product function could incentivize additional liquidity provision.
Second, we reasoned that there could be an alternative AMM for stableswaps,
providing more protection to LPs in edge cases, like the recent events of
Terra. Flexing power could be a gas efficient approach to adjusting curvature
but introduces issues such as reserve depletion and round-trip arbitrage. We
explored these in follow up research. If you’d like to discuss these topics in
more detail, please reach out.

##  2 Constant Function Market Makers

Constant function market makers (CFMMs) are a family of AMMs commonly used to
parameterize asset exchange mechanisms on public blockchains. Critically,
CFMMs rely on liquidity providers (LPs) who provide tokens to a supply of
reserves for use by a smart contract. The contract contains code that executes
swaps for traders. To preserve market stability, swaps must ensure a function
of the reserves is constant. This function is known as the trading function,
also called the scoring rule or the invariant.

For simplicity, we will assume the case of two tokens, although it should be
straightforward to generalize to more than two. Let
$\psi:\mathbf{R}\times\mathbf{R}\rightarrow\mathbf{R}$ be an invariant, and
$x,y\in\mathbf{R}_{+}$ be reserves. A reserve represents the amount of a token
available for swaps in the contract pool. Let
$x^{\prime},y^{\prime}\in\mathbf{R}_{+}$ denote new values for the reserves
after a trade. A trade is allowed if and only if
$\psi(x^{\prime},y^{\prime})=k$ for some constant value $k\in\mathbf{R}_{+}$,
hence the name constant function.

Three examples of trading rules are, borrowing the notation from [1]:

Constant reserve  We begin with a trivial invariant
$\psi_{\text{rsv}}(x,y)=\left\\{\begin{matrix}0&\textup{if }x=k_{1}\textup{
and }y=k_{2}\\\ -\infty&\text{otherwise}\\\ \end{matrix}\right.$ for
$k_{1},k_{2}\in\mathbf{R}$, which only allows trading if it keeps the reserves
at fixed values $a,b\in\mathbf{R}^{+}$. When $\psi$ evaluates to $-\infty$,
trading is not permitted. This is also known as HODL-ing.

Constant sum  Define
$\psi_{\text{sum}}(x,y)=\left\\{\begin{matrix}0&\textup{if }x+y=k\\\
-\infty&\text{otherwise}\\\ \end{matrix}\right.$, also called the “arithmetic
mean”. This function is only usable for asset pairs where the price ratio is
fixed (e.g. USDT-USDC or wBTC-renBTC). Technically, it has no slippage (since
price is fixed) and no impermanent loss (since we can always freely swap one
$x$ for one $y$), but no price adjustments as reserves fluctuate, meaning a
reserve can be depleted entirely. For a real world example, mStable is a DEX
for stablecoins that uses a constant sum trading function.

Constant product  Define
$\psi_{\text{prod}}(x,y)=\left\\{\begin{matrix}0&\textup{if }xy=k\\\
-\infty&\text{otherwise}\\\ \end{matrix}\right.$, also called a “geometric
mean”. We can see that $y$ must grow exponentially large as $x$ nears zero,
discouraging any traders from fully depleting reserves. (Similarly, the
property holds if $y$ is the token nearing zero). The unfortunate consequence
of this design is susceptibility to slippage. Uniswap [2, 3] and Balancer [4,
5] are instances of a constant product.

Curve [6] Define $\psi_{\text{curve}}(x,y)=\left\\{\begin{matrix}0&\textup{if
}\alpha(x+y)+\beta(xy)=k\\\ -\infty&\text{otherwise}\\\ \end{matrix}\right.$,
an interpolation between the constant sum and product functions. As
$\left(\frac{\alpha}{\beta}\right)$ increases, this converges to the constant
sum. As $\left(\frac{\alpha}{\beta}\right)$ decreases, this converges to the
constant product. In this paper, we explore another method to toggle between
arithmetic and geometric means.

Constant harmonic mean  Define
$\psi_{\text{har}}(x,y)=\left\\{\begin{matrix}0&\textup{if
}\frac{1}{\left(\frac{1}{x}+\frac{1}{y}\right)}=k\\\
-\infty&\text{otherwise}\\\ \end{matrix}\right.$. Like the geometric mean,
there is no reserve depletion. To the best of our knowledge, this function has
not been implemented in practice yet. One of the contributions of this paper
is to explore the properties of this trading function and similar relatives.

In this paper, we will propose a new family of constant function market makers
using a power root. Special cases of these power root functions (in
particular, those with non-negative power) have been previously explored by
Clipper [7] and Yieldspace [8].

###  2.1 Marginal Price and Impermanent Loss

We review the marginal price and impermanent loss for the constant sum and
product functions, all well known results.

######  Lemma 2.1.

The marginal price for the constant sum function is $M_{\textup{sum}}=1$. The
marginal price for constant product function is
$M_{\textup{prod}}=\frac{y}{x}$.

###### Proof.

Consider $(x-\Delta x)+(y+\Delta y)=k$. Solving for $\Delta y$, we obtain
$\Delta y=k-x+\Delta x-y$. Then, $\lim_{\Delta x\rightarrow
0}\left(\frac{\Delta y}{\Delta x}\right)=\lim_{\Delta x\rightarrow
0}\left(\frac{k-x+\Delta x-y}{\Delta x}\right)=1$. Next, consider, $(x-\Delta
x)(y+\Delta y)=k$. Again, solving for $\Delta y$, we get $\Delta
y=\frac{y\Delta x}{k-\Delta x}$. So $\lim_{\Delta x\rightarrow 0}\frac{\Delta
y}{\Delta x}=\lim_{\Delta x\rightarrow 0}\frac{y}{x-\Delta x}=\frac{y}{x}$. ∎

In other words, the price ratio for the constant sum function is fixed. The
price is independent of the token reserves. This is not true for the constant
product function.

######  Lemma 2.2.

Let $M^{\prime}=\alpha M$ be a change in marginal price, $\alpha>0$. Ignoring
trading fees, the impermanent loss function for constant product function is
$I_{\textup{prod}}=\frac{2\sqrt{\alpha}}{\alpha+1}-1$. For the constant sum
function, $I_{\textup{sum}}=0$ since the price marginal ratio of $x$ and $y$
must be fixed.

###### Proof.

Let $x^{\prime},y^{\prime}$ be the new reserves corresponding to $M^{\prime}$.
Define $U(x,y,M)=Mx+y$, the portfolio value at price $M$. Then
$I=\left(\frac{U(x^{\prime},y^{\prime},M^{\prime})-U(x,y,M^{\prime})}{U(x,y,M^{\prime})}\right)$,
the normalized amount the liquidity provider would have been better off by
keeping tokens out of the pool.

Starting with constant sum, we have
$U(x^{\prime},y^{\prime},M^{\prime})=M^{\prime}x^{\prime}+y^{\prime}=x^{\prime}+y^{\prime}=k$,
and $U(x,y,M^{\prime})=M^{\prime}x+y=x+y=k$. So
$I_{\text{sum}}=\frac{k-k}{k}=0$.

The constant product is slightly more intricate. Since $M=\frac{y}{x}$, we
have $y=Mx$ and so $xy=x^{2}M=k$. Thus, $x=\sqrt{\frac{k}{M}}$ and
$y=\sqrt{kM}$. Now,
$U(x^{\prime},y^{\prime},M^{\prime})=M^{\prime}\sqrt{\frac{k}{M^{\prime}}}+\sqrt{kM^{\prime}}=2\sqrt{\alpha
kM}$. Similarly, $U(x,y,M^{\prime})=(\alpha
M)\sqrt{\frac{k}{M}}+\sqrt{kM}=(\alpha+1)\sqrt{kM}$. So
$I_{\text{prod}}=\frac{2\sqrt{\alpha}\sqrt{kM}-(\alpha+1)\sqrt{kM}}{(\alpha+1)\sqrt{kM}}=\frac{2\sqrt{\alpha}}{\alpha+1}-1$.
∎

##  3 Value Functions for Liquidity Providers

Given a trading function, a reasonable question to ask is what is the LP
payoff function? Similarly, given a LP payoff function, what is the
corresponding trading function? To answer these questions, prior work [1]
formulates the trading and value functions as dual convex optimization
problems. We summarize the findings below:

Let $a,b\in\mathbf{R}_{+}$ denote the true (external market) price of $x,y$,
respectively. Define a value function
$V:\mathbf{R}_{+}\times\mathbf{R}_{+}\rightarrow\mathbf{R}$ as a function that
maps true prices to a payoff amount [9]. Then, prior work [9] has shown that

$V(a,b)=\inf_{x,y\in\mathbf{R}_{+}}\\{ax+by|\psi(x,y)=k\\}$ (1)

Equation 1 shows that traders and LPs are at odds in a zero-sum game. That is,
traders achieve maximum profit when LPs achieve minimum value, preserving the
constant function. (The converse is also true.) This intuition leads to the
foundational result that

$\psi(x,y)=\inf_{a,b\in\mathbf{R}}\\{ax+by-V(a,b)\\}.$ (2)

In other words, the trading and value functions are Fenchel conjugates of one
another. This duality does not hold for all value functions $V$. We require
$V$ to be consistent, which is composed of four requirements: concavity, non-
decreasing, non-negative, and 1-homogeneous.

We list the value function for popular trading functions, and defer to [1] for
derivations. It is straightforward to verify all value functions listed below
are consistent.

Constant reserve  $V_{\text{rsv}}(a,b)=a+b$, the sum value function.

Constant sum  $V_{\text{sum}}(a,b)=\min\\{a,b\\}$, the minimum value function.

Constant product  $V_{\text{prod}}(a,b)=\sqrt{ab}$, the product value
function.

While enlightening, this analysis so far leaves us wanting more. What is the
relationship between these three value functions? Are there other value
functions of the same family? Why does the constant product trading function
map to a product value function but constant sum maps to a minimum function?
Next, we take a step towards an answer.

##  4 Constant Power Root Market Makers

We structure the section as follows: first, we introduce a family of value
functions that contain the constant reserve, sum, and product functions as
special cases; second, we derive the corresponding trading function; third, we
compute several properties of interest, such as marginal price and impermanent
loss. Proofs are provided inline.

Figure 1: Examples of power root value functions that interpolate between
$p=0$ (constant product) and $p=1$ (constant reserve) and $p=-\infty$
(constant sum).

###  4.1 Power Root Value Function

Define the power root value function as

$V_{\text{pow}}(a,b,p)=(a^{p}+b^{p})^{\frac{1}{p}}$ (3)

for a fixed constant $p\leq 1$. Note that $p$ does not have to be an integer.
Equation 3 is equivalent to a $p$-norm when $a,b,p\geq 0$. However, the two
are not identical in properties, particularly in terms of concavity, as we
will show in Section 4.2.

We claim that all the value functions corresponding to the constant reserve,
sum, and product invariants are special cases of the power root value
function. Consider:

######  Lemma 4.1.

Suppose $a,b>0$. If $p=1$, then $V_{\text{pow}}(a,b,1)=V_{\text{rsv}}$. As
$p\rightarrow 0$, we have $V_{\text{pow}}(a,b,0)\rightarrow V_{\text{prod}}$.
As $p\rightarrow-\infty$, we have $V_{\text{pow}}(a,b,-\infty)\rightarrow
V_{\text{sum}}$.

###### Proof.

Begin with $p=1$. We have $V_{\text{pow}}(a,b,1)=a+b=V_{\textup{rsv}}$.

Next, consider $p\rightarrow-\infty$. Note that
$(a^{p}+b^{p})^{\frac{1}{p}}\geq\left(2\min\\{a,b\\}^{p}\right)^{\frac{1}{p}}=2^{\frac{1}{p}}\min\\{a,b\\}$
by definition of minimum. But also
$(a^{p}+b^{p})^{\frac{1}{p}}\leq\left(\min\\{a,b\\}^{p}\right)^{\frac{1}{p}}=\min\\{a,b\\}$
since $p<0$. By squeeze theorem, we have
$(a^{p}+b^{p})^{\frac{1}{p}}=\min\\{a,b\\}$.

Finally, consider $p\rightarrow 0$. If $a,b\geq 0$, then:

$\displaystyle\lim_{p\rightarrow 0}(a^{p}+b^{p})^{\frac{1}{p}}$
$\displaystyle=\exp\log\lim_{p\rightarrow
0}(a^{p}+b^{p})^{\frac{1}{p}}=\exp\lim_{p\rightarrow
0}\log(a^{p}+b^{p})^{\frac{1}{p}}$ $\displaystyle=\exp\lim_{p\rightarrow
0}\frac{\log(a^{p}+b^{p})}{p}=\exp\lim_{p\rightarrow
0}\frac{\left(\frac{a^{p}\log a+b^{p}\log b}{a^{p}+b^{p}}\right)}{1}$
$\displaystyle=\exp\left(\frac{\log a+\log b}{2}\right)=\sqrt{ab}$

∎

Economic Interpretation. We can view value functions as production functions
in economic theory. For instance, $V_{\text{prod}}$ is equivalent to the Cobb-
Douglas production function, $V_{\text{rsv}}$ is equivalent to the perfect
substitute (linear) production function, and $V_{\text{sum}}$ is equivalent to
the Leontief production function. Further, $V_{\text{pow}}$ is equivalent to
the constant elasticity of substitution, of which the perfect substitute,
Leontief, and Cobb-Douglas are special cases of. This matches the result shown
in Lemma 4.1.

###  4.2 Power Root Trading Function

Before we can apply Equation 2 to derive a trading function, we must verify
that $V_{\text{pow}}$ satisfies the four conditions for consistency [1].

######  Lemma 4.2.

$f(a,b)=(a^{p}+b^{p})^{\frac{1}{p}}$ for $p\leq 1$, $a,b\in\mathbf{R}$ is
concave.

###### Proof.

We first show that $f$ is quasiconcave, then 1-homogenous, which implies
concavity.

A function is quasiconcave if it is a monotonically increasing function of a
concave function. Let $g(a,b)=a^{p}+b^{p}$. If $p>1$, this is not concave.
Then, if $0\leq p\leq 1$, set $f(a,b)=g(a,b)^{\frac{1}{p}}$. Clearly $f$ is a
monotonic function of $g$. It remains to show that $g$ is concave. To see
this, note that $\nabla_{p,a}g=pa^{p-1}$, and
$\nabla^{2}_{p,a}g=p(p-1)a^{p-2}\leq 0$ since $p-1\leq 0$. Similarly,
$\nabla^{2}_{p,b}g\leq 0$. Thus, the Hessian of $g$ is a diagonal matrix with
non-positive entries, and hence semidefinite. We conclude $g$ is concave.
Next, suppose $p<0$. Then $f=g^{\frac{1}{p}}$ is a monotonically decreasing
function of $g$. But then $f$ is a monotonically increasing function of $-g$.
The Hessian of $-g$ has entries $-p(p-1)a^{p-2}$ which are again non-positive,
making $-g$ concave.

$f$ is also 1-homogeneous. To see this, note
$f(ka,kb)=\left((ka)^{p}+(kb)^{p}\right)^{\frac{1}{p}}=\left(k^{p}\left(a^{p}+b^{p}\right)\right)^{\frac{1}{p}}=k\left(a^{p}+b^{p}\right)^{\frac{1}{p}}=kf(a,b)$.
Given quasiconcavity and homogeneity, we have concavity. ∎

Lemma 4.2 shows the power root is a concave function for $p\leq 1$.

As a corollary, we obtain our first theorem.

######  Theorem 4.3.

The value function $V_{\text{pow}}(a,b)=(a^{p}+b^{p})^{\frac{1}{p}}$ is
consistent.

###### Proof.

Lemma 4.2 shows concavity and homogeneity. For $a,b\geq 0$, it is true that
$V_{\text{pow}}(a,b)\geq 0$ for all $p\leq 1$ so $V_{\text{pow}}$ is non-
negative. Finally, pick $a^{\prime}\geq a$ and $b^{\prime}\geq b$. Then
$V_{\text{pow}}(a^{\prime},b^{\prime})=((a^{\prime})^{p}+(b^{\prime})^{p})^{\frac{1}{p}}\geq(a^{p}+b^{p})^{\frac{1}{p}}=V_{\text{pow}}(a,b)$,
showing that it is non-decreasing. ∎

Now that we have shown $V_{\text{pow}}$ is consistent we are free to compute
$\psi_{\text{pow}}=\inf_{a,b\in\mathbf{R}}\\{ax+by-V_{\text{pow}}(a,b)\\}$ as
in Equation 2. We claim the following:

######  Theorem 4.4.

$\psi_{\text{pow}}(x,y)=\left\\{\begin{matrix}0&\text{if
}\left(x^{q}+y^{q}\right)^{\frac{1}{q}}\leq 1\\\ -\infty&\text{otherwise}\\\
\end{matrix}\right.$ where $q=\frac{p}{p-1}$.

###### Proof.

We will show this in the more general case of $n$ tokens
$\mathbf{x}=(x_{1},\ldots x_{n})$ with prices
$\mathbf{c}=(c_{1},\ldots,c_{n})$. By definition, we have
$\psi(\mathbf{x})=\inf_{\mathbf{c}}\left\\{x^{T}c-\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}\right\\}$.
Note that this is a convex objective as $x^{T}c$ is affine and the negation of
a concave function convex. Then:

$\psi(\mathbf{x})=\inf_{\mathbf{c}}\left\\{\mathbf{x}^{T}\mathbf{c}-\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}\right\\}=-\sup_{\mathbf{c}}\left\\{-\mathbf{x}^{T}\mathbf{c}+\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}\right\\}=-f^{*}(-\mathbf{x})$

where $f^{*}$ is the convex conjugate of
$f=-\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}$. This can be written as the
closed form $f^{*}(-\mathbf{x})=\left\\{\begin{matrix}0&\text{if
}\left(\sum_{i}x_{i}^{q}\right)^{\frac{1}{q}}\leq 1\\\
\infty&\text{otherwise}\\\ \end{matrix}\right.$ where $q=\frac{p}{p-1}$. Then
$\psi_{\text{pow}}(\mathbf{x})=-f^{*}(-\mathbf{x})=\left\\{\begin{matrix}0&\text{if
}\left(\sum_{i}x_{i}^{q}\right)^{\frac{1}{q}}\leq 1\\\
-\infty&\text{otherwise}\\\ \end{matrix}\right.$. For two tokens,
$\psi_{\text{pow}}(x,y)=\left\\{\begin{matrix}0&\text{if
}\left(x^{q}+y^{q}\right)^{\frac{1}{q}}\leq 1\\\ -\infty&\text{otherwise}\\\
\end{matrix}\right.$. ∎

Given the form of Theorem 4.4, we highlight a few special cases. If
$p\rightarrow 0$, then $q\rightarrow 0$. If $p\rightarrow-\infty$, then
$q\rightarrow 1$. If $p\rightarrow 1$, then $q\rightarrow-\infty$. This is
consistent with what we know about constant reserve, sum, and product
functions. The value function for the product invariant is also a product,
which is shown by $p,q$ both converging to 0 (see Lemma 4.1). The value
function for constant sum is a minimum function, which is captured by $q$
converging to 1 when $p$ converges to $-\infty$ (again, recall Lemma 4.1).

Figure 2: Examples of power root that interpolate between $q=-1$ to $q=1$
(constant sum), including $q=0$ (constant product). We plot the constant
reserve in the dotted line.

Figure 2 visualizes the trading curve for a range of powers $q$. We include
$q=0$ (constant product), $q=1$ (constant sum), and $q=-\infty$ (constant
reserve, shown in dotted line) for comparisons. We observe that varying
$q\in(-\infty,1]$ predictably controls the curvature of the trading function
between two extreme functions.

Harmonic Mean Result  In the case $q\rightarrow-1$, we recover the constant
harmonic mean invariant. By Theorem 4.3, we know $\psi_{\text{har}}(x,y)$ is
concave. Further, by Theorem 4.4, we have that its value function is
$V_{\text{har}}(a,b)=(a^{\frac{1}{2}}+b^{\frac{1}{2}})^{2}$ as $p=\frac{1}{2}$
when $q=-1$. This function has higher curvature than constant product.

###  4.3 Marginal Price Function

Given the constant power root trading function, we can derive an expression
for the marginal price as a function of $p$. The “marginal” price represents
the price of one token in terms of the other assuming an infinitesimally small
trade.

Begin with $\left((x-\Delta x)^{q}+(y+\Delta y)^{q}\right)^{\frac{1}{q}}=k$.
Then $\Delta y=(k^{q}-(x-\Delta x)^{q})^{\frac{1}{q}}-y$. Dividing by $\Delta
x$, we obtain $\frac{\Delta y}{\Delta x}=\frac{(k^{q}-(x-\Delta
x)^{q})^{\frac{1}{q}}-y}{\Delta x}$. Derive the marginal price using
L’Hopital’s rule:

$\displaystyle\small M_{\text{pow}}(q)$ $\displaystyle=\lim_{\Delta
x\rightarrow 0}\frac{\Delta y}{\Delta x}=\lim_{\Delta x\rightarrow
0}\left(\frac{\frac{d\Delta y}{d\Delta x}}{\frac{d\Delta x}{d\Delta
x}}\right)=\lim_{\Delta x\rightarrow 0}\left(\frac{d}{d\Delta
x}\left((k^{q}-(x-\Delta x)^{q})^{\frac{1}{q}}-y\right)\right)$
$\displaystyle=\lim_{\Delta x\rightarrow 0}\left(\frac{1}{q}(k^{q}-(x-\Delta
x)^{q})^{\frac{1}{q}-1}\cdot-q(x-\Delta x)^{q-1}\cdot-1\right)$
$\displaystyle=(k^{q}-x^{q})^{\frac{1}{q}-1}\cdot
x^{q-1}=(y^{q})^{\frac{1}{q}-1}\cdot x^{q-1}$

Since $\frac{1}{q}-1=\frac{1-q}{q}$, we obtain the following expression

$M_{\text{pow}}(q)=x^{q-1}y^{1-q}$ (4)

A quick inspection of Equation 4 and Lemma 2.1 shows that for $q=1$, we have
$M_{\text{pow}}(1)=x^{0}y^{0}=1=M_{\text{sum}}$, and
$M_{\text{pow}}(0)=x^{-1}y^{1}=\frac{y}{x}=M_{\text{prod}}$. That is, the
marginal price for the constant sum and product invariants are again, special
cases of the constant power root.

Figure 4(a) plots the marginal price as a function of the reserve ratios
between $x$ and $y$. As $q\rightarrow 1$, we see the marginal price converge
to a constant function at 1. As $q\rightarrow-\infty$, it approaches an
exponentially increasing function. When $q=0$, the price is linear.

###  4.4 Impermanent Loss Function

Using the result in Section 4.3, we show the following theorem:

######  Theorem 4.5.

Let $\alpha>0$ be a change in marginal price $M=M_{\text{pow}}(q)$. The
impermanent loss for the constant power root trading function is

$I_{\textup{proot}}(q)=\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha
M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}\left(\frac{\alpha M+(\alpha
M)^{\frac{1}{1-q}}}{\alpha M+M^{\frac{1}{1-q}}}\right)-1.$ (5)

###### Proof.

First, we wish to represent $x$ and $y$ in terms of the constant $k$ and the
marginal price $M$ only. Recall from Equation 4 that $M=x^{q-1}y^{1-q}$. So
$y=M^{\frac{1}{1-q}}x$. Since $(x^{q}+y^{q})^{\frac{1}{q}}=k$, we compute
$x=\frac{k}{(1+M^{\frac{q}{1-q}})^{\frac{1}{q}}}$, and thus
$y=\frac{kM^{\frac{1}{1-q}}}{(1+M^{\frac{q}{1-q}})^{\frac{1}{q}}}$.

Second, we can compute value $U(x,y,M)=Mx+y$. Note $M^{\prime}=\alpha M$. Let
$x^{\prime},y^{\prime}$ be the token reserves at the new marginal price
$M^{\prime}$. Then
$U(x^{\prime},y^{\prime},M^{\prime})=M^{\prime}\left(\frac{k}{(1+(M^{\prime})^{\frac{q}{1-q}})^{\frac{1}{q}}}\right)+\left(\frac{k(M^{\prime})^{\frac{1}{1-q}}}{(1+(M^{\prime})^{\frac{q}{1-q}})^{\frac{1}{q}}}\right)=\frac{\alpha
kM+k(\alpha M)^{\frac{1}{1-q}}}{(1+(\alpha
M)^{\frac{q}{1-q}})^{\frac{1}{q}}}$. Similarly, compute
$U(x,y,M^{\prime})=\frac{\alpha
kM+kM^{\frac{1}{1-q}}}{(1+M^{\frac{q}{1-q}})^{\frac{1}{q}}}$.

Now, use the definition that
$I=\frac{U(x^{\prime},y^{\prime},M^{\prime})-U(x,y,M^{\prime})}{U(x,y,M^{\prime})}$.
To be pedantic, we obtain

$I=\left(\frac{\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha
M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}(\alpha M+(\alpha
M)^{\frac{1}{1-q}})-(\alpha M+M^{\frac{1}{1-q}})}{\alpha
M+M^{\frac{1}{1-q}}}\right).$

Divide by the denominator to find the result. ∎

We aim to show special cases of this impermanent loss. As these require
nontrivial work, we do so in the following corollaries.

######  Corollary 4.5.1.

$\lim_{q\rightarrow 0}I_{\textup{proot}}(q)=I_{\textup{prod}}$.

###### Proof.

We compute the limit separately for the three pieces of
$I_{\textup{proot}}(q)$.

  1. 1.

$\lim_{q\rightarrow 0}\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha
M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}=\exp\lim_{q\rightarrow
0}\left(\frac{\log\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha
M)^{\frac{q}{1-q}}}\right)}{q}\right)=\left(\frac{M}{\alpha
M}\right)^{\frac{1}{2}}=\alpha^{-\frac{1}{2}}$.

  2. 2.

$\lim_{q\rightarrow 0}\left(\frac{\alpha M+(\alpha M)^{\frac{1}{1-q}}}{\alpha
M+M^{\frac{1}{1-q}}}\right)=\frac{2\alpha
M}{(\alpha+1)M}=\frac{2\alpha}{\alpha+1}$.

Altogether, the limit evaluates to
$\frac{1}{\sqrt{\alpha}}\cdot\frac{2\alpha}{\alpha+1}-1=\frac{2\sqrt{\alpha}}{\alpha+1}-1$.
Recall Lemma 2.2 to see this is equivalent to $I_{\textup{prod}}$. ∎

######  Corollary 4.5.2.

$\lim_{q\rightarrow 1}I_{\textup{proot}}(q)=I_{\textup{sum}}$.

###### Proof.

Consider only the first term in $I_{\textup{proot}}$ and apply exp-log to get
separate limits. Let
$J(q)=I_{\text{pow}}(q)+1=\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha
M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}\left(\frac{\alpha M+(\alpha
M)^{\frac{1}{1-q}}}{\alpha M+M^{\frac{1}{1-q}}}\right)$. Then,

$\lim_{q\rightarrow 1}J(q)=\exp\left(\log\lim_{q\rightarrow
1}A+\log\lim_{q\rightarrow 1}B\right).$

Focusing on the expression inside the $\log$, we will study each of these in
turn. First,

$\displaystyle\log\lim_{q\rightarrow 1}A$ $\displaystyle=\lim_{q\rightarrow
1}\log\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha
M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}=\lim_{q\rightarrow
1}\frac{1}{q}\cdot\log\left(\lim_{q\rightarrow
1}\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)$
$\displaystyle=\log\left(\frac{\frac{M^{\frac{-q}{q-1}}\log
M}{(q-1)^{2}}}{\frac{(\alpha M)^{\frac{-q}{q-1}}\log(\alpha
M)}{(q-1)^{2}}}\right)=\log\left(\lim_{q\rightarrow
1}\alpha^{\frac{-q}{q-1}}\cdot\frac{\log M}{\log(\alpha M)}\right)$
$\displaystyle=\lim_{q\rightarrow
1}\left(\frac{q}{q-1}\right)\log\alpha+\log\left(\frac{\log M}{\log(\alpha
M)}\right)$

where the swaps between the limit and log follows by the continuity of log.

This limit is undefined but we can evaluate the left and right limits. If
$q\rightarrow 1^{+}$, then $\left(\frac{q}{q-1}\right)\rightarrow\infty$,
leaving $\log\lim_{q\rightarrow
1^{+}}A=\left\\{\begin{matrix}-\infty&0<\alpha<1\\\ 0&\alpha=1\\\
\infty&\alpha>1\end{matrix}\right.$. If $q\rightarrow 1^{-}$, we have
$\left(\frac{q}{q-1}\right)\rightarrow-\infty$, leaving
$\log\lim_{q\rightarrow 1^{-}}A=\left\\{\begin{matrix}\infty&0<\alpha<1\\\
0&\alpha=1\\\ -\infty&\alpha>1\end{matrix}\right.$.

Next, we can evaluate the second term:

$\displaystyle\log\lim_{q\rightarrow 1}B$
$\displaystyle=\log\lim_{q\rightarrow 1}\left(\frac{\alpha M+(\alpha
M)^{\frac{1}{1-q}}}{\alpha M+M^{\frac{1}{1-q}}}\right)=\log\lim_{q\rightarrow
1}\left(\frac{\frac{(\alpha M)^{\frac{-1}{q-1}}\log(\alpha
M)}{(q-1)^{2}}}{\frac{M^{\frac{-1}{q-1}}\log M}{(q-1)^{2}}}\right)$
$\displaystyle=\log\lim_{q\rightarrow 1}\left(\ \frac{(\alpha
M)^{\frac{-1}{q-1}}\log(\alpha M)}{M^{\frac{-1}{q-1}}\log
M}\right)=\log\lim_{q\rightarrow
1}\left(\alpha^{\frac{-1}{q-1}}\cdot\frac{\log(\alpha M)}{\log M}\right)$

where the second equality follows by L’Hopital’s rule.

Again, this limit doesn’t exist but we can evaluate the left and right limits.
If $q\rightarrow 1^{+}$, then $\left(\frac{-1}{q-1}\right)\rightarrow-\infty$,
leaving $\log\lim_{q\rightarrow
1^{+}}A=\left\\{\begin{matrix}\infty&0<\alpha<1\\\ 0&\alpha=1\\\
-\infty&\alpha>1\end{matrix}\right.$. If $q\rightarrow 1^{-}$, we have
$\left(\frac{-1}{q-1}\right)\rightarrow\infty$, leaving
$\log\lim_{q\rightarrow 1^{-}}A=\left\\{\begin{matrix}-\infty&0<\alpha<1\\\
0&\alpha=1\\\ \infty&\alpha>1\\\ \end{matrix}\right.$.

Now, we notice that $\log\lim A+\log\lim B=0$ for all cases of $\alpha$ and
$q$ coming from left or right. Note we cannot take the limit of $A+B$ as each
is not defined.

Thus, we have $\lim_{q\rightarrow 1}J(q)=\exp 0=1$. So $\lim_{q\rightarrow
1}I_{\textup{proot}}(q)=0$, which is $I_{\textup{sum}}$. ∎

Corollaries 4.5.1 and 4.5.2 show that like the marginal price, the constant
sum and product impermanent loss functions are special cases of the constant
power root.

Figure 3: Impermanent loss as a function of $-\infty<q\leq 1$ with comparisons
to constant sum, constant reserve, and constant product market makers (i.e.
Uniswap).

We plot the impermanent loss as a function of $q$ in Figure 3, where the
constant product (i.e. Uniswap) is shown in purple stars, constant reserve is
shown in black hexagons, and the constant sum is shown with an orange cross
(note this is only a single point as marginal price does not change for the
constant sum invariant). Figure 3 shows a gradient of loss functions as $q$
varies. In particular, we see increased impermanent loss as $q$ approaches 1
and reduced impermanent loss as $q$ approaches $-\infty$. This is aligned with
prior work [10] that suggests trading functions with flatter curvature have
higher loss.

###  4.5 Price Impact

Next, we compute the price impact function [10], or the change to marginal
price given a trade of size $\Delta x$, as $\frac{d\Delta y}{d\Delta x}$, the
derivative of the price function. Equation 6 shows the price impact function
for power roots.

$\frac{d\Delta y}{d\Delta x}=(x^{q}+y^{q}-(x-\Delta
x)^{q})^{\frac{1-q}{q}}\cdot(x-\Delta x)^{q-1}$ (6)

Refer to [10] for derivations for the constant sum and product functions. It
is straightforward to show that those are special cases of Equation 6 by $q=0$
and $q=1$. Figure 4(b) shows the price impact for constant power root market
makers of varying $q$. When $q\rightarrow 1$, the price impact function
approaches 0 slope, which makes sense given that the marginal price is
constant when $q=1$. When $q\rightarrow-\infty$, the price impact function has
a faster increasing slope, representing higher levels of price sensitivity.

Practically, we note that price impact function is closely related to slippage
as a constant function market maker with high price impact will likely
experience higher slippage rates. As a base example, when $q=1$, there is zero
slippage due to the constant marginal price, or equivalently, its price impact
function having zero slope.

(a) Marginal price as a function of $q$. On the x-axis, we plot a ratio of
$\frac{y}{x}$ with $x=1$.

(b) Impact of a trade on price as a function of the trade size ($\Delta
x\in[0,9000]$, $x,y=10000$).

Figure 4: Marginal price is shown on the left, defined as the price in the
limit of an infinitesimally small trade. Price impact is shown on the right,
the sensitivity of price in response to trade size. In both figures, we see a
continuum between $q=-1$ and $q=1$.

In summary, there is a trade-off between impermanent loss and price impact,
which is perhaps not surprising. For large negative powers, the invariant has
low loss for LPs but high price slippage for traders. For powers close to one,
the opposite is true.

###  4.6 Value Derivatives

Since impermanent loss can be difficult to interpret, we also compute the
value $U(x,y,M)$ as well as derivatives with respect to price, such as delta
$\Delta=\frac{\delta U}{\delta M}$ and gamma $\Gamma=\frac{\delta^{2}U}{\delta
M^{2}}$. Continuing from Section 4.4, we can simplify the expression for value
using only the liquidity amount $k$ and the marginal price $M$, removing
reserves from the equation:

$U(M,k)=Mk\left(1+M^{\frac{q}{1-q}}\right)^{\frac{q-1}{q}}$ (7)

Taking first and second derivatives, we arrive at closed form expressions for
the greeks:

$\Delta(M,k)=k\left(M^{\frac{q}{q-1}}+1\right)^{-\frac{1}{q}},\qquad\Gamma(M,k)=\left(\frac{-1}{1-q}\right)M^{\frac{q}{1-q}-1}\left(M^{\frac{q}{1-q}}+1\right)^{\frac{-1}{q}-1}$
(8)

In the following figure, we visualize the greeks for a variety of powers $q$.

(a) Value $U$

(b) Delta $\Delta$

(c) Gamma $\Gamma$

Figure 5: Visualizing value, delta, and gamma for a range of powers. In
particular, we compare $q=0$ (constant product, Uniswap) to $q=1$ (constant
sum) to $q=-1$ (constant harmonic mean) to $q=-100$ (a proxy for $q=-\infty$,
also called constant reserve or HODL).

In Figure 5, we vary the marginal price $M$ between 0 and 1 and study the
effect on value, delta, and gamma. For each subplot, we normalize the y axis
to be between 0 and 1 for visual comparison. As such, the reader should focus
on the shape rather than the magnitudes. We make a few observations. First, in
Figure 5(a), for positive powers, the larger the power, the less curvature in
the value function. Interestingly, for larger negative powers, we observe a
similar behavior, as $q=-100$ and $q=1$ have similar shape. Recalling payoff
functions from Figure 2, we note that Figure 5(a) shows the same plot in lower
dimensions.

Second, we observe more diverse delta functions as $q$ spans between 0 and 1
in Figure 5(b). For smaller positive powers, we observe delta to increase
exponentially as price goes to zero, whereas for larger positive powers, we
observe delta to increase exponentially as price grows large. For powers close
to $q=0.5$, we observe near linear change in delta. Third, in Figure 5(c), we
observe that subtle differences in value are exaggerated as gamma functions
across powers differ in behavior. This large range in gamma functions may
suggest power roots to play a role in structured products to achieve a desired
gamma. We note that delta and gamma for negatives powers closely mimic those
of constant product.

###  4.7 Reserve Depletion

A benefit of the Uniswap trading function ($q=0$) is a guarantee of no reserve
depletion. For any value of token $x>0$ and any constant $k$, we have a
$y=\frac{k}{x}>0$. In practice, this implies no trade can conduct a trade
large enough to deplete resources. This property, however, does not hold for
the sum invariant ($q=1$), where the analogous expression $y=k-x$ suggests
that $x\leq k$, otherwise $y\leq 0$.

The power root invariant with $q\leq 0$ guarantees no reserve depletion.
However for powers $0<q\leq 1$ it, like the sum, has the same point of reserve
depletion, namely $x=k$. One can see this from the equation
$y=(k^{q}-x^{q})^{\frac{1}{q}}$, which implies $k^{q}\geq x^{q}$ is required.
As $q\rightarrow 0$, this constraint is removed, and power root collapses to
product. However, for $q$ closer to 0, we observe more incentives to not
deplete reserves due to price increases, though it is theoretically possible.
For example, for $q=\epsilon$ close to 0, the marginal price is
$\frac{y^{1-\epsilon}}{x^{1-\epsilon}}\approx\frac{y}{x}$. If $x$ is near
depleted (and $y$ near $k$), the price will be tending towards $\infty$.

Figure 6: The price of token $x$ relative to token $y$ as a function of the
trade size.

Figure 6 visualizes the relative price between two tokens as a function of
trade size in token $x$. Constant sum and product are shown with special
markers. We make a few observations. First, the relative price decreases as
trade size grows, which is expected given the concavity of the trading
functions. Second, for $0<q<1$, the plotted lines intersect the x-axis,
representing points of depleted reserves (for $q=1$, we have the point of
depletion at $x=1$). For $q\leq 0$, the plotted lines never intersect the
x-axis. Third, for $0<q<1$, there are segments where the price is better than
constant product, which suggests better conditions for traders assuming small
trades. This is not the case for large trades. Clipper [7] formalized this
approach by only allowing small trades. For $q<0$, prices are bounded above by
constant product ($q=0$), meaning traders face a higher cost.

##  5 Summary

We proposed a new constant function market maker using the power root equation
$\psi_{\text{pow}}(\mathbf{x})=\left(\sum_{i}x_{i}^{q}\right)^{\frac{1}{q}}$
with the corresponding payoff (value) function for liquidity providers as
$V_{\text{pow}}(\mathbf{c})=\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}$ with
$q=\frac{p}{p-1}$. Inspired by economic production functions, we showed this
choice to be a generalization of the constant reserve, sum, and product. The
constant power root function interpolates between the constant reserve, sum,
and product functions in terms of marginal price, price impact, and
impermanent loss. In our analysis, we observe a trade-off between low slippage
and impermanent loss, and susceptibility to reserve depletion.

## Acknowledgement

A special thanks must go to Guillaume Lambert, Alok Vasudev, Theo Diamandis,
Dan Robinson, and Joey Santoro for their helpful feedback and discussion.

## References

  * [1] Guillermo Angeris, Alex Evans, and Tarun Chitra.  Replicating market makers.  arXiv preprint arXiv:2103.14769, 2021.
  * [2] Guillermo Angeris, Hsien-Tang Kao, Rei Chiang, Charlie Noyes, and Tarun Chitra.  An analysis of uniswap markets.  arXiv preprint arXiv:1911.03380, 2019.
  * [3] Hayden Adams, Noah Zinsmeister, Moody Salem, River Keefer, and Dan Robinson.  Uniswap v3 core.  Technical report, Technical report, 2021.
  * [4] Fernando Martinelli and Nikolai Mushegian.  A non-custodial portfolio manager, liquidity provider, and price sensor.  URl: https://balancer. finance/whitepaper, 2019.
  * [5] Alex Evans.  Liquidity provider returns in geometric mean markets.  arXiv preprint arXiv:2006.08806, 2020.
  * [6] Michael Egorov.  Stableswap-efficient mechanism for stablecoin liquidity.  Retrieved Feb, 24:2021, 2019.
  * [7] Abraham Othman.  New invariants for automated market making.  2021\.
  * [8] Allan Niemerg, Dan Robinson, and Lev Livnev.  Yieldspace: An automated liquidity provider for fixed yield tokens.  2020\.
  * [9] Guillermo Angeris and Tarun Chitra.  Improved price oracles: Constant function market makers.  In Proceedings of the 2nd ACM Conference on Advances in Financial Technologies, pages 80–91, 2020.
  * [10] Guillermo Angeris, Alex Evans, and Tarun Chitra.  When does the tail wag the dog? curvature and market making.  arXiv preprint arXiv:2012.08040, 2020.