MarginHook on BNB Chain

Uniswap v4 Hook Contract 0xba933d3c37d5b26fbb21ae6894ce6ebfc48f6888 on BNB Chain · Custom pricing · Verified contract

Volume (24h)
$0
Value locked (TVL)
$0
All-time volume
$0
Pools using this hook
8
Swaps (24h)
1 (1 traders)
Total swaps
48,625

What it does

MarginHook is a Uniswap v4 hook that replaces standard AMM swap pricing with a custom margin trading curve, routing swaps through an external pair pool manager and blocking direct v4 liquidity provision.

How it works step by step

  • Registers each new pool with the pair pool manager in beforeInitialize, requiring the pool key to reference this hook.
  • Replaces the AMM curve in beforeSwap by returning a custom delta, with swap math computed by the external pair pool manager.
  • Settles exact-input and exact-output swaps against the PoolManager, creating credits or debts that the swapper claims or pays.
  • Blocks native Uniswap v4 liquidity by reverting in beforeAddLiquidity, so liquidity is provided only through the pair pool manager.
  • Updates pool status balances before and after each swap through the status manager.
Swap behaviour
beforeSwap delegates pricing to pairPoolManager.swap, then settles the specified and unspecified tokens with the PoolManager via take and settle (minting claims or transferring ERC20 to the PoolManager) and returns a custom BeforeSwapDelta together with the swap fee.
Liquidity behaviour
No v4 liquidity callbacks: beforeAddLiquidity reverts with 'No v4 Liquidity allowed', so liquidity cannot be added to the pool through the PoolManager. Liquidity is managed separately by the pair pool manager outside v4 accounting.
Fee behaviour
Swap fee is returned by pairPoolManager.swap and passed to the PoolManager as the override fee in beforeSwap; margin fee and lending rates are tracked in pool status by the external pair pool manager.
Owner & admin controls
Owner (Solmate Owned) can transfer ownership via transferOwnership; the hook itself exposes no pause, parameter setter or upgrade function in the ABI. Pool initialization and the pair pool manager logic are delegated to the external pairPoolManager, whose admin controls are not visible in the provided source.

Enabled Uniswap v4 callbacks

beforeInitialize, beforeAddLiquidity, beforeSwap, beforeSwapReturnDelta

beforeInitialize validates the pool keys hook and registers the pool with the pair pool manager; beforeSwap routes swaps into a custom curve and uses return deltas to settle input and output against the PoolManager; beforeAddLiquidity is used only to block native v4 liquidity.

Security & trust assessment

Risk level: medium (verified source, medium confidence).

Who controls it: The owner can transfer ownership to any address, but no owner-only function affecting pool funds or swap logic is exposed on the hook itself. Trust is concentrated in pairPoolManager, which is set immutably at construction and controls reserves, the swap curve and balances.

Risk to user funds: The hook takes input tokens from the PoolManager and pays output tokens to the PoolManager via return deltas, and the pair pool manager holds the underlying reserves; user funds are therefore exposed to the correctness of this hook and the external pair pool manager, not just to pool-level AMM math.

Security findings

  • [high] Custom curve bypasses standard AMM pricing: beforeSwap returns a custom delta, so the hook overrides standard AMM pricing and settles tokens against the PoolManager and the pair pool manager; swap outcomes depend entirely on external logic.
  • [medium] Funds custodied by external pair pool manager: Input and output settlements are routed through pairPoolManager as the take and settle recipient, so the external pair pool manager holds pool tokens and its correctness is critical to user funds.
  • [low] Single owner key with ownership transfer: Owned contract with transferOwnership and no timelock or multisig requirement visible in this source; ownership control is over the hook only.
  • [info] Status manager dependency on every swap: Hook calls setBalances and update on the status manager around each swap, so an error in those external status updates could affect pool accounting for all swaps.

Contract details

Verified source
Yes (MarginHook)
Compiler
solc 0.8.26+commit.8a97fa7a
Bytecode size
4,351 bytes
Upgradeable proxy
No
Detected patterns
ownable, return-delta

Pools using MarginHook