Closed Sohill-Patel closed 1 year ago
Does the party have sufficient balance to cover the margin required for their LP orders? This could be one of the cases where we check for provided liquidity, uncross the book, then deploy the LP orders, and only then know/determine that the LP has insufficient balance.
@EVODelavega thats exactly whats going on at that time! Everything from General account is transferred to margin then from bond to margin. This is ST issue
{
"id": "2790-184",
"block": "ACDB030EBA09323AEEC0CADC5E246626574C237BC07418E66F26C4267A51529C",
"type": "BUS_EVENT_TYPE_LEDGER_MOVEMENTS",
"ledgerMovements": {
"ledgerMovements": [
{
"entries": [
{
"fromAccount": {
"assetId": "c5ac040edb250b1a3c5ee536c26c87177303c30d767bacf1f103f0a31ed485c2",
"type": "ACCOUNT_TYPE_GENERAL",
"owner": "02232b62c41d3f82432eb780bb72d0c0282492dbe1ce040bdd7e50f38ecbb24f"
},
"toAccount": {
"assetId": "c5ac040edb250b1a3c5ee536c26c87177303c30d767bacf1f103f0a31ed485c2",
"type": "ACCOUNT_TYPE_MARGIN",
"owner": "02232b62c41d3f82432eb780bb72d0c0282492dbe1ce040bdd7e50f38ecbb24f",
"marketId": "3560c44505f58f5ab0cdf8159bf7c1428fa251c85609825b0af03e1756db2f45"
},
"amount": "5550067936690876510828000",
"type": "TRANSFER_TYPE_MARGIN_LOW",
"timestamp": "1692840492875692564",
"fromAccountBalance": "0",
"toAccountBalance": "5574729628651904617648000"
},
{
"fromAccount": {
"assetId": "c5ac040edb250b1a3c5ee536c26c87177303c30d767bacf1f103f0a31ed485c2",
"type": "ACCOUNT_TYPE_BOND",
"owner": "02232b62c41d3f82432eb780bb72d0c0282492dbe1ce040bdd7e50f38ecbb24f",
"marketId": "3560c44505f58f5ab0cdf8159bf7c1428fa251c85609825b0af03e1756db2f45"
},
"toAccount": {
"assetId": "c5ac040edb250b1a3c5ee536c26c87177303c30d767bacf1f103f0a31ed485c2",
"type": "ACCOUNT_TYPE_MARGIN",
"owner": "02232b62c41d3f82432eb780bb72d0c0282492dbe1ce040bdd7e50f38ecbb24f",
"marketId": "3560c44505f58f5ab0cdf8159bf7c1428fa251c85609825b0af03e1756db2f45"
},
"amount": "390500000000000000000000",
"type": "TRANSFER_TYPE_MARGIN_LOW",
"timestamp": "1692840492875692564",
"fromAccountBalance": "0",
"toAccountBalance": "5965229628651904617648000"
}
],
"balances": [
{
"account": {
"assetId": "c5ac040edb250b1a3c5ee536c26c87177303c30d767bacf1f103f0a31ed485c2",
"type": "ACCOUNT_TYPE_MARGIN",
"owner": "02232b62c41d3f82432eb780bb72d0c0282492dbe1ce040bdd7e50f38ecbb24f",
"marketId": "3560c44505f58f5ab0cdf8159bf7c1428fa251c85609825b0af03e1756db2f45"
},
"balance": "5940567936690876510828000"
}
]
},
Problem encountered
When a market moves from opening auction > continuous trading, lp commitment was cancelled by vega (the cancellation was not requested by ST)
Observed behaviour
md events show the market in opening auction with
supplied stake = 390500000000000000000000
{"id":"2789-57","block":"4EDC58706C5E6BA5BC7AA87122B514F0EBF28D48E2897B482AC064192677C177","type":"BUS_EVENT_TYPE_MARKET_DATA","marketData":{"markPrice":"0","bestBidPrice":"100100000","bestBidVolume":"500000","bestOfferPrice":"95100000","bestOfferVolume":"500000","bestStaticBidPrice":"100100000","bestStaticBidVolume":"500000","bestStaticOfferPrice":"95100000","bestStaticOfferVolume":"500000","midPrice":"97600000","staticMidPrice":"97600000","market":"3560c44505f58f5ab0cdf8159bf7c1428fa251c85609825b0af03e1756db2f45","timestamp":"1692840492472578623","auctionEnd":"1692840482000000000","auctionStart":"1692840481000000000","indicativePrice":"97600000","indicativeVolume":"500000","marketTradingMode":"TRADING_MODE_OPENING_AUCTION","trigger":"AUCTION_TRIGGER_OPENING","targetStake":"1349076000000000000000","suppliedStake":"390500000000000000000000","marketValueProxy":"0","liquidityProviderFeeShare":[{"party":"02232b62c41d3f82432eb780bb72d0c0282492dbe1ce040bdd7e50f38ecbb24f","equityLikeShare":"1","averageEntryValuation":"390500000000000000000000","averageScore":"1","virtualStake":"390500000000000000000000.0000000000000000"}],"marketState":"STATE_PENDING","nextMarkToMarket":"-6795364578871345152","lastTradedPrice":"0","marketGrowth":"0"},"version":1,"chainId":"testnet-001","txHash":"4EDC58706C5E6BA5BC7AA87122B514F0EBF28D48E2897B482AC064192677C177"}
The next event is shows the market moves to continuous trading and now the supplied stake=0
{"id":"2790-227","block":"ACDB030EBA09323AEEC0CADC5E246626574C237BC07418E66F26C4267A51529C","type":"BUS_EVENT_TYPE_MARKET_DATA","marketData":{"markPrice":"97600000","bestBidPrice":"90000000","bestBidVolume":"500000","bestOfferPrice":"120000000","bestOfferVolume":"500000","bestStaticBidPrice":"90000000","bestStaticBidVolume":"500000","bestStaticOfferPrice":"120000000","bestStaticOfferVolume":"500000","midPrice":"105000000","staticMidPrice":"105000000","market":"3560c44505f58f5ab0cdf8159bf7c1428fa251c85609825b0af03e1756db2f45","timestamp":"1692840492875692564","openInterest":"500000","indicativePrice":"0","marketTradingMode":"TRADING_MODE_CONTINUOUS","targetStake":"1349076000000000000000","suppliedStake":"0","marketValueProxy":"0","marketState":"STATE_ACTIVE","nextMarkToMarket":"1692840492875692564","lastTradedPrice":"97600000","marketGrowth":"0"},"version":1,"chainId":"testnet-001","txHash":"ACDB030EBA09323AEEC0CADC5E246626574C237BC07418E66F26C4267A51529C"}
and this is because in the same block lp commitment got cancelled. The
"updatedAt":"1692840492875692564"=01:28:12.875
and looking in the ST logs at that time test was submitting normal orders to move market to continuous trading. There was no lp cancellation requests around that time{"id":"2790-195","block":"ACDB030EBA09323AEEC0CADC5E246626574C237BC07418E66F26C4267A51529C","type":"BUS_EVENT_TYPE_LIQUIDITY_PROVISION","liquidityProvision":{"id":"ef7abd4c5d006346588d48157fda869b6d9343d3a9e4773e6ead04f396c7c03e","partyId":"02232b62c41d3f82432eb780bb72d0c0282492dbe1ce040bdd7e50f38ecbb24f","createdAt":"1692840484947254816","updatedAt":"1692840492875692564","marketId":"3560c44505f58f5ab0cdf8159bf7c1428fa251c85609825b0af03e1756db2f45","commitmentAmount":"390500000000000000000000","fee":"0.3","version":"1","status":"STATUS_CANCELLED","reference":"EFC50251F5CD4A3"},"version":1,"chainId":"testnet-001","txHash":"ACDB030EBA09323AEEC0CADC5E246626574C237BC07418E66F26C4267A51529C"}
Expected behaviour
LP provision should not be cancelled when market moves from opening auction > continuous trading
Steps to reproduce
Software version
dev branch
Failing test
test_settlement_trigger_priority
Jenkins run
https://jenkins.ops.vega.xyz/job/common/job/system-tests-nightly/1056/testReport/junit/tests.cash_settled_futures/csf_test/Call_tests___full_a_f___test_settlement_trigger_priority_before_termination_/
Configuration used
No response
Relevant log output