Skip to content

Commit

Permalink
math refactor (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel authored Feb 26, 2024
1 parent 3043135 commit 1fd1ce1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ConstantSum/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Constant Sum Market Maker
This will be all the background needed to understand the `GeometricMean` DFMM.
This will be all the background needed to understand the `ConstantSum` DFMM.

## Conceptual Overview
The `ConstantSum` DFMM gives the LP a portfolio that will allow exchange of a pair of tokens at a single price.
Expand Down Expand Up @@ -63,7 +63,7 @@ Allocations and deallocations should not change the price of a pool and since th
We need only compute the new $L$.
Specifically:
$$
L + \Delta_L = x+\Delta_X + \frac{y+\Delta_Y}{P}
\Delta_L = \Delta_X + \frac{\Delta_Y}{P}
$$


Expand Down
25 changes: 19 additions & 6 deletions src/GeometricMean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,30 @@ $$


## Allocations and Deallocations
Allocations and deallocations should not change the price of a pool, so the ratio of reserves cannot change:
**Input $\delta_X$:** If a user wants to allocate a specific amount of $\delta_X$, then it must be that:
$$
P = \frac{w_x}{w_y} \frac{y}{x} = \frac{w_x}{w_y} \frac{y+\Delta_y}{x+\Delta_x}.
\frac{x}{L} = \frac{x+\Delta_X}{L+\Delta_L}
$$
**Input $\Delta_X$:** If a user wants to allocate a specific amount of $\Delta_X$, then they must also allocate:
which yields:
$$
\boxed{\Delta_Y = \frac{y}{x}(x+\Delta_X)-y}
\Delta_L = L \frac{\Delta_X}{x}
$$
**Input $\Delta_Y$:** For a given $\Delta_Y$, then they must have:
Then it must be that since the ratio of reserves cannot change.
$$
\boxed{\Delta_X = \frac{x}{y}(y+\Delta_Y)-x}
\Delta_Y = y\frac{\Delta_X}{x}
$$

**Input $\Delta_Y$:** To allocate a specific amount of $\Delta_Y$, then it must be that:
$$
\frac{y}{\mu L} = \frac{y+\Delta_Y}{\mu(L+\Delta_L)}
$$
which yields:
$$
\Delta_L = L \frac{\Delta_Y}{y}
$$
and we likewise get
$$
\Delta_X = x\frac{\Delta_Y}{y}
$$


Expand Down

0 comments on commit 1fd1ce1

Please sign in to comment.