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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@snowmonster_defi/sdk

v1.0.3

Published

🚀 The most powerful DEX aggregator SDK on Avalanche by SnowMonster DeFi. Get the best swap rates across Trader Joe, Pangolin & more with a single API call. Features React hooks, TypeScript support, and partner fee sharing up to 0.50%.

Readme

@danaszova/avax-router-sdk

npm version npm downloads bundle size License: MIT TypeScript Live Demo

🚀 The Most Powerful DEX Aggregator SDK on Avalanche

Stop manually checking multiple DEXes. Get the best swap rate with a single API call.

Try Live Demo →


What Problem Does This Solve?

Every DEX on Avalanche has different prices and liquidity. Finding the best swap rate means checking Trader Joe, Pangolin, and others manually. This SDK does it for you automatically - querying all DEXes in parallel and returning the best execution.

Result: Users get more tokens for their swaps. You earn partner fees. Everyone wins.


Installation

npm install @danaszova/avax-router-sdk

Quick Start

30-Second Example (Copy & Paste)

import { AvaxRouter } from '@danaszova/avax-router-sdk';

const router = new AvaxRouter();

// Get the best quote across all DEXes
const quote = await router.getBestQuote({
  tokenIn: 'AVAX',
  tokenOut: 'USDC', 
  amountIn: '1.0',
});

console.log(`You get: ${quote.amountOutFormatted} USDC`);
console.log(`Best DEX: ${quote.bestDex}`);
console.log(`Savings: ${quote.savingsVsWorst}% vs worst route`);

React Example

import { useQuote, useSwap } from '@danaszova/avax-router-sdk/react';

function SwapWidget() {
  const { quote, loading } = useQuote({
    tokenIn: 'AVAX',
    tokenOut: 'USDC',
    amountIn: '1.0',
  });

  const { swap } = useSwap();

  if (loading) return <div>Finding best price...</div>;

  return (
    <div>
      <h2>Best Price: {quote?.amountOutFormatted} USDC</h2>
      <p>via {quote?.bestDex}</p>
      <button onClick={() => swap(quote, signer)}>Swap</button>
    </div>
  );
}

API Reference

Core SDK

new AvaxRouter(config?)

Create a new router instance.

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiUrl | string | Production API | Custom API endpoint | | partnerId | string | - | Your partner ID for fee sharing | | partnerAddress | string | - | Address to receive partner fees | | partnerFeeBps | number | 0 | Partner fee in basis points (max: 50 = 0.50%) |

router.getBestQuote(params)

Get the best quote across all supported DEXes.

const quote = await router.getBestQuote({
  tokenIn: 'AVAX',      // Token symbol or address
  tokenOut: 'USDC',     // Token symbol or address
  amountIn: '1.0',      // Amount as string
  slippagePercent: 0.5, // Optional, default 0.5%
});

Returns:

{
  amountOut: string;          // Raw output amount
  amountOutFormatted: string; // Human-readable amount
  bestDex: string;            // DEX with best price
  route: string[];            // Swap route path
  priceImpact: number;        // Price impact %
  savingsVsWorst: number;     // Savings vs worst DEX
}

router.getAllQuotes(params)

Get quotes from all DEXes for comparison.

const quotes = await router.getAllQuotes({
  tokenIn: 'AVAX',
  tokenOut: 'USDC',
  amountIn: '1.0',
});

quotes.forEach(q => {
  console.log(`${q.dex}: ${q.amountOutFormatted}`);
});

router.swap(params, signer)

Execute a swap with the best route.

import { ethers } from 'ethers';

const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const result = await router.swap({
  tokenIn: 'AVAX',
  tokenOut: 'USDC',
  amountIn: '1.0',
  slippagePercent: 0.5,
}, signer);

console.log(`TX: ${result.txHash}`);

router.getSupportedTokens()

Get list of all supported tokens.

router.getSupportedDexes()

Get list of all supported DEXes.


React Hooks

useQuote(params)

React hook for fetching quotes with auto-refresh.

const { 
  quote,           // Best quote
  quotes,          // All DEX quotes
  loading,         // Loading state
  error,           // Error object
  refetch          // Manual refetch function
} = useQuote({
  tokenIn: 'AVAX',
  tokenOut: 'USDC',
  amountIn: '1.0',
  autoFetch: true,          // Auto-fetch on mount
  refreshInterval: 10000,   // Refresh every 10s
});

useSwap(config?)

React hook for executing swaps.

const { 
  swap,      // Execute swap function
  txHash,    // Transaction hash after swap
  loading,   // Loading state
  error,     // Error object
  reset      // Reset state
} = useSwap({
  partnerId: 'your-id',
  partnerFeeBps: 25,
});

// Execute
await swap({
  tokenIn: 'AVAX',
  tokenOut: 'USDC',
  amountIn: '1.0',
}, signer);

useTokenPrice(token)

Get real-time token price.

const { price, loading, error } = useTokenPrice('AVAX');

useWallet()

Get wallet connection state.

const { address, isConnected, chainId } = useWallet();

💰 Partner Fees (Monetize Your App!)

Earn up to 0.50% on every swap through your integration:

const router = new AvaxRouter({
  partnerId: 'my-dapp',
  partnerAddress: '0xYourAddress',
  partnerFeeBps: 25, // 0.25% fee
});

| Daily Volume | Your Fee (0.25%) | Monthly Earnings | |--------------|------------------|------------------| | $10,000 | $25/day | $750 | | $100,000 | $250/day | $7,500 | | $1,000,000 | $2,500/day | $75,000 |


Supported DEXes

| DEX | Type | Status | |-----|------|--------| | Trader Joe V1 | AMM | ✅ Live | | Trader Joe V2 | Liquidity Book | ✅ Live | | Pangolin | AMM | ✅ Live |


Token Addresses

import { AVALANCHE_TOKENS } from '@danaszova/avax-router-sdk';

AVALANCHE_TOKENS.AVAX;   // Native
AVALANCHE_TOKENS.WAVAX;  // 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7
AVALANCHE_TOKENS.USDC;   // 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
AVALANCHE_TOKENS.USDT;   // 0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7
AVALANCHE_TOKENS.JOE;    // 0x6e84a6216eA6dACC71eE8E6b0a5B7322EEbC0fDd
AVALANCHE_TOKENS.PNG;    // 0x60781C2586D68229fde47564546784ab3fACA982

TypeScript Support

Full TypeScript support with exported types:

import type { 
  Quote,
  SwapParams,
  SwapResult,
  AvaxRouterConfig,
  Token,
  Dex,
  UseQuoteOptions,
  UseSwapOptions,
} from '@danaszova/avax-router-sdk';

Bundle Size

| Format | Size | Gzipped | |--------|------|---------| | ESM | ~7KB | ~2.5KB | | CJS | ~8KB | ~2.8KB |

Tree-shakeable! Import only what you need.


Requirements

  • Node.js >= 16
  • React >= 18 (for React hooks)
  • ethers >= 6 (for swap execution)

Framework Examples

Next.js App Router

// app/api/quote/route.ts
import { AvaxRouter } from '@danaszova/avax-router-sdk';

const router = new AvaxRouter();

export async function GET(req: Request) {
  const { searchParams } = new URL(req.url);
  const quote = await router.getBestQuote({
    tokenIn: searchParams.get('from')!,
    tokenOut: searchParams.get('to')!,
    amountIn: searchParams.get('amount')!,
  });
  return Response.json(quote);
}

wagmi/viem

import { useAccount, useWalletClient } from 'wagmi';
import { useQuote } from '@danaszova/avax-router-sdk/react';

function SwapComponent() {
  const { data: walletClient } = useWalletClient();
  const { quote } = useQuote({ tokenIn: 'AVAX', tokenOut: 'USDC', amountIn: '1' });
  // Use walletClient to sign transactions
}

License

MIT © AVAX Router Team


Built with ❤️ on Avalanche

Website · Docs · Twitter · Discord