crisp.marketBuy()
Buy with a cash budget through the optimized execution path.
spendAmount is a decimal cash budget, not shares. Uses automatic execution-cell discovery and bounded same-intent fallback. Persist the key and exact input before calling.
trading workflow · All SDK methods
Import and runtime
@crisp-trade/partner-sdk — server only; never expose credentials to the browser.
Client setup and shared behavior
Arguments
| Argument | Presence | Released TypeScript type |
|---|---|---|
user | Required | |
input | Required | |
idempotencyKey | Required | |
options | Optional | |
Named types are expanded under “Exact released types” below. Parameters are in call order; optional does not imply nullable.
Example
Example IDs and intent keys are illustrative. Replace them with authenticated account resources and your persisted intent. Browser route names are example routes you implement on your own backend.
// Use a reused, server-only CrispClient (see client setup).
const result = await crisp.marketBuy(
'user-123',
{
marketId:
'0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
tokenId: '12345678901234567890',
spendAmount: '2.00',
},
'persisted-intent-0001',
);
console.log(result.data.command, result.data.order);Returns
Returns a promise for a typed response wrapper. Inspect data and its state; a resolved request is not necessarily a successful financial outcome.
Return type
Promise<Response<OrderResult>>Errors and lifecycle
Errors and retry policy. Financial uncertainty requires recovery with the original intent, never a new key. Realtime helpers must be stopped on logout/account switch.
Related HTTP operations
Exact released types
Extracted from the shipped SDK 0.13.0, not separately maintained signatures.
Full signature
crisp.marketBuy(user: string, input: {
marketId: string;
tokenId: string;
spendAmount: string;
priceLimit?: string;
}, idempotencyKey: string, options?: OrderOptions): Promise<Response<OrderResult>>OrderOptions
export type OrderOptions = {
signal?: AbortSignal;
traceId?: string;
};Response
export interface Response<T> {
data: T;
status: number;
requestId: string;
retryAfterMs: number | null;
asOf?: string | null;
freshness?: string | null;
}OrderResult
export type OrderResult = Omit<Operations["placeOrder"]["data"], "externalUserId"> & {
externalUserId?: string;
};