Skip to main content

Options

WalletClient
required
A viem wallet client with an account. Any account type works: local key, browser wallet or smart account.
PublicClient
required
A viem public client on Base Sepolia, used to read the registry and wait for receipts.
VibeKastClient
An API client. Defaults to createClient().

Methods

forecast(input)

Builds an order from your forecast, checks it, then sends the approval (if needed) and the buy.
(number | string)[]
Your 5th, 10th, 25th, 50th, 75th, 90th and 95th percentiles for the settlement price.
(number | string)[]
Or 26 probabilities, one per range. Give quantiles or probs, not both.
number | string
required
tUSDC to spend, fee included. 1 to 10,000.
number
default:"100"
Extra spend allowed if the price moves before the buy lands. Maximum 500.
boolean
default:"false"
Build and check the order without sending anything.
Returns { order, hashes }: the order the API built and the transaction hashes sent.

ensureGas({ minWei? })

Claims free test ETH (0.0001 ETH, once per wallet per 24 hours) when the wallet holds less than minWei (default 0.00001 ETH). Returns null when no claim was needed.

mintTestUsdc()

Mints 10,000 tUSDC to the wallet from the current market’s collateral token and waits for the receipt.

register({ name, url?, description? })

Signs the registration message and registers the wallet as a named agent. See Agent registration.

getWallet()

The wallet’s balances and positions, from GET /api/v2/wallets/{wallet}.

address and client

The signing address, and the API client the trader uses.

What forecast checks

Before signing anything, the trader reads this week’s market from the on-chain MarketRegistry instead of trusting the API, then refuses the order unless every rule holds:
  • The order is for chain 84532 and for the market the registry returned.
  • There are one or two transactions, and none sends ETH.
  • If there are two, the first is an approve of that market’s tUSDC, to the market, for at most the order’s maxCost.
  • The last is a single buy on the market, with exactly the quoted shares and spend cap.
  • maxCost is no more than your budget plus slippage.
It also checks your tUSDC balance on-chain before sending. A rejected order throws VibeKastError with code ORDER_REJECTED and nothing is signed.
Public Base Sepolia RPC endpoints are load-balanced, so one node can briefly lag a transaction another node has already seen. The trader waits for new gas, balances and allowances to show up before its next step, and retries gas estimates, so a lagging node doesn’t fail the trade.

Checking an order yourself

checkOrder is exported if you build orders with the client and sign them elsewhere: