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

@dimes-dot-fi/sdk

v1.3.0

Published

TypeScript SDK for the Dimes prediction market API

Readme


Dimes Multiply is a middle-layer protocol that lets trading terminals, wallets, and apps offer up to 10x leveraged exposure on prediction markets (Polymarket) without building internal leverage infrastructure. This SDK gives you a type-safe TypeScript client for the Multiply API, a quote engine with auto-correction, React hooks, and viem-compatible on-chain transaction builders.

Features

  • Full API client — typed methods for markets, quotes, positions, and contract info with automatic camelCase conversion
  • Quote engineexecuteQuote() handles the draft → promote flow, retries on market-moved errors, and auto-corrects leverage/collateral/slippage
  • React hooksuseMarkets(), usePositions(), useQuote(), useContractInfo(), and more — works with your existing TanStack Query setup
  • On-chain builders — viem-compatible transaction data for createPosition, approve, and requestClose
  • Signature verification — verify quote signatures against the contract-info endpoint with per-client caching
  • Auth managementApiKeyAuth auto-obtains and refreshes JWTs; JwtAuth for static or dynamic tokens
  • Error handling — typed DimesApiError with friendly messages, structured hints, and programmatic correction suggestions
  • Tree-shakeable — three entry points, ESM + CJS, zero runtime dependencies beyond humps

Install

npm install @dimes-dot-fi/sdk

Entry Points

| Import | What | Peer deps | |--------|------|-----------| | @dimes-dot-fi/sdk | Client, quote engine, errors, types | — | | @dimes-dot-fi/sdk/react | React hooks + provider | react, @tanstack/react-query | | @dimes-dot-fi/sdk/contract | Tx builders, signature verification | viem |

Quick Start

Client setup

Your backend holds the Dimes API key and exposes an endpoint that generates JWTs for your users (see Authentication). Point JwtAuth at that endpoint — it fetches, caches, and auto-refreshes tokens:

import { DimesClient, JwtAuth } from "@dimes-dot-fi/sdk";

const client = new DimesClient({
  auth: new JwtAuth({
    tokenUrl: "https://your-backend.com/api/dimes-token",
  }),
});

For server-side (Node.js) where you hold the API key directly:

import { DimesClient, ApiKeyAuth } from "@dimes-dot-fi/sdk";

const client = new DimesClient({
  auth: new ApiKeyAuth({
    apiKey: process.env.DIMES_API_KEY,
    walletAddress: "0x1234...abcd",
  }),
});

Browse markets

const { data: markets } = await client.getMarkets();
const market = await client.getMarket("will-btc-hit-100k-2026");

console.log(market.leverage.maxBps); // 100000 (10x)

Execute a quote

import { executeQuote } from "@dimes-dot-fi/sdk";

const result = await executeQuote(client, {
  marketTicker: "will-btc-hit-100k-2026",
  side: "yes",
  collateralUsd: 25,
  leverageBps: 50000, // 5x
  slippageBps: 300,
});

console.log(result.offer.entryPriceUsd);
console.log(result.corrections); // auto-applied adjustments, if any

executeQuote handles the full lifecycle: creates a draft quote, promotes it, retries on market-moved errors, and auto-corrects parameters when the API suggests adjustments. Hook into each stage:

const result = await executeQuote(client, params, {
  onDraftReady: (draft) => showPreview(draft),
  onMarketMoved: (event) => showRetryNotice(event.retryCount),
  onCorrection: (adj) => showAdjustment(adj.field, adj.toLabel),
  maxRetries: 3,
});

Open a position on-chain

import { buildCreatePositionTx, buildApproveTx, verifyOfferSignature } from "@dimes-dot-fi/sdk/contract";

// Verify the quote signature
await verifyOfferSignature(client, result.offer, userAddress);

// Build viem-compatible transactions
const approveTx = buildApproveTx(usdcAddress, vaultAddress, amount);
const createTx = buildCreatePositionTx(result.offer);

await walletClient.writeContract(approveTx);
await walletClient.writeContract(createTx);

Close a position

import { buildRequestCloseTx } from "@dimes-dot-fi/sdk/contract";

const closeTx = buildRequestCloseTx(vaultAddress, positionKey);
await walletClient.writeContract(closeTx);

React

import { DimesClient, JwtAuth } from "@dimes-dot-fi/sdk";
import { DimesProvider } from "@dimes-dot-fi/sdk/react";

const client = new DimesClient({
  auth: new JwtAuth({ tokenUrl: "https://your-backend.com/api/dimes-token" }),
});

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <DimesProvider client={client}>
        <YourApp />
      </DimesProvider>
    </QueryClientProvider>
  );
}

All hooks accept optional queryOptions for full control over caching, polling, and queryClient selection:

import { useMarkets, usePositions, useQuote, useContractInfo } from "@dimes-dot-fi/sdk/react";

function Dashboard() {
  const { data: markets } = useMarkets();
  const { data: positions } = usePositions({ status: "open" });
  const { data: contractInfo } = useContractInfo(); // cached, staleTime: Infinity
  const { state, execute, reset } = useQuote();

  // state.phase: "idle" | "loading-draft" | "draft-ready" | "promoting" | "promoted" | "error"
}

Error Handling

import { DimesApiError, formatErrorMessage, quoteErrorHint, hintAdjustment } from "@dimes-dot-fi/sdk";

try {
  await executeQuote(client, params);
} catch (err) {
  if (err instanceof DimesApiError) {
    // User-friendly message for any error code
    console.log(formatErrorMessage(err.code, err.params));

    // Programmatic correction hints for leverage/collateral/slippage errors
    const hint = quoteErrorHint(err.code, err.params, { leverageBps: params.leverageBps });
    const adj = hintAdjustment(hint, params);
    if (adj) {
      console.log(`Suggestion: adjust ${adj.field} to ${adj.toLabel}`);
    }
  }
}

The SDK's HTTP client automatically retries on 429 (rate limit) with Retry-After support and refreshes auth on 401.

Sandbox

const client = new DimesClient({
  baseUrl: "https://api-sandbox.dimes.fi",
  auth: new ApiKeyAuth({
    apiKey: "dm_sbx_skey_...",
    walletAddress: "0x...",
  }),
});

Same API, same contracts, fake USDC. Get a sandbox key via the Telegram link on dimes.fi.

API Method Reference

| Endpoint | Method | React Hook | |----------|--------|------------| | GET /markets | client.getMarkets() | useMarkets() | | GET /markets/:ticker | client.getMarket(ticker) | useMarket(ticker) | | GET /contract-info | client.getContractInfo() | useContractInfo() | | GET /positions | client.getPositions() | usePositions() | | GET /limits | client.getLimits() | useLimits() | | POST /draft-quotes | client.createDraftQuote() | — | | POST /promoted-quotes/:id | client.promoteDraftQuote() | — | | POST /quotes | client.createQuote() | — | | Draft → Promote (full flow) | executeQuote() | useQuote() | | Cancel position | client.cancelPosition() | useCancelPosition() |

Documentation

Publishing

# Bump version
pnpm version patch   # or minor/major

# Publish (pass the auth token inline to bypass 2FA requirement)
npm publish --access public --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=npm_XXXX

Then update the UI:

cd ~/bl/dimes-ui && pnpm add @dimes-dot-fi/sdk@<version>

License

MIT