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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@daos/trading-sdk

v0.1.1

Published

TypeScript SDK for programmatic DAO treasury trading on DAOS.fun

Readme

@daos/trading-sdk

npm version TypeScript License: MIT

TypeScript SDK for programmatic DAO treasury trading using Jupiter aggregator

Secure, type-safe trading for DAO treasuries with built-in authorization, transaction signing, and comprehensive error handling.

🚀 Features

  • 🔐 Secure Trading: Your keys never leave your control
  • ⚡ Complete Flow: Quote → Build → Sign → Execute
  • 📊 Real-time Quotes: Powered by Jupiter
  • 🎯 Type Safety: Full TypeScript support
  • 🔄 Error Handling: Comprehensive error handling and retry logic

📦 Installation

npm install @daos/trading-sdk dotenv
yarn add @daos/trading-sdk dotenv
pnpm add @daos/trading-sdk dotenv

🔧 Quick Start

Environment Setup

export DAO_MINT="your_dao_mint_address"
export DELEGATE_PRIVATE_KEY="[1,2,3,...]"  # Array or base58 format

Basic Usage

import 'dotenv/config';
import { DAOTradingSDK, TOKENS } from '@daos/trading-sdk';

// Initiate Trading SDK
const trader = DAOTradingSDK.fromEnv();

// Trade 0.1 SOL for USDC
const result = await trader.trade(
  TOKENS.SOL,   // From SOL
  TOKENS.USDC,  // To USDC
  0.1,          // Amount: 0.1 SOL
  {
    slippageBps: 50,
  }
);

console.log('Transaction signature:', result.signature);

📚 API Reference

DAOTradingSDK

Methods

trade(inputMint, outputMint, amount, options?)

Complete trading flow in one call.

const result = await trader.trade(
  TOKENS.SOL,
  TOKENS.BONK, 
  0.05,
  { slippageBps: 100 }
);
getQuote(inputMint, outputMint, amount, slippageBps?)

Get a trading quote from Jupiter.

const quote = await trader.getQuote(TOKENS.SOL, TOKENS.USDC, 0.1, 50);
performSwap(quoteResponse, options?)

Build and get signed DAO transaction.

const swapResult = await trader.performSwap(quote.quoteResponse);
executeTransaction(signedTransaction, inputMint, outputMint)

Submit user-signed transaction for broadcast.

const result = await trader.executeTransaction(signedTx, inputMint, outputMint);

🏷️ Token Constants

Pre-defined token mints for popular tokens:

import { TOKENS } from '@daos/trading-sdk';

TOKENS.SOL    // Solana
TOKENS.USDC   // USD Coin
TOKENS.USDT   // Tether
TOKENS.BONK   // Bonk
TOKENS.WIF    // Dogwifhat
TOKENS.JUP    // Jupiter
TOKENS.RAY    // Raydium
TOKENS.ORCA   // Orca
// ... and more

🎯 Examples

Step-by-Step Trading

// Step 1: Get quote
const quote = await trader.getQuote(TOKENS.SOL, TOKENS.USDC, 0.1);
console.log(`Expected output: ${quote.outAmount} USDC`);

// Step 2: Build transaction
const swapResult = await trader.performSwap(quote.quoteResponse);

// Step 3: Sign transaction
const transaction = VersionedTransaction.deserialize(
  Buffer.from(swapResult.data, 'base64')
);
transaction.sign([delegateKeypair]);

// Step 4: Execute
const result = await trader.executeTransaction(
  Buffer.from(transaction.serialize()).toString('base64'),
  TOKENS.SOL,
  TOKENS.USDC
);

Multiple Trades

const trades = [
  { from: TOKENS.SOL, to: TOKENS.USDC, amount: 0.1 },
  { from: TOKENS.SOL, to: TOKENS.BONK, amount: 0.05 },
];

for (const trade of trades) {
  try {
    const result = await trader.trade(trade.from, trade.to, trade.amount);
    console.log(`✅ ${trade.amount} SOL → ${trade.to}: ${result.signature}`);
  } catch (error) {
    console.error(`❌ Trade failed:`, error);
  }
}

⚙️ Configuration

TradeOptions

interface TradeOptions {
  slippageBps?: number;                    // Slippage tolerance (basis points)
  wrapAndUnwrapSol?: boolean;             // Auto wrap/unwrap SOL (default: true)
  dynamicComputeUnitLimit?: boolean;       // Dynamic compute units (default: true)
  prioritizationFeeLamports?: number;      // Priority fee in lamports
  computeUnitPriceMicroLamports?: number; // Compute unit price
}

Environment Variables

# Required
export DAO_MINT="your_dao_mint_address"
export DELEGATE_PRIVATE_KEY="[1,2,3,...]"  # Array or base58 format

🔒 Security

  • 🔐 Private Key Control: Your private keys never leave your environment
  • 🛡️ Authorization Required: Delegate must be authorized for the DAO
  • ✅ Transaction Signing: You control all transaction signing
  • 🔍 Validation: Built-in authorization and parameter validation

🛡️ Error Handling

The SDK provides detailed error messages for different scenarios:

try {
  const result = await trader.trade(TOKENS.SOL, TOKENS.USDC, 0.1);
} catch (error) {
  if (error.message.includes('DELEGATE_NOT_AUTHORIZED')) {
    console.error('Delegate wallet not authorized');
  } else if (error.message.includes('Quote failed')) {
    console.error('Failed to get Jupiter quote');
  } else {
    console.error('Unexpected error:', error);
  }
}

📋 TypeScript Support

Full TypeScript support with exported types:

import type {
  DAOTradingConfig,
  QuoteResponse,
  TradeResult,
  TradeOptions,
  WalletInfo,
} from '@daos/trading-sdk';

🚨 Important Notes

  1. Delegate Authorization: Your delegate wallet must be authorized for the DAO
  2. Quote Expiry: Jupiter quotes expire quickly (30-60 seconds)
  3. Network Fees: Account for SOL network fees and priority fees
  4. Start Small: Test with minimal amounts first
  5. Rate Limits: Respect API rate limits

🆘 Troubleshooting

Common Issues

"DELEGATE_NOT_AUTHORIZED"

  • Ensure your delegate wallet is authorized in DAO settings
  • Verify you're using the correct DAO mint address

"Quote failed"

  • Check if the token pair has sufficient liquidity
  • Verify token mint addresses are correct

"Transaction failed"

  • Increase slippage tolerance for volatile tokens
  • Ensure sufficient balance in DAO treasury
  • Check priority fees are adequate

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests.

📞 Support


Ready to start programmatic DAO trading! 🚀