For the complete documentation index, see llms.txt. This page is also available as Markdown.

Decrease Position

The decreasePosition function allows users to reduce the size of an existing position.

Function Signature

decreasePosition(
  pcpId: string,
  collateralToken: string,
  indexToken: string,
  amount: bigint,
  long: boolean,
  indexPrice: number,
  collateralPrice: number,
  isTriggerOrder?: boolean,
  isTakeProfitOrder?: boolean,
  isIocOrder?: boolean,
  pricesSlippage?: number,
  collateralSlippage?: number,
  relayerFee?: bigint
): Promise<TransactionBlock>

Parameters

  • pcpId: The ID of the position to decrease

  • collateralToken: The token used as collateral (e.g., "USDC")

  • indexToken: The token used as the market index (e.g., "BTC")

  • amount: The amount to decrease the position by

  • long: Boolean indicating if this is a long (true) or short (false) position

  • indexPrice: The current price of the index token

  • collateralPrice: The current price of the collateral token

  • isTriggerOrder: Boolean indicating if this is a trigger order (default: false)

  • isTakeProfitOrder: Boolean indicating if this is a take profit order (default: true)

  • isIocOrder: Boolean indicating if this is an IOC (Immediate-or-Cancel) order (default: false)

  • pricesSlippage: Maximum allowed slippage for prices (default: 0.003 or 0.3%)

  • collateralSlippage: Maximum allowed slippage for collateral (default: 0.5 or 50%)

  • relayerFee: Fee paid to the relayer (default: 1)

Return Value

Returns a Promise that resolves to a TransactionBlock object.

Usage Example

Last updated