πŸ”©Velar SDK

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:

SwapService

Handles all swap-related operations:

Getting Started

  1. Initialize the SDK:

  1. Create a swap instance:

  1. Execute operations:

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 Telegramarrow-up-right or Discordarrow-up-right. Our documentation is regularly updated to help you make the most of the Velar SDK.

Last updated

Was this helpful?