HOOK use-trade
useTrade
Place and cancel HIP-4 prediction market orders. Takes ExchangeClient (NOT HIP4Client) — create with new ExchangeClient({ transport, wallet }). Returns { buy(params), sell(params), cancel(asset, oid), isSubmitting, lastResult, error }. TradeParams: { coin, asset, shares, price, tif?, markPx?, builder? }.
Install
$
npx shadcn@latest add https://ui.purrdict.xyz/r/use-trade.json Signature
useTrade(client?: HIP4Client, signer: HIP4Signer) Returns
{ buy, sell, cancel, isSubmitting, error } Usage
const { buy, sell, cancel } = useTrade(client, signer)
await buy({
coin: market.yesCoin,
shares: 20,
price: 0.55,
}) Dependencies
npm packages
Registry components