Skip to content

Commit

Permalink
Update NBTest_049_CPCBalancer.py
Browse files Browse the repository at this point in the history
Update NBTest_049_CPCBalancer.py
  • Loading branch information
sklbancor committed Aug 21, 2023
1 parent 880c782 commit a7cc95d
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions resources/NBTest/NBTest_049_CPCBalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@
assert not raises(c0.description)
assert raises(c1.description).startswith("only implemented for")

assert not raises(c0.tvl)
assert raises(c1.tvl).startswith("only implemented for")

assert not raises(lambda: c0.kbar)
assert raises(lambda: c1.kbar).startswith("only implemented for")

assert not raises(lambda: c0.p_max)
assert raises(lambda: c1.p_max).startswith("only implemented for")
Expand All @@ -192,9 +188,6 @@
assert not raises(c0.format)
assert raises(c1.format).startswith("only implemented for")

assert not raises(c0.format)
assert raises(c1.format).startswith("only implemented for")

assert not raises(c0.xyfromp_f)
assert raises(c1.xyfromp_f).startswith("only implemented for")

Expand All @@ -215,6 +208,12 @@
assert not raises(lambda: c0.p)
assert not raises(lambda: c1.p)

assert not raises(lambda: c0.kbar)
assert not raises(lambda: c1.kbar)

assert not raises(c0.tvl)
assert not raises(c1.tvl)

assert not raises(c0.yfromx_f, 110)
assert not raises(c1.yfromx_f, 110)

Expand Down Expand Up @@ -251,6 +250,23 @@
assert iseq(c1.p, 2 * c1.eta)
assert iseq(c2.p, 2 * c2.eta)

# #### TVL
#
# $$
# \mathrm{TVL} = x_a*p + y_a
# $$

assert c0.x == c0.x_act
assert c0.y == c0.y_act
assert c1.x == c1.x_act
assert c1.y == c1.y_act
assert c2.x == c2.x_act
assert c2.y == c2.y_act

assert iseq(c0.tvl(), 100 * c0.p + 200)
assert iseq(c1.tvl(), 100 * c1.p + 200)
assert iseq(c2.tvl(), 100 * c2.p + 200)

# #### Pool constant $k$
#
# $$
Expand All @@ -266,6 +282,20 @@
assert iseq(c1.k**(2/3), c1.x**(2/3) * c1.y**(1/3))
assert iseq(c2.k**(1/3), c1.x**(1/3) * c1.y**(2/3))

# #### Pool constant $\bar k$
#
# $$
# x^\alpha\, y^{1-\alpha} = \bar k = k^\alpha
# $$

assert iseq(c0.kbar, c0.x**(1/2) * c0.y**(1/2))
assert iseq(c1.kbar, c1.x**(2/3) * c1.y**(1/3))
assert iseq(c2.kbar, c1.x**(1/3) * c1.y**(2/3))

assert iseq(c0.kbar, c0.k**c0.alpha)
assert iseq(c1.kbar, c1.k**c1.alpha)
assert iseq(c2.kbar, c2.k**c2.alpha)

# #### Token balance function $y(x)$
#
# $$
Expand Down

0 comments on commit a7cc95d

Please sign in to comment.