Socket
Book a DemoInstallSign in
Socket

dexterity-sdk

Package Overview
Dependencies
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dexterity-sdk

SDK and CLI for interacting with Dexterity AMM protocol

0.8.28
next
latest
npmnpm
Version published
Weekly downloads
73
-27%
Maintainers
1
Weekly downloads
 
Created
Source

Dexterity SDK

Dexterity Banner

A TypeScript SDK and CLI for interacting with the Dexterity AMM protocol on Stacks. Dexterity uses an isolated vault system where each liquidity pool exists as an independent smart contract for enhanced security.

npm version License: MIT

Quick Start

npm install dexterity-sdk
import { Dexterity } from "dexterity-sdk";

// Get a quote for swapping tokens
const quote = await Dexterity.getQuote(
  "SP123.token-a",  // token in
  "SP456.token-b",  // token out
  1000000          // amount (in smallest units)
);

// Execute the swap (client mode)
await Dexterity.executeSwap(
  "SP123.token-a", 
  "SP456.token-b", 
  1000000
);

Features

  • 🔄 Advanced Trading

    • Direct token swaps
    • Multi-hop routing with automatic path finding
    • Price quotes and analysis
    • Automated price discovery
    • Configurable fees and slippage protection
  • 💧 Liquidity Management

    • Add/remove liquidity
    • Track reserves across pools
    • Fair LP token distribution
    • Balanced and imbalanced deposits
  • 🛡️ Enterprise Security

    • Isolated vault contracts
    • Post-condition checks
    • Transaction preview
    • API key rotation
    • Rate limiting protection
  • 🔍 Discovery & Analysis

    • Automatic vault discovery
    • Route optimization
    • Debug utilities
    • Testing utilities

Core Concepts

Environment Setup

Create a .env file in your project root:

# .env
STACKS_API_KEY="your-api-key"  # Required for higher rate limits
SEED_PHRASE="..."              # Optional: Only for server environments

Configuration

The SDK supports both client-side (browser) and server-side usage:

// Client-side (browser)
Dexterity.configure({
  mode: "client",
  network: 'testnet',
});

// Server-side
Dexterity.configure({
  mode: "server",
  network: 'mainnet,
  apiKey: process.env.HIRO_API_KEY,
});

Any configuration can be modified:

// Update individual settings
Dexterity.configure({ maxHops: 3 });
Dexterity.configure({ defaultSlippage: 0.5 });

// Get current config
const config = Dexterity.config

Working with Quotes

Get quotes for potential trades:

// Simple quote
const quote = await Dexterity.getQuote(
  tokenInContract,
  tokenOutContract,
  amount
);

console.log({
  amountIn: quote.amountIn,
  amountOut: quote.amountOut,
  expectedPrice: quote.expectedPrice,
  minimumReceived: quote.minimumReceived,
  fee: quote.fee
});

// Execute the quoted trade
await Dexterity.executeSwap(
  tokenInContract, 
  tokenOutContract, 
  amount,
  { fee: 10000 } // optional parameters
);

Pool Operations

Interact with individual liquidity pools:

// Get a specific pool
const vault = Dexterity.build("SP123.pool-abc");

// Get pool information
const [tokenA, tokenB] = vault.getTokens();
const [reserveA, reserveB] = vault.getReserves();

// Get a quote from the pool
const quote = await vault.quote(
  1000000,
  Opcode.swapExactAForB()
);

CLI Usage

The SDK includes a powerful CLI for interacting with the protocol:

# Install globally
npm install -g dexterity-sdk

# Get a quote
dexterity quote .stx SP2ZNGJ85ENDY6QRHQ5P2D4FXKGZWCKTB2T0Z55KS.charisma-token 1000000

# List all pools
dexterity vaults

# Show debug information
dexterity -d inspect -g

CLI Configuration

Manage CLI settings:

# View config
dexterity config ls

# Set values
dexterity config set maxHops 3 # router graph search depth
dexterity config set defaultSlippage 0.02 # 2% slippage

# Reset to defaults
dexterity config reset

Inspection Commands

Analyze protocol components:

# Inspect a pool
dexterity inspect -v SP2ZNGJ85ENDY6QRHQ5P2D4FXKGZWCKTB2T0Z55KS.charisma-token

# Analyze token routes
dexterity inspect -r .stx SP2ZNGJ85ENDY6QRHQ5P2D4FXKGZWCKTB2T0Z55KS.charisma-token

# Show routing statistics
dexterity inspect -g

Development

Testing

# Run tests
npm test

# With coverage
npm run test:coverage

Building

# Clean and build
npm run clean && npm run build

# Development
npm run dev

Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -am 'Add some amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

Keywords

defi

FAQs

Package last updated on 07 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.