Skip to content

LimitOrderHook: review notes #141

Description

@luiz-lvj

Grouping a set of observations about LimitOrderHook in one place, for tracking and to reduce duplicate reports. Items are summarized briefly and are not all confirmed. No severity is assigned here.

- Withdrawal accounting can underflowwithdraw computes currency*Total - checkpoint while currency*Total is decremented on each withdrawal, so an earlier withdrawal can push a total below a later user's checkpoint and block that withdrawal. Already tracked in #129. #138
- Final cancel clears order totals — On the last cancel, order totals are zeroed without redeeming fee claims minted to the hook by earlier partial cancels, leaving those claims unaccounted. Already tracked in #127. #138
- Checkpoint set before fee realization — A placement records its checkpoint from current totals before modifyLiquidity credits previously accrued fees, so newly added liquidity can share fees accrued before it joined. #138
- Boundary fills can be skipped — The tick is derived from sqrtPriceX96 rather than slot0.tick; at an exact boundary on a downward move the order at that tick can be left unfilled, so withdraw reverts NotFilled until price re-enters. #153
- PoolKey.hooks not validatedplaceOrder/cancelOrder accept a caller-supplied PoolKey without checking key.hooks == address(this), so orders can be placed against pools configured with a different hook. #149
- In-range check based on deltas — Out-of-range placement is inferred from balance-delta zero-checks rather than comparing the current tick to the order range, so a boundary placement with a one-sided principal can create in-range liquidity. #149
- Fill crediting the deposited token (tickSpacing = 1) — Already tracked in #132. #153
- Native currency order settlement — Native-currency settlement can spend the hook's own ETH rather than the intended payer. #154

  • Per-swap tick scanafterSwap iterates every crossed tick in tickSpacing steps calling _fillOrder, so gas scales with the size of the tick move and a wide swap can revert. See LimitOrderHook: L-08 scan only the ticks that hold an order #150
  • Per-swap fill cost scales with orders crossed — Each crossed order is filled with a modifyLiquidity removal, around 123k gas, with no cap and no minimum order size, so a swap crossing a dense range can revert.

Source: src/general/LimitOrderHook.sol.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions