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

@minswap/sdk-v2

v1.0.0

Published

TypeScript SDK for the Minswap API: tokens, pools, aggregator swaps, farms, and MIN staking

Downloads

79

Readme

@minswap/sdk-v2

A TypeScript SDK for the Minswap API. Construct one instance and reach each area through its module: tokens, pools, aggregator swaps, liquidity (add/remove/zap), farms, MIN staking, portfolio, and orders.

The SDK is an API client — it never signs or submits transactions. Action methods return CBOR for you to sign with your own wallet.

Install

pnpm add @minswap/sdk-v2
# or: npm install @minswap/sdk-v2

Runs in Node and the browser on native fetch; no heavyweight chain library is pulled in. Farm and staking actions need a wallet's UTxOs — see Chain access — which is the only part that may need extra setup.

Quick start

import { MinswapSdk } from "@minswap/sdk-v2";

const sdk = new MinswapSdk();

// Reads
const ada = await sdk.token.getById("lovelace");
const pools = await sdk.pool.list({ sortBy: "tvl_usd", limit: 20 });
const positions = await sdk.portfolio.getDefi("addr1...");

// Aggregator swap: quote, build, sign yourself, submit
const quote = await sdk.aggregator.estimate({
  amount: "1000000",
  tokenIn: "lovelace",
  tokenOut: "29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c6.4d494e",
  slippage: 0.5,
});
const { cbor } = await sdk.aggregator.buildTx({
  sender: "addr1...",
  estimate: { amount: "1000000", tokenIn: "lovelace", tokenOut: quote.tokenOut, slippage: 0.5 },
  minAmountOut: quote.minAmountOut,
});
// sign `cbor` with your wallet, then:
// await sdk.aggregator.submitTx({ cbor, witnessSet });

Configuration

const sdk = new MinswapSdk({
  network: "mainnet",        // default
  currency: "USD",           // or "ADA"; per-call overridable
  apiKey: process.env.MINSWAP_API_KEY, // raises the rate limit
  timeoutMs: 30_000,
  retry: { retries: 2, baseDelayMs: 300 },
  // endpoints: { appApiUrl, aggregatorApiUrl, keyAppApiUrl }, // for staging/local
  // fetch: customFetch,     // inject for tests or non-global fetch
  // rpcProvider,            // required only by farm/staking actions
});

Modules

| Module | What it does | | --- | --- | | sdk.token | getById, getByIds, list, getOhlc, getTradeHistory | | sdk.pool | list, getById, getByIds, getOhlc, getEvents | | sdk.portfolio | getDefi — a wallet's LP, farm, and staking positions | | sdk.order | getHistory — DEX order history across protocols | | sdk.aggregator | estimate, buildTx, submitTx, cancelOrders, getPendingOrders | | sdk.liquidity | addLiquidity, removeLiquidity, zapIn, zapOut — across DEX V2, V1, Stableswap | | sdk.farm | list, getPositions, deposit, withdraw, harvest, emergencyWithdraw | | sdk.staking | list, getPositions, stake, unstake |

farm.deposit and farm.withdraw branch for you — a first deposit versus adding to a stake, a partial withdrawal versus withdrawing all — based on your current position. staking routes tiered versus flexible automatically. liquidity resolves the pool and version from a pair (or LP token) + amount + slippage; orders are built client-side and need the optional @minswap/internal-sdk peer (see Chain access).

Documentation

Per-module reference, each with every function, description, usage, and examples:

Chain access

Farm and staking actions build transactions that spend the wallet's UTxOs, so the SDK needs to know what the wallet holds. Supply an RpcProvider:

import { MinswapSdk, KupoRpcProvider } from "@minswap/sdk-v2";

const sdk = new MinswapSdk({
  rpcProvider: new KupoRpcProvider({ url: "https://your-kupo:1442" }),
});

KupoRpcProvider turns Kupo UTxOs into the CBOR the API expects. That requires a Cardano serializer, which it loads from the optional peer dependency @minswap/internal-sdk:

pnpm add @minswap/internal-sdk

That serializer ships Node-targeted WebAssembly, so KupoRpcProvider's default path is Node-only. In a browser, either supply your own KupoSerializer, or implement the small RpcProvider interface against a server that returns already-serialized UTxOs. Reads (token, pool, portfolio, order, aggregator quotes) never need any of this.

Errors

Every failure throws a MinswapError with a typed code and matching details:

import { MinswapError, MinswapErrorCode } from "@minswap/sdk-v2";

try {
  await sdk.token.getById(id);
} catch (e) {
  if (MinswapError.is(e, MinswapErrorCode.RATE_LIMITED)) {
    // e.details.retryAfterMs is typed here
  }
}

Nothing returns null to signal an error. Responses are validated at the boundary, so a backend change surfaces as a located PARSE_ERROR rather than a silent undefined.

Development

pnpm install
pnpm test          # vitest (hermetic — fake fetch, no network)
pnpm run type-check
pnpm run lint
pnpm run build     # tsup -> dist (ESM + CJS + .d.ts)

License

MIT