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

@kamiyo-org/settlement

v1.0.0

Published

Protocol-level settlement for x402 routers. Measurable SLA violations with oracle consensus.

Readme

@kamiyo-org/settlement

Settlement hook for x402 routers.

Installation

pnpm add @kamiyo-org/settlement

Quick Start

import { SettlementClient, ViolationType, createViolation } from '@kamiyo-org/settlement';
import { Connection, Keypair } from '@solana/web3.js';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const wallet = Keypair.generate();

const settlement = new SettlementClient({ connection, wallet });

const violation = createViolation(
  ViolationType.Latency,
  5000,
  15000,
  responseData
);

const result = await settlement.requestSettlement({
  paymentRef: 'x402-payment-tx-signature',
  provider: providerPubkey,
  violation,
});

console.log(result.settlementId, result.refundPercent);

Violation Types

| Type | Description | Default Refund | |------|-------------|----------------| | Timeout | No response | 100% | | ServerError | 5xx response | 100% | | Latency | Response > SLA | 25-75% (scaled) | | Malformed | Invalid format | 75% | | Incomplete | Partial response | 50% | | RateLimit | 429 response | 25% |

Latency Scaling

1-2x SLA → 25% refund
2-3x SLA → 50% refund
>3x SLA  → 75% refund

Settlement Flow

  1. Agent calls requestSettlement() with violation evidence
  2. Provider has 1 hour to respond
  3. Provider accepts → funds redistributed
  4. Provider contests → escalates to oracle voting
  5. No response → auto-resolves in agent's favor

Usage

import { SettlementClient, ViolationType, createViolation } from '@kamiyo-org/settlement';

const settlement = new SettlementClient({ connection, wallet, programId });

async function handleInferenceRequest(req) {
  const startTime = Date.now();

  try {
    const response = await callGpuProvider(req);
    const latency = Date.now() - startTime;

    if (latency > req.sla.maxLatencyMs) {
      await settlement.requestSettlement({
        paymentRef: req.paymentTx,
        provider: req.provider,
        violation: createViolation(
          ViolationType.Latency,
          req.sla.maxLatencyMs,
          latency,
          JSON.stringify(response)
        ),
      });
    }

    return response;
  } catch (error) {
    if (error.code === 'TIMEOUT') {
      await settlement.requestSettlement({
        paymentRef: req.paymentTx,
        provider: req.provider,
        violation: createViolation(
          ViolationType.Timeout,
          req.sla.maxLatencyMs,
          -1,
          error.message
        ),
      });
    }
    throw error;
  }
}

API

SettlementClient

const client = new SettlementClient({
  connection: Connection,
  wallet?: Keypair,
  programId?: PublicKey,
});

await client.checkEligibility(paymentRef: string): Promise<EligibilityResult>
await client.requestSettlement(request: SettlementRequest): Promise<SettlementResult>
await client.getStatus(settlementId: string): Promise<SettlementState | null>
await client.respondToSettlement(settlementId: string, response: SettlementResponse): Promise<SettlementResult>
await client.escalateToOracles(settlementId: string): Promise<SettlementResult>
await client.resolveWithOracleScore(settlementId: string, score: number): Promise<SettlementResult>

Violation Helpers

createViolation(type, expected, actual, evidenceData): Violation
calculateRefund(violation): number
hashEvidence(data): string
validateViolation(violation): { valid: boolean; error?: string }

Oracle Functions

computeCommitmentHash(settlementId, oracle, score, salt): Uint8Array
calculateConsensus(scores): ConsensusResult

Limitless Commit-Reveal Adapter

import {
  LimitlessCommitRevealAdapter,
  computeLimitlessCommitmentHash,
} from '@kamiyo-org/settlement';
import { randomBytes } from 'crypto';

const adapter = new LimitlessCommitRevealAdapter({
  threshold: 3,
  onThresholdReached: async ({ settlementId, consensusScore }) => {
    return settlement.resolveWithOracleScore(settlementId, consensusScore);
  },
});

const settlementId = 'settlement-123';
const oracleId = '0x1111111111111111111111111111111111111111';
const score = 74;
const salt = new Uint8Array(randomBytes(32));

adapter.submitCommitment({
  settlementId,
  oracleId,
  commitmentHash: computeLimitlessCommitmentHash(settlementId, oracleId, score, salt),
});

await adapter.submitAttestation({
  settlementId,
  oracleId,
  score,
  salt,
});

// Optional: retry callback-driven settlement if downstream settlement endpoint was unavailable.
await adapter.finalize(settlementId);

When threshold attestations are revealed, the adapter computes a consensus score (median) and calls onThresholdReached.

Limitless resources:

TypeScript SDK wiring example:

import { ethers } from 'ethers';
import { HttpClient, MarketFetcher, OrderClient } from '@limitless-exchange/sdk';

const httpClient = new HttpClient({
  baseURL: 'https://api.limitless.exchange',
  apiKey: process.env.LIMITLESS_API_KEY,
});
const marketFetcher = new MarketFetcher(httpClient);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!);
const orderClient = new OrderClient({ httpClient, wallet, marketFetcher });

Limitless Verdict Court (Production Layer)

LimitlessVerdictCourt extends commit-reveal into a production settlement pipeline with:

  • weighted quorum (threshold + minWeight)
  • provider diversity requirements (minProviderCount)
  • deterministic verdict receipts (attestationRoot, transcriptHash)
  • resumable state snapshots (exportSnapshot() / importSnapshot())
import {
  LimitlessVerdictCourt,
  computeLimitlessCourtCommitmentHash,
} from '@kamiyo-org/settlement';

const court = new LimitlessVerdictCourt({
  threshold: 3,
  minWeight: 4,
  minProviderCount: 2,
  oracles: [
    { id: '0x1111111111111111111111111111111111111111', provider: 'primary', weight: 2 },
    { id: '0x2222222222222222222222222222222222222222', provider: 'primary', weight: 1 },
    { id: '0x3333333333333333333333333333333333333333', provider: 'backup', weight: 2 },
  ],
  onVerdict: async (verdict) => settlement.resolveWithOracleScore(verdict.settlementId, verdict.oracleScore),
});

const settlementId = 'settlement-123';
const oracleId = '0x1111111111111111111111111111111111111111';
const score = 74;
const confidence = 0.91;
const evidenceHash = 'a'.repeat(64);
const salt = new Uint8Array(randomBytes(32));

court.submitCommitment({
  settlementId,
  oracleId,
  commitmentHash: computeLimitlessCourtCommitmentHash(
    settlementId,
    oracleId,
    score,
    confidence,
    evidenceHash,
    salt
  ),
});

const result = await court.submitAttestation({
  settlementId,
  oracleId,
  score,
  confidence,
  evidenceHash,
  salt,
});

if (result.settlementTriggered) {
  console.log(result.verdict?.attestationRoot);
}

// Optional: retry finalization after temporary settlement callback failures.
await court.finalize(settlementId);

Constants

KAMIYO_PROGRAM_ID    // Mainnet program address
RESPONSE_TIMEOUT_MS  // 1 hour
MIN_ORACLES          // 3
MAX_SCORE_DEVIATION  // 15 points
COMMIT_PHASE_DURATION  // 5 minutes
REVEAL_PHASE_DURATION  // 30 minutes

License

MIT