decred.org/dcrdex@v1.0.5/docs/images/break-even-half-gap.tex (about) 1 \documentclass[]{article} 2 \begin{document} 3 4 In a buy\textrightarrow sell sequence with a positive gap, we end up with more of the quote asset and less of the base asset. Setting our loss ratio equal to our profit ratio, we get 5 6 \[ 7 \frac{F_B}{L} = \frac{p_sL - p_bL - F_Q}{p_bL} 8 \] 9 10 where $ F_B $ and $ F_Q $ are the fees accumulated for the base and quote assets respectively, $ p_b $ and $ p_s $ are the buy and sell prices, and $ L $ is the market's lot size. 11 12 Rearranging, we get 13 14 \[ 15 p_bF_B = p_sL - p_bL - F_Q 16 \] 17 18 Noting that for mid-gap price, $ r $, and half-gap width $ g $, 19 20 \[ 21 p_b = r - g 22 \] 23 \[ 24 p_s = r + g 25 \] 26 27 substituting, 28 29 \[ 30 (r - g)F_B = (r + g)L - (r - g)L - F_Q 31 \] 32 33 and solving for $ g $ yields our break-even half-gap. 34 35 36 \[ 37 g = \frac{rF_B + F_Q}{F_B + 2L} 38 \] 39 40 \end{document}