Velar SDK 0.7.0-beta [Latest]

Installation:

npm i @velarprotocol/velar-sdk

Velar SDK Types:

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

  export interface SwapConfig {
      account: string;
      inToken: string;  // Token Symbol or Token Contract Address
      outToken: string; // Token Symbol or 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:

Swap:

Available tokens:

https://sdk-beta.velar.network/tokens/symbolsarrow-up-right

For more detailed information and additional functions, please refer to the npm library herearrow-up-right.

Last updated

Was this helpful?