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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@blockchainbros/vidar-amm-sdk

v0.4.5

Published

TypeScript SDK for Vidar AMM on Solana

Readme

Vidar AMM SDK

TypeScript SDK for interacting with the Vidar AMM smart contracts on the Solana blockchain. Supports liquidity provision, staking, rewards claiming, token swaps (including optional commit-reveal), and full pool lifecycle management.

Installation

npm install @blockchainbros/vidar-amm-sdk

Core Concepts

LP Tokens (lpMint)

When you provide liquidity, you receive LP tokens which represent your ownership share in a pool. These tokens are minted via lpMint.

  • Add liquidity → mint LP tokens
  • Remove liquidity → burn LP tokens
  • Stake LP tokens → lock them for yield rewards

Vaults

  • vaultA, vaultB: Store the two assets of the pool
  • feeVault: Accumulates trading fees (90% to LPs, 10% to admin)
  • stakingRewardVault: Distributes staking rewards (from fees, not inflation)
  • lpStakeVault: Holds LP tokens from stakers

SDK Usage

Initialize SDK

import { loadVidarAmm } from '@blockchainbros/vidar-amm-sdk';

const program = loadVidarAmm(
  'https://api.mainnet-beta.solana.com',
  wallet, // Anchor-compatible wallet
  'confirmed'
);

Pool Lifecycle

Initialize Pool

import { initializePool } from '@blockchainbros/vidar-amm-sdk';

const tx = await initializePool(program, {
  payer: wallet.publicKey,
  pool: new PublicKey('...'),
  authority: new PublicKey('...'),
  tokenA: new PublicKey('...'),
  tokenB: new PublicKey('...'),
  vaultA: new PublicKey('...'),
  vaultB: new PublicKey('...'),
  feeVault: new PublicKey('...'),
  stakingRewardVault: new PublicKey('...'),
  lpStakeVault: new PublicKey('...'),
  lpMint: new PublicKey('...')
}, {
  feeBasisPoints: 30,
  tickSpacing: 60,
  lowerTick: -60,
  upperTick: 60
});

Liquidity Operations

Add Liquidity

import { addLiquidity } from '@blockchainbros/vidar-amm-sdk';

const tx = await addLiquidity(program, {
  user: wallet.publicKey,
  pool: new PublicKey('...'),
  userTokenA: new PublicKey('...'),
  userTokenB: new PublicKey('...'),
  vaultA: new PublicKey('...'),
  vaultB: new PublicKey('...'),
  lpMint: new PublicKey('...'),
  userLpToken: new PublicKey('...'),
  authority: new PublicKey('...'),
  position: new PublicKey('...')
}, new BN('1000000000'), new BN('1000000000'));

Remove Liquidity

import { removeLiquidity } from '@blockchainbros/vidar-amm-sdk';

const tx = await removeLiquidity(program, {
  user: wallet.publicKey,
  pool: new PublicKey('...'),
  vaultA: new PublicKey('...'),
  vaultB: new PublicKey('...'),
  userTokenA: new PublicKey('...'),
  userTokenB: new PublicKey('...'),
  lpMint: new PublicKey('...'),
  userLpToken: new PublicKey('...'),
  position: new PublicKey('...'),
  authority: new PublicKey('...')
}, new BN('1000000000'));

Swap Operations

Instant Swap

import { swap } from '@blockchainbros/vidar-amm-sdk';

const tx = await swap(program, {
  user: wallet.publicKey,
  pool: new PublicKey('...'),
  userSource: new PublicKey('...'),
  userDestination: new PublicKey('...'),
  vaultSource: new PublicKey('...'),
  vaultDestination: new PublicKey('...'),
  feeVault: new PublicKey('...'),
  stakingRewardVault: new PublicKey('...'),
  authority: new PublicKey('...')
}, new BN('1000000000'), new BN('900000000'));

Commit-Reveal Swap (if enabled)

import { swapCommit, swapReveal } from '@blockchainbros/vidar-amm-sdk';

// 1. Commit hash
await swapCommit(program, {
  user: wallet.publicKey,
  commitIndex: new PublicKey('...'),
  pool: new PublicKey('...')
}, hash, nonce);

// 2. Reveal with actual amounts and preimage
await swapReveal(program, {
  user: wallet.publicKey,
  pool: new PublicKey('...'),
  commit: new PublicKey('...'),
  vaultSource: new PublicKey('...'),
  vaultDestination: new PublicKey('...'),
  userSource: new PublicKey('...'),
  userDestination: new PublicKey('...'),
  feeVault: new PublicKey('...'),
  stakingRewardVault: new PublicKey('...'),
  authority: new PublicKey('...')
}, amountIn, minAmountOut, deadline, nonce);

Staking & Rewards

Stake LP Tokens

import { stake } from '@blockchainbros/vidar-amm-sdk';

await stake(program, {
  user: wallet.publicKey,
  pool: new PublicKey('...'),
  userLpToken: new PublicKey('...'),
  stakeVault: new PublicKey('...'),
  authority: new PublicKey('...'),
  stakeAccount: new PublicKey('...')
}, new BN('1000000000'));

Unstake

import { unstake } from '@blockchainbros/vidar-amm-sdk';

await unstake(program, {
  user: wallet.publicKey,
  pool: new PublicKey('...'),
  userLpToken: new PublicKey('...'),
  stakeVault: new PublicKey('...'),
  stakeAccount: new PublicKey('...'),
  authority: new PublicKey('...')
}, new BN('1000000000'));

Claim Rewards

import { claimRewards } from '@blockchainbros/vidar-amm-sdk';

await claimRewards(program, {
  user: wallet.publicKey,
  pool: new PublicKey('...'),
  stakeAccount: new PublicKey('...'),
  stakingRewardVault: new PublicKey('...'),
  lpStakeVault: new PublicKey('...'),
  userRewardAccount: new PublicKey('...'),
  authority: new PublicKey('...')
});

Fee & Reward Distribution Model

  • 90% of trading fees go to LPs (automatically added to the pool)
  • 10% of trading fees go to protocol feeVault (for admin use)
  • No inflation: all rewards are from real volume and protocol usage

License

MIT