From 0e4b4928f2760a51cddd732e6d583b3bebf61021 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Tue, 30 Apr 2024 11:23:32 +0100 Subject: [PATCH] feat: add checking on asset releasing --- .../auctions/opening-auction-expiry.feature | 44 ++++++++++++------- .../spots/opening-auction-expires.feature | 10 +++++ 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/core/integration/features/auctions/opening-auction-expiry.feature b/core/integration/features/auctions/opening-auction-expiry.feature index 59c4f134cd3..a1e194952cf 100644 --- a/core/integration/features/auctions/opening-auction-expiry.feature +++ b/core/integration/features/auctions/opening-auction-expiry.feature @@ -6,7 +6,7 @@ Feature: Set up a market, create indiciative price different to actual opening a | 0.1 | 0.1 | 2 | -3 | 0.2 | Given the markets: | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | - | ETH/DEC19 | BTC | BTC | my-simple-risk-model | default-margin-calculator | 5 | default-none | default-basic | default-eth-for-future | 0.25 | 0 | default-futures | + | ETH/DEC19 | BTC | ETH | my-simple-risk-model | default-margin-calculator | 5 | default-none | default-basic | default-eth-for-future | 0.25 | 0 | default-futures | And the following network parameters are set: | name | value | | market.auction.minimumDuration | 5 | @@ -19,15 +19,11 @@ Feature: Set up a market, create indiciative price different to actual opening a 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 | - | party1 | BTC | 100000000 | - | party2 | BTC | 100000000 | - | party3 | BTC | 100000000 | - | party4 | BTC | 100000000 | - | party5 | BTC | 100000000 | - | party6 | BTC | 100000000 | - | party7 | BTC | 100000000 | - | lpprov | BTC | 100000000 | + | party | asset | amount | + | party1 | ETH | 100000 | + | party5 | ETH | 10000 | + | party6 | ETH | 10000 | + | lpprov | ETH | 10000 | # Start market with some dead time And the network moves ahead "5" blocks @@ -41,19 +37,25 @@ Feature: Set up a market, create indiciative price different to actual opening a # Ensure an indicative price/volume of 10, although we will not uncross at this price point And the parties place the following orders: | party | market id | side | volume | price | resulting trades | type | tif | reference | - | party6 | ETH/DEC19 | buy | 1 | 10 | 0 | TYPE_LIMIT | TIF_GFA | t6-b-1 | + | party6 | ETH/DEC19 | buy | 1 | 20 | 0 | TYPE_LIMIT | TIF_GFA | t6-b-1 | When the network moves ahead "1" blocks Then the market data for the market "ETH/DEC19" should be: | trading mode | | TRADING_MODE_OPENING_AUCTION | And the parties place the following orders: | party | market id | side | volume | price | resulting trades | type | tif | reference | - | party5 | ETH/DEC19 | buy | 1 | 10 | 0 | TYPE_LIMIT | TIF_GFA | t5-s-1 | + | party5 | ETH/DEC19 | sell | 1 | 21 | 0 | TYPE_LIMIT | TIF_GFA | t5-s-1 | # place orders to set the actual price point at which we'll uncross to be 10000 When the network moves ahead "1" blocks Then the market data for the market "ETH/DEC19" should be: | trading mode | | TRADING_MODE_OPENING_AUCTION | + + Then the parties should have the following account balances: + | party | asset | market id | margin | general | bond | + | party1 | ETH | ETH/DEC19 | 0 | 70000 | 30000 | + | party5 | ETH | ETH/DEC19 | 3 | 9997 | | + | party6 | ETH | ETH/DEC19 | 2 | 9998 | | When the network moves ahead "10" blocks # Now the market should be cancelled @@ -66,8 +68,20 @@ Feature: Set up a market, create indiciative price different to actual opening a | 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" + Then "party1" should have general account balance of "100000" for asset "ETH" + Then "party5" should have general account balance of "10000" for asset "ETH" + Then "party6" should have general account balance of "10000" for asset "ETH" + + # Then debug transfers + # check transfers for asset releasing + Then the following transfers should happen: + | from | to | from account | to account | market id | amount | asset | + | party1 | party1 | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_GENERAL | ETH/DEC19 | 30000 | ETH | + + Then the parties should have the following account balances: + | party | asset | market id | margin | general | bond | + | party1 | ETH | ETH/DEC19 | 0 | 100000 | 0 | + | party5 | ETH | ETH/DEC19 | 0 | 10000 | | + | party6 | ETH | ETH/DEC19 | 0 | 10000 | | diff --git a/core/integration/features/spots/opening-auction-expires.feature b/core/integration/features/spots/opening-auction-expires.feature index 40cebb200ff..968063d3f34 100644 --- a/core/integration/features/spots/opening-auction-expires.feature +++ b/core/integration/features/spots/opening-auction-expires.feature @@ -38,6 +38,8 @@ Feature: Set up a spot market, with an opening auction, then uncross the book. M | party3 | BTC/ETH | buy | 1 | 110 | 0 | TYPE_LIMIT | TIF_GFA | t3-b-1 | Then "party1" should have holding account balance of "100" for asset "ETH" + Then "party2" should have holding account balance of "95" for asset "ETH" + Then "party3" should have holding account balance of "110" for asset "ETH" When the network moves ahead "1" blocks Then the market data for the market "BTC/ETH" should be: @@ -62,3 +64,11 @@ Feature: Set up a spot market, with an opening auction, then uncross the book. M Then "party2" should have general account balance of "100000" for asset "ETH" Then "party3" should have general account balance of "100000" for asset "ETH" + # check transfers for asset releasing + Then the following transfers should happen: + | from | to | from account | to account | market id | amount | asset | + | party3 | party3 | ACCOUNT_TYPE_HOLDING | ACCOUNT_TYPE_GENERAL | | 110 | ETH | + | party2 | party2 | ACCOUNT_TYPE_HOLDING | ACCOUNT_TYPE_GENERAL | | 95 | ETH | + | party1 | party1 | ACCOUNT_TYPE_HOLDING | ACCOUNT_TYPE_GENERAL | | 100 | ETH | + | party3 | party3 | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_GENERAL | BTC/ETH | 3000 | ETH | +