npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ostium-ts-sdk

v0.1.0

Published

TypeScript SDK for the Ostium decentralized perpetuals trading platform on Arbitrum

Downloads

86

Readme

ostium-ts-sdk

TypeScript SDK for the Ostium decentralized perpetuals trading platform on Arbitrum.

Features

  • Trading — Open, close, and modify positions (TP/SL, collateral, leverage) with market, limit, and stop orders
  • Subgraph queries — Fetch open trades, limit orders, order history, pair details, and more
  • Live prices — Real-time bid/ask/mid prices and market status
  • Trade metrics — PnL, funding fees, rollover fees, liquidation price, and price impact calculations
  • Balances — On-chain USDC balance reads
  • Testnet faucet — Claim testnet USDC

Installation

bun add ostium-ts-sdk

Quick start

import { OstiumSDK } from "ostium-ts-sdk";

const sdk = new OstiumSDK("mainnet", process.env.PRIVATE_KEY, process.env.RPC_URL);

// List all trading pairs with live prices
const pairs = await sdk.getFormattedPairsDetails();
console.log(pairs);

// Get open trades for the connected wallet
const [trades, address] = await sdk.getOpenTrades();
console.log(`${address} has ${trades.length} open trades`);

// Open a long position: 100 USDC collateral, 10x leverage, pair 0 (e.g. BTC/USD)
const result = await sdk.ostium.performTrade({
  collateral: 100,
  leverage: 10,
  asset_type: 0,
  direction: true, // true = long, false = short
});

// Get trade metrics (PnL, fees, liquidation price)
const metrics = await sdk.getOpenTradeMetrics(0, 0);
console.log(`PnL: ${metrics.pnl_percent}%, Liq price: ${metrics.liquidation_price}`);

Configuration

| Environment variable | Description | |---|---| | PRIVATE_KEY | Wallet private key (hex, with or without 0x prefix) | | RPC_URL | Arbitrum RPC endpoint |

Both can be passed directly to the constructor or read from environment variables automatically.

// Read-only mode (no private key needed for queries)
const sdk = new OstiumSDK("mainnet", undefined, "https://arb1.arbitrum.io/rpc");

// Testnet
const testSdk = new OstiumSDK("testnet", privateKey, rpcUrl);

// Delegation mode (trade on behalf of another address)
const sdk = new OstiumSDK("mainnet", privateKey, rpcUrl, false, true);

SDK modules

Access sub-modules directly from the SDK instance:

| Module | Access | Description | |---|---|---| | Trading | sdk.ostium | Open/close trades, update TP/SL, add/remove collateral, cancel orders, USDC approval | | Subgraph | sdk.subgraph | Query pairs, open trades, limit orders, order history | | Prices | sdk.price | Live bid/ask/mid prices and market status | | Balances | sdk.balance | On-chain USDC balance reads | | Faucet | sdk.faucet | Testnet USDC faucet (testnet only, null on mainnet) |

Trade metrics

Compute a full snapshot of an open trade's current state:

const metrics = await sdk.getOpenTradeMetrics(pairId, tradeIndex);
// metrics: { pnl, pnl_percent, rollover, funding, net_pnl, net_value,
//            liquidation_price, price_impact, is_market_open, bid, mid, ask }

Funding and rollover rates

// Funding rate for a pair (default: 24h period)
const [accLong, accShort, fundingRate, targetRate] =
  await sdk.getFundingRateForPairId(0);

// Rollover rate
const rolloverRate = await sdk.getRolloverRateForPairId(0);

Advanced: formulae exports

For custom calculations, individual formulae are exported:

import {
  GetTakeProfitPrice,
  GetStopLossPrice,
  CurrentTradeProfitP,
  GetCurrentRolloverFee,
  GetTradeFundingFee,
  getTradeLiquidationPrice,
  getTradeMetrics,
} from "ostium-ts-sdk";

Development

bun install          # Install dependencies
bun test             # Run all tests
bun run build        # Compile TypeScript
bun run typecheck    # Type check without emitting

License

See LICENSE for details.