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

@meteora-ag/referral

v0.0.2

Published

Referral staking SDK

Readme

@meteora-ag/referral

TypeScript SDK for the Meteora Referral Staking Program on Solana.

Program ID: refr2gvtDhaFMqEAjnbK8X7xunqysns4MjVuz8PSf7r

Installation

bun add @meteora-ag/referral

Quick Start

Initialize a Staking Pool

import { Connection, Keypair } from "@solana/web3.js";
import BN from "bn.js";
import { Referral } from "@meteora-ag/referral";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const payer = Keypair.generate();
const staking = Keypair.generate();

const transaction = await Referral.initializeStaking(connection, {
  owner: payer.publicKey,
  tokenMint,
  stakingPenaltyFeeReceiver: feeReceiver.publicKey,
  staking,
  payer: payer.publicKey,
  unstakeCooldownSeconds: new BN(86400),
  minStakingAmount: new BN(1_000_000),
  immediateUnstakePenaltyBps: 500, // 5%
});

Interact with an Existing Pool

const referral = await Referral.create(connection, stakingAddress);

// Initialize escrow for a user
const escrowTx = await referral.initializeEscrow({
  owner: user.publicKey,
  payer: payer.publicKey,
});

// Stake tokens
const stakeTx = await referral.stake({
  escrowAddress,
  payer: user.publicKey,
  amount: new BN(10_000_000),
});

// Quote immediate unstake with 1% slippage tolerance
const wrapper = referral.getStakingWrapper();
const { userReceiveAmount, penaltyFeeAmount, minReceiveAmount } =
  wrapper.quoteImmediateUnstake(new BN(10_000_000), 100);

// Immediate unstake (slippageBps auto-calculates minimumOutAmount)
const immUnstakeTx = await referral.immediateUnstake({
  escrowAddress,
  owner: user.publicKey,
  maxAmount: new BN(10_000_000),
  slippageBps: 100, // 1%
  receiver: user.publicKey,
});

// Or unstake with cooldown
const { transaction: unstakeTx, unstakeKeypair } = await referral.unstake({
  escrowAddress,
  owner: user.publicKey,
  payer: user.publicKey,
  maxAmount: new BN(10_000_000),
});

// Withdraw after cooldown
const withdrawTx = await referral.withdraw({
  unstakeAddress: unstakeKeypair.publicKey,
  escrowAddress,
  owner: user.publicKey,
  rentReceiver: user.publicKey,
  receiver: user.publicKey,
});

Staking Flow

User                                    Program
 |                                         |
 |-- initialize_escrow ------------------>|  Create escrow account
 |                                         |
 |-- stake(amount) ---------------------->|  Transfer tokens -> vault
 |                                         |
 |-- unstake(max_amount) ---------------->|  Start cooldown timer
 |         |                               |
 |         |-- withdraw ----------------->|  After cooldown: tokens -> user
 |         |                               |
 |         +-- cancel_unstake ----------->|  Return to staked state
 |                                         |
 +-- immediate_unstake(max_amount) ------>|  Deduct penalty, tokens -> user

Instructions

Permissionless

| Method | Description | | ------------------- | ---------------------------------------------------------------------- | | initializeStaking | Create a staking pool with cooldown, minimum stake, and penalty config | | initializeEscrow | Create a per-user escrow account linked to a staking pool | | stake | Deposit tokens into the vault | | unstake | Begin a time-locked unstake with cooldown | | cancelUnstake | Cancel a pending unstake, returning tokens to staked state | | withdraw | Claim tokens after the unstake cooldown has elapsed | | immediateUnstake | Instantly withdraw staked tokens, paying a penalty fee | | closeEscrow | Close an empty escrow account and reclaim rent | | claimPenaltyFee | Withdraw accumulated penalty fees to the configured fee receiver |

Permissioned (Owner)

| Method | Description | | -------------------------- | ----------------------------------------------------------------- | | updatePenaltyFeeReceiver | Change the account that receives penalty fees | | updateConfig | Modify staking pool parameters (cooldown, min stake, penalty bps) | | transferOwner | Transfer staking pool ownership to a new account |

Account Wrappers

The SDK provides read-only wrappers for convenient state access:

  • StakingWrapper — Pool state, config, and metrics
  • EscrowWrapper — User escrow balances with isEmpty() / canClose() helpers
  • UnstakeWrapper — Unstake record with canWithdraw() / getTimeUntilWithdrawable() cooldown helpers

Development

bun install
bun run build
bun test