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

@somnia-react/autonomous-sdk

v0.1.1

Published

TypeScript SDK for deploying and managing Somnia reactive handlers

Readme

@somnia-react/autonomous-sdk

Comprehensive TypeScript SDK for deploying, managing, and monitoring reactive handlers on Somnia. Provides type-safe abstractions for handler deployment, subscription management, and event decoding.

🚀 Features

  • Type-Safe Deployment – Deploy all 6 handler types with automatic verification
  • Fluent Subscription API – Build complex event subscriptions with chainable methods
  • Event Decoding – Parse and type events from handler execution logs
  • Full TypeScript Support – Complete type definitions for all APIs
  • Tested – 67 comprehensive unit tests with 100% coverage of core functionality
  • ESM & CJS – Works in modern and legacy JavaScript environments

📦 Installation

npm install @somnia-react/autonomous-sdk

Or with pnpm:

pnpm add @somnia-react/autonomous-sdk

Or with yarn:

yarn add @somnia-react/autonomous-sdk

📥 Imports & Subpath Exports

The SDK provides multiple entry points for modular imports:

Main Export (Everything)

import {
  deployAutoCompoundHandler,
  createAutoCompoundSubscription,
  createEventDecoder,
} from "@somnia-react/autonomous-sdk";

Deployment Module

import { deployAutoCompoundHandler } from "@somnia-react/autonomous-sdk/deployment";

Subscriptions Module

import { createAutoCompoundSubscription } from "@somnia-react/autonomous-sdk/subscriptions";

Decoders Module

import { createEventDecoder } from "@somnia-react/autonomous-sdk/decoders";

Benefits of subpath imports:

  • Tree-shakeable for smaller bundle sizes
  • Logical organization of functionality
  • Clear API boundaries

🎯 Quick Start

Deploy a Handler

import { deployAutoCompoundHandler } from "@somnia-react/autonomous-sdk/deployment";

const handler = await deployAutoCompoundHandler({
  compoundToken: "0x1234567890123456789012345678901234567890",
  rewardToken: "0x0987654321098765432109876543210987654321",
});

console.log("Handler deployed at:", handler.address);

Create a Subscription

import { createAutoCompoundSubscription } from "@somnia-react/autonomous-sdk/subscriptions";

const subscription = createAutoCompoundSubscription(
  "0x1234567890123456789012345678901234567890",
  150000 // target utilization
);

console.log("Subscription ID:", subscription.id);

Decode Events

import { createEventDecoder } from "@somnia-react/autonomous-sdk/decoders";

const decoder = createEventDecoder();
const event = decoder.parseSuccessEvent(contractLog);

console.log("Event parsed:", event);

📚 Modules

Deployment

Deploy reactive handlers with automatic contract verification and configuration.

Handlers:

  • EventFilterThrottle – Rate-limit event processing
  • AutoCompound – Automated vault compounding
  • CronScheduler – Time-based execution
  • LiquidationGuardian – Protocol safety monitoring
  • CrossCallOrchestrator – Cross-chain message handling
  • UpgradeableReactiveProxy – Upgradeable handler wrapper

Subscriptions

Create and manage event subscriptions with a fluent, chainable API.

Features:

  • Fluent builder pattern for complex subscription configs
  • Event signature validation with support for indexed parameters and tuple types
  • Address filtering with validation
  • Chain ID validation
  • Factory functions for each handler type

Decoders

Parse and decode events from handler execution logs.

Event Types:

  • Success events
  • Error events
  • Execution events
  • Throttle events
  • Scheduled execution events
  • Cross-call events

🔧 API Reference

See docs/api-reference.md for complete API documentation.

💡 Examples

Example 1: Deploy and Subscribe to Auto-Compound Handler

import {
  deployAutoCompoundHandler,
  createAutoCompoundSubscription,
} from "@somnia-react/autonomous-sdk";

// Deploy the handler
const handler = await deployAutoCompoundHandler({
  compoundToken: "0x2260fac5e5542a773aa44fbcff9ffc5ed186a000", // WBTC
  rewardToken: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
});

// Create a subscription to trigger on RewardAdded events
const subscription = createAutoCompoundSubscription(
  handler.address,
  150000 // 150% target utilization
);

console.log(`Handler: ${handler.address}`);
console.log(`Subscription: ${subscription.id}`);

Example 2: Build Complex Subscription

import { SubscriptionBuilder } from "@somnia-react/autonomous-sdk/subscriptions";

const subscription = new SubscriptionBuilder("0x...")
  .onEvent("SwapExactTokensForTokens(uint256,uint256,address[],address,uint256)")
  .fromChain(1) // Ethereum
  .toChain(42161) // Arbitrum
  .withAddress(["0xE592427A0AEce92De3Edee1F18E0157C05861564"]) // Swap router
  .build();

Example 3: Decode Handler Events

import { createEventDecoder } from "@somnia-react/autonomous-sdk/decoders";

const decoder = createEventDecoder();

// Parse logs from handler execution
const logs = [
  /* contract logs from handler execution */
];

for (const log of logs) {
  const event = decoder.parseSuccessEvent(log);
  console.log("Success:", event);
}

🛠️ Development

Build

pnpm build

Outputs:

  • ESM modules: dist/**/*.mjs
  • CommonJS modules: dist/**/*.js
  • Type declarations: dist/**/*.d.ts, dist/**/*.d.mts

Test

pnpm test

Run with coverage:

pnpm test:coverage

📋 Requirements

  • Node.js 18+
  • TypeScript 4.7+
  • ethers.js v6

📝 License

MIT

🗺️ Architecture

src/
├── deployment/          # Handler deployment utilities
│   ├── types.ts        # Deployment type definitions
│   ├── verify.ts       # Contract verification helpers
│   └── deployer.ts     # Deployment functions (6 handlers)
│
├── subscriptions/       # Subscription management
│   ├── types.ts        # Subscription type definitions
│   ├── validators.ts   # Event signature & config validators
│   └── subscription-builder.ts  # Builder class + factory functions
│
└── decoders/           # Event decoding utilities
    ├── types.ts        # Event type definitions
    └── event-decoder.ts # EventDecoder class (8 event types)

📞 Support