code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/network_position_disposal.feature (about) 1 Feature: Network disposing position 2 3 Background: 4 5 Given the average block duration is "1" 6 7 Given the following network parameters are set: 8 | name | value | 9 | market.value.windowLength | 1h | 10 | network.markPriceUpdateMaximumFrequency | 0s | 11 And the following assets are registered: 12 | id | decimal places | quantum | 13 | USD.0.10 | 0 | 10 | 14 15 # disposal strat 1 set to 0.5 for scenario at line 244 16 Given the liquidation strategies: 17 | name | disposal step | disposal fraction | full disposal size | max fraction consumed | disposal slippage range | 18 | disposal-strat-1 | 5 | 0.2 | 0 | 0.1 | 0.5 | 19 | disposal-strat-2 | 5 | 0.2 | 5 | 0.1 | 0.1 | 20 21 And the log normal risk model named "log-normal-risk-model-1": 22 | risk aversion | tau | mu | r | sigma | 23 | 0.000001 | 0.00000380258 | 0 | 0 | 1.5 | 24 And the price monitoring named "price-monitoring-1": 25 | horizon | probability | auction extension | 26 | 100000 | 0.99 | 60 | 27 And the liquidity sla params named "SLA": 28 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 29 | 1 | 0.85 | 1 | 0.5 | 30 And the markets: 31 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | liquidation strategy | 32 | ETH/MAR22 | ETH | USD.0.10 | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-eth-for-future | 0.001 | 0 | SLA | disposal-strat-1 | 33 | ETH/MAR23 | ETH | USD.0.10 | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-eth-for-future | 0.001 | 0 | SLA | disposal-strat-2 | 34 35 36 Scenario: Network takes over distressed position and disposes position over time (0012-POSR-022)(0012-POSR-023) 37 38 Given the parties deposit on asset's general account the following amount: 39 | party | asset | amount | 40 | lp1 | USD.0.10 | 100000000000 | 41 | aux1 | USD.0.10 | 10000000000 | 42 | aux2 | USD.0.10 | 10000000000 | 43 | atRiskParty | USD.0.10 | 180 | 44 And the parties submit the following liquidity provision: 45 | id | party | market id | commitment amount | fee | lp type | 46 | lp1 | lp1 | ETH/MAR22 | 500000 | 0 | submission | 47 When the parties place the following orders: 48 | party | market id | side | volume | price | resulting trades | type | tif | reference | 49 | lp1 | ETH/MAR22 | buy | 1000 | 999 | 0 | TYPE_LIMIT | TIF_GTC | best-bid | 50 | lp1 | ETH/MAR22 | sell | 1000 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | best-ask | 51 When the parties place the following orders: 52 | party | market id | side | volume | price | resulting trades | type | tif | 53 | aux1 | ETH/MAR22 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 54 | aux2 | ETH/MAR22 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 55 And the opening auction period ends for market "ETH/MAR22" 56 Then the market data for the market "ETH/MAR22" should be: 57 | mark price | trading mode | 58 | 1000 | TRADING_MODE_CONTINUOUS | 59 60 Given the parties place the following orders: 61 | party | market id | side | volume | price | resulting trades | type | tif | 62 | aux1 | ETH/MAR22 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 63 | atRiskParty | ETH/MAR22 | sell | 10 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 64 Then the network moves ahead "1" blocks 65 66 Then the parties should have the following profit and loss: 67 | party | volume | unrealised pnl | realised pnl | 68 | atRiskParty | -10 | 0 | 0 | 69 And the parties should have the following margin levels: 70 | party | market id | maintenance | search | initial | release | 71 | atRiskParty | ETH/MAR22 | 156 | 171 | 187 | 218 | 72 And the parties should have the following account balances: 73 | party | asset | market id | margin | general | 74 | atRiskParty | USD.0.10 | ETH/MAR22 | 175 | 5 | 75 76 Given the parties amend the following orders: 77 | party | reference | price | size delta | tif | 78 | lp1 | best-ask | 1011 | 0 | TIF_GTC | 79 | lp1 | best-bid | 1009 | 0 | TIF_GTC | 80 And the parties place the following orders: 81 | party | market id | side | volume | price | resulting trades | type | tif | 82 | aux1 | ETH/MAR22 | buy | 1 | 1010 | 0 | TYPE_LIMIT | TIF_GTC | 83 | aux2 | ETH/MAR22 | sell | 1 | 1010 | 1 | TYPE_LIMIT | TIF_GTC | 84 Then the network moves ahead "1" blocks 85 Then the market data for the market "ETH/MAR22" should be: 86 | mark price | trading mode | 87 | 1010 | TRADING_MODE_CONTINUOUS | 88 Then debug trades 89 90 Then the parties should have the following profit and loss: 91 | party | market id | volume | unrealised pnl | realised pnl | 92 | atRiskParty | ETH/MAR22 | 0 | 0 | -180 | 93 And the following network trades should be executed: 94 | party | aggressor side | volume | 95 | atRiskParty | sell | 10 | 96 And clear trade events 97 98 # Position size is 10, next disposal should be ceil(10*0.2)=ceil(2)=2 99 Then the network moves ahead "5" blocks 100 And the following network trades should be executed: 101 | party | aggressor side | volume | 102 | lp1 | buy | 2 | 103 Then debug trades 104 And clear trade events 105 106 # Position size is 8, next disposal should be ceil(8*0.2)=ceil(1.6)=2 107 Then the network moves ahead "5" blocks 108 Then debug trades 109 And the following network trades should be executed: 110 | party | aggressor side | volume | 111 | lp1 | buy | 2 | 112 And clear trade events 113 114 # Position size is 6, next disposal should be ceil(6*0.2)=ceil(1.4)=2 115 Then the network moves ahead "5" blocks 116 Then debug trades 117 And the following network trades should be executed: 118 | party | aggressor side | volume | 119 | lp1 | buy | 2 | 120 And clear trade events 121 122 # Position size is 4, next disposal should be ceil(10*0.2)=ceil(2)=2 123 Then the network moves ahead "5" blocks 124 And the following network trades should be executed: 125 | party | aggressor side | volume | 126 | lp1 | buy | 1 | 127 And clear trade events 128 129 # Position size is 3, next disposal should be ceil(10*0.2)=ceil(2)=2 130 Then the network moves ahead "5" blocks 131 And the following network trades should be executed: 132 | party | aggressor side | volume | 133 | lp1 | buy | 1 | 134 And clear trade events 135 136 # Position size is 2, next disposal should be ceil(10*0.2)=ceil(2)=2 137 Then the network moves ahead "5" blocks 138 And the following network trades should be executed: 139 | party | aggressor side | volume | 140 | lp1 | buy | 1 | 141 And clear trade events 142 143 # Position size is 1, next disposal should be ceil(10*0.2)=ceil(2)=2 144 Then the network moves ahead "5" blocks 145 And the following network trades should be executed: 146 | party | aggressor side | volume | 147 | lp1 | buy | 1 | 148 And clear trade events 149 150 151 Scenario: Network takes over distressed position and disposes position full position once position smaller than full disposal size (0012-POSR-022)(0012-POSR-024) 152 153 Given the parties deposit on asset's general account the following amount: 154 | party | asset | amount | 155 | lp1 | USD.0.10 | 100000000000 | 156 | aux1 | USD.0.10 | 10000000000 | 157 | aux2 | USD.0.10 | 10000000000 | 158 | atRiskParty | USD.0.10 | 180 | 159 And the parties submit the following liquidity provision: 160 | id | party | market id | commitment amount | fee | lp type | 161 | lp1 | lp1 | ETH/MAR23 | 500000 | 0 | submission | 162 When the parties place the following orders: 163 | party | market id | side | volume | price | resulting trades | type | tif | reference | 164 | lp1 | ETH/MAR23 | buy | 1000 | 999 | 0 | TYPE_LIMIT | TIF_GTC | best-bid | 165 | lp1 | ETH/MAR23 | sell | 1000 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | best-ask | 166 When the parties place the following orders: 167 | party | market id | side | volume | price | resulting trades | type | tif | 168 | aux1 | ETH/MAR23 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 169 | aux2 | ETH/MAR23 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 170 And the opening auction period ends for market "ETH/MAR23" 171 Then the market data for the market "ETH/MAR23" should be: 172 | mark price | trading mode | 173 | 1000 | TRADING_MODE_CONTINUOUS | 174 175 Given the parties place the following orders: 176 | party | market id | side | volume | price | resulting trades | type | tif | 177 | aux1 | ETH/MAR23 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 178 | atRiskParty | ETH/MAR23 | sell | 10 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 179 Then the network moves ahead "1" blocks 180 181 Then the parties should have the following profit and loss: 182 | party | volume | unrealised pnl | realised pnl | 183 | atRiskParty | -10 | 0 | 0 | 184 And the parties should have the following margin levels: 185 | party | market id | maintenance | search | initial | release | 186 | atRiskParty | ETH/MAR23 | 156 | 171 | 187 | 218 | 187 And the parties should have the following account balances: 188 | party | asset | market id | margin | general | 189 | atRiskParty | USD.0.10 | ETH/MAR23 | 175 | 5 | 190 191 Given the parties amend the following orders: 192 | party | reference | price | size delta | tif | 193 | lp1 | best-ask | 1011 | 0 | TIF_GTC | 194 | lp1 | best-bid | 1009 | 0 | TIF_GTC | 195 And the parties place the following orders: 196 | party | market id | side | volume | price | resulting trades | type | tif | 197 | aux1 | ETH/MAR23 | buy | 1 | 1010 | 0 | TYPE_LIMIT | TIF_GTC | 198 | aux2 | ETH/MAR23 | sell | 1 | 1010 | 1 | TYPE_LIMIT | TIF_GTC | 199 Then the network moves ahead "1" blocks 200 Then the market data for the market "ETH/MAR23" should be: 201 | mark price | trading mode | 202 | 1010 | TRADING_MODE_CONTINUOUS | 203 Then debug trades 204 205 Then the parties should have the following profit and loss: 206 | party | market id | volume | unrealised pnl | realised pnl | 207 | atRiskParty | ETH/MAR23 | 0 | 0 | -180 | 208 And the following network trades should be executed: 209 | party | aggressor side | volume | 210 | atRiskParty | sell | 10 | 211 And clear trade events 212 213 # Position size is 10, next disposal should be ceil(10*0.2)=ceil(2)=2 214 Then the network moves ahead "5" blocks 215 And the following network trades should be executed: 216 | party | aggressor side | volume | 217 | lp1 | buy | 2 | 218 Then debug trades 219 And clear trade events 220 221 # Position size is 8, next disposal should be ceil(8*0.2)=ceil(1.6)=2 222 Then the network moves ahead "5" blocks 223 Then debug trades 224 And the following network trades should be executed: 225 | party | aggressor side | volume | 226 | lp1 | buy | 2 | 227 And clear trade events 228 229 # Position size is 6, next disposal should be ceil(6*0.2)=ceil(1.4)=2 230 Then the network moves ahead "5" blocks 231 Then debug trades 232 And the following network trades should be executed: 233 | party | aggressor side | volume | 234 | lp1 | buy | 2 | 235 And clear trade events 236 237 # Position size is 4, next disposal should be ceil(10*0.2)=ceil(2)=2 238 Then the network moves ahead "5" blocks 239 And the following network trades should be executed: 240 | party | aggressor side | volume | 241 | lp1 | buy | 4 | 242 And clear trade events 243 244 Scenario: Network takes over distressed position and attempts to dispose position during price monitoring auction 245 246 Given the parties deposit on asset's general account the following amount: 247 | party | asset | amount | 248 | lp1 | USD.0.10 | 100000000000 | 249 | aux1 | USD.0.10 | 10000000000 | 250 | aux2 | USD.0.10 | 10000000000 | 251 | atRiskParty | USD.0.10 | 180 | 252 And the parties submit the following liquidity provision: 253 | id | party | market id | commitment amount | fee | lp type | 254 | lp1 | lp1 | ETH/MAR22 | 500000 | 0 | submission | 255 When the parties place the following orders: 256 | party | market id | side | volume | price | resulting trades | type | tif | reference | 257 | lp1 | ETH/MAR22 | buy | 1000 | 999 | 0 | TYPE_LIMIT | TIF_GTC | best-bid | 258 | lp1 | ETH/MAR22 | sell | 1000 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | best-ask | 259 When the parties place the following orders: 260 | party | market id | side | volume | price | resulting trades | type | tif | 261 | aux1 | ETH/MAR22 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 262 | aux2 | ETH/MAR22 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 263 And the opening auction period ends for market "ETH/MAR22" 264 Then the market data for the market "ETH/MAR22" should be: 265 | mark price | trading mode | 266 | 1000 | TRADING_MODE_CONTINUOUS | 267 268 Given the parties place the following orders: 269 | party | market id | side | volume | price | resulting trades | type | tif | 270 | aux1 | ETH/MAR22 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 271 | atRiskParty | ETH/MAR22 | sell | 10 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 272 Then the network moves ahead "1" blocks 273 274 Then the parties should have the following profit and loss: 275 | party | volume | unrealised pnl | realised pnl | 276 | atRiskParty | -10 | 0 | 0 | 277 And the parties should have the following margin levels: 278 | party | market id | maintenance | search | initial | release | 279 | atRiskParty | ETH/MAR22 | 156 | 171 | 187 | 218 | 280 And the parties should have the following account balances: 281 | party | asset | market id | margin | general | 282 | atRiskParty | USD.0.10 | ETH/MAR22 | 175 | 5 | 283 284 Given the parties amend the following orders: 285 | party | reference | price | size delta | tif | 286 | lp1 | best-ask | 1240 | 0 | TIF_GTC | 287 | lp1 | best-bid | 1009 | 0 | TIF_GTC | 288 And the parties place the following orders: 289 | party | market id | side | volume | price | resulting trades | type | tif | 290 | aux1 | ETH/MAR22 | buy | 1 | 1010 | 0 | TYPE_LIMIT | TIF_GTC | 291 | aux2 | ETH/MAR22 | sell | 1 | 1010 | 1 | TYPE_LIMIT | TIF_GTC | 292 Then the network moves ahead "1" blocks 293 Then the market data for the market "ETH/MAR22" should be: 294 | mark price | trading mode | 295 | 1010 | TRADING_MODE_CONTINUOUS | 296 Then debug trades 297 298 Then the parties should have the following profit and loss: 299 | party | market id | volume | unrealised pnl | realised pnl | 300 | atRiskParty | ETH/MAR22 | 0 | 0 | -180 | 301 And the following network trades should be executed: 302 | party | aggressor side | volume | 303 | atRiskParty | sell | 10 | 304 And clear trade events 305 306 And the market data for the market "ETH/MAR22" should be: 307 | mark price | trading mode | horizon | min bound | max bound | 308 | 1010 | TRADING_MODE_CONTINUOUS | 100000 | 802 | 1238 | 309 Then debug detailed orderbook volumes for market "ETH/MAR22" 310 And the parties place the following orders: 311 | party | market id | side | volume | price | resulting trades | type | tif | 312 | aux1 | ETH/MAR22 | buy | 1 | 1239 | 0 | TYPE_LIMIT | TIF_GTC | 313 | aux2 | ETH/MAR22 | sell | 1 | 1239 | 0 | TYPE_LIMIT | TIF_GTC | 314 315 And the market data for the market "ETH/MAR22" should be: 316 | mark price | trading mode | 317 | 1010 | TRADING_MODE_MONITORING_AUCTION | 318 319 When the network moves ahead "30" blocks 320 Then the market data for the market "ETH/MAR22" should be: 321 | mark price | trading mode | 322 | 1010 | TRADING_MODE_MONITORING_AUCTION | 323 324 When the network moves ahead "31" blocks 325 Then the market data for the market "ETH/MAR22" should be: 326 | mark price | trading mode | 327 | 1239 | TRADING_MODE_CONTINUOUS | 328 329 # Position size is 10, next disposal should be ceil(10*0.2)=ceil(2)=2 330 And the following network trades should be executed: 331 | party | aggressor side | volume | 332 | lp1 | buy | 2 | 333 Then debug trades 334 And clear trade events 335 336 # Position size is 8, next disposal should be ceil(8*0.2)=ceil(1.6)=2 337 Then the network moves ahead "5" blocks 338 Then debug trades 339 And the following network trades should be executed: 340 | party | aggressor side | volume | 341 | lp1 | buy | 2 | 342 And clear trade events 343 344 # Position size is 6, next disposal should be ceil(6*0.2)=ceil(1.4)=2 345 Then the network moves ahead "5" blocks 346 Then debug trades 347 And the following network trades should be executed: 348 | party | aggressor side | volume | 349 | lp1 | buy | 2 | 350 And clear trade events 351 352 # Position size is 4, next disposal should be ceil(10*0.2)=ceil(2)=2 353 Then the network moves ahead "5" blocks 354 And the following network trades should be executed: 355 | party | aggressor side | volume | 356 | lp1 | buy | 1 | 357 And clear trade events 358 359 # Position size is 3, next disposal should be ceil(10*0.2)=ceil(2)=2 360 Then the network moves ahead "5" blocks 361 And the following network trades should be executed: 362 | party | aggressor side | volume | 363 | lp1 | buy | 1 | 364 And clear trade events 365 366 # Position size is 2, next disposal should be ceil(10*0.2)=ceil(2)=2 367 Then the network moves ahead "5" blocks 368 And the following network trades should be executed: 369 | party | aggressor side | volume | 370 | lp1 | buy | 1 | 371 And clear trade events 372 373 # Position size is 1, next disposal should be ceil(10*0.2)=ceil(2)=2 374 Then the network moves ahead "5" blocks 375 And the following network trades should be executed: 376 | party | aggressor side | volume | 377 | lp1 | buy | 1 | 378 And clear trade events