Scripts

This directory contains utility scripts for the Thetanuts SDK.

Available Scripts

run-mainnet-tests.ts

A standalone script that runs mainnet integration tests without the Vitest framework.

Purpose

  • Quick verification of SDK functionality

  • Simple pass/fail output

  • Doesn't require test framework setup

  • Useful for CI/CD pipelines

Usage

# Via npm
npm run test:mainnet:standalone

# Directly with tsx
npx tsx scripts/run-mainnet-tests.ts

Output

Exit Codes

Code
Meaning

0

All tests passed

1

One or more tests failed

Configuration

The script uses these addresses (defined at top of file):

Tests Performed

Suite
Tests

Client Configuration

Chain ID, OptionBook address, tokens, implementations

ERC20 Module

Decimals for USDC/WETH/cbBTC, balance, allowance

API Module

Fetch orders, protocol stats

Utils Module

Decimal conversions (strike, USDC, price)

OptionBook Module

Compute nonce, get fees

Pricing Module

URL configuration, method availability

NPM Scripts Reference

These scripts are defined in package.json:

Build Scripts

Script
Description

npm run build

Build for production (CJS + ESM + types)

npm run dev

Watch mode build for development

npm run clean

Remove dist/ directory

Test Scripts

Script
Description

npm test

Run all unit tests

npm run test:watch

Run tests in watch mode

npm run test:coverage

Generate coverage report

npm run test:mainnet

Run mainnet integration tests (Vitest)

npm run test:mainnet:standalone

Run mainnet tests (standalone)

Code Quality Scripts

Script
Description

npm run lint

Check for linting errors

npm run lint:fix

Fix auto-fixable lint errors

npm run typecheck

Check TypeScript types

Creating New Scripts

When adding new scripts:

  1. Create the script in scripts/ directory

  2. Use TypeScript with .ts extension

  3. Add shebang for direct execution: #!/usr/bin/env npx tsx

  4. Add npm script to package.json

  5. Document in this README

Example Script Template

Last updated