PartyA Facet (0.8.4)
Party A Facet (0.8.4)
The Party A Facet is the primary interface for Party A users to interact with the SYMM protocol. It enables users to send trade quotes (with optional affiliate information), cancel quotes, and request the closure or cancellation of a position. The underlying logic is implemented in the PartyAFacetImpl
library, while this contract serves as the external API and emits events to reflect state changes.
Note: This facet ensures that only eligible Party A users (i.e. not liquidated or suspended) can perform these actions. In addition, some events are emitted for backward compatibility and may be removed in future versions.
sendQuoteWithAffiliate()
Sends a new quote to the protocol with an affiliate. The Affiliate is the frontend's MultiAccount address. The quote is initially set to a pending state and includes parameters for allowed Party B addresses, symbol details, position and order types, pricing, risk parameters (such as CVA, liquidation fee, and maintenance margins), and a Muon signature for UPnL and price verification.
Frontends use sendQuoteWithAffiliate()
to facilitate trades. This is primarily to help track fees.
Function Signature:
Parameters:
partyBsWhiteList: Array of Party B addresses allowed to interact with this quote.
symbolId: Unique identifier for the trading symbol (e.g. BTCUSDT).
positionType: Position type, either LONG or SHORT.
orderType: Order type, either LIMIT or MARKET.
price: For limit orders, the desired open price; for market orders, the price threshold.
quantity: The size of the position.
cva: Credit Valuation Adjustment value.
lf: Liquidation Fee, representing the penalty that the liquidated side must pay.
partyAmm: Party A Maintenance Margin value.
partyBmm: Party B Maintenance Margin value.
maxFundingRate: The maximum funding rate allowed.
deadline: Timestamp by which Party B must act on the quote.
affiliate: Address of the affiliate associated with this quote.
upnlSig: A structure containing the Muon signature for user UPnL and symbol price verification.
Example Usage:
Events Emitted:
SendQuote(address sender, uint256 quoteId, address[] partyBsWhiteList, uint256 symbolId, PositionType positionType, OrderType orderType, uint256 price, uint256 upnlPrice, uint256 quantity, uint256 cva, uint256 lf, uint256 partyAmm, uint256 partyBmm, uint256 tradingFee, uint256 deadline)
sendQuote()
Sends a new quote to the protocol without affiliate information. This function behaves similarly to sendQuoteWithAffiliate
but sets the affiliate field to the zero address.
Function Signature:
Parameters:
The parameters are identical to sendQuoteWithAffiliate
except that the affiliate
parameter is omitted (and implicitly set to address(0)
).
Example Usage:
Events Emitted:
SendQuote(...)
(The same event is emitted as insendQuoteWithAffiliate
.)
expireQuote()
Expires one or more quotes based on their deadlines. If a quote has expired, it will be canceled or marked as closed. The function iterates over an array of quote IDs and emits corresponding events for each quote depending on its new state.
Function Signature:
Parameters:
expiredQuoteIds: An array of quote IDs that are to be expired.
Example Usage:
Events Emitted:
Depending on the resulting quote status:
ExpireQuoteClose(QuoteStatus, uint256, uint256)
for quotes that are closed.ExpireQuoteOpen(QuoteStatus, uint256)
for quotes that are opened.ExpireQuote(QuoteStatus, uint256)
for backward compatibility.
requestToCancelQuote()
Allows Party A to request the cancellation of a quote. If the quote has not been locked, it is canceled immediately; if locked, the quote’s status is set to CANCEL_PENDING
.
Function Signature:
Parameters:
quoteId: The identifier of the quote to cancel.
Example Usage:
Events Emitted:
If the quote expires:
ExpireQuoteOpen(QuoteStatus, uint256, uint256)
andExpireQuote(QuoteStatus, uint256)
If canceled or pending cancellation:
RequestToCancelQuote(address partyA, address partyB, QuoteStatus quoteStatus, uint256 quoteId)
requestToClosePosition()
Requests the closure of an open position by specifying the desired close price, the quantity to close, the order type for closure, and a deadline. The quote’s status is updated to CLOSE_PENDING
.
Function Signature:
Parameters:
quoteId: The ID of the quote associated with the position.
closePrice: The price at which Party A wishes to close the position.
quantityToClose: The quantity of the position to close.
orderType: The order type (LIMIT or MARKET) for closing.
deadline: The timestamp by which Party B must respond; otherwise, the close request may time out.
Example Usage:
Events Emitted:
RequestToClosePosition(address partyA, address partyB, uint256 quoteId, uint256 closePrice, uint256 quantityToClose, OrderType orderType, uint256 deadline, QuoteStatus quoteStatus, uint256 closeId)
A backward compatibility event (without the
closeId
) is also emitted.
requestToCancelCloseRequest()
Allows Party A to cancel a pending close request. If the close request has not been fulfilled and is within the deadline, the quote’s status is updated accordingly.
Function Signature:
Parameters:
quoteId: The ID of the quote whose close request is to be canceled.
Example Usage:
Events Emitted:
If the quote reopens due to expiry:
ExpireQuoteClose(QuoteStatus, uint256, uint256)
andExpireQuote(QuoteStatus, uint256)
Otherwise, if the cancellation is pending:
RequestToCancelCloseRequest(address partyA, address partyB, uint256 quoteId, QuoteStatus quoteStatus, uint256 closeId)
(Also a backward compatibility event without
closeId
is emitted.)
Last updated