LogoLogo
Nekodex AppDiscord
Nekodex (Playground)
Nekodex (Playground)
  • Nekodex $(=ↀωↀ=)
    • Terms of Service
  • Introducing Perp v3
  • All About Perp
    • Project overview
      • Product info
      • About us
      • Governance
    • Roadmap
    • Official links
    • FAQs
    • PERP Token
    • Contact us
    • More
      • Security & Audits
      • Partnerships
      • Careers
      • Marketing
      • Legacy Docs
  • Docs for Users
    • Earn yield
    • Trade perpetual futures
      • Fees & system limits
      • Perp Smart Account
      • Perp contract specs
    • Provide liquidity (LP)
    • How Perp v3 works
      • Pyth Oracles
    • Security
  • Docs for Devs
    • Technical Overview
    • Contracts
      • Address Manager
      • Borrowing Fee
      • Circuit Breaker
      • ⭐Clearinghouse
      • Config
      • Funding Fee
      • ⭐Maker
        • Oracle Maker
        • Spot Hedge Maker
      • Maker Reporter
      • ⭐Order Gateway
      • Quoter
      • ⭐Vault
    • Dev FAQ
    • API
      • Subgraph
    • Error codes
Powered by GitBook
On this page
  • openPosition
  • closePosition
  • liquidate
  • setAuthorization
  • isLiquidatable

Was this helpful?

  1. Docs for Devs
  2. Contracts

Clearinghouse

PreviousCircuit BreakerNextConfig

Last updated 1 year ago

Was this helpful?

All basic exchange functions are kept in the clearinghouse contract. This includes open and close position, and liquidation functions.

Find parameters like marketID in

openPosition

Open a position or update the size of an existing position (you can only have one position in a given asset).

Parameters

struct OpenPositionParams {
        uint256 ;
        address maker; // Maker type, e.g. spotHedgeMaker
        bool isBaseToQuote;
        bool isExactInput;
        uint256 amount;
        uint256 oppositeAmountBound; // Control slippage
        uint256 deadline; // Timestamp
        bytes makerData; // @param makerData Encoded calls are custom data defined by maker
    }

Returns

returns (int256 base, int256 quote);

closePosition

Close a position. Note you can also close using openPosition and opening an equal size position of the opposite direction (e.g. long closes short).

Parameters

struct ClosePositionParams {
        uint256 marketId;
        address maker;
        uint256 oppositeAmountBound;
        uint256 deadline;
        bytes makerData;
    }

Returns

returns (int256 base, int256 quote);

liquidate

Liquidate a position. Contract will test the position for eligibility before liquidation.

Parameters

struct LiquidatePositionParams {
        uint256 marketId;
        address liquidator;
        address trader;
        uint256 positionSize;
    }

Returns

returns (int256 liquidatedAccountBaseDelta, int256 liquidatedAccountQuoteDelta)

Event

event Liquidated(
        uint256 indexed marketId,
        address indexed liquidator,
        address indexed trader,
        int256 positionSizeDelta,
        int256 positionNotionalDelta,
        uint256 price,
        uint256 penalty,
        uint256 liquidationFeeToLiquidator,
        uint256 liquidationFeeToProtocol
    )

setAuthorization

Delegate open and close permissions; delegation is currently limited to order gateway contracts only.

isLiquidatable

Parameters

struct isLiquidatableParams {
        uint256 marketId;
        address trader;
        uint256 price;
    }

Returns

bool
⭐
Metadata