code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/accounts_and_fees/0013-ACCT-024.feature (about) 1 Feature: Spot market 2 3 Scenario: Double entry accounting is maintained at all points i.e. every transfer event has a source account and destination account 4 and the balance of the source account before the transfer equals to the balance of source account minus the transfer amount 5 after the transfer and balance of the destination account before the transfer plus the transfer amount equals to the balance 6 of the destination account after the transfer. (0013-ACCT-024) 7 8 Background: 9 10 Given the following network parameters are set: 11 | name | value | 12 | network.markPriceUpdateMaximumFrequency | 0s | 13 | market.value.windowLength | 1h | 14 15 Given the following assets are registered: 16 | id | decimal places | 17 | ETH | 2 | 18 | BTC | 2 | 19 20 Given the fees configuration named "fees-config-1": 21 | maker fee | infrastructure fee | 22 | 0.01 | 0.03 | 23 Given the log normal risk model named "lognormal-risk-model-1": 24 | risk aversion | tau | mu | r | sigma | 25 | 0.001 | 0.01 | 0 | 0.0 | 1.2 | 26 And the price monitoring named "price-monitoring-1": 27 | horizon | probability | auction extension | 28 | 360000 | 0.999 | 1 | 29 30 And the spot markets: 31 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | decimal places | position decimal places | sla params | 32 | BTC/ETH | BTC/ETH | BTC | ETH | lognormal-risk-model-1 | 1 | fees-config-1 | price-monitoring-1 | 2 | 2 | default-basic | 33 34 # setup accounts 35 Given the parties deposit on asset's general account the following amount: 36 | party | asset | amount | 37 | party1 | ETH | 10000 | 38 | party2 | BTC | 100 | 39 And the average block duration is "1" 40 41 # At this point we have a total of 10,000 ETH in the system and 100 BTC. These are all stored in the user accounts. 42 43 # Place some orders to allow us out of the opening auction 44 And the parties place the following orders: 45 | party | market id | side | volume | price | resulting trades | type | tif | 46 | party1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 47 | party2 | BTC/ETH | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 48 49 And the opening auction period ends for market "BTC/ETH" 50 When the network moves ahead "1" blocks 51 And clear transfer response events 52 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 53 54 # After the auction there were 2 trades so the assets have moved about. 55 # There are no fees in the opening auction so all the assets are stored in the users accounts 56 # ETH = 9,990 + 10 = 10,000 57 # BTC = 99 + 1 = 100 58 59 Then "party1" should have general account balance of "9990" for asset "ETH" 60 Then "party1" should have holding account balance of "0" for asset "ETH" 61 Then "party1" should have general account balance of "1" for asset "BTC" 62 63 Then "party2" should have general account balance of "10" for asset "ETH" 64 Then "party2" should have general account balance of "99" for asset "BTC" 65 Then "party2" should have holding account balance of "0" for asset "BTC" 66 67 # No fees in opening auction 68 And the accumulated liquidity fees should be "0" for the market "BTC/ETH" 69 And the accumulated infrastructure fees should be "0" for the asset "BTC" 70 And the accumulated infrastructure fees should be "0" for the asset "ETH" 71 72 # Place some orders to create some trades 73 And the parties place the following orders: 74 | party | market id | side | volume | price | resulting trades | type | tif | 75 | party1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 76 | party2 | BTC/ETH | sell | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 77 78 # These orders have created trades and paid fees on them. 79 Then the following transfers should happen: 80 | from | to | from account | to account | market id | amount | asset | 81 | party1 | party1 | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_HOLDING | | 10 | ETH | 82 | party2 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_MAKER | BTC/ETH | 1 | ETH | 83 | party2 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | BTC/ETH | 1 | ETH | 84 | party2 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | BTC/ETH | 0 | ETH | 85 | market | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/ETH | 1 | ETH | 86 | party1 | party1 | ACCOUNT_TYPE_HOLDING | ACCOUNT_TYPE_GENERAL | | 10 | ETH | 87 | party2 | party1 | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_GENERAL | | 1 | BTC | 88 | party1 | party2 | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_GENERAL | | 10 | ETH | 89 90 # party1 started with 9990 ETH but sold 9 to leave 9981 91 # started with 1 BTC but bought 1 to give 2 92 # party2 started with 10 ETH but bought 8 to give 18 93 # started with 99 BTC but sold one to give 98 94 # infra started with 0 ETH but gained 1 due to fees 95 96 # ETH = 9,981 + 18 + 1 = 10,000 97 # BTC = 2 + 98 = 100 98 Then "party1" should have general account balance of "9981" for asset "ETH" 99 Then "party1" should have holding account balance of "0" for asset "ETH" 100 Then "party1" should have general account balance of "2" for asset "BTC" 101 102 Then "party2" should have general account balance of "18" for asset "ETH" 103 Then "party2" should have general account balance of "98" for asset "BTC" 104 Then "party2" should have holding account balance of "0" for asset "BTC" 105 106 And the accumulated liquidity fees should be "0" for the market "BTC/ETH" 107 And the accumulated infrastructure fees should be "0" for the asset "BTC" 108 And the accumulated infrastructure fees should be "1" for the asset "ETH"