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

@phantom/perps-client

v0.1.4

Published

Hyperliquid perpetuals client for Phantom Wallet

Readme

@phantom/perps-client

Hyperliquid perpetuals trading client for Phantom API. Handles EIP-712 signing and Phantom backend API calls for the full perpetuals lifecycle — from funding deposits through position management.

Architecture

PerpsClient
    ├── Read operations  →  Phantom backend API  →  Hyperliquid data
    └── Write operations →  EIP-712 sign  →  Phantom backend  →  Hyperliquid exchange

Installation

yarn add @phantom/perps-client

Usage

import { PerpsClient } from "@phantom/perps-client";

const client = new PerpsClient({
  evmAddress: "0xYourEvmAddress",
  signTypedData: async typedData => {
    // Sign EIP-712 typed data and return 0x-prefixed hex signature
    return phantomClient.ethereumSignTypedData({
      walletId,
      typedData,
      networkId: "eip155:42161", // Arbitrum — used for all Hyperliquid signing
      derivationIndex: 0,
    });
  },
  apiBaseUrl: "https://api.phantom.app", // optional
});

// Read
const balance = await client.getBalance();
const positions = await client.getPositions();
const orders = await client.getOpenOrders();
const markets = await client.getMarkets();

// Write
await client.openPosition({ market: "BTC", direction: "long", sizeUsd: "100", leverage: 10, orderType: "market" });
await client.closePosition({ market: "BTC" });
await client.cancelOrder({ market: "BTC", orderId: 12345 });
await client.updateLeverage({ market: "BTC", leverage: 5, marginType: "cross" });

// Internal transfers (both accounts on Hypercore)
await client.deposit("100"); // spot → perp
await client.withdraw("50"); // perp → spot

API Reference

Constructor

new PerpsClient(options: PerpsClientOptions)

| Option | Type | Description | | --------------- | ------------------------------------------------- | --------------------------------------------------------- | | evmAddress | string | The wallet's EVM address (0x-prefixed) | | signTypedData | (typedData: Eip712TypedData) => Promise<string> | Signs EIP-712 data, returns 0x-prefixed hex signature | | apiBaseUrl | string? | Phantom API base URL (default: https://api.phantom.app) |

Read Methods

| Method | Returns | Endpoint | | --------------------- | -------------------- | --------------------------------------------- | | getBalance() | PerpAccountBalance | GET /swap/v2/perp/balance | | getPositions() | PerpPosition[] | GET /swap/v2/perp/positions-and-open-orders | | getOpenOrders() | PerpOrder[] | GET /swap/v2/perp/positions-and-open-orders | | getMarkets() | PerpMarket[] | GET /swap/v2/perp/markets | | getTradeHistory() | HistoricalOrder[] | GET /swap/v2/perp/trade-history | | getFundingHistory() | FundingActivity[] | GET /swap/v2/perp/deposits-and-withdrawals |

Write Methods

| Method | Signs | Endpoint | | ------------------------ | ---------------------------------- | --------------------------------------- | | openPosition(params) | Exchange/Agent EIP-712 | POST /swap/v2/exchange | | closePosition(params) | Exchange/Agent EIP-712 | POST /swap/v2/exchange | | cancelOrder(params) | Exchange/Agent EIP-712 | POST /swap/v2/exchange | | updateLeverage(params) | Exchange/Agent EIP-712 | POST /swap/v2/exchange | | deposit(amountUsdc) | HyperliquidSignTransaction EIP-712 | POST /swap/v2/transfer-usdc-spot-perp | | withdraw(amountUsdc) | HyperliquidSignTransaction EIP-712 | POST /swap/v2/transfer-usdc-spot-perp |