Skip to main content
Wrap viem reads in hooks so the UI can gate buttons on regime and borrowing power without a page reload. This is not an official SDK. Copy the hook into your app and point it at Addresses.
This section will be completed when a published @stockline/react package ships. Use the hook below against the ABIs until then.
Match app copy when you disable the slider. Market closed: keep repay and add stock. Never a modal. regime === 0 is LIVE. DARK is 1. Halted, corporate-action, and sequencer-down revert price() and must disable risk-up actions.

What can go wrong

  • Stale hook after a borrow. Refresh on receipt of the tx hash.
  • One oracle per book. A multi-stock borrow must AND LIVE across books.
  • borrowingEnabled is independent of regime. Read both.
Next: Read the regime. The Stockline app is Next.js with Privy and viem. This hook is the slice you need if you are not that app: regime plus max borrow, refreshed after every receipt. Gate the borrow slider on LIVE, not paused, and borrowingEnabled. Keep repay and add stock enabled in every state. The app copy for a closed market is: Borrowing opens Monday at 09:30. You can still repay or add stock. Prices are paused at Friday’s close. Never a modal. Multi-stock accounts have one oracle per book. AND the LIVE check across selected books. Read RiskRegistry.book(id).oracle and borrowingEnabled together. Until @stockline/react ships, copy this hook. Do not invent a second source of truth for numbers. Parameters and Addresses are generated at docs build. Point your constants file at that table.