LogoLogo
Website
  • πŸ‘‹Welcome to Velar
  • Overview
    • πŸ’‘Introduction
    • πŸ›£οΈRoadmap
    • ✨Architecture
  • Getting Started
    • πŸ’»How to Use Velar Products
    • 🌊Providing Liquidity
    • 🚜Yield Farming
    • πŸ”Staking $VELAR Tokens
    • 🧩Building Integrations
    • 🀹Giving Feedback
    • πŸ‘‹Joining Community Channels
  • Velar PerpDex
    • πŸŽ›οΈCore Concepts
    • 🟧Stacks
    • πŸŸ₯Mezo (Coming Soon)
  • Velar Versions
    • ☸️Velar Dharma
      • Automated Market Maker (AMM)
      • Liquidity Pools & Yield Farming
      • IDO Launchpad
      • Bridge
      • MemeStacker
    • πŸ’‘Velar Artha
      • πŸ“ŠPerpetual Swaps
      • 🚿Concentrated Liquidity
      • πŸŒ‰Cross-Chain Bridge
    • πŸ›£οΈVelar Kama
    • ✨Velar Moksha
  • Audits
    • πŸ’‘Introduction
    • πŸ›£οΈAMM Audit on Clarity
    • 🚊PerpDex Audit on Clarity
    • πŸš‰PerpDex Audit on EVM
  • Token
    • πŸ’‘Introduction
    • πŸŽ›οΈTokenomics
    • πŸ“’Vesting Contracts
    • πŸͺœEmission
  • Developers
    • πŸ”¨Contract Addresses
    • πŸ”©Velar SDK
      • Velar SDK 0.7.0-beta [Latest]
      • Velar SDK 0.6.9
    • πŸ”¬Velar API
    • πŸ”₯Velar Verified Burner Contract
    • Velar Assets
  • Velar Executive Leadership
    • ♣️CEO - Mithil Thakore
    • ♠️CMO - Peter Watson
Powered by GitBook
On this page
  • Installation
  • Available Versions
  • Key Features
  • Core Components
  • Getting Started
  • Token Support
  • Migration Guide
  • Best Practices
  • Support

Was this helpful?

  1. Developers

Velar SDK

PreviousContract AddressesNextVelar SDK 0.7.0-beta [Latest]

Last updated 3 months ago

Was this helpful?

The Velar SDK is a powerful toolkit that enables seamless integration with the Velar Protocol, allowing developers to implement token swaps, manage liquidity, and interact with the Velar DEX ecosystem. This SDK provides a robust set of tools for building decentralized applications on the Stacks blockchain.

Installation

npm i @velarprotocol/velar-sdk

Available Versions

The latest version introduces significant improvements and changes:

  • Added support for all VELAR DEX listed tokens

  • Direct token contract address support in SwapConfig

  • Enhanced AmountOutResponse with detailed path information

  • Simplified API with removal of SwapType requirement

  • Removed support for swapTokensForExactTokens

Stable release with core functionality:

  • Support for token swapping operations

  • Implementation of swapTokensForExactTokens

  • Includes bug fix for assetName in swap operations

  • Uses SwapType enum for different swap operations

Key Features

  • Token Swapping: Execute token swaps with optimal routing

  • Price Computation: Calculate swap amounts with slippage protection

  • Pair Management: Query available trading pairs

  • Multi-hop Routing: Support for complex swap paths

  • Contract Integration: Seamless integration with Stacks blockchain

Core Components

The SDK is built around several key interfaces and classes:

VelarSDK Class

The main entry point for interacting with the protocol:

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

SwapService

Handles all swap-related operations:

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

Getting Started

  1. Initialize the SDK:

import { VelarSDK } from '@velarprotocol/velar-sdk';
const sdk = new VelarSDK();
  1. Create a swap instance:

const swapInstance = await sdk.getSwapInstance({
  account: userAddress,
  inToken: inputToken,  // Token Symbol or Contract Address
  outToken: outputToken // Token Symbol or Contract Address
});
  1. Execute operations:

// Get computed amount
const amountOut = await swapInstance.getComputedAmount({
  amount: 10,
  slippage: 0.5 // optional
});

// Perform swap
const swapOptions = await swapInstance.swap({
  amount: 10
});

Token Support

The SDK supports a wide range of tokens on the Velar DEX, including:

  • Core tokens: STX, VELAR, aeUSDC, aBTC

  • Ecosystem tokens: SOME, ROCK, MICK, WELSH, LEO

  • Staked variants: stSTX, sODIN, sROO, sWELSH

  • And many more

For the latest list of supported tokens and their trading pairs, you can use the getPairs method or check the official token list at: https://sdk-beta.velar.network/tokens/symbols

Migration Guide

When upgrading from 0.6.9 to 0.7.0-beta:

  1. Remove all SwapType references

  2. Update getComputedAmount implementation to handle new response type

  3. Remove any swapTokensForExactTokens implementations

  4. Update token inputs to optionally use contract addresses

Best Practices

  • Always implement proper error handling

  • Use slippage protection for better trade execution

  • Test with small amounts before large transactions

  • Keep the SDK updated to the latest stable version

  • Monitor transaction status using provided callbacks

Support

For technical support, bug reports, or feature requests, please join our community on or . Our documentation is regularly updated to help you make the most of the Velar SDK.

πŸ”©
Velar SDK 0.7.0-beta [Latest]
Velar SDK 0.6.9
Telegram
Discord