Source Code Overview

This directory contains the complete source code for the Thetanuts SDK.

Architecture

src/
├── index.ts           # Main entry point - exports all public APIs
├── abis/              # Smart contract ABIs
├── chains/            # Chain configuration and network support
├── client/            # ThetanutsClient main class
├── modules/           # Feature modules (10 total)
├── types/             # TypeScript type definitions
└── utils/             # Utility functions

Module Architecture Diagram

┌─────────────────────────────────────────────────────────────────┐
│                      ThetanutsClient                            │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │  Configuration: chainId, provider, signer, URLs         │   │
│  └─────────────────────────────────────────────────────────┘   │
├─────────────────────────────────────────────────────────────────┤
│                         MODULES                                 │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐  │
│  │  ERC20   │ │OptionBook│ │   API    │ │  OptionFactory   │  │
│  │  Module  │ │  Module  │ │  Module  │ │     Module       │  │
│  └──────────┘ └──────────┘ └──────────┘ └──────────────────┘  │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐  │
│  │  Option  │ │  Events  │ │WebSocket │ │    PricingV4     │  │
│  │  Module  │ │  Module  │ │  Module  │ │     Module       │  │
│  └──────────┘ └──────────┘ └──────────┘ └──────────────────┘  │
│  ┌──────────┐ ┌──────────────────┐                             │
│  │  Utils   │ │   RFQKeyManager  │                             │
│  │  Module  │ │      Module      │                             │
│  └──────────┘ └──────────────────┘                             │
├─────────────────────────────────────────────────────────────────┤
│                      DEPENDENCIES                               │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐  │
│  │  Types   │ │   ABIs   │ │  Chains  │ │     Utils        │  │
│  └──────────┘ └──────────┘ └──────────┘ └──────────────────┘  │
└─────────────────────────────────────────────────────────────────┘

Entry Point: index.ts

The main entry point (index.ts) exports:

Client

ABIs

Types

All type definitions from ./types/:

  • Client configuration types (client.ts)

  • Common enums and literals (common.ts)

  • OptionBook order and trading types (optionBook.ts)

  • OptionFactory RFQ types (optionFactory.ts)

  • Option position types (option.ts)

  • API response types (api.ts)

  • State API types for RFQ indexer (stateApi.ts)

  • Event types (events.ts)

  • Error types (errors.ts)

  • ERC20 operation types (erc20.ts)

  • WebSocket types (websocket.ts)

  • Pricing types (pricing.ts)

  • Logger interface (logger.ts)

Utilities

Chain Configuration

Data Flow

Read Operations

Write Operations

Build Output

After running npm run build, the dist/ directory contains:

File Size Summary

Directory
Files
Description

abis/

5

Smart contract ABI definitions

chains/

1

Chain configuration (Base mainnet)

client/

2

ThetanutsClient entry point

modules/

10

Feature modules (ERC20, OptionBook, API, OptionFactory, Option, Events, WebSocket, PricingV4, Utils, RFQKeyManager)

types/

13

TypeScript type definitions

utils/

5

Utility functions (decimals, errors, logger, validation)

index.ts

1

Main entry point — exports all public APIs

See Also

Last updated