Lets first document the process i want on grafana
Grafana plots:
- Plot the asset depth and the rune depth on grafana for every asset
- Calculate the asset price in runes = asset depth/rune depth
- Calculate the market price of the asset denominated in rune
- Make the plots of 2 and 3 in the same panel (One on the left y axis, and the another in the right z axis)
- Make the market delta plot for the asset = (Pool price of the asset - Dex price of the asset)/(Pool price of the asset)
Lets calculate the process of arbitrage in the backend but plot it on grafana
- At any moment --> instantaneously you will have the asset price in RUNE (step 2)
- Calculate the delta for this asset price (step 5)
- Our objective is to reduce the delta by 50%
Show this example for the bnb pool using a sandbox
Example :
print the following
X = Rune depth Y = asset depth
- asset price = Y/X
- calculate the market delta = (asset price - binance dex mid pt)/asset price
Now we will only target to do 20% of the trade at a time
- so the delta = (binance mid pt (Market price) - asset price)
Is 3 positive or negative ??
For 3 (take that sign in the calculation of the trade size y)
-
so the trade size = (delta * rune depth * asset depth)/(5 * asset depth) # remember its 20% at one time
-
so the output = (trade size * rune depth * asset depth)/(trade size + asset depth)^2
-
Now update the pool depth parameters : New Asset depth = Old Asset depth + trade size ; Rune depth = Rune Asset depth + output
-
Calculate the new asset price = Y/X ---> this should be closer to the market price of the asset