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

     1  Feature: Volume discount program - program enactment
     2  
     3    Volume discount program rewards parties who comprise above a specified
     4    taker volume with a discount on their fees.
     5  
     6    Tests check on program enactment party benefit factors are updated
     7    correctly and applied in the next epoch.
     8  
     9    Background:
    10      
    11      # Initialise the network and register the assets
    12      Given the average block duration is "1"
    13      And the following network parameters are set:
    14        | name                                    | value |
    15        | market.fee.factors.makerFee             | 0.01  |
    16        | market.fee.factors.infrastructureFee    | 0.01  |
    17        | market.fee.factors.treasuryFee          | 0.1   |
    18        | market.fee.factors.buybackFee           | 0.1   |
    19        | network.markPriceUpdateMaximumFrequency | 0s    |
    20        | validators.epoch.length                 | 20s   |
    21        | market.auction.minimumDuration          | 1     |
    22  
    23      And the following assets are registered:
    24        | id      | decimal places | quantum |
    25        | USD-0-1 | 0              | 1       |
    26        | MXN-0-1 | 0              | 1       |
    27  
    28      # Initialise the parties and deposit assets
    29      Given the parties deposit on asset's general account the following amount:
    30        | party | asset   | amount   |
    31        | aux1  | USD-0-1 | 1000000  |
    32        | aux2  | USD-0-1 | 1000000  |
    33        | aux1  | MXN-0-1 | 10000000 |
    34        | aux2  | MXN-0-1 | 10000000 |
    35  
    36      # Setup the markets
    37      And the markets:
    38        | 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 |
    39        | BTC/USD-0-1 | USD        | USD-0-1 | default-log-normal-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 1e-3                   | 0                         | default-futures | 0              | 0                       |
    40        | BTC/MXN-0-1 | VND        | MXN-0-1 | default-log-normal-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 1e-3                   | 0                         | default-futures | 0              | 0                       |
    41      And the spot markets:
    42        | id              | name    | base asset | quote asset | risk model                    | auction duration | fees         | price monitoring | decimal places | position decimal places | sla params    |
    43        | MXN-0-1/USD-0-1 | MXN/USD | MXN-0-1    | USD-0-1     | default-log-normal-risk-model | 1                | default-none | default-none     | 0              | 0                       | default-basic |
    44        | USD-0-1/MXN-0-1 | MXN/USD | USD-0-1    | MXN-0-1     | default-log-normal-risk-model | 1                | default-none | default-none     | 0              | 0                       | default-basic |
    45      And the parties place the following orders:
    46        | party | market id   | side | volume | price | resulting trades | type       | tif     |
    47        | aux1  | BTC/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |
    48        | aux2  | BTC/USD-0-1 | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |
    49      And the parties place the following orders:
    50        | party | market id   | side | volume | price  | resulting trades | type       | tif     |
    51        | aux1  | BTC/MXN-0-1 | buy  | 1      | 500000 | 0                | TYPE_LIMIT | TIF_GTC |
    52        | aux2  | BTC/MXN-0-1 | sell | 1      | 500000 | 0                | TYPE_LIMIT | TIF_GTC |
    53      And the parties place the following orders:
    54        | party | market id       | side | volume | price | resulting trades | type       | tif     |
    55        | aux1  | MXN-0-1/USD-0-1 | buy  | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |
    56        | aux2  | MXN-0-1/USD-0-1 | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |
    57      And the parties place the following orders:
    58        | party | market id       | side | volume | price  | resulting trades | type       | tif     |
    59        | aux1  | USD-0-1/MXN-0-1 | buy  | 1      | 500000 | 0                | TYPE_LIMIT | TIF_GTC |
    60        | aux2  | USD-0-1/MXN-0-1 | sell | 1      | 500000 | 0                | TYPE_LIMIT | TIF_GTC |
    61      When the network moves ahead "2" blocks
    62      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/USD-0-1"
    63      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "MXN-0-1/USD-0-1"
    64  
    65      Given the parties deposit on asset's general account the following amount:
    66        | party  | asset   | amount   |
    67        | party1 | USD-0-1 | 1000000  |
    68        | party2 | USD-0-1 | 1000000  |
    69        | party1 | MXN-0-1 | 10000000 |
    70        | party2 | MXN-0-1 | 10000000 |
    71        
    72  
    73    Scenario: No program currently active, new program enacted, discount factors applied from the start of the next epoch.
    74  
    75      # First generate some taker volume, so in the next epoch after the program is created party1 will qualify for discount factors
    76      Given the parties place the following orders:
    77        | party  | market id | side | volume | price | resulting trades | type       | tif     | error |
    78        | aux1   | <market>  | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
    79        | party1 | <market>  | buy  | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
    80      When the network moves ahead "1" blocks
    81      Then the following trades should be executed:
    82        | buyer  | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee |
    83        | party1 | aux1   | 1    | 50000 | buy            | 500             | 500                      |
    84  
    85      # Enact the new volume discount program
    86      Given the volume discount program tiers named "vdt":
    87        | volume | infra factor | liquidity factor | maker factor |
    88        | 1      | 0.1          | 0.1              | 0.1          |
    89      And the volume discount program:
    90        | id  | tiers | closing timestamp | window length |
    91        | id1 | vdt   | 0                 | 1             |
    92  
    93      # Move ahead to the first epoch after enactment, check party1 is receiving discounts proportional to the discount factors
    94      Given the network moves ahead "1" epochs
    95      And the parties place the following orders:
    96        | party  | market id | side | volume | price | resulting trades | type       | tif     | error |
    97        | aux1   | <market>  | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
    98        | party1 | <market>  | buy  | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
    99      When the network moves ahead "1" blocks
   100      Then the following trades should be executed:
   101        | buyer  | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee volume discount | buyer infrastructure fee volume discount |
   102        | party1 | aux1   | 1    | 50000 | buy            | 450             | 450                      | 50                              | 50                                       |
   103  
   104    Examples:
   105      # Check the above scenario for a derivative and spot market    
   106        | market          |
   107        | BTC/USD-0-1     |
   108        | MXN-0-1/USD-0-1 |
   109  
   110  
   111    Scenario: Program currently active, program update enacted, discount factors applied from the start of the next epoch.
   112  
   113      # Enact the original referral program and move to the first epoch after enactment
   114      Given the volume discount program tiers named "vdt":
   115        | volume | infra factor | liquidity factor | maker factor |
   116        | 1      | 0.1          | 0.1              | 0.1          |
   117      And the volume discount program:
   118        | id  | tiers | closing timestamp | window length |
   119        | id1 | vdt   | 0                 | 1             |
   120      And the network moves ahead "1" epochs
   121  
   122      # First generate some taker volume, so in the next epoch party1 will qualify for the discount factors
   123      Given the parties place the following orders:
   124        | party  | market id | side | volume | price | resulting trades | type       | tif     | error |
   125        | aux1   | <market>  | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   126        | party1 | <market>  | buy  | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   127      When the network moves ahead "1" blocks
   128      Then the following trades should be executed:
   129        | buyer  | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee |
   130        | party1 | aux1   | 1    | 50000 | buy            | 500             | 500                      |
   131  
   132      # Move ahead an epoch so factors updated, check party1 is receiving discounts proportional to the discount factors
   133      Given the network moves ahead "1" epochs
   134      And the parties place the following orders:
   135        | party  | market id | side | volume | price | resulting trades | type       | tif     | error |
   136        | aux1   | <market>  | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   137        | party1 | <market>  | buy  | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   138      When the network moves ahead "1" blocks
   139      Then the following trades should be executed:
   140        | buyer  | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee volume discount | buyer infrastructure fee volume discount |
   141        | party1 | aux1   | 1    | 50000 | buy            | 450             | 450                      | 50                              | 50                                       |
   142  
   143      # Enact an update to the discount program - doubling the discounts
   144      Given the volume discount program tiers named "vdt":
   145        | volume | infra factor | liquidity factor | maker factor |
   146        | 1000   | 0.2          | 0.2              | 0.2          |
   147      And the volume discount program:
   148        | id  | tiers | closing timestamp | window length |
   149        | id1 | vdt   | 0                 | 1             |
   150  
   151      # Before moving to the next epoch, check party1 is still receiving discounts proportional to the original discount factor
   152      Given the parties place the following orders:
   153        | party  | market id | side | volume | price | resulting trades | type       | tif     | error |
   154        | aux1   | <market>  | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   155        | party1 | <market>  | buy  | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   156      When the network moves ahead "1" blocks
   157      Then the following trades should be executed:
   158        | buyer  | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee volume discount | buyer infrastructure fee volume discount |
   159        | party1 | aux1   | 1    | 50000 | buy            | 450             | 450                      | 50                              | 50                                       |
   160  
   161      # # Move to the first epoch after program update, check party1 is now receiving discounts proportional to the updated discount factor
   162      Given the network moves ahead "1" epochs
   163      And the parties place the following orders:
   164        | party  | market id | side | volume | price | resulting trades | type       | tif     | error |
   165        | aux1   | <market>  | sell | 1      | 50000 | 0                | TYPE_LIMIT | TIF_GTC |       |
   166        | party1 | <market>  | buy  | 1      | 50000 | 1                | TYPE_LIMIT | TIF_GTC |       |
   167      When the network moves ahead "1" blocks
   168      Then debug trades
   169      And the following trades should be executed:
   170        | buyer  | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee volume discount | buyer infrastructure fee volume discount |
   171        | party1 | aux1   | 1    | 50000 | buy            | 400             | 400                      | 100                             | 100                                      |
   172  
   173    Examples:
   174      # Check the above scenario for a derivative and spot market    
   175        | market          |
   176        | BTC/USD-0-1     |
   177        | MXN-0-1/USD-0-1 |