TypeScript SDK for Hyperhook — hourly BTC UP/DOWN markets on a Uniswap v4 hook.
Read market state and curve quotes off-chain, build transaction calldata with viem, and sign with any wallet. The SDK does not send transactions or hold keys.
npm install github:CrimsonLuckyLabs/hyperhook-sdk viemOr in package.json:
{
"dependencies": {
"@hyperhook/sdk": "github:CrimsonLuckyLabs/hyperhook-sdk",
"viem": "^2"
}
}git clone https://github.com/CrimsonLuckyLabs/hyperhook-sdk.git
cd hyperhook-sdk
npm install
npm run buildimport {
createHyperhookClient,
applySlippageBps,
defaultDeadline,
} from "@hyperhook/sdk";
const client = createHyperhookClient({ chainId: 1 });
const market = await client.getMarket();
console.log(market.epoch, market.tradingOpen);
console.log("UP spot (USDC):", Number(market.curve.upSpotWei) / 1e6);
const amount = 3_000_000n; // $3 USDC (6 decimals)
const quote = await client.quoteBuy({ side: "up", collateralAmount: amount });
const tx = client.buildBuyTx({
side: "up",
amount,
minNetOut: applySlippageBps(quote.tokensOut, 100),
deadline: defaultDeadline(),
});
// Pass tx.to + tx.data to your wallet (viem, ethers, MetaMask, etc.)| API | Description |
|---|---|
getMarket() |
Epoch, strike, trading open, curve spots, token addresses, floor |
getCurveState() |
Raw curve inputs for custom quotes |
getUserPosition(address, epoch?) |
hhUP / hhDOWN stake for an account |
quoteBuy({ side, collateralAmount }) |
Outcome tokens for a USDC buy |
quoteSellOpen({ side, tokenAmount }) |
USDC proceeds for an open-epoch sell |
buildBuyTx / buildSellOpenTx |
Calldata for curve trades |
buildRedeemWinnerTx |
Claim winner after epoch (+ tax window rules on-chain) |
buildSellWinnerWithTaxTx |
Early winner exit with decay tax |
buildClaimConsolationTx |
Loser consolation claim |
buildRedeemAtFloorTx |
Burn $HYPERHOOK for backing USDC |
buildApproveCollateralTx |
ERC20 approve Hyperhook to spend USDC |
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const wallet = createWalletClient({
account,
chain: mainnet,
transport: http("https://ethereum.publicnode.com"),
});
const client = createHyperhookClient({ chainId: 1 });
const allowance = await client.getCollateralAllowance(account.address);
if (allowance < amount) {
const approve = client.buildApproveCollateralTx({ amount: 2n ** 256n - 1n });
await wallet.sendTransaction({ ...approve, account });
}
const buy = client.buildBuyTx({ side: "up", amount, minNetOut, deadline: defaultDeadline() });
await wallet.sendTransaction({ ...buy, account });Mainnet defaults are bundled. For other hooks or chains:
import { createHyperhookClientAsync } from "@hyperhook/sdk";
const client = await createHyperhookClientAsync({
chainId: 1,
hook: "0xYourHyperhookAddress",
rpcUrl: "https://your-rpc.example",
});| Address | |
|---|---|
| Hyperhook | 0x9aEF5dd3Be8ff4746e62946b85C5948CDD92C488 |
| USDC | 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 |
| Default RPC | https://ethereum.publicnode.com |
npm run build # compile to dist/Peer dependency: viem ^2.
MIT — see LICENSE.