Skip to content

Quote API

Hooks can change swap output: charge a fee, rebate tokens, or replace the curve entirely. A quote computed from pool liquidity alone can be wrong for a hooked pool. HookKit quotes with the onchain V4Quoter (0x8dc178efb8111bb0973dd9d722ebeff267c98f94), which simulates the real swap through the PoolManager, so the pool’s hook runs exactly as it would on chain.

GET /v1/quote?poolId=&tokenIn=&amount=&exactOut=false&hookData=0x
POST /v1/quote
Field Required Notes
poolId one of 32-byte PoolId of an indexed pool
currency0, currency1, fee, tickSpacing, hooks one of The pool key, for any pool
tokenIn no Input token address. Must be one of the pool’s currencies
zeroForOne no Alternative to tokenIn. Default true (currency0 in)
amount yes Decimal string in token units, e.g. "0.01". Input amount, or output amount when exactOut
exactOut no true to quote the input needed for an exact output. Default false
hookData no Bytes passed to the hook. Default 0x
Terminal window
curl -X POST https://api.hookkit.dev/v1/quote \
-H "content-type: application/json" \
-d '{
"currency0": "0x0000000000000000000000000000000000000000",
"currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
"fee": 500,
"tickSpacing": 10,
"tokenIn": "0x0000000000000000000000000000000000000000",
"amount": "0.01"
}'
{
"poolId": "0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",
"zeroForOne": true,
"exactOut": false,
"tokenIn": { "address": "0x0000000000000000000000000000000000000000", "symbol": "ETH", "name": "Ether", "decimals": 18 },
"tokenOut": { "address": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168", "symbol": "USDG", "name": "Global Dollar", "decimals": 6 },
"amountIn": "0.01",
"amountOut": "23.204353",
"amountInRaw": "10000000000000000",
"amountOutRaw": "23204353",
"executionPrice": 2320.4353,
"gasEstimate": "42553",
"hooked": false
}

The same call against a dynamic-fee pool whose hook has afterSwap and afterSwapReturnDelta. The hook runs inside the quote, and the much higher gasEstimate reflects it.

Terminal window
curl "https://api.hookkit.dev/v1/quote?poolId=0x641df1e1715c14a6ed27188b42f1b0ac0cc58dc8ce86ca18fd1810addb97eddc&tokenIn=0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73&amount=0.001"
{
"poolId": "0x641df1e1715c14a6ed27188b42f1b0ac0cc58dc8ce86ca18fd1810addb97eddc",
"zeroForOne": true,
"exactOut": false,
"tokenIn": { "address": "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73", "symbol": "WETH", "name": "WETH", "decimals": 18 },
"tokenOut": { "address": "0xe8C701e699e6027654A5634732EC67914BD13Ba3", "symbol": "LARP", "name": "Live Action Roleplay", "decimals": 18 },
"amountIn": "0.001",
"amountOut": "18464680.431194936202548221",
"amountInRaw": "1000000000000000",
"amountOutRaw": "18464680431194936202548221",
"executionPrice": 18464680431.194935,
"gasEstimate": "962269",
"hooked": true
}
Field Meaning
amountIn, amountOut Decimal strings, already scaled by token decimals
amountInRaw, amountOutRaw Raw integer amounts
executionPrice amountOut / amountIn in token units, including LP fee, hook effects, and price impact
gasEstimate Gas the V4Quoter measured for the swap, hook included
hooked Whether the pool has a hook

If the simulated swap reverts, the API returns 422 no_route:

{
"error": {
"code": "no_route",
"message": "Quote reverted: no liquidity in range, the hook rejected the swap, or the amount exceeds the pool (revert 0x6190b2b0)"
}
}

The revert selector is included so you can match it against the hook’s custom errors. Common causes: no liquidity in range, a hook that only allows certain senders or requires specific hookData, or an amount larger than the pool can fill.

import { HookKit, HookKitError } from "@hookkit/sdk"
const hookkit = new HookKit()
try {
const q = await hookkit.quote({
poolId: "0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",
tokenIn: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
amount: "25",
})
console.log(`${q.amountIn} ${q.tokenIn.symbol} -> ${q.amountOut} ${q.tokenOut.symbol}`)
} catch (e) {
if (e instanceof HookKitError && e.code === "no_route") {
// the hook or the pool rejected this swap
}
}