# Captain Hook: skill file for agents

Captain Hook launches tokens on Uniswap v4 on Robinhood Chain (chain id 4663). Every token has one pool, native ETH / token, whose trading rules ("Hook Blocks") are fixed at launch and enforced by one shared hook. Launch liquidity is locked forever. Site: https://www.captainhook.tech. Human docs: https://www.captainhook.tech/docs.

Ground rules for an agent: reading is free and safe. Buying, selling, launching and claiming send transactions that can't be undone: confirm each one, with its amounts, with your user first.

## Contracts (Robinhood Chain)

New launches go to v2. Tokens launched before it stay on v1, which works the same way with fewer blocks (see "Older tokens (v1)" below). A token's version is the hook in its pool key.

- Hook: `0x4d4fd5a3c6a81e1f729549b511cae7cd0028a8cc`
- Factory (launches): `0x1002eb1195ffc8907ca98a5c559f9666b76ccbcb`
- Router (buys and sells): `0x8d92ff3ea0251990c4203d562c86b37bea60fea6`
- Vault (dev buys and Team Vesting): `0x4a7e17702009ead048231dbff12b0ab1f04a9498`
- Uniswap v4 PoolManager: `0x8366a39CC670B4001A1121B8F6A443A643e40951`

ABIs as JSON: https://www.captainhook.tech/abi/hook-v2.json, https://www.captainhook.tech/abi/factory-v2.json, https://www.captainhook.tech/abi/router-v2.json, https://www.captainhook.tech/abi/vault.json, https://www.captainhook.tech/abi/token.json

## Read a token

1. `factory.keyOf(token)` returns its pool key `(currency0, currency1, fee, tickSpacing, hooks)`: currency0 is native ETH (`0x0`), fee 0, tick spacing 60. If v2's factory doesn't know the token, ask v1's. The pool id is `keccak256(abi.encode(key))`.
2. `hook.pools(poolId)` returns `(creator, launchTime, liquidity)`. A zero creator means it isn't a Captain Hook token.
3. `hook.rulesOf(poolId)` returns `(rules, caps)`, `hook.payoutsOf(poolId)` the payouts, `hook.payeesOf(poolId)` Revenue Router's wallets and shares (up to 8), and `hook.extrasOf(poolId)` Wallet Cap and Exit Clock. Fees, taxes and shares are in pips (1,000,000 = 100%); windows are in seconds; caps are in token units (18 decimals).
   - rules: baseFee, dynamicFee, dynBase, dynMax, dynSensitivity, snipeWindow, snipeStartFee, maxTxWindow, buyTax, sellTax, sandwichGuard, allowlistWindow, payouts, extras
   - caps: snipeMaxBuy (tokens the whole pool may sell per second during Anti-Snipe), maxTxAmount (tokens each wallet may buy, and sell, per second during Max Transaction)
   - payouts: payeeShare, payeeCount, buybackShare, buybackEvery, burnShare
   - extras: walletCapWindow, exitStartFee, exitPeriod, walletCap
4. Anti-Snipe's, Max Transaction's and Wallet Cap's windows start when the Allowlist Phase ends (launchTime + allowlistWindow). During the Allowlist Phase only listed wallets trade: `hook.allowlisted(poolId, wallet)`.
5. The token is a plain ERC-20 (`name`, `symbol`, `totalSupply`, `balanceOf`); its card is in `description()`, `image()`, `website()`, `x()`, `telegram()`.

## Quote and trade

- Quote a buy: `eth_call` `router.buy(key, 0, you, deadline, referrer)` with the ETH as value, from the buyer's address. The return value is the tokens out, after fees, taxes and any Auto Burn. Quote a sell the same way with `router.sell(key, amountIn, 0, you, deadline, referrer)`, once the router is approved.
- Buy: `router.buy(key, minOut, to, deadline, referrer)`, payable. Sell: `token.approve(router, amountIn)`, then `router.sell(key, amountIn, minOut, to, deadline, referrer)`. `referrer` may be `0x0` (see Referrals).
- Set `minOut` from the quote less your slippage (the site uses 3% unless the user picks otherwise). Take `deadline` from the chain's latest block timestamp plus a few minutes, not from a local clock.
- Trading opens the second after launch. Only exact-input swaps work, and a swap that couldn't go through in full is refused.
- Trade through this router: swaps from any other contract can't trade during an Allowlist Phase, can't buy while Wallet Cap is on (RouterOnly), and pay Exit Clock's full starting fee.
- Wallet Cap: while its window lasts, each wallet can buy at most `walletCap` tokens in all (`hook.walletBought(poolId, wallet)` so far, counting the buyer).
- Exit Clock: sells pay an extra fee, in the swap's tax, that falls from exitStartFee to 0 over exitPeriod seconds held (`hook.holdings(poolId, wallet)` gives the amount and average buy time of the wallet's own buys; tokens beyond it, including ones bought for it by another wallet, pay the full start fee). Buy into the wallet you'll sell from.
- Errors: BuyTooLarge (over Anti-Snipe's per-second cap; try smaller or a moment later), SwapTooLarge (over the wallet's Max Transaction cap this second), WalletCapReached, RouterOnly, SameBlockSell (Sandwich Guard: wait a block), NotAllowlisted, NotOpenYet (the launch second), PartialFill (the pool can't fill all of it), TooLittleReceived (price moved past minOut), Expired.

## Referrals

- A trader's first swap that names a `referrer` ties them together for good (`router.referrerOf(trader)`); later ones can't change it, and nobody can refer themselves.
- The referrer gets 10% of the pool fee on that trader's swaps through the router, out of Captain Hook's part, never the trader's or the creator's, and none of Anti-Snipe's launch fee. It's claimed like other earnings.
- Codes: `router.claimCode(code)` (3 to 20 bytes of a-z, 0-9 and hyphens, left-aligned in a bytes32; one per wallet, for good), `router.codeOwner(code)`, `router.codeOf(wallet)`. Links: https://www.captainhook.tech/r/{code} or https://www.captainhook.tech/r/{address}.

## Launch

`factory.launch(params)`, payable: any ETH sent is the creator's dev buy, held by the vault for devLockDays days (1 to 365; 0 means 7). The caller is the creator, so send it from the creator's own wallet, never through a forwarder or multicall contract. `params`:
- name (1 to 48 bytes), symbol (1 to 12), supply (1e18 to 1e33 base units), startMcap (in wei)
- settings: baseFee (500 to 30,000 pips), dynamicFee, dynBase (500 to 30,000), dynMax (5,000 to 100,000, at least dynBase), dynSensitivity (up to 500, in hundredths), snipeWindow (5 to 600 s, or 0 for off), snipeStartFee (up to 500,000), snipeMaxBuy (1,000 to 50,000 pips of supply), maxTxWindow (60 to 86,400 s, or 0), maxTxShare (1,000 to 50,000), walletCapWindow (60 to 86,400 s, or 0), walletCapShare (1,000 to 50,000), buyTax and sellTax (up to 100,000 each), exitStartFee (up to 100,000, or 0), exitPeriod (1 hour to 30 days, in seconds), sandwichGuard, allowlistWindow (10 to 600 s, or 0), buybackShare (50,000 to 1,000,000, or 0), buybackEvery (2 to 50), burnShare (1,000 to 50,000, or 0), vestWallet, vestShare (10,000 to 200,000, or 0), vestCliff (up to 365 days, in seconds), vestDuration (30 to 1,460 days, in seconds), devLockDays (0 to 365)
- meta: description (up to 160 bytes), image (ipfs:// or https://, up to 300), website, x, telegram (up to 120 each)
- payees: Revenue Router's wallets, up to 8 different ones, each with a share in pips of the creator's income, together at most 1,000,000
- allowlist: up to 200 addresses (the creator is always added)
`factory.toRules(settings, payees, supply)` checks the settings without launching: it reverts with `BadSetting(name)` on the first one out of range.

## Earnings

- `hook.claimable(account)` is the ETH a creator, payee or referrer can claim; `hook.claim(to)` sends it.
- Revenue Router's shares wait in each pool's pot (`hook.royalties(poolId)`); `hook.claimFrom(to, poolIds)` shares them out and claims. Anyone can call `hook.distribute(poolId)`.
- `vault.releaseDevTokens(token)` and `vault.releaseVested(token)` send unlocked dev-buy and team tokens to their owner; anyone may call them.

## Older tokens (v1)

Tokens launched before v2 stay on v1: hook `0x50570ee9e8826e04609d7b5e6404efd2634c28cc`, factory `0x9da7ba9ef891c011227900a0eb6150a86aaa3e3f`, router `0x7814ef43c3ff258ceec3857874b9d31d01d69205` (ABIs: https://www.captainhook.tech/abi/hook.json, https://www.captainhook.tech/abi/factory.json, https://www.captainhook.tech/abi/router.json). The same reads and trades work there, with these differences:
- `router.buy(key, minOut, to, deadline)` and `router.sell(key, amountIn, minOut, to, deadline)` take no referrer.
- There's no Wallet Cap or Exit Clock, and no `extrasOf` or `payeesOf`. rules end at payouts, and payouts are team, teamShare, buybackShare, buybackEvery, burnShare (Revenue Split pays one team wallet).
- A dev buy is locked 7 days, and the factory releases dev-buy and team tokens: `factory.releaseDevTokens(token)`, `factory.releaseVested(token)`.
- Launch new tokens on v2.

## Safety report

https://www.captainhook.tech/scan/{address} reports on any token or Uniswap v4 hook in plain words, with a trust score for Captain Hook tokens and a hook score for any hook (method: https://www.captainhook.tech/docs#scores).
