code.vegaprotocol.io/vega@v0.79.0/core/integration/features/0084-VDPR-018.feature (about)

     1  Feature: A volume_discount_factors tier with differing factors across the three options has each factor set correctly (0084-VDPR-018)
     2  
     3    Background:
     4  
     5      Given the margin calculator named "margin-calculator-1":
     6        | search factor | initial factor | release factor |
     7        | 1.2           | 1.5            | 1.7            |
     8      Given the log normal risk model named "log-normal-risk-model":
     9        | risk aversion | tau | mu | r | sigma |
    10        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
    11  
    12      Given the liquidity monitoring parameters:
    13        | name       | triggering ratio | time window | scaling factor |
    14        | lqm-params | 1.0              | 20s         | 1.0            |
    15  
    16      And the following network parameters are set:
    17        | name                                    | value |
    18        | market.value.windowLength               | 60s   |
    19        | network.markPriceUpdateMaximumFrequency | 0s    |
    20        | limits.markets.maxPeggedOrders          | 6     |
    21        | market.auction.minimumDuration          | 1     |
    22  
    23  
    24      #risk factor short:3.5569036
    25      #risk factor long:0.801225765
    26      And the volume discount program tiers named "VDP-01":
    27        | volume | infra factor | liquidity factor | maker factor |
    28        | 1000   | 0.001        | 0.002            | 0.003        |
    29        | 2000   | 0.005        | 0.006            | 0.007        |
    30        | 3000   | 0.010        | 0.012            | 0.014        |
    31      And the volume discount program:
    32        | id  | tiers  | closing timestamp | window length |
    33        | id1 | VDP-01 | 0                 | 4             |
    34  
    35      And the following assets are registered:
    36        | id  | decimal places |
    37        | ETH | 0              |
    38      And the fees configuration named "fees-config-1":
    39        | maker fee | infrastructure fee | liquidity fee method | liquidity fee constant |
    40        | 0.0004    | 0.001              | METHOD_CONSTANT      | 0                      |
    41  
    42      And the fees configuration named "fees-config-2":
    43        | maker fee | infrastructure fee | liquidity fee method | liquidity fee constant | buy back fee | treasury fee |
    44        | 0         | 0                  | METHOD_CONSTANT      | 0.1                    | 0.001        | 0.002        |
    45  
    46      And the price monitoring named "price-monitoring":
    47        | horizon | probability | auction extension |
    48        | 3600    | 0.99        | 3                 |
    49  
    50      And the liquidity sla params named "SLA-22":
    51        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    52        | 0.5         | 0.6                          | 1                             | 1.0                    |
    53  
    54      And the following network parameters are set:
    55        | name                                                | value |
    56        | market.liquidity.bondPenaltyParameter               | 0.2   |
    57        | validators.epoch.length                             | 5s    |
    58        | market.liquidity.stakeToCcyVolume                   | 1     |
    59        | market.liquidity.successorLaunchWindowLength        | 1h    |
    60        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.7   |
    61        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.6   |
    62        | validators.epoch.length                             | 10s   |
    63        | market.liquidity.earlyExitPenalty                   | 0.25  |
    64  
    65      Given the average block duration is "1"
    66  
    67    Scenario: Check the factors after each epoch, basically same as 0084-VDPR-012.
    68      Given the markets:
    69        | id        | quote name | asset | liquidity monitoring | risk model            | margin calculator   | auction duration | fees          | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params |
    70        | ETH/MAR24 | ETH        | ETH   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 1e0                    | 0                         | SLA-22     |
    71  
    72      And the parties deposit on asset's general account the following amount:
    73        | party  | asset | amount   |
    74        | lp1    | ETH   | 10000000 |
    75        | party1 | ETH   | 10000000 |
    76        | party2 | ETH   | 10000000 |
    77        | party3 | ETH   | 10000000 |
    78  
    79      And the parties submit the following liquidity provision:
    80        | id   | party | market id | commitment amount | fee  | lp type    |
    81        | lp_1 | lp1   | ETH/MAR24 | 100000            | 0.02 | submission |
    82  
    83      When the parties place the following orders:
    84        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    85        | party1 | ETH/MAR24 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    86        | party1 | ETH/MAR24 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    87        | lp1    | ETH/MAR24 | buy  | 100    | 990   | 0                | TYPE_LIMIT | TIF_GTC |
    88        | lp1    | ETH/MAR24 | sell | 100    | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
    89        | party2 | ETH/MAR24 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    90        | party2 | ETH/MAR24 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    91  
    92      Then the opening auction period ends for market "ETH/MAR24"
    93      And the following trades should be executed:
    94        | buyer  | price | size | seller |
    95        | party1 | 1000  | 1    | party2 |
    96      And the market data for the market "ETH/MAR24" should be:
    97        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    98        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 3556         | 100000         | 1             |
    99      And the parties have the following discount factors:
   100        | party  | maker factor | liquidity factor | infra factor |
   101        | party3 | 0            | 0                | 0            |
   102        | party1 | 0            | 0                | 0            |
   103        | party2 | 0            | 0                | 0            |
   104        | lp1    | 0            | 0                | 0            |
   105  
   106      Then the parties place the following orders:
   107        | party  | market id | side | volume | price | resulting trades | type        | tif     |
   108        | party3 | ETH/MAR24 | buy  | 1      | 0     | 1                | TYPE_MARKET | TIF_IOC |
   109        | party3 | ETH/MAR24 | sell | 1      | 0     | 1                | TYPE_MARKET | TIF_IOC |
   110      When the network moves ahead "1" epochs
   111      Then the parties have the following discount factors:
   112        | party  | maker factor | liquidity factor | infra factor |
   113        | party3 | 0.007        | 0.006            | 0.005        |
   114        | party1 | 0            | 0                | 0            |
   115        | party2 | 0            | 0                | 0            |
   116        | lp1    | 0            | 0                | 0            |
   117  
   118      When the parties place the following orders:
   119        | party  | market id | side | volume | price | resulting trades | type        | tif     |
   120        | party3 | ETH/MAR24 | buy  | 20     | 0     | 1                | TYPE_MARKET | TIF_IOC |
   121        | party3 | ETH/MAR24 | sell | 20     | 0     | 1                | TYPE_MARKET | TIF_IOC |
   122        | party1 | ETH/MAR24 | buy  | 1      | 0     | 1                | TYPE_MARKET | TIF_IOC |
   123        | party1 | ETH/MAR24 | sell | 1      | 0     | 1                | TYPE_MARKET | TIF_IOC |
   124      And the network moves ahead "1" epochs
   125      Then the parties have the following discount factors:
   126        | party  | maker factor | liquidity factor | infra factor |
   127        | party3 | 0.014        | 0.012            | 0.01         |
   128        | party1 | 0.007        | 0.006            | 0.005        |
   129        | party2 | 0            | 0                | 0            |
   130        | lp1    | 0            | 0                | 0            |
   131  
   132      # when trade_value_for_fee_purposes>0, then total fee should be maker_fee_after_referral_discount+ treasury_fee + buyback_fee when fee_factor[infrastructure] = 0, fee_factor[liquidity] = 0 (0083-RFPR-053)
   133      # now lets reset the infra fee to 0 and do a trade with party 3:
   134      When the following network parameters are set:
   135        | name                                 | value |
   136        | market.fee.factors.makerFee          | 0.1   |
   137        | market.fee.factors.infrastructureFee | 0     |
   138        | market.fee.factors.buybackFee        | 0.001 |
   139        | market.fee.factors.treasuryFee       | 0.002 |
   140  
   141      And the parties place the following orders:
   142        | party  | market id | side | volume | price | resulting trades | type        | tif     |
   143        | party3 | ETH/MAR24 | sell | 11     | 0     | 1                | TYPE_MARKET | TIF_IOC |
   144  
   145      # trade value is 11*990 = 10,890
   146      # infra fee is set to 0
   147      # liquidity fee is set to 0
   148      # maker fee before discount = 10,890 * 0.1 => 1089
   149      # maker fee discount = 1089*0.014 => 15
   150      # maker fee after discount = 1089-15=1074
   151      # buyback = 11
   152      # treasury = 22
   153      # total = 1074 + 33
   154      Then the following trades should be executed:
   155        | seller | price | size | buyer | seller fee | seller infrastructure fee | seller liquidity fee | seller maker fee | seller infrastructure fee volume discount | seller liquidity fee volume discount | seller maker fee volume discount |
   156        | party3 | 990   | 11   | lp1   | 1107       | 0                         | 0                    | 1074             | 0                                         | 0                                    | 15                               |
   157  
   158      # when trade_value_for_fee_purposes>0, then total fee should be infrastructure_fee_after_referral_discount+ treasury_fee + buyback_fee when fee_factor[maker] = 0, fee_factor[liquidity] = 0 (0083-RFPR-055)
   159      # now lets reset the maker fee to 0 and do a trade with party 3:
   160      When the following network parameters are set:
   161        | name                                 | value |
   162        | market.fee.factors.makerFee          | 0     |
   163        | market.fee.factors.infrastructureFee | 0.2   |
   164  
   165      # trade value is 11*990 = 10,890
   166      # maker fee is set to 0
   167      # liquidity fee is set to 0
   168      # infra fee before discount = 10,890 * 0.2 => 2178
   169      # infra fee discount = 2178*0.01 => 21
   170      # infra fee after discount = 2178-21=2157
   171      # buyback = 11
   172      # treasury = 22
   173      # total = 2157 + 33
   174      And the parties place the following orders:
   175        | party  | market id | side | volume | price | resulting trades | type        | tif     |
   176        | party3 | ETH/MAR24 | sell | 11     | 0     | 1                | TYPE_MARKET | TIF_IOC |
   177  
   178      Then the following trades should be executed:
   179        | seller | price | size | buyer | seller fee | seller infrastructure fee | seller liquidity fee | seller maker fee | seller infrastructure fee volume discount | seller liquidity fee volume discount | seller maker fee volume discount |
   180        | party3 | 990   | 11   | lp1   | 2190       | 2157                      | 0                    | 0                | 21                                        | 0                                    | 0                                |
   181      And the parties have the following discount factors:
   182        | party  | maker factor | liquidity factor | infra factor |
   183        | party3 | 0.014        | 0.012            | 0.01         |
   184        | party1 | 0.007        | 0.006            | 0.005        |
   185        | party2 | 0            | 0                | 0            |
   186        | lp1    | 0            | 0                | 0            |
   187  
   188      # check if the tiers carry over in to the next epochs
   189      When the network moves ahead "1" epochs
   190      Then the parties have the following discount factors:
   191        | party  | maker factor | liquidity factor | infra factor |
   192        | party3 | 0.014        | 0.012            | 0.01         |
   193        | party1 | 0.007        | 0.006            | 0.005        |
   194        | party2 | 0            | 0                | 0            |
   195        | lp1    | 0            | 0                | 0            |
   196  
   197      # 2 epochs later, nothing has changed
   198      When the network moves ahead "2" epochs
   199      Then the parties have the following discount factors:
   200        | party  | maker factor | liquidity factor | infra factor |
   201        | party3 | 0.014        | 0.012            | 0.01         |
   202        | party1 | 0.007        | 0.006            | 0.005        |
   203        | party2 | 0            | 0                | 0            |
   204        | lp1    | 0            | 0                | 0            |
   205  
   206      # one epoch later, party 1 lost their benefits, party3 traded later on, they keep their benefits one more epoch.
   207      When the network moves ahead "1" epochs
   208      Then the parties have the following discount factors:
   209        | party  | maker factor | liquidity factor | infra factor |
   210        | party3 | 0.014        | 0.012            | 0.01         |
   211        | party1 | 0            | 0                | 0            |
   212        | party2 | 0            | 0                | 0            |
   213        | lp1    | 0            | 0                | 0            |
   214  
   215      # next epoch, the benefits should have expired
   216      When the network moves ahead "1" epochs
   217      Then the parties have the following discount factors:
   218        | party  | maker factor | liquidity factor | infra factor |
   219        | party3 | 0            | 0                | 0            |
   220        | party1 | 0            | 0                | 0            |
   221        | party2 | 0            | 0                | 0            |
   222        | lp1    | 0            | 0                | 0            |