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

@luckyswaps/sdk

v1.4.1

Published

LuckySwaps integrates tightly with Jupiter and thus uses mostly similar interfaces. If you ever integrated with Jupiter, it should be easy for you to also integrate with Luckyswaps.

Readme

Luckyswaps SDK

LuckySwaps integrates tightly with Jupiter and thus uses mostly similar interfaces. If you ever integrated with Jupiter, it should be easy for you to also integrate with Luckyswaps.

Howto

Integrate with LuckySwaps using the SDK

1. Install required libraries

Running this example requires a minimum of NodeJS 16. In your command line terminal, install the libraries.

npm i @luckyswaps/sdk

2. Get a program instance

import { PublicKey, Keypair } from "@solana/web3.js";
import assert from "assert";
import {
  getProgram,
  swap,
  LuckySwapParams,
  MAX_THRESHOLD,
} from "@luckyswaps/sdk";

const keyPair = Keypair.generate();
const program = getProgram("https://api.mainnet-beta.solana.com", keyPair);

4. Get the route for a swap

Here, we are getting a quote to swap from SOL to USDC.

// Swapping SOL to USDC with input 0.1 SOL and 0.5% slippage
const params: LuckySwapParams = {

  // Payer that signs the transactions
  payerAccount: new PublicKey(
    "G2FJbtHdaBP5qaFTKyBuTGYHqenTFFpmpz2DSD5A5BH7",
  ),

  // input and output mint (will be used for Jupiter swap)
  inputMint: new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // USDC
  outputMint: new PublicKey("So11111111111111111111111111111111111111112"), // WSOL

  // associated token accounts for both mint owned by the user
  userSourceAccount: new PublicKey(
    "CqMKa8z4WHpcW4pR7vWEAB96nerRPwBYi1ZJJhsP4bNw",
  ),
  userTargetAccount: new PublicKey(
    "FBAoSPT2L5qJJPmMJ1w9uo9ExuTXC4SHK4322ESuBpg7",
  ),

  // a reference to our program (e.g. API connection)
  program: program,

  // The amount to swap (ExactIn)
  amount: amount,

  // The threshold defines the winning probability and the multiplier
  // if you want a 50% win chance (including house-edge, you chose multiplier: 2)
  threshold: Math.round(MAX_THRESHOLD / multiplier),

  // optional parameters when calling /quote on jupiter
  // https://station.jup.ag/api-v6/get-quote
  jupiterQuoteParams: {},

  // optional parameters when calling /swap-instruction on jupiter
  // https://station.jup.ag/api-v6/post-swap-instructions
  jupiterSwapParams: {},
};

5. Get the serialized transactions to perform the swap

Once we have the quote, we need to serialize the quote into a swap transaction that can be submitted on chain.

// get serialized transactions for the swap
const instructions = await swap(params);

The returned instructions are identical to what you would expect when calling https://quote-api.jup.ag/v6/swap-instructions.

6. Deserialize and sign the transaction

The following is standard Jupiter

const {
  tokenLedgerInstruction: tokenLedgerPayload, // If you are using `useTokenLedger = true`.
  swapInstruction: swapInstructionPayload, // The actual swap instruction.
  addressLookupTableAddresses, // The lookup table addresses that you can use if you are using versioned transaction.
} = instructions;

// A withdraw instruction that will increase the user input token account amount.
const withdrawInstruction = ...;

// Coupled with the tokenLedgerInstruction, the swap instruction will use the
// user increased amount of the input token account after the withdrawal as input amount.
const tokenLedgerInstruction = new TransactionInstruction({
  programId: new PublicKey(tokenLedgerPayload.programId),
  keys: tokenLedgerPayload.accounts.map((key) => ({
    pubkey: new PublicKey(key.pubkey),
      isSigner: key.isSigner,
      isWritable: key.isWritable,
    })),
  data: Buffer.from(tokenLedgerPayload.data, "base64"),
});

const swapInstruction = new TransactionInstruction({
  programId: new PublicKey(swapInstructionPayload.programId),
  keys: swapInstructionPayload.accounts.map((key) => ({
    pubkey: new PublicKey(key.pubkey),
      isSigner: key.isSigner,
      isWritable: key.isWritable,
    })),
  data: Buffer.from(swapInstructionPayload.data, "base64"),
});

const getAdressLookupTableAccounts = async (
  keys: string[]
): Promise<AddressLookupTableAccount[]> => {
  const addressLookupTableAccountInfos =
    await connection.getMultipleAccountsInfo(
      keys.map((key) => new PublicKey(key))
    );

  return addressLookupTableAccountInfos.reduce((acc, accountInfo, index) => {
    const addressLookupTableAddress = keys[index];
    if (accountInfo) {
      const addressLookupTableAccount = new AddressLookupTableAccount({
        key: new PublicKey(addressLookupTableAddress),
        state: AddressLookupTableAccount.deserialize(accountInfo.data),
      });
      acc.push(addressLookupTableAccount);
    }

    return acc;
  }, new Array<AddressLookupTableAccount>());
};

const addressLookupTableAccounts: AddressLookupTableAccount[] = [];

addressLookupTableAccounts.push(
  ...(await getAdressLookupTableAccounts(addressLookupTableAddresses))
);

const messageV0 = new TransactionMessage({
  payerKey: payerPublicKey,
  recentBlockhash: blockhash,
  instructions: [tokenLedgerInstruction, withdrawInstruction, swapInstruction],
}).compileToV0Message(addressLookupTableAccounts);
const transaction = new VersionedTransaction(messageV0);