⭐Clearinghouse
All basic exchange functions are kept in the clearinghouse contract. This includes open and close position, and liquidation functions.
openPosition
openPositionOpen 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
closePositionClose 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
liquidateLiquidate 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
setAuthorizationDelegate open and close permissions; delegation is currently limited to order gateway contracts only.
isLiquidatable
isLiquidatableParameters
struct isLiquidatableParams {
uint256 marketId;
address trader;
uint256 price;
}Returns
boolLast updated
Was this helpful?