Installation

Install the SDK and its peer dependency. The whole setup takes under 5 minutes.

Install

npm install @taurusswap/sdk algosdk

Or with yarn / pnpm:

yarn add @taurusswap/sdk algosdk
pnpm add @taurusswap/sdk algosdk

algosdk ^3.0.0 is a peer dependency — it must be installed separately so your app controls the version. The SDK was built against algosdk v3.

TypeScript Configuration

The SDK uses BigInt literals and ES2020 features. Your tsconfig.json must target ES2020 or later:

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["ES2020"],
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "esModuleInterop": true
  }
}

If you're using Next.js 13+, these are already the defaults — no changes needed.

Quickstart

The fastest way to verify the installation. This reads pool state from testnet and prints the current reserves:

import { TaurusClient } from '@taurusswap/sdk';

const client = new TaurusClient(); // defaults to testnet AlgoNode

async function main() {
  const pool = await client.getPoolState();

  console.log('Tokens in pool:', pool.n);
  console.log('Token ASA IDs:', pool.tokenAsaIds);
  console.log('Total TVL (microunits):', pool.actualReservesRaw.reduce((a, b) => a + b, 0n));

  // Format as USD (all stablecoins, 6 decimals)
  const tvlUsd = pool.actualReservesRaw.reduce((sum, r) => sum + Number(r), 0) / 1e6;
  console.log('Total TVL (USD):', tvlUsd.toFixed(2));
}

main().catch(console.error);

Custom Configuration

Pass a TaurusClientConfig to TaurusClient to point at different endpoints or your own pool:

import { TaurusClient, type TaurusClientConfig } from '@taurusswap/sdk';

const config: TaurusClientConfig = {
  // Algod — defaults to https://testnet-api.algonode.cloud
  algodUrl:   'https://mainnet-api.algonode.cloud',
  algodToken: '',              // empty string for AlgoNode public endpoint

  // Indexer — defaults to https://testnet-idx.algonode.cloud
  indexerUrl: 'https://mainnet-idx.algonode.cloud',

  // Pool — defaults to 758284478 (testnet)
  poolAppId: 123456789,

  // Pool state cache TTL in milliseconds (default 10 000 = 10s)
  // Set to 0 to disable caching entirely
  cacheTtlMs: 15_000,
};

const client = new TaurusClient(config);

Using the Low-Level API

If you already have an algosdk.Algodv2 instance (e.g. from your wallet adapter), you can skip TaurusClient and call functions directly:

import { readPoolState, getSwapQuote } from '@taurusswap/sdk';
import algosdk from 'algosdk';

const algod = new algosdk.Algodv2('', 'https://testnet-api.algonode.cloud');
const POOL_APP_ID = 758284478;

const pool  = await readPoolState(algod, POOL_APP_ID);
const quote = getSwapQuote(pool, 0, 1, 10_000_000n); // synchronous!
console.log('amountOut:', quote.amountOut);

Environment Variables (Next.js)

Recommended pattern for Next.js apps:

// lib/taurus.ts
import { TaurusClient } from '@taurusswap/sdk';

export const taurusClient = new TaurusClient({
  algodUrl:   process.env.NEXT_PUBLIC_ALGOD_URL  ?? 'https://testnet-api.algonode.cloud',
  algodToken: process.env.NEXT_PUBLIC_ALGOD_TOKEN ?? '',
  indexerUrl: process.env.NEXT_PUBLIC_INDEXER_URL ?? 'https://testnet-idx.algonode.cloud',
  poolAppId:  Number(process.env.NEXT_PUBLIC_POOL_APP_ID ?? 758284478),
});

Troubleshooting

"BigInt is not supported"

Your tsconfig target is below ES2020. Set "target": "ES2020" and add "ES2020" to the lib array.

"Cannot find module '@taurusswap/sdk'"

rm -rf node_modules package-lock.json
npm install

Box not found errors on fresh pools

A pool with no liquidity yet may not have all boxes initialised. The SDK returns empty arrays gracefully — always check pool.ticks.length before quoting.