Python SDK for the Dimes Multiply leverage protocol. Multiply is an embedded leverage layer for prediction markets — it lets traders take leveraged positions on market outcomes across platforms like Polymarket and Kalshi.
pip install dimes-multiplyfrom multiply import MultiplyClient
client = MultiplyClient(api_key="your-api-key")
# Browse prediction markets with leverage
markets = client.get_markets(
platform="polymarket",
status="active",
min_leverage=3,
)
# Open a 5x leveraged long position
result = client.create_position(
market_id=markets.data[0]["id"],
outcome_id=markets.data[0]["outcomes"][0]["id"],
side="long",
collateral_usdc=100,
leverage=5,
)
pos = result.position
print(f"Opened {pos.leverage}x position — notional: ${pos.notional_usdc}")| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str |
required | API key from app.dimes.fi/developers |
base_url |
str |
https://api.dimes.fi/v1 |
API base URL |
chain_id |
int |
137 |
Chain ID (Polygon) |
timeout |
float |
30 |
Request timeout in seconds |
The client can be used as a context manager:
with MultiplyClient(api_key="your-key") as client:
markets = client.get_markets()List available prediction markets with optional filters.
markets = client.get_markets(
platform="polymarket", # Filter by platform
status="active", # "active", "paused", "resolved", "expired"
min_liquidity=10_000, # Minimum USDC liquidity
min_leverage=2, # Minimum leverage available
query="election", # Search query
limit=50, # Results per page (max 200)
offset=0, # Pagination offset
)Get a single market by ID.
Get leverage tiers, margin requirements, and funding rates.
info = client.get_leverage("market_abc123")
print(f"Max leverage: {info.max_leverage}x")
print(f"Funding rate: {info.funding_rate_annualized}%")
for tier in info.tiers:
print(f" {tier.leverage}x — margin: {tier.initial_margin:.0%}")Open a leveraged position.
result = client.create_position(
market_id="market_abc123",
outcome_id="outcome_yes",
side="long", # "long" or "short"
collateral_usdc=100, # Collateral in USDC
leverage=5, # Leverage multiplier
max_slippage=0.01, # 1% slippage tolerance
)Get position details including current PnL.
List all positions. Optionally filter by "open", "closed", or "liquidated".
Close a position fully or partially.
# Close 50% of a position
result = client.close_position("pos_xyz789", fraction=0.5)Get account summary with balance, locked collateral, unrealized PnL, and health factor.
All Pydantic models are importable:
from multiply import (
Market,
Position,
LeverageInfo,
LeverageTier,
CreatePositionParams,
Account,
)See the examples/ directory:
- basic_usage.py — Browse markets, check leverage, open a position
The SDK raises httpx.HTTPStatusError for non-2xx responses:
import httpx
try:
result = client.create_position(...)
except httpx.HTTPStatusError as e:
print(f"API error {e.response.status_code}: {e.response.text}")MIT