code.vegaprotocol.io/vega@v0.79.0/core/integration/features/transfers/fee_discounts.feature (about)

     1  Feature: Transfer fee discounts
     2  
     3  
     4  # this sets up party f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c with a tranfer discount of 324
     5  Background:
     6      Given time is updated to "2021-08-26T00:00:00Z"
     7  
     8      Given the fees configuration named "fees-config-1":
     9        | maker fee | infrastructure fee |
    10        | 0.005     | 0.002              |
    11      And the price monitoring named "price-monitoring":
    12        | horizon | probability | auction extension |
    13        | 1       | 0.99        | 3                 |
    14  
    15      And the simple risk model named "simple-risk-model-1":
    16        | long | short | max move up | min move down | probability of trading |
    17        | 0.2  | 0.1   | 100         | -100          | 0.1                    |
    18  
    19      And the markets:
    20        | id        | quote name | asset | risk model          | margin calculator         | auction duration | fees          | price monitoring | data source config     | position decimal places | linear slippage factor | quadratic slippage factor | sla params      |
    21        | ETH/DEC21 | ETH        | ETH   | simple-risk-model-1 | default-margin-calculator | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 2                       | 0.25                   | 0                         | default-futures |
    22      And the following network parameters are set:
    23        | name                                               | value |
    24        | market.liquidity.providersFeeCalculationTimeStep | 1s    |
    25  
    26      Given the following network parameters are set:
    27        | name                                    | value |
    28        | transfer.fee.factor                     |  1    |
    29        | network.markPriceUpdateMaximumFrequency | 0s    |
    30        | transfer.fee.maxQuantumAmount           |  1    |
    31        | transfer.feeDiscountDecayFraction       |  0.9  |
    32        | limits.markets.maxPeggedOrders          | 4     |
    33        | validators.epoch.length                 | 20s   |
    34  
    35      # setup accounts
    36      Given the parties deposit on asset's general account the following amount:
    37        | party   | asset | amount    |
    38        | aux1    | ETH   | 100000000 |
    39        | aux2    | ETH   | 100000000 |
    40        | trader3 | ETH   | 10000     |
    41        | trader4 | ETH   | 10000     |
    42        | lpprov  | ETH   | 10000000  |
    43        | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c  | ETH   | 10000000  |
    44  
    45      Then the parties place the following orders:
    46        | party | market id | side | volume | price | resulting trades | type       | tif     |
    47        | aux1  | ETH/DEC21 | buy  | 1000   | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    48        | aux2  | ETH/DEC21 | sell | 1000   | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    49        | aux1  | ETH/DEC21 | buy  | 100    | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    50        | aux2  | ETH/DEC21 | sell | 100    | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    51      And the parties submit the following liquidity provision:
    52        | id  | party  | market id | commitment amount | fee | lp type    |
    53        | lp1 | lpprov | ETH/DEC21 | 90000             | 0.1 | submission |
    54        | lp1 | lpprov | ETH/DEC21 | 90000             | 0.1 | submission |
    55      And the parties place the following pegged iceberg orders:
    56        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    57        | lpprov | ETH/DEC21 | 10000     | 1                    | buy  | BID              | 20000  | 100    |
    58        | lpprov | ETH/DEC21 | 10000     | 1                    | sell | ASK              | 20000  | 100    |
    59  
    60      Then the opening auction period ends for market "ETH/DEC21"
    61      And the market data for the market "ETH/DEC21" should be:
    62        | mark price | trading mode            |
    63        | 1000       | TRADING_MODE_CONTINUOUS |
    64      When the parties place the following orders "1" blocks apart:
    65        | party   | market id | side | volume | price | resulting trades | type       | tif     |
    66        | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH/DEC21 | buy  | 300    | 1002  | 0                | TYPE_LIMIT | TIF_GTC |
    67        | trader4 | ETH/DEC21 | sell | 400    | 1002  | 1                | TYPE_LIMIT | TIF_GTC |
    68  
    69      Then the following trades should be executed:
    70        | buyer   | price | size | seller  | aggressor side |
    71        | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | 1002  | 300  | trader4 | sell           |
    72  
    73      And the following transfers should happen:
    74        | from    | to      | from account            | to account                       | market id | amount | asset |
    75        | trader4 | market  | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_MAKER          | ETH/DEC21 | 16     | ETH   |
    76        | trader4 |         | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_INFRASTRUCTURE |           | 7      | ETH   |
    77        | trader4 | market  | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_LIQUIDITY      | ETH/DEC21 | 301    | ETH   |
    78        | market  | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL             | ETH/DEC21 | 16     | ETH   |
    79  
    80      # make the epoch end so that the fees are registered
    81      And the network moves ahead "1" epochs
    82      And the current epoch is "2"
    83  
    84      
    85  @fee-discount
    86  Scenario: transfer where fee-discount has decayed to 0 results in no fee discount (0057-TRAN-016)
    87  
    88      And the parties have the following transfer fee discounts:
    89      | party                                                              | asset | available discount |
    90      | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c   |  ETH  | 16                 |
    91      
    92      # let the discount decay to zero
    93      Given the following network parameters are set:
    94        | name                                    | value |
    95        | transfer.feeDiscountDecayFraction       |  0.0  |
    96      And the network moves ahead "1" epochs
    97  
    98      And the parties have the following transfer fee discounts:
    99      | party                                                              | asset | available discount |
   100      | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c   |  ETH  | 0                  |
   101  
   102  
   103      Given "f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c" should have general account balance of "9998393" for asset "ETH"
   104      And the accumulated infrastructure fees should be "7" for the asset "ETH"
   105  
   106      # now do a transfer and check we pay the full fees
   107      # They will transfers 10000, fee is 0.5 * 10000 = 5000, discount is 0
   108      # 9998686 - 10000 - 5000 = 9983686
   109      Given the parties submit the following one off transfers:
   110      | id | from   |  from_account_type    |   to   |   to_account_type    | asset | amount | delivery_time         |
   111      | 1  | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c |  ACCOUNT_TYPE_GENERAL | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_GENERAL | ETH  |  10000 | 2021-08-26T00:09:01Z  |
   112    
   113      Given time is updated to "2021-08-26T00:10:01Z"
   114      Then "f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c" should have general account balance of "9983393" for asset "ETH"
   115      Then "a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4" should have general account balance of "10000" for asset "ETH"
   116  
   117      # check fee went to insurance account
   118      And the accumulated infrastructure fees should be "5007" for the asset "ETH"
   119  
   120      # now try to transfer the rest, we won't have enough so it should get rejected
   121      Given the parties submit the following one off transfers:
   122      | id | from                                                             |  from_account_type    |   to                                                             |   to_account_type    | asset | amount   | delivery_time         | error                        |
   123      | 1  | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c |  ACCOUNT_TYPE_GENERAL | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_GENERAL | ETH   |  9983686 | 2021-08-26T00:09:01Z  | could not pay the fee for transfer: not enough funds to transfer | 
   124