code.vegaprotocol.io/vega@v0.79.0/core/integration/features/transfers/0057-TRAN-023.feature (about)

     1  Feature: Test one off transfers
     2  
     3  Background:
     4      Given time is updated to "2021-08-26T00:00:00Z"
     5  
     6      Given the markets:
     7        | id        | quote name | asset | risk model                    | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
     8        | BTC/DEC23 | BTC        | BTC   | default-simple-risk-model-3   | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                       | default-futures |
     9  
    10      Given the following network parameters are set:
    11        | name                                    | value |
    12        | transfer.fee.factor                     |  0.5  |
    13        | network.markPriceUpdateMaximumFrequency |  0s   |
    14        | transfer.fee.maxQuantumAmount           |  1    |
    15        | transfer.feeDiscountDecayFraction       |  0.9  |
    16        | limits.markets.maxPeggedOrders          |  1500 |
    17  
    18      Given the parties deposit on asset's general account the following amount:
    19        | party                                                            | asset | amount        |
    20        | 1234567890123456789012345678901234567890123456789012345678900001 | BTC   | 1000000000000 |
    21        | 1234567890123456789012345678901234567890123456789012345678900002 | BTC   | 1000000000000 |
    22        | aux                                                              | BTC   | 1000000       |
    23        | aux2                                                             | BTC   | 1000000       |
    24        | lpprov                                                           | BTC   | 90000000      |
    25  
    26      And create the network treasury account for asset "VEGA"
    27  
    28      When the parties submit the following liquidity provision:
    29        | id  | party  | market id | commitment amount | fee | lp type    |
    30        | lp1 | lpprov | BTC/DEC23 | 90000000          | 0.1 | submission |
    31        | lp1 | lpprov | BTC/DEC23 | 90000000          | 0.1 | submission |
    32  
    33      And the parties place the following pegged iceberg orders:
    34        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    35        | lpprov | BTC/DEC23 | 2         | 1                    | buy  | BID              | 50     | 100    |
    36        | lpprov | BTC/DEC23 | 2         | 1                    | sell | ASK              | 50     | 100    |
    37  
    38      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    39      When the parties place the following orders:
    40        | party | market id | side | volume | price | resulting trades | type       | tif     |
    41        | aux   | BTC/DEC23 | buy  | 1      | 40    | 0                | TYPE_LIMIT | TIF_GTC |
    42        | aux   | BTC/DEC23 | sell | 1      | 60    | 0                | TYPE_LIMIT | TIF_GTC |
    43        | aux2  | BTC/DEC23 | buy  | 1      | 50    | 0                | TYPE_LIMIT | TIF_GTC |
    44        | aux   | BTC/DEC23 | sell | 1      | 50    | 0                | TYPE_LIMIT | TIF_GTC |
    45  
    46      Then the opening auction period ends for market "BTC/DEC23"
    47      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/DEC23"
    48  
    49  Scenario: Make sure we are not charged for a transfer if we have a discount (0057-TRAN-023)
    50    # party1 needs to place trades so they pay a taker fee
    51      When the parties place the following orders:
    52        | party                                                            | market id | side | volume | price | resulting trades | type        | tif     |
    53        | 1234567890123456789012345678901234567890123456789012345678900002 | BTC/DEC23 | sell | 100    | 50    | 0                | TYPE_LIMIT  | TIF_GTC |
    54        | 1234567890123456789012345678901234567890123456789012345678900001 | BTC/DEC23 | buy  | 100    | 0     | 1                | TYPE_MARKET | TIF_FOK |
    55  
    56    # Move forward 3 epochs and check the discount after each step
    57    Then the network moves ahead "1" epochs
    58  
    59    And the parties have the following transfer fee discounts:
    60    | party                                                              | asset | available discount |
    61    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 500                |
    62  
    63    Then the network moves ahead "1" epochs
    64  
    65    And the parties have the following transfer fee discounts:
    66    | party                                                              | asset | available discount |
    67    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 450                |
    68  
    69    Then the network moves ahead "1" epochs
    70  
    71    And the parties have the following transfer fee discounts:
    72    | party                                                              | asset | available discount |
    73    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 405                |
    74  
    75    # Make sure we know how much BTC party1 has
    76    Then "1234567890123456789012345678901234567890123456789012345678900001" should have general account balance of "999999997340" for asset "BTC"
    77  
    78    # party1 makes a transfer and should get a reduced transfer fee
    79    Given the parties submit the following one off transfers:
    80      | id | from                                                             |  from_account_type   | to                                                               |   to_account_type    | asset | amount | delivery_time        |
    81      | 1  | 1234567890123456789012345678901234567890123456789012345678900001 | ACCOUNT_TYPE_GENERAL | 1234567890123456789012345678901234567890123456789012345678900002 | ACCOUNT_TYPE_GENERAL | BTC   | 100    | 2021-08-26T00:00:00Z |
    82  
    83    # Make sure that party1 has not paid a fee for this transfer (only the transferred amount is removed from the GENERAL account) 393999998840-100
    84    Then "1234567890123456789012345678901234567890123456789012345678900001" should have general account balance of "999999997240" for asset "BTC"
    85  
    86    # After the transfer the discount amount will be reduced by the amount we didn't get charged (50)
    87    And the parties have the following transfer fee discounts:
    88    | party                                                              | asset | available discount |
    89    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 355                |
    90  
    91  
    92  
    93  Scenario: Make sure we are only charged for a transfer after the discount is used up (0057-TRAN-023)
    94    # party1 needs to place trades so they pay a taker fee
    95      When the parties place the following orders:
    96        | party                                                            | market id | side | volume | price | resulting trades | type        | tif     |
    97        | 1234567890123456789012345678901234567890123456789012345678900002 | BTC/DEC23 | sell | 100    | 50    | 0                | TYPE_LIMIT  | TIF_GTC |
    98        | 1234567890123456789012345678901234567890123456789012345678900001 | BTC/DEC23 | buy  | 100    | 0     | 1                | TYPE_MARKET | TIF_FOK |
    99  
   100    # Move forward 3 epochs and check the discount after each step
   101    Then the network moves ahead "1" epochs
   102  
   103    And the parties have the following transfer fee discounts:
   104    | party                                                              | asset | available discount |
   105    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 500                |
   106  
   107    Then the network moves ahead "1" epochs
   108  
   109    And the parties have the following transfer fee discounts:
   110    | party                                                              | asset | available discount |
   111    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 450                |
   112  
   113    Then the network moves ahead "1" epochs
   114  
   115    And the parties have the following transfer fee discounts:
   116    | party                                                              | asset | available discount |
   117    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 405                |
   118  
   119    # Make sure we know how much BTC party1 has
   120    Then "1234567890123456789012345678901234567890123456789012345678900001" should have general account balance of "999999997340" for asset "BTC"
   121  
   122    # party1 makes a transfer and should get a reduced transfer fee
   123    Given the parties submit the following one off transfers:
   124      | id | from                                                             |  from_account_type   | to                                                               |   to_account_type    | asset | amount | delivery_time        |
   125      | 1  | 1234567890123456789012345678901234567890123456789012345678900001 | ACCOUNT_TYPE_GENERAL | 1234567890123456789012345678901234567890123456789012345678900002 | ACCOUNT_TYPE_GENERAL | BTC   | 1000   | 2021-08-26T00:00:00Z |
   126  
   127    # fee = 1000 * 0.5 == 500. fee after discount = 500-405 = 95
   128    # 999999997340-(1000+95) 
   129    Then "1234567890123456789012345678901234567890123456789012345678900001" should have general account balance of "999999996245" for asset "BTC"
   130  
   131    # After the transfer the discount amount will be reduced by the amount we didn't get charged (50)
   132    And the parties have the following transfer fee discounts:
   133    | party                                                              | asset | available discount |
   134    | 1234567890123456789012345678901234567890123456789012345678900001   | BTC   | 0                  |