💰
Sudo Gitbook
  • 👋Welcome to Sudo
  • Overview
    • 💡What is Sudo
    • ✨Sudo Features
  • Trade on Sudo
    • 💎Start trading
      • Supported Assets
      • Fees
      • Market Hours
    • 📚Educational Resources
      • What Are Perpetual Futures?
      • Using Leverage Wisely
      • Risk Management Fundamentals
      • What is Sharpe Ratio
      • Real Trading Scenarios
      • Avoiding Rookie Mistakes
  • Liquidity Providers
    • 💰How to provide liquidity
    • 🛰️SLP
    • 🏦SLP Staking
  • S Rewards
    • S Card
      • Getting S Card
      • S Points
      • Using Your S Card
  • Sudo API
    • Sudo API Reference
      • Trader Data
      • Market Info
  • Sudo SDK
    • Introduction to Sudo SDK
    • Core Concepts
    • Installation and Setup
    • Quick Start
    • 📚v0.0.6
      • API Reference
        • SudoAPI
          • Open Position
          • Decrease Position
          • Pledge In Position
          • Redeem From Position
          • Cancel Order
          • getPositionCapInfoList
          • getPositionInfoList
          • getPositionConfig
        • OracleAPI
          • subOraclePrices
      • Changelog
    • Best Practices
    • Troubleshooting
  • Feature Details
    • Algorithm Balanced Funding Rate (ABFR)
    • Risk control
    • FAQ
    • Roadmap
    • On-chain program
Powered by GitBook
On this page
  1. Sudo SDK
  2. v0.0.6
  3. API Reference
  4. SudoAPI

getPositionInfoList

The getPositionInfoList function retrieves detailed information about positions based on a list of position cap information.

Function Signature

getPositionInfoList(
  positionCapInfoList: IPositionCapInfo[],
  owner: string
): Promise<IPositionInfo[]>

Parameters

  • positionCapInfoList: An array of IPositionCapInfo objects, typically obtained from getPositionCapInfoList.

  • owner: A string representing the owner's address.

Return Value

Returns a Promise that resolves to an array of IPositionInfo objects. Each IPositionInfo object contains detailed information about a position, including:

interface IPositionInfo {
  id: string;
  long: boolean;
  owner: string;
  version: number;
  collateralToken: string;
  indexToken: string;
  collateralAmount: number;
  positionAmount: number;
  reservedAmount: number;
  positionSize: number;
  lastFundingRate: number;
  lastReservingRate: number;
  reservingFeeAmount: number;
  fundingFeeValue: number;
  closed: boolean;
  openTimestamp: number;
  protocol?: string;
}

Description

This function takes a list of position cap information and fetches detailed data for each position. It calculates additional information such as reserving fee amount and funding fee value for open positions.

Usage Example

const owner = "0x1234..."; // Replace with actual owner address
const sudoAPI = new SudoAPI(provider);

try {
  const positionCaps = await sudoAPI.getPositionCapInfoList(owner);
  const positionInfoList = await sudoAPI.getPositionInfoList(positionCaps, owner);
  console.log("Position Info List:", positionInfoList);
} catch (error) {
  console.error("Error fetching position information:", error);
}

Notes

  • The function sorts the returned positions by openTimestamp in ascending order.

  • For open positions, the function calculates reservingFeeAmount and fundingFeeValue using separate API calls.

  • If there's an error calculating reservingFeeAmount or fundingFeeValue, these values are set to 0 and the error is logged.

PreviousgetPositionCapInfoListNextgetPositionConfig

Last updated 9 months ago

📚