AegisHook on Ink
Uniswap v4 Hook Contract 0xe449e013004db4a5681e9622ca10c5ba0ea610cc on Ink · Dynamic fee · Verified contract
- Volume (24h)
- $250.67K
- Value locked (TVL)
- $3.41M
- All-time volume
- $5.43M
- Pools using this hook
- 101
- Swaps (24h)
- 3,363 (137 traders)
- Total swaps
- 49,707
What it does
AegisHook takes a dynamic swap fee on every pool it is attached to, skims a configurable share of swap input as a hook fee, and periodically reinvests those accumulated fees into a full-range liquidity position through the AegisEngine.
How it works step by step
- Sets the swap fee for each pool from the DynamicFeeManager in beforeSwap, capped at ENGINE_MAX_SWAP_FEE_PIPS (0.1%) when the sender is the AegisEngine.
- Charges a hook fee (a percentage of the swap fee, set per pool by the owner) in the input currency by minting ERC-6909 claims on the PoolManager and returning a delta to the swap.
- Accumulates hook fees in _pendingFees and, at most once per REINVEST_COOLDOWN (1 hour), sends them to AEGIS_ENGINE.modifyLiquidity to mint full-range liquidity held by the hook.
- Grows the oracle cardinality of each pool toward TARGET_CARDINALITY on swaps and forwards tick observations to the OracleManager and fee state to the DynamicFeeManager and LimitOrderManager.
- Lets the owner pause reinvestment, set per-pool hook fee rates, and withdraw AegisEngine market shares held by the hook.
- Swap behaviour
- beforeSwap reads the pre-swap tick, obtains the active fee from the DynamicFeeManager, caps it for engine-initiated swaps, and for exact-input swaps returns a before-swap delta that takes the hook fee from the specified input. afterSwap updates the oracle and fee manager, notifies the LimitOrderManager, computes the hook fee for exact-output swaps through the after-swap return delta, attempts reinvestment, and flushes the swap's hook fee into _pendingFees.
- Liquidity behaviour
- No liquidity callbacks.
- Fee behaviour
- The LP fee is set dynamically per swap by the DynamicFeeManager and returned as an override fee flag. A hook fee of hookFeePpm / 1e6 of that swap fee is taken in the input currency and held as ERC-6909 claims, later pooled and reinvested. The owner can set hookFeePpm anywhere from 0 to 100% per pool.
- Owner & admin controls
- The owner (set at deployment to AEGIS_INITIALIZER) can pause and unpause reinvestment, set hookFeePpm for any pool up to 100%, withdraw AegisEngine market shares held by the hook to any address, and transfer or renounce ownership. The contract is not behind a proxy in the provided ABI and no upgrade function is listed. The DynamicFeeManager, OracleManager, LimitOrderManager and AegisEngine are external contracts whose administration is outside this source.
Enabled Uniswap v4 callbacks
afterInitialize, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta
afterInitialize records the pool with the oracle, fee manager and limit order manager and requires a dynamic-fee pool. beforeSwap sets the dynamic fee, grows oracle cardinality, and takes the hook fee on exact-input swaps. afterSwap updates oracle and fee state, takes the hook fee on exact-output swaps, triggers reinvestment and notifies the limit order manager. beforeSwapReturnDelta and afterSwapReturnDelta let the hook take a share of the swap amounts.
Security & trust assessment
Risk level: medium (verified source, high confidence).
Who controls it: The owner key can set any pool's hook fee up to 100%, drain reinvested AegisEngine shares to any address, pause reinvestment and transfer or renounce ownership. Users cannot veto these changes.
Risk to user funds: The hook holds ERC-6909 claims on the PoolManager from hook fees and, after reinvestment, AegisEngine shares for full-range liquidity. It takes a share of each swap's input or output through return deltas. The owner can move the engine shares and set the fee taken from swaps, but the source shows no direct path to withdraw user swap funds.
Security findings
- [high] Owner can raise the hook fee up to 100%: setHookFeePpm accepts any value up to PPM_SCALE (1,000,000), so the owner can set a pool's hook fee to 100% of the swap fee. That charges traders the full swap fee as a hook fee on every swap, with no timelock or cap visible in the source.
- [medium] Owner can withdraw reinvested engine shares: withdrawMarketShares transfers AegisEngine shares for a pool, held by the hook from reinvested fees, to any non-zero address with no timelock. Reinvested liquidity is therefore fully controlled by the owner key.
- [medium] Swap liveness depends on external dependency calls: If DYNAMIC_FEE_MANAGER.prepareSwap reverts, the caught error leaves activeFee at 0 and the swap reverts with InvalidFee. The LimitOrderManager onAfterSwap and onAfterInitialize calls and the PoolManager calls are not wrapped in try/catch, so a revert there blocks swaps or pool initialization. The source says this is intentional.
- [info] Pause does not halt swaps: pause() only stops _tryReinvest. Swaps, fee charging and fee accrual continue while paused, so the pause is not an emergency stop for trading.
- [low] Single-frame transient accumulator: CurrentSwapHookFeeCache assumes at most one active swap frame per pool. The source documents that a nested same-pool swap would misattribute fees. This is safe only while no callback path initiates a same-pool swap, which the code asserts but does not enforce.
Contract details
- Verified source
- Yes (AegisHook)
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Bytecode size
- 11,512 bytes
- Upgradeable proxy
- No
- Detected patterns
- moves-currency, oracle, ownable, pausable, return-delta
Pools using AegisHook
- USD₮0 / WETH (Dynamic fee) — 24h volume $62.59K, TVL $1.02M, 329 swaps today
- WETH / kBTC (Dynamic fee) — 24h volume $58.62K, TVL $317.86K, 197 swaps today
- USDC / kBTC (Dynamic fee) — 24h volume $41.16K, TVL $416.09K, 162 swaps today
- USDC / WETH (Dynamic fee) — 24h volume $39.57K, TVL $201.31K, 322 swaps today
- USD₮0 / USDC (Dynamic fee) — 24h volume $24.59K, TVL $533.62K, 236 swaps today
- USD₮0 / kBTC (Dynamic fee) — 24h volume $22.79K, TVL $517.24K, 108 swaps today
- ETH / wSPYx (Dynamic fee) — 24h volume $821, TVL $1.78K, 213 swaps today
- USDG / wSPYx (Dynamic fee) — 24h volume $267, TVL <$0.01, 21 swaps today
- USDC / USDG (Dynamic fee) — 24h volume $191, TVL $401.95K, 51 swaps today
- wQQQx / USDG (Dynamic fee) — 24h volume $75, TVL $97, 3 swaps today
- wMSTRx / USDG (Dynamic fee) — 24h volume $1.31, TVL $22, 78 swaps today
- WETH / USDG (Dynamic fee) — 24h volume $0.01, TVL $1.25, 3 swaps today
- wMSTRx / wSPYx (Dynamic fee) — 24h volume $0, TVL $0, 330 swaps today
- wPLTRx / wSPYx (Dynamic fee) — 24h volume $0, TVL $0, 327 swaps today
- wSPCXx / wSPYx (Dynamic fee) — 24h volume $0, TVL $0, 302 swaps today
- wTSLAx / wSPYx (Dynamic fee) — 24h volume $0, TVL $0, 296 swaps today
- wNFLXx / wSPYx (Dynamic fee) — 24h volume $0, TVL $0, 225 swaps today
- wNVDAx / wSPYx (Dynamic fee) — 24h volume $0, TVL $0, 160 swaps today
- USD₮0 / USDG (Dynamic fee) — 24h volume $0, TVL $0, 0 swaps today
- ETH / USDC (Dynamic fee) — 24h volume $0, TVL $0, 0 swaps today