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

@solsdk/xswap_sdk

v5.1.8

Published

Universal cross-chain swaps SDK

Downloads

13

Readme

@solsdk/xswap_sdk – Universal Cross-Chain Swap SDK

@solsdk/xswap_sdk is a robust TypeScript SDK designed to simplify and accelerate cross-chain token swaps across leading blockchain ecosystems. With a modular, extensible architecture and strict type safety, it empowers developers to integrate seamless cross-chain transfers and swaps into their applications with confidence.

Installation

npm install @solsdk/xswap_sdk
pnpm install @solsdk/xswap_sdk
yarn add @solsdk/xswap_sdk

Why @solsdk/xswap_sdk?

  • Universal: Supports major EVM chains (Arbitrum, Optimism, Base, Hyperliquid), Solana, and Sui out of the box.
  • Secure: Built with strict TypeScript types and best security practices.
  • Modular: Easily extend or customize for new chains and protocols.
  • Developer-Friendly: Clean, intuitive API and clear error handling.
  • Production-Ready: Designed for reliability and scalability in real-world applications.

Architecture

@solsdk/xswap_sdk uses a modular approach with chain-specific SDKs:

  • EVMSDK – For Ethereum-compatible chains (Arbitrum, Optimism, Base, Hyperliquid)
  • SolanaSDK – For Solana blockchain
  • SuiSDK – For Sui blockchain

Quick Start

Import and Initialize

import { ChainID, EVMSDK, SolanaSDK, SuiSDK } from "@solsdk/xswap_sdk";

// EVM Example (Arbitrum)
const arbitrumSdk = new EVMSDK({
  chainId: ChainID.Arbitrum,
  privateKey: "0x...", // Your private key
  rpcProviderUrl: "https://arbitrum-mainnet.public.blastapi.io", // Optional
});

// EVM Example (Hyperliquid)
const hyperliquidSdk = new EVMSDK({
  chainId: ChainID.Hyperliquid,
  privateKey: "0x...", // Your private key
  rpcProviderUrl: "https://hyperliquid-rpc.public.blastapi.io", // Optional
});

// Solana Example
const solanaSdk = new SolanaSDK({
  privateKey: "...", // Your private key
  commitment: "finalized", // Or 'confirmed'
  rpcProviderUrl: "https://api.mainnet-beta.solana.com", // Optional
});

// Sui Example
const suiSdk = new SuiSDK({
  privateKey: "...", // Your private key
});

Creating and Submitting Cross-Chain Orders

// Prepare a cross-chain order from Arbitrum to Solana
const preparedOrder = await arbitrumSdk.createOrder({
  sourceChainId: ChainID.Arbitrum,
  sourceTokenAddress: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
  sourceTokenAmount: BigInt(12000),
  destinationChainId: ChainID.Solana,
  destinationTokenAddress: "So11111111111111111111111111111111111111112",
  destinationTokenMinAmount: BigInt(10000),
  destinationAddress: "3Kiz4oBXpR9YuPNsVfvE5XnNzgwjrM9m2CbRzyyEVkpQ",
  minStablecoinAmount: BigInt(11000),
  deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
});

// Or create and send the order in one step
const response = await arbitrumSdk.createAndSendOrder({
  sourceChainId: ChainID.Arbitrum,
  sourceTokenAddress: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
  sourceTokenAmount: BigInt(12000),
  destinationChainId: ChainID.Solana,
  destinationTokenAddress: "So11111111111111111111111111111111111111112",
  destinationTokenMinAmount: BigInt(10000),
  destinationAddress: "3Kiz4oBXpR9YuPNsVfvE5XnNzgwjrM9m2CbRzyyEVkpQ",
  minStablecoinAmount: BigInt(11000),
  deadline: Math.floor(Date.now() / 1000) + 3600,
});

// Create and send a cross-chain order from Hyperliquid to Optimism
const hyperliquidResponse = await hyperliquidSdk.createAndSendOrder({
  sourceChainId: ChainID.Hyperliquid,
  sourceTokenAddress: "0x4300000000000000000000000000000000000003", // USDC on Hyperliquid
  sourceTokenAmount: BigInt(10_000_000), // 10 USDC (6 decimals)
  destinationChainId: ChainID.Optimism,
  destinationTokenAddress: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607", // USDC on Optimism
  destinationTokenMinAmount: BigInt(9_500_000), // 9.5 USDC minimum
  destinationAddress: "0xYourOptimismAddress", // Optimism address
  minStablecoinAmount: BigInt(9_800_000), // Protocol minimum
  deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
});

Supported Chains

| Chain | Chain ID | Status | | ----------- | -------- | ------------ | | Arbitrum | 42161 | ✅ Supported | | Optimism | 10 | ✅ Supported | | Base | 8453 | ✅ Supported | | Hyperliquid | 999 | ✅ Supported | | Solana | 7565164 | ✅ Supported | | Sui | 101 | ✅ Supported |

Examples

Cross-Chain Order from Arbitrum to Solana

import { ChainID, EVMSDK, ValidationError } from "@solsdk/xswap_sdk";

async function createCrossChainOrder() {
  try {
    const sdk = new EVMSDK({
      chainId: ChainID.Arbitrum,
      privateKey: process.env.PRIVATE_KEY as `0x${string}`,
    });

    const response = await sdk.createAndSendOrder({
      sourceChainId: ChainID.Arbitrum,
      sourceTokenAddress: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", // USDT on Arbitrum
      sourceTokenAmount: BigInt(10_000_000), // 10 USDT (6 decimals)
      destinationChainId: ChainID.Solana,
      destinationTokenAddress: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", // USDT on Solana
      destinationTokenMinAmount: BigInt(9_500_000), // 9.5 USDT minimum
      destinationAddress: "3Kiz4oBXpR9YuPNsVfvE5XnNzgwjrM9m2CbRzyyEVkpQ", // Solana address
      minStablecoinAmount: BigInt(9_800_000), // Protocol minimum
      deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
    });

    return response;
  } catch (error) {
    if (error instanceof ValidationError) {
      console.error("Invalid order parameters:", error.message);
    } else {
      console.error("Failed to create and send order:", error);
    }
    throw error;
  }
}

Cross-Chain Order from Hyperliquid to Optimism

import { ChainID, EVMSDK, ValidationError } from "@solsdk/xswap_sdk";

async function createHyperliquidToOptimismOrder() {
  try {
    const sdk = new EVMSDK({
      chainId: ChainID.Hyperliquid,
      privateKey: process.env.PRIVATE_KEY as `0x${string}`,
    });

    const response = await sdk.createAndSendOrder({
      sourceChainId: ChainID.Hyperliquid,
      sourceTokenAddress: "0x4300000000000000000000000000000000000003", // USDC on Hyperliquid
      sourceTokenAmount: BigInt(10_000_000), // 10 USDC (6 decimals)
      destinationChainId: ChainID.Optimism,
      destinationTokenAddress: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607", // USDC on Optimism
      destinationTokenMinAmount: BigInt(9_500_000), // 9.5 USDC minimum
      destinationAddress: "0xYourOptimismAddress", // Optimism address
      minStablecoinAmount: BigInt(9_800_000), // Protocol minimum
      deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
    });

    return response;
  } catch (error) {
    if (error instanceof ValidationError) {
      console.error("Invalid order parameters:", error.message);
    } else {
      console.error("Failed to create and send order:", error);
    }
    throw error;
  }
}

Contributing

We welcome contributions from the community! Please open issues or submit pull requests to help us improve @solsdk/xswap_sdk.

License

MIT


Ready to simplify cross-chain swaps? Install @solsdk/xswap_sdk and start building today!