Skip to content

Commit

Permalink
Merge pull request #11220 from vegaprotocol/0043-MKTL-012
Browse files Browse the repository at this point in the history
feat: add checking on asset releasing
  • Loading branch information
peterbarrow authored May 1, 2024
2 parents e2ac7be + 0e4b492 commit 3323afc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
44 changes: 29 additions & 15 deletions core/integration/features/auctions/opening-auction-expiry.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 | |


10 changes: 10 additions & 0 deletions core/integration/features/spots/opening-auction-expires.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 |

0 comments on commit 3323afc

Please sign in to comment.