code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spots/opening-auction-uncrossing.feature (about) 1 Feature: Set up a spot market, with an opening auction, then uncross the book. Make sure opening auction can end. 2 Background: 3 4 Given the fees configuration named "fees-config-1": 5 | maker fee | infrastructure fee | 6 | 0.005 | 0.002 | 7 And the simple risk model named "my-simple-risk-model": 8 | long | short | max move up | min move down | probability of trading | 9 | 0.08628781058136630000 | 0.09370922348428490000 | -1 | -1 | 0.2 | 10 And the fees configuration named "my-fees-config": 11 | maker fee | infrastructure fee | 12 | 0.004 | 0.001 | 13 And the spot markets: 14 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | sla params | 15 | BTC/ETH | BTC/ETH | BTC | ETH | my-simple-risk-model | 5 | fees-config-1 | default-none | default-basic | 16 17 Scenario: set up 2 parties with balance 18 # setup accounts 19 Given the parties deposit on asset's general account the following amount: 20 | party | asset | amount | 21 | party1 | ETH | 1000000000 | 22 | party2 | ETH | 1000000000 | 23 | party2 | BTC | 5 | 24 25 # place orders and generate trades 26 And the parties place the following orders: 27 | party | market id | side | volume | price | resulting trades | type | tif | reference | 28 | party2 | BTC/ETH | buy | 1 | 950000 | 0 | TYPE_LIMIT | TIF_GTC | t2-b-1 | 29 | party1 | BTC/ETH | buy | 1 | 1000000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | 30 | party2 | BTC/ETH | sell | 5 | 1000000 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-1 | 31 32 Then "party2" should have holding account balance of "5" for asset "BTC" 33 Then "party1" should have holding account balance of "1000000" for asset "ETH" 34 35 When the opening auction period ends for market "BTC/ETH" 36 37 And the following trades should be executed: 38 | buyer | price | size | seller | 39 | party1 | 1000000 | 1 | party2 | 40 41 And "party1" should have general account balance of "1" for asset "BTC" 42 # party 2 has an order of 5 sell BTC so it would have transferred 1 to party 1 for the sell and 1 remains in the holding account 43 And "party2" should have general account balance of "0" for asset "BTC" 44 And "party2" should have holding account balance of "4" for asset "BTC" 45 46 And "party1" should have general account balance of "999000000" for asset "ETH" 47 # party 2 has a buy order so it also has 950000 in the holding account 48 And "party2" should have holding account balance of "950000" for asset "ETH" 49 And "party2" should have general account balance of "1000050000" for asset "ETH" 50 51 And the mark price should be "1000000" for the market "BTC/ETH" 52 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 53 54 # now that we're not in opening auction or any auction lets do a buy some more BTC 55 And the parties place the following orders: 56 | party | market id | side | volume | price | resulting trades | type | tif | reference | 57 | party1 | BTC/ETH | buy | 2 | 1000000 | 1 | TYPE_LIMIT | TIF_GTC | t3-b-2 | 58 59 # fees should be paid by the buyer 60 Then "party1" should have general account balance of "3" for asset "BTC" 61 # 14k paid in fees by the aggressor (party1) => 999000000 - 2000000 - 14000 = 62 And "party1" should have general account balance of "996986000" for asset "ETH" 63 64 # seller gets 2 * 1000000 ETH + 10k maker fees 65 And "party2" should have holding account balance of "2" for asset "BTC" 66 And "party2" should have general account balance of "1002060000" for asset "ETH" 67 68 # now lets make the seller the aggressor, party1 now wants to sell their BTC for 950000 69 # because they are paying the fees they get 950000 - fees = 950000-6650 = 943,350 70 # party1 transfers 1 BTC to party2 from their general account 71 # party2 gets the 950000 released from holding account and pays 943350 to party1 and 6650 fees 72 # out of the 6650 ETH, 4750 ETH are maker fees which go to the general account of party2 73 # therefore in total the geneal account balance of ETH for party2 after the trade is 1002060000 + 4750 74 And the parties place the following orders: 75 | party | market id | side | volume | price | resulting trades | type | tif | reference | 76 | party1 | BTC/ETH | sell | 1 | 950000 | 1 | TYPE_LIMIT | TIF_GTC | t3-b-2 | 77 78 Then "party1" should have general account balance of "2" for asset "BTC" 79 # 996986000 + 943350 (950000 - fees) 80 And "party1" should have general account balance of "997929350" for asset "ETH" 81 And "party1" should have holding account balance of "0" for asset "ETH" 82 83 And "party2" should have general account balance of "1" for asset "BTC" 84 And "party2" should have general account balance of "1002064750" for asset "ETH" 85 And "party2" should have holding account balance of "0" for asset "ETH" 86 And "party2" should have holding account balance of "2" for asset "BTC" 87