code.vegaprotocol.io/vega@v0.79.0/core/integration/features/volume-rebate/0095-HVMR-cap.feature (about)

     1  Feature: Volume rebate program - rebate cap
     2  
     3    Background:
     4      
     5      # Initialise the network and register the assets
     6      Given the average block duration is "1"
     7      And the following network parameters are set:
     8        | name                                    | value |
     9        | market.fee.factors.makerFee             | 0.01  |
    10        | market.fee.factors.infrastructureFee    | 0.01  |
    11        | network.markPriceUpdateMaximumFrequency | 0s    |
    12        | validators.epoch.length                 | 20s   |
    13        | market.auction.minimumDuration          | 1     |
    14  
    15      And the following assets are registered:
    16        | id      | decimal places | quantum |
    17        | USD-0-1 | 0              | 1       |
    18  
    19      # Initialise the parties and deposit assets
    20      Given the parties deposit on asset's general account the following amount:
    21        | party | asset   | amount  |
    22        | aux1  | USD-0-1 | 1000000 |
    23        | aux2  | USD-0-1 | 1000000 |
    24  
    25      # Setup the markets
    26      Given the price monitoring named "price-monitoring":
    27        | horizon | probability | auction extension |
    28        | 3600    | 0.99        | 1                 |
    29      And the markets:
    30        | id          | quote name | asset   | risk model                    | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      | decimal places | position decimal places |
    31        | BTC/USD-0-1 | USD        | USD-0-1 | default-log-normal-risk-model | default-margin-calculator | 1                | default-none | price-monitoring | default-eth-for-future | 1e-3                   | 0                         | default-futures | 0              | 0                       |
    32      And the parties place the following orders:
    33        | party | market id   | side | volume | price | resulting trades | type       | tif     |
    34        | aux1  | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |
    35        | aux2  | BTC/USD-0-1 | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |
    36      When the network moves ahead "2" blocks
    37      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/USD-0-1"
    38  
    39      Given the parties deposit on asset's general account the following amount:
    40        | party  | asset   | amount  |
    41        | party1 | USD-0-1 | 1000000 |
    42        | party2 | USD-0-1 | 1000000 |
    43        
    44  
    45    Scenario Outline: Fixed buyback, treasury and rebate factors. Rebate capped correctly where necessary. (0095-HVMR-029)(0095-HVMR-030)(0095-HVMR-031)
    46  
    47      Given the following network parameters are set:
    48        | name                           | value      |
    49        | market.fee.factors.buybackFee  | <buyback>  |
    50        | market.fee.factors.treasuryFee | <treasury> |
    51      And the volume rebate program tiers named "vrt":
    52        | fraction | rebate          |
    53        | 0.0001   | 0.001           |
    54        | 0.5000   | <rebate factor> |
    55      And the volume rebate program:
    56        | id | tiers | closing timestamp | window length |
    57        | id | vrt   | 0                 | 1             |
    58      And the network moves ahead "1" epochs
    59  
    60      Given the parties place the following orders:
    61        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
    62        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
    63        | aux1   | BTC/USD-0-1 | sell | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
    64        | party2 | BTC/USD-0-1 | buy  | 2      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
    65        | aux1   | BTC/USD-0-1 | sell | 2      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
    66      When the network moves ahead "1" blocks
    67      Then the following trades should be executed:
    68        | buyer  | seller | size | price | aggressor side | buyer maker fee | seller maker fee |
    69        | party1 | aux1   | 1    | 50000 | sell           | 0               | 500              |
    70        | party2 | aux1   | 2    | 50000 | sell           | 0               | 1000             |
    71  
    72      Given the network moves ahead "1" epochs
    73      And the parties place the following orders:
    74        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
    75        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
    76        | party2 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
    77        | aux1   | BTC/USD-0-1 | sell | 2      | 50000 | 2                | TYPE_LIMIT | TIF_GTC |       |
    78      When the network moves ahead "1" blocks
    79      Then the following trades should be executed:
    80        | buyer  | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee |
    81        | party1 | aux1   | 1    | 50000 | sell           | 0                           | 50                           |
    82        | party2 | aux1   | 1    | 50000 | sell           | 0                           | <rebate amount>              |
    83      Then the following transfers should happen:
    84        | from | to     | from account            | to account           | market id   | amount          | asset   | type                                        |
    85        |      | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | 50              | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
    86        |      | party2 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | <rebate amount> | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
    87  
    88    Examples:
    89        | buyback | treasury | rebate factor | rebate amount |
    90        | 0.001   | 0.001    | 0.001         | 50            |
    91        | 0.001   | 0.001    | 0.002         | 100           |
    92        | 0.001   | 0.001    | 0.003         | 100           |
    93        | 0.002   | 0.000    | 0.001         | 50            |
    94        | 0.002   | 0.000    | 0.002         | 100           |
    95        | 0.002   | 0.000    | 0.003         | 100           |
    96        | 0.000   | 0.002    | 0.001         | 50            |
    97        | 0.000   | 0.002    | 0.002         | 100           |
    98        | 0.000   | 0.002    | 0.003         | 100           |
    99  
   100  
   101  
   102    Scenario Outline: Fixed buyback and treasury factors. Variable rebate factors. Rebate capped correctly where necessary. (0095-HVMR-032)(0095-HVMR-033)
   103  
   104      Given the following network parameters are set:
   105        | name                           | value      |
   106        | market.fee.factors.buybackFee  | <buyback>  |
   107        | market.fee.factors.treasuryFee | <treasury> |
   108      And the volume rebate program tiers named "vrt":
   109        | fraction | rebate                  |
   110        | 0.0001   | 0.001                   |
   111        | 0.5000   | <initial rebate factor> |
   112      And the volume rebate program:
   113        | id | tiers | closing timestamp | window length |
   114        | id | vrt   | 0                 | 1             |
   115      And the network moves ahead "1" epochs
   116  
   117      Given the parties place the following orders:
   118        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   119        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   120        | aux1   | BTC/USD-0-1 | sell | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   121        | party2 | BTC/USD-0-1 | buy  | 2      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   122        | aux1   | BTC/USD-0-1 | sell | 2      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   123      When the network moves ahead "1" blocks
   124      Then the following trades should be executed:
   125        | buyer  | seller | size | price | aggressor side | buyer maker fee | seller maker fee |
   126        | party1 | aux1   | 1    | 50000 | sell           | 0               | 500              |
   127        | party2 | aux1   | 2    | 50000 | sell           | 0               | 1000             |
   128  
   129      Given the network moves ahead "1" epochs
   130      And the parties place the following orders:
   131        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   132        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   133        | party2 | BTC/USD-0-1 | buy  | 2      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   134        | aux1   | BTC/USD-0-1 | sell | 3      | 50000 | 2                | TYPE_LIMIT | TIF_GTC |       |
   135      When the network moves ahead "1" blocks
   136      Then the following trades should be executed:
   137        | buyer  | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee |
   138        | party1 | aux1   | 1    | 50000 | sell           | 0                           | 50                           |
   139        | party2 | aux1   | 2    | 50000 | sell           | 0                           | <initial rebate amount>      |
   140      Then the following transfers should happen:
   141        | from | to     | from account            | to account           | market id   | amount                  | asset   | type                                        |
   142        |      | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | 50                      | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   143        |      | party2 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | <initial rebate amount> | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   144  
   145      Given the volume rebate program tiers named "vrt":
   146        | fraction | rebate                  |
   147        | 0.0001   | 0.001                   |
   148        | 0.5000   | <updated rebate factor> |
   149      And the volume rebate program:
   150        | id | tiers | closing timestamp | window length |
   151        | id | vrt   | 0                 | 2             |
   152      # Note, we are having to forward two epochs here to ensure the
   153      # program is updated and then the updated benefits are used to set
   154      # the rebate factor. In future, this may be reworked so the program
   155      # is upated before the rebates are set on the same epoch boundary.
   156      When the network moves ahead "2" epochs
   157      And the parties place the following orders:
   158        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   159        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   160        | party2 | BTC/USD-0-1 | buy  | 2      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   161        | aux1   | BTC/USD-0-1 | sell | 3      | 50000 | 2                | TYPE_LIMIT | TIF_GTC |       |
   162      And the network moves ahead "1" blocks
   163      Then the following trades should be executed:
   164        | buyer  | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee |
   165        | party1 | aux1   | 1    | 50000 | sell           | 0                           | 50                           |
   166        | party2 | aux1   | 2    | 50000 | sell           | 0                           | <updated rebate amount>      |
   167      Then the following transfers should happen:
   168        | from | to     | from account            | to account           | market id   | amount                  | asset   | type                                        |
   169        |      | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | 50                      | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   170        |      | party2 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | <updated rebate amount> | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   171  
   172    Examples:
   173        | buyback | treasury | initial rebate factor | initial rebate amount | updated rebate factor | updated rebate amount |
   174        | 0.001   | 0.001    | 0.001                 | 100                   | 0.003                 | 200                   |
   175        | 0.002   | 0.000    | 0.001                 | 100                   | 0.003                 | 200                   |
   176        | 0.000   | 0.002    | 0.001                 | 100                   | 0.003                 | 200                   |
   177        | 0.001   | 0.001    | 0.003                 | 200                   | 0.001                 | 100                   |
   178        | 0.002   | 0.000    | 0.003                 | 200                   | 0.001                 | 100                   |
   179        | 0.000   | 0.002    | 0.003                 | 200                   | 0.001                 | 100                   |
   180  
   181  
   182    Scenario Outline: Fixed rebate factors. Variable treasury and buyback factors. Rebate capped correctly where necessary. (0095-HVMR-034)(0095-HVMR-035)(0095-HVMR-036)(0095-HVMR-037)(0095-HVMR-038)(0095-HVMR-039)
   183  
   184      Given the following network parameters are set:
   185        | name                           | value              |
   186        | market.fee.factors.buybackFee  | <initial buyback>  |
   187        | market.fee.factors.treasuryFee | <initial treasury> |
   188      And the volume rebate program tiers named "vrt":
   189        | fraction | rebate   |
   190        | 0.0001   | 0.001    |
   191        | 0.5000   | <rebate> |
   192      And the volume rebate program:
   193        | id | tiers | closing timestamp | window length |
   194        | id | vrt   | 0                 | 1             |
   195      And the network moves ahead "1" epochs
   196  
   197      Given the parties place the following orders:
   198        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   199        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   200        | aux1   | BTC/USD-0-1 | sell | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   201        | party2 | BTC/USD-0-1 | buy  | 2      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   202        | aux1   | BTC/USD-0-1 | sell | 2      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   203      When the network moves ahead "1" blocks
   204      Then the following trades should be executed:
   205        | buyer  | seller | size | price | aggressor side | buyer maker fee | seller maker fee |
   206        | party1 | aux1   | 1    | 50000 | sell           | 0               | 500              |
   207        | party2 | aux1   | 2    | 50000 | sell           | 0               | 1000             |
   208  
   209      Given the network moves ahead "1" epochs
   210      And the parties place the following orders:
   211        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   212        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   213        | party2 | BTC/USD-0-1 | buy  | 2      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   214        | aux1   | BTC/USD-0-1 | sell | 3      | 50000 | 2                | TYPE_LIMIT | TIF_GTC |       |
   215      When the network moves ahead "1" blocks
   216      Then the following trades should be executed:
   217        | buyer  | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee |
   218        | party1 | aux1   | 1    | 50000 | sell           | 0                           | 50                           |
   219        | party2 | aux1   | 2    | 50000 | sell           | 0                           | <initial rebate amount>      |
   220      Then the following transfers should happen:
   221        | from | to     | from account            | to account           | market id   | amount                  | asset   | type                                        |
   222        |      | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | 50                      | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   223        |      | party2 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | <initial rebate amount> | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   224  
   225      Given the following network parameters are set:
   226        | name                           | value              |
   227        | market.fee.factors.buybackFee  | <updated buyback>  |
   228        | market.fee.factors.treasuryFee | <updated treasury> |
   229      When the network moves ahead "1" epochs
   230      And the parties place the following orders:
   231        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   232        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   233        | party2 | BTC/USD-0-1 | buy  | 2      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   234        | aux1   | BTC/USD-0-1 | sell | 3      | 50000 | 2                | TYPE_LIMIT | TIF_GTC |       |
   235      And the network moves ahead "1" blocks
   236      Then the following trades should be executed:
   237        | buyer  | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee |
   238        | party1 | aux1   | 1    | 50000 | sell           | 0                           | 50                           |
   239        | party2 | aux1   | 2    | 50000 | sell           | 0                           | <updated rebate amount>      |
   240      Then the following transfers should happen:
   241        | from | to     | from account            | to account           | market id   | amount                  | asset   | type                                        |
   242        |      | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | 50                      | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   243        |      | party2 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | <updated rebate amount> | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   244  
   245    Examples:
   246        | rebate | initial buyback | initial treasury | initial rebate amount | updated buyback | updated treasury | updated rebate amount |
   247        | 0.003  | 0.002           | 0.002            | 300                   | 0.001           | 0.001            | 200                   |
   248        | 0.003  | 0.004           | 0.000            | 300                   | 0.002           | 0                | 200                   |
   249        | 0.003  | 0.000           | 0.004            | 300                   | 0               | 0.002            | 200                   |
   250        | 0.003  | 0.001           | 0.001            | 200                   | 0.002           | 0.002            | 300                   |
   251        | 0.003  | 0.002           | 0.000            | 200                   | 0.004           | 0                | 300                   |
   252        | 0.003  | 0.000           | 0.002            | 200                   | 0               | 0.004            | 300                   |
   253  
   254  
   255    Scenario Outline: Fees updated mid epoch, fees not affected untill next epoch (0029-FEES-051)(0029-FEES-052)
   256  
   257      Given the following network parameters are set:
   258        | name                           | value              |
   259        | market.fee.factors.buybackFee  | <initial buyback>  |
   260        | market.fee.factors.treasuryFee | <initial treasury> |
   261      And the volume rebate program tiers named "vrt":
   262        | fraction | rebate   |
   263        | 0.0001   | <rebate> |
   264      And the volume rebate program:
   265        | id | tiers | closing timestamp | window length |
   266        | id | vrt   | 0                 | 1             |
   267      And the network moves ahead "1" epochs
   268  
   269      Given the parties place the following orders:
   270        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   271        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   272        | party2 | BTC/USD-0-1 | sell | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   273      When the network moves ahead "1" blocks
   274      Then the following trades should be executed:
   275        | buyer  | seller | size | price | aggressor side | buyer maker fee | seller maker fee |
   276        | party1 | party2 | 1    | 50000 | sell           | 0               | 500              |
   277  
   278      Given the network moves ahead "1" epochs
   279      And the parties place the following orders:
   280        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   281        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   282        | party2 | BTC/USD-0-1 | sell | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   283      When the network moves ahead "1" blocks
   284      Then the following trades should be executed:
   285        | buyer  | seller | size | price | aggressor side | seller treasury fee       | seller buyback fee       | seller high volume maker fee |
   286        | party1 | party2 | 1    | 50000 | sell           | <initial treasury amount> | <initial buyback amount> | <initial rebate amount>      |
   287      Then the following transfers should happen:
   288        | from | to     | from account            | to account           | market id   | amount                  | asset   | type                                        |
   289        |      | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | <initial rebate amount> | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   290  
   291      Then clear trade events
   292      Given the following network parameters are set:
   293        | name                           | value              |
   294        | market.fee.factors.buybackFee  | <updated buyback>  |
   295        | market.fee.factors.treasuryFee | <updated treasury> |
   296      And the network moves ahead "1" blocks
   297      When the parties place the following orders:
   298        | party  | market id   | side | volume | price | resulting trades | type       | tif     | error |
   299        | party1 | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   300        | party2 | BTC/USD-0-1 | sell | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   301      When the network moves ahead "1" blocks
   302      Then debug trades
   303      Then the following trades should be executed:
   304        | buyer  | seller | size | price | aggressor side | seller treasury fee       | seller buyback fee       | seller high volume maker fee |
   305        | party1 | party2 | 1    | 50000 | sell           | <updated treasury amount> | <updated buyback amount> | <updated rebate amount>      |
   306      Then the following transfers should happen:
   307        | from | to     | from account            | to account           | market id   | amount                  | asset   | type                                        |
   308        |      | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | BTC/USD-0-1 | <updated rebate amount> | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE |
   309  
   310    Examples:
   311        | rebate | initial buyback | initial treasury | initial buyback amount | initial treasury amount | initial rebate amount | updated buyback | updated treasury | updated buyback amount | updated treasury amount | updated rebate amount |
   312        | 0.003  | 0.004           | 0                | 50                     | 0                       | 150                   | 0.001           | 0                | 0                      | 0                       | 50                    |
   313        | 0.003  | 0               | 0.004            | 0                      | 50                      | 150                   | 0               | 0.001            | 0                      | 0                       | 50                    |
   314        | 0.003  | 0.002           | 0.002            | 25                     | 25                      | 150                   | 0.001           | 0.001            | 0                      | 0                       | 100                   |
   315