code.vegaprotocol.io/vega@v0.79.0/core/integration/features/pap/0097-PAPU-028.feature (about)

     1  Feature: Given a network with two PAP programs, A and B, funded from the same account with a balance of 1000. If the snapshot of program A is triggered and is allocated 1000 tokens for it's next auction, once the snapshot of program B is triggered it will be allocated 0 tokens and it's next auction will be skipped. This happens regardless of whether the auction of program B is triggered before the auction of program A. (0097-PAPU-028).
     2      Background:
     3          Given the log normal risk model named "log-normal-risk-model":
     4              | risk aversion | tau | mu | r | sigma |
     5              | 0.000001      | 0.1 | 0  | 0 | 1.0   |
     6          And the following network parameters are set:
     7              | name                                    | value |
     8              | market.value.windowLength               | 60s   |
     9              | network.markPriceUpdateMaximumFrequency | 0s    |
    10              | limits.markets.maxPeggedOrders          | 6     |
    11              | market.auction.minimumDuration          | 1     |
    12              | market.fee.factors.infrastructureFee    | 0.001 |
    13              | market.fee.factors.makerFee             | 0.004 |
    14              | spam.protection.max.stopOrdersPerMarket | 5     |
    15              | validators.epoch.length                 | 60m   |
    16          And the liquidity monitoring parameters:
    17              | name       | triggering ratio | time window | scaling factor |
    18              | lqm-params | 1.0              | 20s         | 1              |
    19          And the fees configuration named "fees-config-1":
    20              | maker fee | infrastructure fee |
    21              | 0.0004    | 0.001              |
    22          And the price monitoring named "price-monitoring":
    23              | horizon | probability | auction extension |
    24              | 3600    | 0.99        | 30                |
    25          And the liquidity sla params named "SLA-22":
    26              | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    27              | 0.5         | 0.6                          | 1                             | 1.0                    |
    28          And the following network parameters are set:
    29              | name                           | value |
    30              | limits.markets.maxPeggedOrders | 2     |
    31          And the following assets are registered:
    32              | id  | decimal places |
    33              | ETH | 0              |
    34  
    35          And the spot markets:
    36              | id       | name     | base asset | quote asset | liquidity monitoring | risk model            | auction duration | fees          | price monitoring | sla params |
    37              | BTC/ETH  | BTC/ETH  | BTC        | ETH         | lqm-params           | log-normal-risk-model | 2                | fees-config-1 | price-monitoring | SLA-22     |
    38              | BTC/ETH2 | BTC/ETH2 | BTC        | ETH         | lqm-params           | log-normal-risk-model | 2                | fees-config-1 | price-monitoring | SLA-22     |
    39  
    40          Given the parties deposit on asset's general account the following amount:
    41              | party  | asset | amount     |
    42              | party1 | ETH   | 1000000000 |
    43              | party2 | ETH   | 1000000000 |
    44              | party3 | ETH   | 1000000000 |
    45              | party1 | BTC   | 1000000000 |
    46              | party3 | BTC   | 1000000000 |
    47              | lpprov | ETH   | 1000000000 |
    48              | lpprov | BTC   | 1000000000 |
    49  
    50          When the parties submit the following liquidity provision:
    51              | id  | party  | market id | commitment amount | fee | lp type    |
    52              | lp1 | lpprov | BTC/ETH   | 937000            | 0.1 | submission |
    53              | lp1 | lpprov | BTC/ETH   | 937000            | 0.1 | submission |
    54              | lp1 | lpprov | BTC/ETH2  | 937000            | 0.1 | submission |
    55              | lp1 | lpprov | BTC/ETH2  | 937000            | 0.1 | submission |
    56          And the parties place the following pegged iceberg orders:
    57              | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    58              | lpprov | BTC/ETH   | 2         | 1                    | buy  | MID              | 50     | 100    |
    59              | lpprov | BTC/ETH   | 2         | 1                    | sell | MID              | 50     | 100    |
    60              | lpprov | BTC/ETH2  | 2         | 1                    | buy  | MID              | 50     | 100    |
    61              | lpprov | BTC/ETH2  | 2         | 1                    | sell | MID              | 50     | 100    |
    62  
    63          # place orders and generate trades - slippage 100
    64          And the parties place the following orders:
    65              | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
    66              | party2 | BTC/ETH   | buy  | 1      | 950000  | 0                | TYPE_LIMIT | TIF_GTC | t2-b-1    |
    67              | party1 | BTC/ETH   | buy  | 1      | 1000000 | 0                | TYPE_LIMIT | TIF_GFA | t1-b-1    |
    68              | party3 | BTC/ETH   | sell | 1      | 1000000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
    69              | party2 | BTC/ETH2  | buy  | 1      | 950000  | 0                | TYPE_LIMIT | TIF_GTC | t2-b-1    |
    70              | party1 | BTC/ETH2  | buy  | 1      | 1000000 | 0                | TYPE_LIMIT | TIF_GFA | t1-b-1    |
    71              | party3 | BTC/ETH2  | sell | 1      | 1000000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
    72  
    73  
    74          When the opening auction period ends for market "BTC/ETH"
    75          And the mark price should be "1000000" for the market "BTC/ETH"
    76          And the mark price should be "1000000" for the market "BTC/ETH2"
    77  
    78          And the composite price oracles from "0xCAFECAFE2":
    79              | name         | price property   | price type   | price decimals |
    80              | price_oracle | prices.ETH.value | TYPE_INTEGER | 0              |
    81  
    82          And the time triggers oracle spec is:
    83              | name                       | initial    | every |
    84              | auction_vol_snap_schedule1 | 1727136005 | 30    |
    85              | auction_vol_snap_schedule2 | 1727136010 | 30    |
    86              | auction_schedule1          | 1727136012 | 30    |
    87              | auction_schedule2          | 1727136011 | 30    |
    88  
    89          And the average block duration is "1"
    90  
    91          And the parties deposit on asset's general account the following amount:
    92              | party                                                            | asset | amount |
    93              | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | BTC   | 1000   |
    94          Given time is updated to "2024-09-24T00:00:00Z"
    95          And the parties submit the following one off transfers:
    96              | id | from                                                             | from_account_type    | to                                                               | to_account_type            | asset | amount | delivery_time        |
    97              | 1  | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_BUY_BACK_FEES | BTC   | 1000   | 2024-09-23T00:00:00Z |
    98  
    99          And the buy back fees balance should be "1000" for the asset "BTC"
   100  
   101      Scenario: setting up multiple markets with pap program from the same account. The first market with the volume snapshot is earmarking as much as it can and the second market earmarks whatever is left although the second one's auction starts before the first one. (0097-PAPU-027)
   102          When the protocol automated purchase is defined as:
   103              | id    | from | from account type          | to account type               | market id | price oracle | price oracle staleness tolerance | oracle offset factor | auction schedule oracle | auction volume snapshot schedule oracle | auction duration | minimum auction size | maximum auction size | expiry timestamp |
   104              | 12345 | BTC  | ACCOUNT_TYPE_BUY_BACK_FEES | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH   | price_oracle | 10s                              | 1.01                 | auction_schedule1       | auction_vol_snap_schedule1              | 60s              | 100                  | 1000                 | 0                |
   105              | 54321 | BTC  | ACCOUNT_TYPE_BUY_BACK_FEES | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH2  | price_oracle | 10s                              | 1.01                 | auction_schedule2       | auction_vol_snap_schedule2              | 60s              | 100                  | 1000                 | 0                |
   106  
   107          Then the oracles broadcast data with block time signed with "0xCAFECAFE2":
   108              | name             | value   | time offset |
   109              | prices.ETH.value | 1000000 | -1s         |
   110  
   111          And the network moves ahead "30" blocks
   112  
   113          # the volume snapshot for the market BTC/ETH ticks first so it earmarks the maximum it is allowed, i.e. 1000
   114          # the volume snapshot for the market BTC/ETH2 ticks second so it earmarks it has nothing left to earmark and will not enter an auction
   115          Then the automated purchase program for market "BTC/ETH" should have a snapshot balance of "1000"
   116  
   117          # both enter a pap auction
   118          And the trading mode should be "TRADING_MODE_PROTOCOL_AUTOMATED_PURCHASE_AUCTION" for the market "BTC/ETH"
   119          And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH2"
   120  
   121          # for BTC/ETH: an order for sell BTC with size 1000 and price 1.01 * 1000000 is placed
   122          And the order book should have the following volumes for market "BTC/ETH":
   123              | side | price   | volume |
   124              | sell | 1010000 | 1000   |