getPositionConfig

Retrieves and parses the position configuration for a given index token and position type (long or short).

Function Signature

getPositionConfig(
  indexToken: string
  long: boolean
): Promise<IPositionConfig>

Parameters

  • indexToken (string): The token for which to retrieve the position configuration.

  • long (boolean): Indicates whether to retrieve the configuration for a long (true) or short (false) position.

Return Value

Returns a Promise that resolves to an IPositionConfig object. The object contains parsed position configuration, including:

interface IPositionConfig {
    decreaseFeeBps: number;
    liquidationBonus: number;
    liquidationThreshold: number;
    maxLeverage: number;
    minHoldingDuration: number;
    openFeeBps: number;
    maxReservedMultiplier: number;
    minCollateralValue: number;
}

Description

This method fetches the position configuration data from the blockchain for a specified index token and position type. It performs the following steps:

Usage Example

const sudoAPI = new SudoAPI(provider);

try {
  const positionConfig = await sudoAPI.getPositionConfig('BTC', true);
  console.log("Fetched position config:", positionConfig);
} catch (error) {
  console.error("Error fetching position config:", error);
}

Last updated