Quickstart
Get started with taurusSwap in 5 minutes. This guide walks through installing the SDK, connecting to Algorand, reading pool state, and executing your first swap.
Step 1: Install the SDK
npm install @taurus-swap/sdk algosdkThe SDK has algosdkas a peer dependency. Make sure you're using algosdk v3.5.0 or later for full box storage support.
Step 2: Initialize an Algod Client
import algosdk from 'algosdk';
const algodClient = new algosdk.Algodv2(
'YOUR_ALGOD_TOKEN',
'https://testnet-api.algonode.cloud',
''
);
// For mainnet:
// const algodClient = new algosdk.Algodv2(
// 'YOUR_ALGOD_TOKEN',
// 'https://mainnet-api.algonode.cloud',
// ''
// );For local development, use Algorand Sandbox:
const algodClient = new algosdk.Algodv2(
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'http://localhost:4001',
''
);Step 3: Read Pool State
import { readPoolState } from '@taurus-swap/sdk';
const POOL_APP_ID = 758284478; // Testnet deployment
const poolState = await readPoolState(algodClient, POOL_APP_ID);
console.log('Pool state:', poolState);
// {
// n: 5,
// sumX: 12345678901,
// sumXSq: 987654321098765,
// rInt: 50000000,
// sBound: 12345678,
// kBound: 45678901,
// totalR: 62345678,
// virtualOffset: 1000,
// fee_bps: 30,
// numTicks: 3,
// reserves: [1000000000, 2000000000, ...]
// }The reserves array is in microunits. To display in human-readable units, divide by 10⁶ for standard ASA decimals, or use the tokenDecimals map from the pool metadata.
Step 4: Get a Swap Quote
import { getSwapQuote } from '@taurus-swap/sdk';
const quote = await getSwapQuote(
poolState,
{
tokenInIndex: 0, // USDC
tokenOutIndex: 1, // USDT
amountIn: 100_000_000 // 100 USDC (in microunits)
}
);
console.log('Quote:', quote);
// {
// amountOut: 99856432,
// priceImpact: 0.0014,
// fee: 300000,
// ticksCrossed: 0,
// segments: [{ amountIn, amountOut, tickCrossedId: null }]
// }Always show the user priceImpact and amountOut before they sign. The fee is in output token microunits.
Step 5: Execute the Swap
import { executeSwap, buildSwapTransactionGroup } from '@taurus-swap/sdk';
import { Account } from 'algosdk';
const { txGroup, signer } = await buildSwapTransactionGroup(
algodClient,
POOL_APP_ID,
senderAccount,
{
tokenInIndex: 0,
tokenOutIndex: 1,
amountIn: 100_000_000,
minOut: quote.amountOut * 0.995, // 0.5% slippage
claimedOut: quote.amountOut
}
);
const result = await executeSwap(algodClient, txGroup, signer);
console.log('Swap executed:', result);
// {
// confirmedRound: 12345678,
// txId: 'TXID...',
// actualOut: 99856432
// }Next Steps
- Reading Pool State — Deep dive into every field of
PoolState - Quoting Swaps — How the quote engine works, handling stale state
- Adding Liquidity — LP flow with tick parameters and deposit computation
- Try the live app — Execute swaps on testnet with the taurusSwap UI
Note: All examples use testnet. For mainnet, change thePOOL_APP_ID to the mainnet deployment address (seeDeployed Addresses).