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

@velarprotocol/velar-sdk

v0.7.6

Published

Velar-SDK is a user-friendly library to integrate swap functionality.

Readme

VELAR SDK

Velar-SDK is a user-friendly library to integrate swap functionality.

Velar SDK Types

  import { ContractPrincipalCV, PostCondition, PostConditionMode, UIntCV } from "@stacks/transactions";

  export interface SwapConfig {
      account: string;
      inToken: string;  // Token Contract Address
      outToken: string; // Token Contract Address
  }

  export interface ISwapService {
    swap(args: SwapPayload): Promise<SwapResponse>;
    getComputedAmount(args: ComputedAmountPayload): Promise<AmountOutResponse>;
  }

  export interface ComputedAmountPayload {
    amount: Number;
    slippage?: Number;
  }

  interface DestinationToken {
    symbol: string,
    contractAddress: string,
    tokenDecimalNum: Number,
    assetName: string,
  }

  export interface AmountOutResponse {
    value: Number,
    amountOut: Number // raw amount out
    path: Array<string> // route contract addresses
    path2: Array<string> // route symbols
    destinationToken: { symbol: string,  contractAddress: string,  tokenDecimalNum: Number,  assetName: string } // destination token details
    amountOutDecimal: Number // amountOutWithDecimals
    route?: Array<string>, // multihop optimal route
    result?: any // multihop routes results
  }

  export interface SwapResponse {
    contractAddress: string,
    contractName: string,
    functionName: string,
    functionArgs: [
      UIntCV,                  // pool id
      ContractPrincipalCV,    // pool token0 address
      ContractPrincipalCV,    // pool token1 address
      ContractPrincipalCV,    // in token address
      ContractPrincipalCV,    // out token address
      ContractPrincipalCV,    // staking contract
      UIntCV,                 // amount in
      UIntCV                  // amount out
    ],
    postConditions: Array<PostCondition>,
    postConditionMode: PostConditionMode,
  }

  export declare class SwapService {
    constructor(args: SwapConfig);
    swap(args: SwapPayload): Promise<SwapResponse>;
    getComputedAmount(args: ComputedAmountPayload): Promise<AmountOutResponse>;
  }

VELAR SDK Interface

  
  export interface VelarSDKConfig {
      headless: boolean // for Node.js env default false
  }

  export declare class VelarSDK {
    constructor(args?: VelarSDKConfig);
    getPairs (symbol: string): Promise<Array<string>>;
    getSwapInstance(args: SwapConfig): SwapService;
  }

  const sdk = new VelarSDK({
    headless: false, // set to true to disable logging/UI-related behavior
  });

Swap

import {
  VelarSDK,
  getTokens,
  ISwapService,
  SwapResponse,
} from '@velarprotocol/velar-sdk';
import { openContractCall } from '@stacks/connect';

const sdk = new VelarSDK();

async () => {
  const account = '';
  // setup swap instance
  const swapInstance: ISwapService = await sdk.getSwapInstance({
    account: account,
    inToken: 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.wstx',
    outToken: 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.velar-token',
  });

  // to display amount out
  const amount: AmountOutResponse = await swapInstance.getComputedAmount({
    amount: 10,
  });

  // get swap calculated arguments for contract call
  const swapOptions: SwapResponse = await swapInstance.swap({
    amount: 10,
  });

  // build options for contract call
  const options = {
    ...swapOptions,
    network: AppService.getNetwork(),
    appDetails: AppService.getAppDetails(),
    anchorMode: AnchorMode.Any,
    onFinish: data => {},
    onCancel: ex => {},
  };

  // open contract call
  await openContractCall(options);
};

Set Custom RPC URL

  import { VelarSDK } from '@velarprotocol/velar-sdk';
  const sdk = new VelarSDK();
  const CUSTOM_URL = 'https://api.mainnet.hiro.so';  
  sdk.setBlockChainApiUrl(CUSTOM_URL)

Available tokens

https://sdk.velar.network/tokens/symbols