LogoLogo
  • Overview
    • Introduction
    • Table of Contents
  • Token Information
    • Symmio Foundation
  • Protocol Architecture
    • Protocol Introduction
    • Technical Documentation
      • Building an Application with SYMM
        • Introduction and Diamond Explainer
        • Querying Info from the SYMM Diamond
        • MultiAccount
        • Creating an Account and Depositing Funds
        • Sending a Quote
        • Closing a Quote
        • Instant Trading
          • Instant Login (EOA)
          • Instant Login (Account Abstraction)
          • Sending a Quote (Instant Open)
          • Sending a Quote (Instant Close)
        • Frequently Used Queries
      • Solver Docs
        • Solver Docs (github)
        • Solver Implementation Guide (High Level Overview)
        • Building a Solver on SYMMIO
          • 1. Intent Creation
          • 2. Seeing the Intent
          • 3. Hedging Off-Chain
          • 4. Opening/Closing a Position On-Chain
          • Creating the APIs
            • GET Contract Symbols
            • GET Open Interest
            • GET Notional Cap
            • GET Price Range
            • GET Error Codes
            • GET Get Locked Params
            • GET Get Funding Info
            • POST Position State
          • Solver Flow Summary Example
          • Recommended Architecture for Solvers
          • Glossary
        • Conditional Orders Handler
        • Rasa Solver TP/SL Implementation
        • Instant Trading
          • Instant Trading (Solvers)
          • Rasa Instant Trading Implementation
          • Instant Trading Condition Checks
        • Fetching Gas Prices Script
        • How to Add a Market as a Solver
        • Verifying Account Abstracted Instant Actions (ERC-4337)
      • Frontend Docs
        • Setting up a Frontend with SYMMIO
        • Frontend SDK Setup Guide
        • MultiAccount Deployment Guide
        • Instant Trading (Frontends)
          • Account Abstracted Instant Actions (Frontends)
        • Implement a Trading Bot on Symmio (OLD)
          • Setup
          • Creating a Sub-Account
          • Minting Collateral Tokens (Optional)
          • Depositing and Allocating Tokens
          • Obtaining Muon Signatures
          • Sending a Quote
          • Monitoring Price for Execution
      • Contract Docs
        • SYMMIO CORE v0.82
        • Contracts Documentation 0.8.2
          • Main Flow
          • The SYMM Diamond
          • Facets
            • Account Facet
            • Control Facet
            • Funding Rate Facet
            • PartyA Facet
            • PartyB Facet
            • Liquidation Facet
            • View Facet
          • MultiAccount
            • PartyA
            • PartyB
          • SYMM App (Muon)
            • LibMuon
            • MuonStorage
        • Contracts Documentation 0.8.3
          • Facets
            • Control Facet
            • Account Facet
            • PartyA Facet
            • PartyB Facet
            • View Facet
            • Bridge Facet
            • Liquidation Facet (Implementation)
          • Modified Events
          • New Events
          • MuonStorage
        • Contracts Documentation 0.8.4
          • Main Flow (0.8.4)
          • The SYMM Diamond (0.8.4)
          • Facets
            • Account Facet (0.8.4)
            • Bridge Facet (0.8.4)
            • Control Facet (0.8.4)
            • Force Actions Facet (0.8.4)
            • Funding Rate Facet (0.8.4)
            • Liquidations Facet (0.8.4)
            • PartyA Facet (0.8.4)
            • PartyB Group Actions Facet (0.8.4)
            • PartyB Quote Actions Facet (0.8.4)
            • PartyB Position Actions Facet (0.8.4)
            • Settlement Facet (0.8.4)
            • View Facet (0.8.4)
          • MultiAccount (0.8.4)
            • SymmioPartyA
            • SymmioPartyB
          • SYMM App (Muon)
            • LibMuon (0.8.4)
            • MuonStorage (0.8.4)
      • Contract Addresses / Solver Endpoints
        • Mantle
        • Mode
        • IOTA
        • Base
        • BSC
        • Arbitrum
        • Polygon
        • Berachain
        • Solver Endpoints and Addresses
          • Perps Hub
          • Rasa Capital
          • Rasa Capital (Zero Spread)
          • Zenith
      • How to Query our Contracts
      • Muon API Queries
      • Solver Error Codes
      • Interacting with SYMMIO Contracts
    • Protocol higher level architecture
      • 12-Hour Fraud Proof Window
      • PartyB
      • Solver Settings
      • Max Leverage
      • Maintenance Margin (CVA) Calculations
    • Symmio Whitepaper
  • Building on Symmio
    • Builders introduction
    • Solving for Symmio
      • Solver documentation
      • Solver - Example Flow
    • Trading Fees
      • Perps - Settlement Costs
      • Pair Trading - Settlement costs
    • Exchanges (Frontends)
      • Frontend Introduction
      • SDK - SYMM client
      • Trade on Symmio
  • Legal & Brand & Security
    • Security (Audits / Bugbounty)
      • Bug bounty / Coverage
        • How to contact ?
      • Audits
        • SYMM - V0.8 - 0.81
          • Sherlock Audit - Jun 15, 2023
          • Smart State - Jul 2, 2023
        • SYMM - 0.82
          • Sherlock Audit -Aug 30, 2023
        • SYMM - 0.83
          • Sherlock Audit - Jun 17, 2024
        • SYMM - 0.84
          • Sherlock Audit - Oct 3, 2024
        • Vaults
          • Sherlock Audit - Jan 2, 2024
    • Terms of Service & Licensing
      • TRADEMARK & COPYRIGHT NOTICE
      • CONTACT US
      • TERMS OF SERVICE
      • FRONTEND LICENSE
        • Frontend Modifications
        • Frontend Use Grants
      • CONTRACT LICENSE
        • Contract Use Grants
        • Contract Modifications
    • Brand - Assets Logos
Powered by GitBook
LogoLogo

All rights to the people (c) 2023 Symmetry Labs A.G.

On this page
  • forceCancelQuote()
  • forceCancelCloseRequest()
  • forceClosePosition()
  • settleAndForceClosePosition()
  1. Protocol Architecture
  2. Technical Documentation
  3. Contract Docs
  4. Contracts Documentation 0.8.4
  5. Facets

Force Actions Facet (0.8.4)

The Force Actions Facet enables users to take action in situations where counterparties are unresponsive or when market conditions require intervention. It includes methods for:

  • Forcing the cancellation of quotes or close requests.

  • Forcing the closure of positions.

  • Settling UPnLs for the hedger and then forcing the closure of a position.

These functions help protect the system from prolonged exposure to risk and ensure that positions can be closed even when normal procedures fail.


forceCancelQuote()

Forces the cancellation of a quote when Party B is unresponsive. This function requires that the quote is in a CANCEL_PENDING state and that the force-cancellation cooldown has elapsed. It then updates the quote’s status to CANCELED and returns any locked fees to Party A.

Function Signature:

function forceCancelQuote(uint256 quoteId) external notLiquidated(quoteId) whenNotPartyAActionsPaused;

Parameters:

  • quoteId: The unique identifier of the quote to be canceled.

Example Usage:

// Force cancel a quote with ID 42
diamond.forceCancelQuote(42);

Events Emitted:

  • ForceCancelQuote(uint256 quoteId, QuoteStatus quoteStatus)


forceCancelCloseRequest()

Force-cancels a pending close request when Party B fails to respond within the designated cooldown period. This function updates the quote status back to OPENED (thus canceling the close request) and resets associated close parameters.

Function Signature:

function forceCancelCloseRequest(uint256 quoteId) external notLiquidated(quoteId) whenNotPartyAActionsPaused;

Parameters:

  • quoteId: The unique identifier of the quote for which the close request is to be canceled.

Example Usage:

// Force cancel the close request for quote ID 42
diamond.forceCancelCloseRequest(42);

Events Emitted:

  • ForceCancelCloseRequest(uint256 quoteId, QuoteStatus quoteStatus, uint256 closeId)

  • (For backward compatibility, an additional event is emitted without the closeId.)


forceClosePosition()

Force‑closes an open position when market conditions satisfy the force‑close criteria and Party B is either unresponsive or fails to maintain sufficient allocated balance. This function ensures that the quote is in a CLOSE_PENDING state and that all force‑close conditions are met. The conditions include:

  • Cooldown Periods:

    • The startTime specified in the HighLowPriceSig must be at least quote.statusModifyTimestamp + forceCloseFirstCooldown, ensuring that the hedger had enough time to consider the close request.

    • The endTime must be less than or equal to both quote.deadline and block.timestamp - forceCloseSecondCooldown, ensuring that the hedger had sufficient time to fill the close.

  • Timeframe Requirement: If the force‑close results in using the average price (to protect against extreme market moves), the timeframe (endTime - startTime) must exceed forceCloseMinSigPeriod.

  • Price Verification Based on Position Type:

    • For LONG positions: The function checks whether the highest price in the specified timeframe meets or exceeds the requested close price plus a gap ratio (a percentage buffer that accounts for market fluctuations).

      • If true, the close price is set to the requested close price plus a penalty ratio.

      • The final close price is then the higher value between this computed price and the average price over the timeframe.

    • For SHORT positions: The function verifies that the lowest price is less than or equal to the requested close price minus the gap ratio.

      • If true, the close price is computed as the requested close price minus the penalty ratio.

      • The final close price is the lower value between this computed price and the average price.

  • Signature Verification: The function uses the new HighLowPriceSig structure to verify that the market data (high, low, average, and current prices) is authentic and within the acceptable timeframe. This signature is obtained via the priceRange method on Muon.

After all validations pass, the function updates nonce counters for both Party A and Party B, and then calls an internal helper to close the quote. If conditions fail (for example, if the market does not meet the necessary thresholds), Party B may instead be liquidated.


Function Signature:

function forceClosePosition(uint256 quoteId, HighLowPriceSig memory sig)
    external
    notLiquidated(quoteId)
    whenNotPartyAActionsPaused;

Parameters:

  • quoteId: The unique identifier of the quote associated with the position.

  • HighLowPriceSig:

struct HighLowPriceSig {
	bytes reqId;
	uint256 timestamp;
	uint256 symbolId;
	uint256 highest;
	uint256 lowest;
	uint256 averagePrice;
	uint256 startTime;
	uint256 endTime;
	int256 upnlPartyB;
	int256 upnlPartyA;
	uint256 currentPrice;
	bytes gatewaySignature;
	SchnorrSign sigs;
}

Events Emitted:

LiquidatePartyB: If the validations determine that Party B is insolvent (e.g., if closing the position would leave Party B with insufficient funds), an event is emitted to indicate liquidation:

event LiquidatePartyB(address initiator, address partyB, address partyA, uint256 partyBAllocatedBalance, int256 upnlPartyB);

ForceClosePosition: If the force‑close operation completes successfully, the following event is emitted:

event ForceClosePosition(
    uint256 quoteId,
    address partyA,
    address partyB,
    uint256 filledAmount,
    uint256 closedPrice,
    QuoteStatus quoteStatus,
    uint256 closeId
);

(A backward compatibility event without closeId is also emitted.)


settleAndForceClosePosition()

This method extends the force close mechanism to handle cases where the hedger (Party B) lacks sufficient allocated balance to close the position. In such scenarios, the function first settles the UPnL (unrealized profit and loss) for Party B, thereby adjusting the balances, and then force-closes the position.

Function Signature:

function settleAndForceClosePosition(
    uint256 quoteId,
    HighLowPriceSig memory highLowPriceSig,
    SettlementSig memory settleSig,
    uint256[] memory updatedPrices
) external notLiquidated(quoteId) whenNotPartyAActionsPaused;

Parameters:

  • quoteId: The unique identifier of the quote corresponding to the position.

  • highLowPriceSig: A HighLowPriceSig structure containing market price data (including high, low, average, and current prices) and the associated timing information.

struct HighLowPriceSig {
	bytes reqId;
	uint256 timestamp;
	uint256 symbolId;
	uint256 highest;
	uint256 lowest;
	uint256 averagePrice;
	uint256 startTime;
	uint256 endTime;
	int256 upnlPartyB;
	int256 upnlPartyA;
	uint256 currentPrice;
	bytes gatewaySignature;
	SchnorrSign sigs;
}
  • settleSig: A SettlementSig structure that includes data required for settling UPnLs (such as settlement values, quotes settlements data, etc.).

struct SettlementSig {
	bytes reqId;
	uint256 timestamp;
	QuoteSettlementData[] quotesSettlementsData;
	int256[] upnlPartyBs;
	int256 upnlPartyA;
	bytes gatewaySignature;
	SchnorrSign sigs;
}
  • updatedPrices: An array of updated prices to be applied as the new opened prices for the specified quotes during settlement.

Example Usage:

// Settle and force close a position with updated price data
HighLowPriceSig memory highLowSig = /* obtain high/low signature data */;
SettlementSig memory settleSig = /* obtain settlement data */;
uint256[] memory newPrices = new uint256[](1);
newPrices[0] = updatedPrice;
diamond.settleAndForceClosePosition(42, highLowSig, settleSig, newPrices);

Events Emitted:

  • If Party B is liquidated during the process, the event: LiquidatePartyB(address initiator, address partyB, address partyA, uint256 partyBAllocatedBalance, int256 upnlPartyB) is emitted.

  • Otherwise, two key events are emitted:

    • SettleUpnl(...): Emitted with details of the settlement, including the settlement data, updated prices, and new allocated balances.

    • ForceClosePosition(...): Emitted to indicate the successful force closure of the position (with both the current and a backward compatibility version).

PreviousControl Facet (0.8.4)NextFunding Rate Facet (0.8.4)

Last updated 4 months ago