Explanation: Added emission of BalanceChangePartyA in all places where the allocated balance of the user changes. Also, platform fees are now paid to fee collectors of each affiliate separately.
functionemergencyClosePosition(uint256 quoteId,PairUpnlAndPriceSigmemory upnlSig) internal { AccountStorage.Layout storage accountLayout = AccountStorage.layout(); Quote storage quote = QuoteStorage.layout().quotes[quoteId]; Symbol memory symbol = SymbolStorage.layout().symbols[quote.symbolId];require( GlobalAppStorage.layout().emergencyMode || GlobalAppStorage.layout().partyBEmergencyStatus[quote.partyB] ||!symbol.isValid,"PartyBFacet: Operation not allowed. Either emergency mode must be active, party B must be in emergency status, or the symbol must be delisted" );require(quote.quoteStatus == QuoteStatus.OPENED || quote.quoteStatus == QuoteStatus.CLOSE_PENDING,"PartyBFacet: Invalid state"); LibMuon.verifyPairUpnlAndPrice(upnlSig, quote.partyB, quote.partyA, quote.symbolId);uint256 filledAmount = LibQuote.quoteOpenAmount(quote); quote.quantityToClose = filledAmount; quote.requestedClosePrice = upnlSig.price; LibSolvency.isSolventAfterClosePosition(quoteId, filledAmount, upnlSig.price, upnlSig); accountLayout.partyBNonces[quote.partyB][quote.partyA] +=1; accountLayout.partyANonces[quote.partyA] +=1; LibQuote.closeQuote(quote, filledAmount, upnlSig.price);}
Explanation: From time to time, Binance delists some of its pairs. In the current version, we had to put partyBs in emergency mode to let them close their positions without user requests. In the next version, if a symbol becomes invalid, partyB can emergency close all its positions.