code.vegaprotocol.io/vega@v0.79.0/core/integration/features/pap/0097-PAPU-046.feature (about) 1 Feature: If an automated purchase order is fully filled on auction uncrossing, all swapped tokens are transferred to the correct to account. (0097-PAPU-046). 2 3 Background: 4 Given the log normal risk model named "log-normal-risk-model": 5 | risk aversion | tau | mu | r | sigma | 6 | 0.000001 | 0.1 | 0 | 0 | 1.0 | 7 And the following network parameters are set: 8 | name | value | 9 | market.value.windowLength | 60s | 10 | network.markPriceUpdateMaximumFrequency | 0s | 11 | limits.markets.maxPeggedOrders | 6 | 12 | market.auction.minimumDuration | 1 | 13 | market.fee.factors.infrastructureFee | 0.001 | 14 | market.fee.factors.makerFee | 0.004 | 15 | spam.protection.max.stopOrdersPerMarket | 5 | 16 | validators.epoch.length | 60m | 17 And the liquidity monitoring parameters: 18 | name | triggering ratio | time window | scaling factor | 19 | lqm-params | 1.0 | 20s | 1 | 20 And the fees configuration named "fees-config-1": 21 | maker fee | infrastructure fee | 22 | 0.0004 | 0.001 | 23 And the price monitoring named "price-monitoring": 24 | horizon | probability | auction extension | 25 | 3600 | 0.99 | 30 | 26 And the liquidity sla params named "SLA-22": 27 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 28 | 0.5 | 0.6 | 1 | 1.0 | 29 And the following network parameters are set: 30 | name | value | 31 | limits.markets.maxPeggedOrders | 2 | 32 And the following assets are registered: 33 | id | decimal places | 34 | ETH | 0 | 35 36 And the spot markets: 37 | id | name | base asset | quote asset | liquidity monitoring | risk model | auction duration | fees | price monitoring | sla params | 38 | BTC/ETH | BTC/ETH | 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 And the parties place the following pegged iceberg orders: 55 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 56 | lpprov | BTC/ETH | 2 | 1 | buy | MID | 50 | 100 | 57 | lpprov | BTC/ETH | 2 | 1 | sell | MID | 50 | 100 | 58 59 # place orders and generate trades - slippage 100 60 And the parties place the following orders: 61 | party | market id | side | volume | price | resulting trades | type | tif | reference | 62 | party2 | BTC/ETH | buy | 1 | 950000 | 0 | TYPE_LIMIT | TIF_GTC | t2-b-1 | 63 | party1 | BTC/ETH | buy | 1 | 1000000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | 64 | party3 | BTC/ETH | sell | 1 | 1000000 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-1 | 65 66 When the opening auction period ends for market "BTC/ETH" 67 68 And the following trades should be executed: 69 | buyer | price | size | seller | 70 | party1 | 1000000 | 1 | party3 | 71 And the mark price should be "1000000" for the market "BTC/ETH" 72 73 And the composite price oracles from "0xCAFECAFE2": 74 | name | price property | price type | price decimals | 75 | price_oracle | prices.ETH.value | TYPE_INTEGER | 0 | 76 77 And the time triggers oracle spec is: 78 | name | initial | every | 79 | auction_schedule | 1727136001 | 30 | 80 | auction_vol_snap_schedule | 1727136000 | 30 | 81 82 And the average block duration is "1" 83 84 And the parties deposit on asset's general account the following amount: 85 | party | asset | amount | 86 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | BTC | 50000 | 87 Given time is updated to "2024-09-24T00:00:00Z" 88 And the parties submit the following one off transfers: 89 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 90 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_BUY_BACK_FEES | BTC | 5000 | 2024-09-23T00:00:00Z | 91 92 And the buy back fees balance should be "5000" for the asset "BTC" 93 94 Scenario: PAP order is submitted into a PAP auction and is fully matched. The full btc amount is swapped and the corresponding ETH amount is transferred to the corresponding network treasury. 95 When the protocol automated purchase is defined as: 96 | 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 | 97 | 12345 | BTC | ACCOUNT_TYPE_BUY_BACK_FEES | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH | price_oracle | 10s | 1.01 | auction_schedule | auction_vol_snap_schedule | 60s | 100 | 200 | 0 | 98 99 Then the oracles broadcast data with block time signed with "0xCAFECAFE2": 100 | name | value | time offset | 101 | prices.ETH.value | 1000000 | -1s | 102 103 And the network moves ahead "30" blocks 104 105 # maximum auction size is 200 so expect 200 to be earmarked 106 Then the automated purchase program for market "BTC/ETH" should have a snapshot balance of "200" 107 108 # we enter a pap auction 109 And the trading mode should be "TRADING_MODE_PROTOCOL_AUTOMATED_PURCHASE_AUCTION" for the market "BTC/ETH" 110 111 # an order for sell BTC with size 200 and price 1.01 * 1000000 is placed 112 And the order book should have the following volumes for market "BTC/ETH": 113 | side | price | volume | 114 | sell | 1010000 | 200 | 115 116 # lets place a limit order for the buy at 101000 so it crosses 117 And the parties place the following orders: 118 | party | market id | side | volume | price | resulting trades | type | tif | reference | 119 | party2 | BTC/ETH | buy | 200 | 1010000 | 0 | TYPE_LIMIT | TIF_GTC | t2-b-1 | 120 121 # move to the end of the auction 122 And the network moves ahead "61" blocks 123 124 # expect to leave the auction 125 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 126 127 # expect 200 BTC to have been moved from the BTC buy back account 128 And the buy back fees balance should be "4800" for the asset "BTC" 129 # 202000000 - 0.0505 * 200 * 1010000 = 191,799,000 130 And the network treasury balance should be "191799000" for the asset "ETH" 131 And "party2" should have general account balance of "200" for asset "BTC"