|
131 | 131 | AUM_{stableToken}=PoolAmount_{token}\times Price_{token}
|
132 | 132 | $$
|
133 | 133 |
|
| 134 | +</br> |
| 135 | + |
134 | 136 | $$
|
135 | 137 | \begin{align*}
|
136 |
| -AUM_{NonStableToken} & = PoolAmount \times Price + {P\&L_{long}} + {P\&L_{short}}\\ |
137 |
| -P\&L_{long} & = GuranteedUSD - ReserveAmount \times Price\\ |
138 |
| -P\&L_{short} & = \pm Size_{globalShort}\times \frac{\left | Price-avgPrice_{globalShort} \right | }{avgPrice_{globalShort}}\\ |
| 138 | +AUM_{NonStableToken} & = PoolAmount \times Price + {P\&L_{long}} + {P\&L_{short}} \\ |
| 139 | +P\&L_{long} & = GuranteedUSD - ReserveAmount \times Price \\ |
| 140 | +P\&L_{short} & = \pm Size_{globalShort}\times \frac{\left | Price-avgPrice_{globalShort} \right | }{avgPrice_{globalShort}} |
139 | 141 | \end{align*}
|
140 | 142 | $$
|
141 | 143 |
|
142 | 144 | 对于 short 部分:
|
143 | 145 |
|
144 | 146 | $$
|
145 | 147 | \begin{align*}
|
146 |
| -Price > avgPrice_{globalShort}, {User亏损}, {LP盈利}, {P\&L_{short}}>0\\ |
| 148 | +Price > avgPrice_{globalShort}, {User亏损}, {LP盈利}, {P\&L_{short}}>0 \\ |
147 | 149 | Price < avgPrice_{globalShort}, {User盈利}, {LP亏损}, {P\&L_{short}}<0
|
148 | 150 | \end{align*}
|
149 | 151 | $$
|
150 | 152 |
|
151 | 153 | 对于 long 部分:
|
152 | 154 |
|
153 | 155 | $$
|
154 |
| -{\begin{align*} |
155 |
| -GuranteedUSD &: \text{用户开仓时,杠杆数超过1,而向LP借款的部分}\\ |
156 |
| -ReserveAmount\times Price&: \text{LP预留给用户用以实现仓位的部分的当前时刻价值}\\ |
157 |
| -ReserveAmount &: \text{用户开平仓时,那个时刻的仓位价值与那个时刻的价格比,即为LP预留的Token数量}\\ |
158 |
| -\end{align*}} |
| 156 | +\begin{align*} |
| 157 | +GuranteedUSD &: \text{用户开仓时,杠杆数超过1,而向LP借款的部分} \\ |
| 158 | +ReserveAmount\times Price&: \text{LP预留给用户用以实现仓位的部分的当前时刻价值} \\ |
| 159 | +ReserveAmount &: \text{用户开平仓时,那个时刻的仓位价值与那个时刻的价格比,即为LP预留的Token数量} |
| 160 | +\end{align*} |
159 | 161 | $$
|
160 | 162 |
|
161 | 163 | 在合约中,对于 GLP 的定价部分在 GlpManager 中的 getAum 函数中:
|
@@ -219,8 +221,8 @@ reserveAmounts 记录的是开这个仓位的用户,该仓位的总价值兑
|
219 | 221 |
|
220 | 222 | $$
|
221 | 223 | \begin{align*}
|
222 |
| -Price_{avg} & = \frac{ Price \times Size}{Size+\Delta}\\ |
223 |
| -\Delta & = Size^{before} \times \frac{\left | Price - Price_{avg}^{before} \right | }{Price_{avg}^{before}}\\ |
| 224 | +Price_{avg} & = \frac{ Price \times Size}{Size+\Delta} \\ |
| 225 | +\Delta & = Size^{before} \times \frac{\left | Price - Price_{avg}^{before} \right | }{Price_{avg}^{before}} \\ |
224 | 226 | Size & = Size^{before} + \delta Size
|
225 | 227 | \end{align*}
|
226 | 228 | $$
|
|
313 | 315 |
|
314 | 316 | $$
|
315 | 317 | \begin{align*}
|
316 |
| -USD^{out} &=\delta coll+\Delta \times \frac{\delta Size}{Size^{before}} & \text{ 用户获利: } price\ge price_{avg}^{before} \\ |
317 |
| -coll&=coll^{before} - \delta coll & \text{ 用户获利: } price\ge price_{avg}^{before} \\ |
318 |
| -realisedPnL&=realisedPnL^{before}+ \Delta \times \frac{\delta Size}{Size^{before}} & \text{ 用户获利: } price\ge price_{avg}^{before} \\ |
| 318 | +USD^{out} & = \delta coll+\Delta \times \frac{\delta Size}{Size^{before}} & \text{ 用户获利: } price\ge price_{avg}^{before} \\ |
| 319 | +coll & = coll^{before} - \delta coll & \text{ 用户获利: } price\ge price_{avg}^{before} \\ |
| 320 | +realisedPnL & = realisedPnL^{before}+ \Delta \times \frac{\delta Size}{Size^{before}} & \text{ 用户获利: } price\ge price_{avg}^{before} \\ |
319 | 321 | \end{align*}
|
320 | 322 | $$
|
321 | 323 |
|
| 324 | +</br> |
| 325 | + |
322 | 326 | $$
|
323 | 327 | \begin{align*}
|
324 |
| -USD^{out} &= \delta coll & \text{ 用户亏损: } price<price_{avg}^{before} \\ |
325 |
| -coll &= coll^{before}- \Delta \times \frac{\delta Size}{Size^{before}} - \delta coll& \text{ 用户亏损: } price<price_{avg}^{before} \\ |
326 |
| -realisedPnL &= realisedPnL^{before}- \Delta \times \frac{\delta Size}{Size^{before}} & \text{ 用户亏损: } price<price_{avg}^{before} \\ |
| 328 | +USD^{out} & = \delta coll & \text{ 用户亏损: } price<price_{avg}^{before} \\ |
| 329 | +coll & = coll^{before}- \Delta \times \frac{\delta Size}{Size^{before}} - \delta coll& \text{ 用户亏损: } price<price_{avg}^{before} \\ |
| 330 | +realisedPnL & = realisedPnL^{before}- \Delta \times \frac{\delta Size}{Size^{before}} & \text{ 用户亏损: } price<price_{avg}^{before} \\ |
327 | 331 | \end{align*}
|
328 | 332 | $$
|
329 | 333 |
|
|
361 | 365 | $$
|
362 | 366 | \begin{align*}
|
363 | 367 | poolAmount_{token} & = poolAmount_{token}^{before}-\Delta\\
|
364 |
| -\Delta &= \frac{USD^{out}}{price_{max}} |
| 368 | +\Delta & = \frac{USD^{out}}{price_{max}} |
365 | 369 | \end{align*}
|
366 | 370 | $$
|
367 | 371 |
|
|
0 commit comments