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

     1  Feature: Spot market
     2  
     3    Scenario: Spot Order gets filled partially
     4  
     5    Background:
     6  
     7      Given the fees configuration named "fees-config-1":
     8        | maker fee | infrastructure fee |
     9        | 0         | 0                  |
    10      Given the log normal risk model named "lognormal-risk-model-1":
    11        | risk aversion | tau  | mu | r   | sigma |
    12        | 0.001         | 0.01 | 0  | 0.0 | 1.2   |
    13  
    14      And the price monitoring named "price-monitoring-1":
    15        | horizon | probability | auction extension |
    16        | 360000  | 0.999       | 300               |
    17  
    18      And the spot markets:
    19        | id      | name    | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | sla params    |
    20        | BTC/ETH | BTC/ETH | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | default-basic |
    21  
    22      # setup accounts
    23      Given the parties deposit on asset's general account the following amount:
    24        | party  | asset | amount |
    25        | party1 | ETH   | 100    |
    26        | party2 | BTC   | 5      |
    27  
    28      And the average block duration is "1"
    29      # Then "party1" should have holding account balance of "100" for asset "ETH"
    30      # Then "party2" should have holding account balance of "5" for asset "BTC"
    31  
    32      # place orders and generate trades
    33      And the parties place the following orders:
    34        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference       | only |
    35        | party1 | BTC/ETH   | buy  | 1      | 20    | 0                | TYPE_LIMIT | TIF_GFA | party-order1111 |      |
    36        | party2 | BTC/ETH   | sell | 1      | 30    | 0                | TYPE_LIMIT | TIF_GTC | party-order2    |      |
    37        | party1 | BTC/ETH   | buy  | 2      | 10    | 0                | TYPE_LIMIT | TIF_GTC | party-order11   |      |
    38        | party2 | BTC/ETH   | sell | 1      | 90    | 0                | TYPE_LIMIT | TIF_GTC | party-order12   |      |
    39  
    40      Then "party1" should have holding account balance of "40" for asset "ETH"
    41      Then "party1" should have general account balance of "60" for asset "ETH"
    42      Then "party2" should have holding account balance of "2" for asset "BTC"
    43  
    44      And the parties amend the following orders:
    45        | party  | reference    | price | size delta | tif     |
    46        | party2 | party-order2 | 10    | 0          | TIF_GTC |
    47  
    48      And the opening auction period ends for market "BTC/ETH"
    49      Then the market data for the market "BTC/ETH" should be:
    50        | mark price | trading mode            | auction trigger             |
    51        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
    52  
    53      And the market data for the market "BTC/ETH" should be:
    54        | mark price | trading mode            | horizon | min bound | max bound |
    55        | 15         | TRADING_MODE_CONTINUOUS | 360000  | 10        | 22        |
    56  
    57  
    58      And the following trades should be executed:
    59        | buyer  | price | size | seller |
    60        | party1 | 15    | 1    | party2 |
    61  
    62      Then "party1" should have holding account balance of "20" for asset "ETH"
    63      Then "party1" should have general account balance of "65" for asset "ETH"
    64      Then "party1" should have general account balance of "1" for asset "BTC"
    65  
    66      Then "party2" should have holding account balance of "1" for asset "BTC"
    67      #party2 sold 1BTC for 15ETH to party1
    68      Then "party2" should have general account balance of "3" for asset "BTC"
    69      Then "party2" should have general account balance of "15" for asset "ETH"
    70  
    71      And the parties amend the following orders:
    72        | party  | reference     | price | size delta | tif     |
    73        | party2 | party-order12 | 10    | 0          | TIF_GTC |
    74  
    75      And the following trades should be executed:
    76        | buyer  | price | size | seller |
    77        | party1 | 10    | 1    | party2 |
    78  
    79      Then the market data for the market "BTC/ETH" should be:
    80        | mark price | trading mode            | auction trigger             |
    81        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
    82  
    83      Then "party1" should have holding account balance of "10" for asset "ETH"
    84      Then "party1" should have general account balance of "65" for asset "ETH"
    85      Then "party1" should have general account balance of "2" for asset "BTC"
    86  
    87      Then "party2" should have holding account balance of "0" for asset "BTC"
    88      Then "party2" should have general account balance of "3" for asset "BTC"
    89      #party2 sold 1 BTC for 10ETH, and should have 15+10=25ETH now
    90      Then "party2" should have general account balance of "25" for asset "ETH"
    91  
    92      When the network moves ahead "11" blocks
    93  
    94      #check mark price update 0008-SP-TRAD-003
    95      Then the market data for the market "BTC/ETH" should be:
    96        | mark price | trading mode            | auction trigger             |
    97        | 10         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
    98  
    99      And the parties amend the following orders:
   100        | party  | reference     | price | size delta | tif     | error                                                              |
   101        | party1 | party-order11 | 200   | 0          | TIF_GTC | party does not have sufficient balance to cover the trade and fees |
   102  
   103      # example for changing the target stake params
   104      Given the liquidity monitoring parameters:
   105        | name               | triggering ratio | time window | scaling factor |
   106        | updated-lqm-params | 0.2              | 20s         | 1.5            |
   107      
   108      When the spot markets are updated:
   109        | id      | liquidity monitoring | linear slippage factor | quadratic slippage factor |
   110        | BTC/ETH | updated-lqm-params   | 0.5                    | 0.5                       |