Kyber Price Discovery

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Kyber Network price discovery algorithm

Jonathan Nathan
26.4.2018

If most of a token’s volume is traded on KN, how would the price be


set, given a list of trades? Assuming the price (ETH/token) will be given
by P (E) which will be a function of the current ETH reserve size. Then
assuming we want a change in the price to be proportional to the amount
traded we will have:
P (E + ∆E) − P (E)
= r∆E
P (E)
where r is the proportion factor. When ∆E is very small we’ll have
dP (E)
= rdE
P (E)
integration gives
ln P (E) = r · E + A
P (E) = er·E eA
Where eA is the minimal price given by Pmin , so we have

P (E) = Pmin er·E

The amount of tokens Tmax that will be sold until reaching Pmax , is related
to the maximal price on our platform P (Emax ) in the following way
Z Emax
1
Tmax = dE
E P
where Emax is given from Pmax itself,
 
1 Pmax
Emax = ln
r Pmin

1
carrying out the integration and plugging in Emax will give:
 
1 1 1
Tmax = −
r P (E) Pmax
the initial amount of tokens T0 will be given by calculating Tmax at E0 , which
finally gives  
1 1 1
T0 = −
r P0 Pmax
similarly, the initial amount of ETH, E0 , can be deduced from the initial
price P0 as  
1 P0
E0 = ln
r Pmin
So given Pmin , Pmax , P0 , r we can find E0 , T0 , Emax .

1 Net transaction costs


1.1 Trading ∆E ethers
∆E can be positive (increasing the amount of ethers in the reserve and selling
tokens to the trader), or negative. Solving the following integral
Z E+∆E
1
dE = ∆T
E P (E)
will give the result for ∆T
1
· e−r∆E − 1

∆T (∆E) =
r · P (E)

1.2 Trading ∆T tokens


∆T can be positive (increasing the amount of tokens in the reserve and selling
ethers to the trader), or negative. Integrating the following
Z E+∆E
1
dE = ∆T
E P (E)
and solving with respect to ∆E gives
1
∆E(∆T ) = − ln(1 + r · P (E) · ∆T )
r
2
0.200 Pm ax

0.175

0.150

0.125
Price E/T

P0
0.100

0.075
Pm in
0.050

0.025

0.000
0 20 40 60 E_0 80 100 120 140
Invent ory in E E_max

Figure 1: The price function, with relevant parameters. T0 cannot be shown


since its the area under 1/P, not the area under P.

3
2 Trading with spread
I assume that the spread S is given in percentage of the trade, and composed
of 2 different terms: fee spread Sf ee and liquidity spread Sliq , so

S = Sf ee + Sliq

The fee spread vanishes from the system (to cover costs, etc.) The liquidity
spread is returned to the reserve in order to reduce the price increase rate
r and increase liquidity over time. Each side of the reserve should get a
different fraction from the Sliq earnings. The ratio depends on the current
sizes of E and T , and their ratio to the total value of the reserve. In order
to determine the ratio α and the new rate r0 , we do the following process:

1. Calculate the net transaction value given ∆E was traded.

∆Enet = ∆E · (1 − S)
∆Tnet = ∆T (∆Enet )

∆E can be positive (we sell tokens) or negative (we buy tokens). ∆T


is given by the expression in section 1.1 .

2. Calculate the maximal possible extra value for each side

∆Eextra = |Sliq ∆Enet |


∆Textra = |∆T (∆E · (1 − Sf ee )) − ∆Tnet |

3. Define updated reserve values

Enet = E + ∆Enet
Tnet = T + ∆Tnet

4. Calculate how to divide the extra gain between the E and T reserves.
In order to do that, we solve a system of 2 equations:
r · Enet
r0 =
Enet + α∆Eextra
0
Z Emax
1
dE = Tnet + (1 − α)∆Textra
Enet +α∆Eextra P (Enet )

4
 
0 1 Pmax
Where Emax = r0
ln Pmin
. After solving the above equations for α
we get
Enet (r(Tnet + ∆Textra ) − β)
α=
β · ∆Eextra + r · Enet · ∆Textra
r · Enet
r0 =
Enet + α∆Eextra
1 1
where β = P (Enet )
− Pmax
.

5. Now we can finally update the reserve with the extra amounts:

E = E + Enet + α · ∆Eextra
T = T + Tnet + (1 − α) · ∆Textra

5
0.200 Pmax

0.175

0.150

0.125
Price E/T

P0
0.100

0.075
Pmin
0.050

0.025

0.000
0 20 40 60 80 100 120 140 160
Inventory in E

Figure 2: The change in the price function after some volume was traded.
The gray line shows the original price function with rate r and the blue the
modified price with rate r0 and higher liquidity. The green point shows the
current price.

You might also like