From e86ed2526fa0302eed9ed76e0be8b55c92bde9a0 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Mon, 29 Apr 2024 16:32:32 +0100 Subject: [PATCH 1/3] feat: add AC code for 0043-MKTL-012, 013 --- .../features/auctions/opening-auction-expiry.feature | 2 +- core/integration/features/spots/opening-auction-expires.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/integration/features/auctions/opening-auction-expiry.feature b/core/integration/features/auctions/opening-auction-expiry.feature index 4baffc7d78..14efdbc5dd 100644 --- a/core/integration/features/auctions/opening-auction-expiry.feature +++ b/core/integration/features/auctions/opening-auction-expiry.feature @@ -16,7 +16,7 @@ Feature: Set up a market, create indiciative price different to actual opening a | limits.markets.maxPeggedOrders | 2 | @DebugAuctionMax @Expires - Scenario: Simple test verifying the market is cancelled if it failes to leave opening auction + Scenario: 0043-MKTL-012 Simple test verifying the market is cancelled if it failes to leave opening auction # setup accounts Given the parties deposit on asset's general account the following amount: | party | asset | amount | diff --git a/core/integration/features/spots/opening-auction-expires.feature b/core/integration/features/spots/opening-auction-expires.feature index 8579086ff0..970581e8c8 100644 --- a/core/integration/features/spots/opening-auction-expires.feature +++ b/core/integration/features/spots/opening-auction-expires.feature @@ -18,7 +18,7 @@ Feature: Set up a spot market, with an opening auction, then uncross the book. M | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | sla params | | BTC/ETH | BTC/ETH | BTC | ETH | my-simple-risk-model | 5 | fees-config-1 | default-none | default-basic | - Scenario: Ensure spot markets get cancelled if they fail to leave opening auction + Scenario: 0043-MKTL-013 Ensure spot markets get cancelled if they fail to leave opening auction # setup accounts Given the parties deposit on asset's general account the following amount: | party | asset | amount | From 3251828acd44adbb42ef06682f94a282484f2311 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Mon, 29 Apr 2024 16:41:10 +0100 Subject: [PATCH 2/3] feat: add lp general account check after market cancellation --- .../features/auctions/opening-auction-expiry.feature | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/integration/features/auctions/opening-auction-expiry.feature b/core/integration/features/auctions/opening-auction-expiry.feature index 14efdbc5dd..5b0468e463 100644 --- a/core/integration/features/auctions/opening-auction-expiry.feature +++ b/core/integration/features/auctions/opening-auction-expiry.feature @@ -31,6 +31,10 @@ Feature: Set up a market, create indiciative price different to actual opening a # Start market with some dead time And the network moves ahead "5" blocks + Then the parties submit the following liquidity provision: + | id | party | market id | commitment amount | fee | lp type | + | party1 | party1 | ETH/DEC19 | 30000 | 0.1 | submission | + Then the market data for the market "ETH/DEC19" should be: | trading mode | | TRADING_MODE_OPENING_AUCTION | @@ -54,3 +58,5 @@ Feature: Set up a market, create indiciative price different to actual opening a # Now the market should be cancelled Then the last market state should be "STATE_CANCELLED" for the market "ETH/DEC19" + + Then "party1" should have general account balance of "18" for asset "BTC" From 28e8c2edd13b472a3a77935aa0b8b5d9aefa5933 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Mon, 29 Apr 2024 19:32:31 +0100 Subject: [PATCH 3/3] feat: add checking for releasing asset after market cancellation --- .../auctions/opening-auction-expiry.feature | 15 ++++++- .../spots/opening-auction-expires.feature | 39 ++++++++++++++----- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/core/integration/features/auctions/opening-auction-expiry.feature b/core/integration/features/auctions/opening-auction-expiry.feature index 5b0468e463..59c4f134cd 100644 --- a/core/integration/features/auctions/opening-auction-expiry.feature +++ b/core/integration/features/auctions/opening-auction-expiry.feature @@ -58,5 +58,16 @@ Feature: Set up a market, create indiciative price different to actual opening a # Now the market should be cancelled Then the last market state should be "STATE_CANCELLED" for the market "ETH/DEC19" - - Then "party1" should have general account balance of "18" for asset "BTC" + + #orders are cancelled + And the orders should have the following status: + | party | reference | status | + | party5 | t5-s-1 | STATUS_CANCELLED | + | party6 | t6-b-1 | STATUS_CANCELLED | + + #asset is released for party with orders and LP commitment + Then "party1" should have general account balance of "100000000" for asset "BTC" + Then "party5" should have general account balance of "100000000" for asset "BTC" + Then "party6" should have general account balance of "100000000" for asset "BTC" + + diff --git a/core/integration/features/spots/opening-auction-expires.feature b/core/integration/features/spots/opening-auction-expires.feature index 970581e8c8..40cebb200f 100644 --- a/core/integration/features/spots/opening-auction-expires.feature +++ b/core/integration/features/spots/opening-auction-expires.feature @@ -21,23 +21,44 @@ Feature: Set up a spot market, with an opening auction, then uncross the book. M Scenario: 0043-MKTL-013 Ensure spot markets get cancelled if they fail to leave opening auction # setup accounts Given the parties deposit on asset's general account the following amount: - | party | asset | amount | - | party1 | ETH | 1000000000 | - | party2 | ETH | 1000000000 | - | party2 | BTC | 5 | + | party | asset | amount | + | party1 | ETH | 100000 | + | party2 | ETH | 100000 | + | party3 | ETH | 100000 | + | party2 | BTC | 5 | + Then the parties submit the following liquidity provision: + | id | party | market id | commitment amount | fee | lp type | + | lp1 | party3 | BTC/ETH | 3000 | 0.1 | submission | # place orders and generate trades When the parties place the following orders: - | party | market id | side | volume | price | resulting trades | type | tif | reference | - | party2 | BTC/ETH | buy | 1 | 950000 | 0 | TYPE_LIMIT | TIF_GTC | t2-b-1 | - | party1 | BTC/ETH | buy | 1 | 1000000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | + | party | market id | side | volume | price | resulting trades | type | tif | reference | + | party2 | BTC/ETH | buy | 1 | 95 | 0 | TYPE_LIMIT | TIF_GTC | t2-b-1 | + | party1 | BTC/ETH | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | + | party3 | BTC/ETH | buy | 1 | 110 | 0 | TYPE_LIMIT | TIF_GFA | t3-b-1 | - Then "party1" should have holding account balance of "1000000" for asset "ETH" + Then "party1" should have holding account balance of "100" for asset "ETH" When the network moves ahead "1" blocks Then the market data for the market "BTC/ETH" should be: | trading mode | | TRADING_MODE_OPENING_AUCTION | - When the network moves ahead "11" blocks + When the network moves ahead "9" blocks + Then the last market state should be "STATE_PENDING" for the market "BTC/ETH" + + When the network moves ahead "1" blocks Then the last market state should be "STATE_CANCELLED" for the market "BTC/ETH" + + #orders are cancelled + And the orders should have the following status: + | party | reference | status | + | party2 | t2-b-1 | STATUS_CANCELLED | + | party1 | t1-b-1 | STATUS_CANCELLED | + | party3 | t3-b-1 | STATUS_CANCELLED | + + #asset is released for party with orders and LP commitment + Then "party1" should have general account balance of "100000" for asset "ETH" + Then "party2" should have general account balance of "100000" for asset "ETH" + Then "party3" should have general account balance of "100000" for asset "ETH" +