0.2.0, which publishes the account and wallet-v2 APIs from f73ee41. Follow Installation for release and Gateway decoder compatibility.
Common conventions
- Addresses are
`0x${string}`values. - Contract integers use
bigint; small enum/bitmap fields usenumberwhere stated. - A write returns a transaction hash. Await a receipt separately.
- Every write accepts optional
accountandsimulate; simulation is enabled by default. - Account methods accept optional
accountCore; otherwise the configured address is used. - Spot methods always receive the market address.
clientOrderIdis optional opaque correlation data, not an idempotency key.
Client construction
createKuruClient(config)
Construct the combined AccountCore and Spot client.
createKuruClient(config)
Construct the combined AccountCore and Spot client.
{ account, spot } focused clients.createAccountClient(config) / createSpotClient(config)
Construct only one focused client.
createAccountClient(config) / createSpotClient(config)
Construct only one focused client.
createKuruClient.Account client
authorizeAccountSignerBySig and revokeAccountSignerBySig add the live authorizer, nonce, deadline, and signature. Use the exported typed-data builders. Child creation uses the root’s next sequence, not a child-address consent signature.
approveErc20 and allowance operate on the token. Native deposits attach value automatically. Writes return transaction hashes; check receipts separately. Request builders provide calldata without sending.
Positive builder fees are ordinary root free balance. Builders use withdraw; there is no separate claim ledger.
Approved payout helpers
UsebuildApprovedWithdrawalTypedData, buildFulfillApprovedWithdrawalRequest, buildInvalidateApprovedWithdrawalNonceRequest, and buildPreviewWithdrawalRequest. A capacity preview is not complete transaction validation. See WithdrawalLimiter.
Spot client
Market conversion
ReadpricePrecision, sizePrecision, and tickSize from getMarketParams. Use viem’s parseUnits and formatUnits with the decimal exponent represented by each power-of-ten precision, then reject prices not divisible by tickSize. See Orders and Cancellation for a complete example.
Spot reads
getMarketParams({ market })
Read precision, tick, notional, and market fee configuration.
getMarketParams({ market })
Read precision, tick, notional, and market fee configuration.
bestBidAsk({ market })
Read best stored bid and ask.
bestBidAsk({ market })
Read best stored bid and ask.
[bid, ask] as numbers. Empty bid is 0xffff_ffff; empty ask is 0.getL2Book({ market, levels })
Read combined visible active and passive depth.
getL2Book({ market, levels })
Read combined visible active and passive depth.
getOrderId({ market, userId, slotIdx })
Read the live order ID in a maker slot.
getOrderId({ market, userId, slotIdx })
Read the live order ID in a maker slot.
0n for an empty slot. Use the value for optimistic concurrency and
wallet expected-ID bindings.getOrderMinSizeAfterBlock({ market, userId, slotIdx })
Read a slot's RAB block threshold.
getOrderMinSizeAfterBlock({ market, userId, slotIdx })
Read a slot's RAB block threshold.
0 when disabled or empty.getPassiveBand({ market, lowPrice })
Read aggregate passive band state.
getPassiveBand({ market, lowPrice })
Read aggregate passive band state.
getPassivePosition({ market, positionId })
Read a passive position.
getPassivePosition({ market, positionId })
Read a passive position.
estimateSwap({ market, userId?, isBuy, amountIn, builderFeePps? })
Estimate an exact-input swap.
estimateSwap({ market, userId?, isBuy, amountIn, builderFeePps? })
Estimate an exact-input swap.
userId applies that account’s effective fee policy. The estimate cannot predict hook side effects or intervening state changes.Orders and swaps
batch({ market, userId, orders, cancelSlotIdxs?, clientOrderId?, builderConfig?[, account, simulate] })
Execute cancellations and native orders.
batch({ market, userId, orders, cancelSlotIdxs?, clientOrderId?, builderConfig?[, account, simulate] })
Execute cancellations and native orders.
buy/sell or enum), quantity, price, TIF, optional execution instruction, and optional minSizeAfterBlock. Inputs are normalized and range-checked before simulation.Returns the transaction hash. Decode TradesPacked and BookUpdatesPacked from the receipt for outcomes.cancelBySlots({ market, userId, cancelSlotIdxs, clientOrderId?[, account, simulate] })
Cancel explicit maker slots through a cancellation-only batch.
cancelBySlots({ market, userId, cancelSlotIdxs, clientOrderId?[, account, simulate] })
Cancel explicit maker slots through a cancellation-only batch.
cancelAllOrders({ market, userId[, account, simulate] })
Cancel all active slots in one market.
cancelAllOrders({ market, userId[, account, simulate] })
Cancel all active slots in one market.
protocolCancelBySlots(...)
Build or submit the protocol-restricted cancellation path.
protocolCancelBySlots(...)
Build or submit the protocol-restricted cancellation path.
cancelBySlots.replaceBySlotPacked({ market, userId, packedOps, clientOrderId?, builderConfig?[, account, simulate] })
Apply packed slot operations.
replaceBySlotPacked({ market, userId, packedOps, clientOrderId?, builderConfig?[, account, simulate] })
Apply packed slot operations.
packedOps with encodePackedReplaceOp(s) and
encodePackedCancelOp; do not hand-build bit layouts in application code.swap({ market, userId, isBuy, amountIn, minAmountOut, deadline, builderConfig?[, account, simulate] })
Execute an exact-input swap.
swap({ market, userId, isBuy, amountIn, minAmountOut, deadline, builderConfig?[, account, simulate] })
Execute an exact-input swap.
build*Request export. Request builders select the exact ABI overload and return unsent call data.
Order encoding
Trading-wallet signing
The wallet namespace prepares and signs contract-compatible EIP-712 payloads; it does not decide TP/SL or TWAP conditions.prepareReplaceBySlotIntent(input) / prepareBatchIntent(input)
Normalize, validate, hash, and build an immediate wallet intent.
prepareReplaceBySlotIntent(input) / prepareBatchIntent(input)
Normalize, validate, hash, and build an immediate wallet intent.
prepareCreateReplaceTriggerIntent(input) / prepareCreateBatchTriggerIntent(input)
Prepare a stored trigger creation intent.
prepareCreateReplaceTriggerIntent(input) / prepareCreateBatchTriggerIntent(input)
Prepare a stored trigger creation intent.
triggerExpiry and opaque conditionHash. Array sizes, slot bindings,
packed payload shape, integer ranges, and header invariants are validated
locally.prepareCancelTriggerIntent(input)
Prepare an unordered-nonce trigger cancellation.
prepareCancelTriggerIntent(input)
Prepare an unordered-nonce trigger cancellation.
signReplaceBySlotIntent / signBatchIntent / signCreateReplaceTriggerIntent / signCreateBatchTriggerIntent / signCancelTriggerIntent
Prepare and sign one wallet intent.
signReplaceBySlotIntent / signBatchIntent / signCreateReplaceTriggerIntent / signCreateBatchTriggerIntent / signCancelTriggerIntent
Prepare and sign one wallet intent.
WalletIntentSigner. The SDK normalizes
the signature, recovers the signer, and rejects a signer that does not match
the delegated wallet address.createLocalAccountWalletIntentSigner(account) / createWalletClientIntentSigner(walletClient, account)
Adapt viem signers to WalletIntentSigner.
createLocalAccountWalletIntentSigner(account) / createWalletClientIntentSigner(walletClient, account)
Adapt viem signers to WalletIntentSigner.
LocalAccount; use the wallet-client adapter for
injected/JSON-RPC wallets.signPreparedWalletIntent(intent, signer) / recoverWalletIntentSigner(typedData, signature)
Low-level signing and verification helpers.
signPreparedWalletIntent(intent, signer) / recoverWalletIntentSigner(typedData, signature)
Low-level signing and verification helpers.
Prepare EIP-7702 delegation authorization.
Prepare EIP-7702 delegation authorization.
tradingWalletDomain, the corresponding build*TypedData functions, hashPackedOperations, hashExpectedOrderIds, hashCancelSlotIndexes, hashNativeOrders, and normalizeAndHashNativeOrders.
Relay client
The SDK contains a transport client and strict request serializers. See Relay for the signing-to-submission flow and Relay API documentation for canonical service endpoints and wire schemas.createKuruRelayClient(config)
Construct a Relay REST client.
createKuruRelayClient(config)
Construct a Relay REST client.
requestChallenge(wallet[, options]) / exchangeToken(challengeId, signature[, options]) / authenticate(options?)
Run challenge-based Relay authentication.
requestChallenge(wallet[, options]) / exchangeToken(challengeId, signature[, options]) / authenticate(options?)
Run challenge-based Relay authentication.
authenticate performs the full challenge, personal-message signature, token
exchange, wallet-match validation, and optional token retention.submit(request[, options])
Validate and submit any already-built Relay request.
submit(request[, options])
Validate and submit any already-built Relay request.
RelayBroadcastResponse or
throws KuruRelayError.Build and submit a typed Relay action in one call.
Build and submit a typed Relay action in one call.
createRequestId / getAccessToken / setAccessToken / clearAccessToken
Manage request correlation and retained authentication state.
createRequestId / getAccessToken / setAccessToken / clearAccessToken
Manage request correlation and retained authentication state.
expiresAt, and explicitly authenticate again when required; the SDK never refreshes a token implicitly.buildExecuteReplaceBySlotRelayRequest, buildExecuteBatchRelayRequest, buildCreateReplaceTriggerRelayRequest, buildCreateBatchTriggerRelayRequest, buildCancelTriggerRelayRequest, and buildAuthorizeAccountSignerRelayRequest. Authentication adapters are createLocalAccountRelaySigner, createWalletClientRelaySigner, resolveRelayAuthenticationWallet, and signRelayChallenge.
Events
decodeKuruEventLog(log[, abi])
Decode one AccountCore, SpotRouter, OrderBook, or trading-wallet log.
decodeKuruEventLog(log[, abi])
Decode one AccountCore, SpotRouter, OrderBook, or trading-wallet log.
{ address, data, topics }. The default ABI is combinedKuruAbi(). It throws when the log does not match; catch only when intentionally scanning mixed receipts.decodeTradesPacked(packedTrades)
Decode concatenated 64-byte trade records.
decodeTradesPacked(packedTrades)
Decode concatenated 64-byte trade records.
decodeBookUpdatesPacked(packedUpdates)
Decode concatenated 39-byte book records.
decodeBookUpdatesPacked(packedUpdates)
Decode concatenated 39-byte book records.
Errors and utilities
Namespaces and ABI exports
The package root re-exports the public functions and types. Namespaced imports are also available asaccount, spot, tradingWallet, relay, events, products, and utils. Contract ABIs are exposed under abi and generated; CONTRACTS_COMMIT identifies the ABI source revision.
Additional wallet-v2 actions
Prepare typed intents withprepareCancelAllIntent, prepareCancelOrdersByIdIntent, prepareFokSwapIntent, prepareCreateFokSwapTriggerIntent, prepareCreateTwapIntent, prepareCancelTwapIntent, or prepareEmitSignedDataIntent. Sign with signPreparedWalletIntent and encode direct calls with buildWalletActionRequest.
buildExecuteTwapSliceRequest and buildFinalizeTwapRequest encode keeper/lifecycle calls. These direct-contract builders do not add hosted Relay endpoints.
Relay encryption helpers
The Relay SDK providesrequestEncryptionKey, encryptRelayPrivateKey, and decryptRelayPrivateKey for the service’s encrypted-key transport. Use the returned encryption key identifier and expiry when preparing a request. This is distinct from owner-signed EIP-712 action submission and is not required for the direct first-trade tutorial.