@problee/trading-sdk
v0.2.8
Published
Trading-only SDK for Problee prediction markets. Quotes, simulation, calldata preparation, checkout sessions, status, balances, positions, and builder metrics.
Maintainers
Readme
@problee/trading-sdk
Trading-only SDK for Problee markets and Builder hosted checkout.
The canonical Builder Trading contract is the generated OpenAPI document at
https://api.problee.com/api/builder/v1/openapi.json. Treat the TypeScript
types in this package as generated OpenAPI 3.1 mirrors with hand-authored
ergonomic wrappers. Agent/server trading remains separate at
https://api.problee.com/api/agent/v1/openapi.json.
Hosted checkout can trade both auto-priced markets and order book markets; it
does not create markets.
Registry status:
@problee/trading-sdkreleases with the lockstep SDK surface. Install the package or integrate directly against the Builder OpenAPI contract.
import { createTradingClient } from "@problee/trading-sdk";
const client = createTradingClient({ apiKey: process.env.PROBLEE_API_KEY! });
const quote = await client.quote({
chainId: 480,
marketAddress: "0x...",
tradeType: "buy",
side: 0,
amountWei: "1000000000000000000",
collateralToken: "PRB",
});Builder setup and hosted checkout are also exposed without market creation or admin surfaces:
const integration = await client.integrations.create({
name: "Partner app",
environment: "production",
allowedOrigins: ["https://partner.example"],
allowedChains: [480],
allowedCollaterals: ["PRB", "WLD", "USDC"],
});
await client.integrations.verifyOrigin(integration.publicIntegrationId, "https://partner.example");
const walletProfile = await client.integrations.createWalletAuthProfile(
integration.publicIntegrationId,
{
name: "Partner Web3Auth",
provider: "web3auth",
web3AuthClientId: "YOUR_WEB3AUTH_CLIENT_ID",
web3AuthNetwork: "sapphire_mainnet",
allowedCheckoutOrigins: ["https://problee.com"],
loginMode: "custom_jwt",
allowedAuthConnectionIds: ["partner-jwt"],
jwt: {
issuer: "https://issuer.partner.example",
audience: "web3auth-audience",
jwksUrl: "https://issuer.partner.example/.well-known/jwks.json",
subjectClaim: "sub",
verifierIdField: "sub",
},
},
);
const session = await client.builder.createCheckoutSession({
publicIntegrationId: integration.publicIntegrationId,
chainId: 480,
marketAddress: "0x...",
tradeType: "buy",
side: 0,
amountWei: "1000000000000000000",
collateralToken: "PRB",
expectedWalletAddress: "0xuser...",
walletProviderHint: "web3auth",
walletAuthProfileId: walletProfile.walletAuthProfileId,
});Read metrics from the Builder contract:
const metrics = await client.builder.metrics({
from: "2026-05-01T00:00:00.000Z",
});
console.log(metrics.checkout.sessionsCreated);This package does not create markets, resolve markets, or expose consumer-only
endpoints. API keys are server-only. Browser trading should use
@problee/widget or /v3/embed.js, which launch hosted checkout with public
integration IDs and short-lived trade tokens. For Web3Auth/Gmail users,
same-wallet checkout requires the partner's Web3Auth client/config/network/
connection profile; Problee blocks execution when the connected wallet does not
match expectedWalletAddress. Wallet signing remains user-controlled unless an
agent uses its own wallet.
