Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Quickstart

The six-step integration path. Authenticate, list markets, quote, open, monitor, close.

Start in sandbox. Same API, same contract, test pUSD. Swap api.dimes.fi for api-sandbox.dimes.fi and use a dm_sbx_skey_... key — every example below works as-is. Working reference: dimes-demo-ui.

Using the SDK? Install it: npm install @dimes-dot-fi/sdk. See SDK Installation for setup and peer dependencies. Every SDK snippet below has a runnable, type-checked counterpart in examples/ — start with 01-quickstart.ts.


1. Authenticate

curl -X POST https://api.dimes.fi/v1/prediction-markets/tokens \
  -H "Authorization: Api-Key dm_live_skey_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ "wallet_address": "0x1234...abcd" }'
{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "expires_at": "2026-04-16T11:00:00.000Z"
}

JWTs expire in 1 hour. Full details: Authentication.

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

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

ApiKeyAuth obtains and refreshes JWTs automatically. For client-side code with a JWT already in hand, use JwtAuth — see SDK Installation.

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

const queryClient = new QueryClient();
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>
  );
}

Hooks automatically use whatever QueryClientProvider is in your tree.


2. List markets

curl https://api.dimes.fi/v1/prediction-markets/markets

Each market includes leverage.min_bps, step_bps, and per-side max_yes_bps / max_no_bps — clamp input to those. Full shape: API Reference — Markets.

const { data: markets, hasMore } = await client.getMarkets();

for (const market of markets) {
  console.log(market.ticker, market.leverage.maxYesBps, market.leverage.maxNoBps);
}
import { useMarkets } from "@dimes-dot-fi/sdk/react";

function MarketList() {
  const { data, isLoading } = useMarkets();

  if (isLoading) return <div>Loading...</div>;

  return (
    <ul>
      {data?.data.map((market) => (
        <li key={market.ticker}>{market.title}</li>
      ))}
    </ul>
  );
}

3. Request a quote

Draft first — pricing to show the user, no expiry, no capacity held:

Then promote when the user confirms — this returns the signed, executable quote. Submit it on-chain right away — check expires_at for its validity window:

The promoted response carries pricing, fees, liquidation parameters, and a contract_signature for the on-chain call. Full shape and signature verification: API Reference — Quotes.

POST /quotes does both in one call. It works, but the signature starts expiring while the user is still deciding — use it only for flows with no review step. See API Reference — Create quote.

executeQuote handles the draft → promote flow, retries on market-moved errors, and auto-corrects leverage/collateral/slippage when the API suggests adjustments.

Hook into each stage:

useQuote manages the full state machine: idle → loading-draft → draft-ready → promoting → promoted.


4. Open the position

Two on-chain calls: pUSD.approve(vault, total_user_amount) then vault.createPosition(...) with the quote parameters. After the tx confirms, Multiply acquires tokens, finalizes on-chain, and emits position.opened.

Code examples for Polymarket Safe, Proxy, and Deposit Wallet patterns: On-Chain Integration.

buildCreatePositionTx returns a viem-compatible object (address, abi, functionName, args) — pass it directly to walletClient.writeContract().


5. Monitor positions

Each position carries P&L, mark price, margin health, liquidation price, and accrued fees. Display rules: UI Guidelines.


6. Close

The owner calls vault.requestClose(position_key). Multiply sells tokens, distributes proceeds, emits position.closed. If the market resolves first, settlement is automatic.


What's next

Need help? Telegram link at dimes.fi.

Last updated