LogoLogo
  • Introduction
    • 🔴Welcome to IntentX
    • 💢The Omnichain DEX
    • ⚡User Experience Focus
    • 🌐The Meta Front-End
  • On-Chain Derivatives Overview
    • ❓What Problem Does IntentX Solve?
    • 📊Current On-Chain Derivatives Landscape
    • 💡IntentX Solution & Architecture Overview
    • ✅Comparison and Advantages of IntentX
  • IntentX Platform
    • 📈Trading on IntentX
      • 📖Trading Basics
      • 🏫Trading Tutorials
        • 🏫Web3 Wallet
        • 🏫Account Abstracted Wallet
      • 🌡️Liquidations, Margin Management (CVA), and Account Health
      • 📊Instant 1-Click Trading
      • 🛑Take Profit and Stop Loss
      • 💵Collateral & Cross-Margin Accounts
      • 💸Understanding Funding Rates
      • 💰Pricing Data and the Role of Oracles
      • ↕️Unrealized Profit and Loss (uPNL)
      • 📏Open Interest (OI) and Market Activity
      • 🔐Withdrawal Process and Security Measures
      • 📈Advanced Charts by TradingView
    • 🔢Pair List
    • 🌀IntentX Solver Network
      • 🌀Example Solver Order Flow
    • 🫂Referral Program
    • 📱Mobile and Progressive Web App
  • Trading API
    • Introduction
    • Rest API V1
    • Typescript SDK
      • Examples
        • Opening Positions
        • Closing Positions
        • Cancel Positions
        • List Subaccounts
        • List Positions
        • Private Key Authentication
        • Enable Instant Actions
  • Tokenomics
    • 🪙INTX Token and xINTX Staking
    • 🔄Trade & Earn xINTX
    • 📅Token Allocation and Release Schedule
  • Technical Docs (WIP)
    • ⚙️Infrastructure Overview
      • 🔩Technical Docs
      • 🌐Sample Solver Docs
  • Additional Information
    • ❓FAQ
    • 🌐Official Links
    • 📃Terms & Conditions
    • 🔐Security & Audits
    • 🌟Brand & Media Assets
    • 💾Contracts
Powered by GitBook
On this page
  1. Trading API
  2. Typescript SDK
  3. Examples

List Positions

import { SupportedChainId } from "@intentx/core";
import { TradingSDK } from "@intentx/trading-sdk";
import dotenv from "dotenv";

dotenv.config();

async function listPositionsExample() {
  const tradingSDK = new TradingSDK({
    apiKey: process.env.API_KEY,
    baseUrl: process.env.API_BASE_URL ?? undefined,
  });

  const positions = await tradingSDK.tradeManager.getOpenPositionsForSubaccount(
    "0x52D953159a9a636944C9d96E14CB5DF0948323E9",
    SupportedChainId.BASE
  );

  console.log(`You have ${positions.length} open positions`);

  const accountDetails =
    await tradingSDK.accountManager.getSubaccountBalanceDetails(
      "0x52D953159a9a636944C9d96E14CB5DF0948323E9",
      SupportedChainId.BASE
    );

  console.log(
    `You have ${accountDetails.availableForOrder} free balance for orders. Your upnl is $${accountDetails.upnl}`
  );
}

listPositionsExample();
PreviousList SubaccountsNextPrivate Key Authentication

Last updated 1 month ago