code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0044-LIME_lp_at_termination.feature (about)

     1  Feature: Test LP bond account when market is terminated
     2  
     3    Background:
     4  
     5      Given the margin calculator named "margin-calculator-1":
     6        | search factor | initial factor | release factor |
     7        | 1.2           | 1.5            | 1.7            |
     8      Given the log normal risk model named "log-normal-risk-model":
     9        | risk aversion | tau | mu | r | sigma |
    10        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
    11  
    12      And the oracle spec for settlement data filtering data from "0xCAFECAFE19" named "ethDec19Oracle":
    13        | property         | type         | binding         | decimals |
    14        | prices.ETH.value | TYPE_INTEGER | settlement data | 0        |
    15  
    16      And the oracle spec for trading termination filtering data from "0xCAFECAFE19" named "ethDec19Oracle":
    17        | property           | type         | binding             |
    18        | trading.terminated | TYPE_BOOLEAN | trading termination |
    19      #risk factor short:3.5569036
    20      #risk factor long:0.801225765
    21      And the following assets are registered:
    22        | id  | decimal places |
    23        | USD | 0              |
    24      And the fees configuration named "fees-config-1":
    25        | maker fee | infrastructure fee |
    26        | 0.0004    | 0.001              |
    27      And the price monitoring named "price-monitoring":
    28        | horizon | probability | auction extension |
    29        | 360000  | 0.99        | 3                 |
    30      And the following network parameters are set:
    31        | name                                                | value |
    32        | market.value.windowLength                           | 60s   |
    33        | network.markPriceUpdateMaximumFrequency             | 0s    |
    34        | limits.markets.maxPeggedOrders                      | 6     |
    35        | market.auction.minimumDuration                      | 1     |
    36        | market.fee.factors.infrastructureFee                | 0.001 |
    37        | market.fee.factors.makerFee                         | 0.004 |
    38        | market.liquidity.bondPenaltyParameter               | 0.2   |
    39        | validators.epoch.length                             | 5s    |
    40        | market.liquidity.stakeToCcyVolume                   | 1     |
    41        | market.liquidity.successorLaunchWindowLength        | 1h    |
    42        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.19  |
    43        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 1     |
    44        | validators.epoch.length                             | 2s    |
    45      Given the liquidity monitoring parameters:
    46        | name       | triggering ratio | time window | scaling factor |
    47        | lqm-params | 0.5              | 20s         | 1.0            |
    48  
    49      And the liquidity sla params named "SLA":
    50        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    51        | 1.0         | 0.5                          | 1                             | 1.0                    |
    52      And the markets:
    53        | id        | quote name | asset | liquidity monitoring | risk model            | margin calculator   | auction duration | fees          | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params |
    54        | ETH/MAR22 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | price-monitoring | ethDec19Oracle     | 1                      | 0                         | SLA        |
    55      And the following network parameters are set:
    56        | name                                             | value |
    57        | market.liquidity.providersFeeCalculationTimeStep | 2s    |
    58  
    59      Given the average block duration is "2"
    60    @Now @SLABond @Liquidation
    61    Scenario: 001: All liquidity providers in the market receive a greater than zero amount of liquidity fee
    62      Given the parties deposit on asset's general account the following amount:
    63        | party  | asset | amount |
    64        | lp1    | USD   | 159000 |
    65        | lp2    | USD   | 100000 |
    66        | party1 | USD   | 100000 |
    67        | party2 | USD   | 100000 |
    68        | party3 | USD   | 100000 |
    69  
    70      And the parties submit the following liquidity provision:
    71        | id   | party | market id | commitment amount | fee   | lp type    |
    72        | lp_1 | lp1   | ETH/MAR22 | 3000              | 0.002 | submission |
    73        | lp_2 | lp2   | ETH/MAR22 | 1000              | 0.001 | submission |
    74  
    75      When the network moves ahead "2" blocks
    76      And the parties place the following pegged iceberg orders:
    77        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    78        | lp1   | ETH/MAR22 | 5         | 1                    | buy  | BID              | 5      | 20     |
    79        | lp1   | ETH/MAR22 | 5         | 1                    | sell | ASK              | 5      | 20     |
    80        | lp2   | ETH/MAR22 | 2         | 1                    | buy  | BID              | 2      | 20     |
    81        | lp2   | ETH/MAR22 | 2         | 1                    | sell | ASK              | 2      | 20     |
    82  
    83      Then the parties place the following orders:
    84        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    85        | party1 | ETH/MAR22 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    86        | party1 | ETH/MAR22 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    87        | party2 | ETH/MAR22 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    88        | party2 | ETH/MAR22 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    89  
    90      Then the opening auction period ends for market "ETH/MAR22"
    91      And the following trades should be executed:
    92        | buyer  | price | size | seller |
    93        | party1 | 1000  | 1    | party2 |
    94  
    95      And the market data for the market "ETH/MAR22" should be:
    96        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    97        | 1000       | TRADING_MODE_CONTINUOUS | 360000  | 756       | 1309      | 3556         | 4000           | 1             |
    98      # # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569036*10000
    99  
   100      And the liquidity fee factor should be "0.002" for the market "ETH/MAR22"
   101  
   102      And the liquidity provider fee shares for the market "ETH/MAR22" should be:
   103        | party | equity like share | average entry valuation |
   104        | lp1   | 0.75              | 3000                    |
   105        | lp2   | 0.25              | 4000                    |
   106  
   107      And the parties should have the following account balances:
   108        | party | asset | market id | margin | general | bond |
   109        | lp1   | USD   | ETH/MAR22 | 26677  | 129323  | 3000 |
   110        | lp2   | USD   | ETH/MAR22 | 10671  | 88329   | 1000 |
   111      #initial margin lp2: 2*1000*3.5569036*1.5=10670
   112  
   113      Then the parties should have the following profit and loss:
   114        | party  | volume | unrealised pnl | realised pnl |
   115        | lp1    | 0      | 0              | 0            |
   116        | lp2    | 0      | 0              | 0            |
   117        | party1 | 1      | 0              | 0            |
   118        | party2 | -1     | 0              | 0            |
   119  
   120      When the parties place the following orders:
   121        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   122        | party1 | ETH/MAR22 | buy  | 15     | 1120  | 2                | TYPE_LIMIT | TIF_GTC | buy-1     |
   123  
   124      And the market data for the market "ETH/MAR22" should be:
   125        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   126        | 1000       | TRADING_MODE_CONTINUOUS | 360000  | 756       | 1309      | 56910        | 4000           | 16            |
   127  
   128      And the parties should have the following account balances:
   129        | party | asset | market id | margin | general | bond |
   130        | lp1   | USD   | ETH/MAR22 | 26677  | 129346  | 3000 |
   131        | lp2   | USD   | ETH/MAR22 | 10671  | 88329   | 1000 |
   132  
   133      When the network moves ahead "2" blocks
   134      Then the parties should have the following profit and loss:
   135        | party  | volume | unrealised pnl | realised pnl |
   136        | lp1    | -5     | 0              | 0            |
   137        | lp2    | 0      | 0              | 0            |
   138  
   139      And the parties should have the following account balances:
   140        | party | asset | market id | margin | general | bond |
   141        | lp1   | USD   | ETH/MAR22 | 38278 | 117745   | 2430 |
   142        | lp2   | USD   | ETH/MAR22 | 2691   | 96309   | 810  |
   143  
   144      When the oracles broadcast data signed with "0xCAFECAFE19":
   145        | name               | value |
   146        | trading.terminated | true  |
   147      #And time is updated to "2020-01-01T01:01:01Z"
   148      Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/MAR22"
   149      And the market data for the market "ETH/MAR22" should be:
   150        | mark price | trading mode            | horizon | ref price | min bound | max bound | target stake | supplied stake | open interest |
   151        | 1120       | TRADING_MODE_NO_TRADING | 360000  | 1060      | 801       | 1387      | 63739        | 3240           | 16            |
   152  
   153      Then the oracles broadcast data signed with "0xCAFECAFE19":
   154        | name             | value |
   155        | prices.ETH.value | 1600  |
   156      And the network moves ahead "3" blocks
   157  
   158      Then the parties should have the following profit and loss:
   159        | party  | volume | unrealised pnl | realised pnl |
   160        | lp1    | -5     | 0              | -2400        |
   161        | lp2    | 0      | 0              | 0            |
   162  
   163      And the parties should have the following account balances:
   164        | party | asset | market id | margin | general | bond |
   165        | lp1   | USD   | ETH/MAR22 | 0      | 155592  | 0    |
   166        | lp2   | USD   | ETH/MAR22 | 0      | 99657   | 0    |
   167  
   168      And the insurance pool balance should be "1408" for the market "ETH/MAR22"
   169