NewtonSanctionsHook
EthereumNewtonSanctionsHook is a Uniswap v4 hook on Ethereum. Runs code on every swap. Can block LP withdrawals. Gates who can add liquidity. Runs at pool creation. Handles donations to LPs.
- Contract name
- NewtonSanctionsHook
How this hook works
Signed tradesA signed trades hook. It uses an outside price feed, needs signed approvals and controls who adds or removes liquidity.
Uses an outside price feed
It reads a price from an outside source (an oracle) and uses it in its rules.
The code that does this (lookup):function _lookup(address[] memory who, bool enforceAge) internal view returns (bool[] memory flags) { uint256 updated = sanctionsOracle.getLastUpdateBlockTimestamp(); // RedStone records the timestamp of the block that updated the list, so a later one is a bad answer if (updated > block.timestamp) revert OracleAnswerMalformed(); if (enforceAge && block.timestamp - updated > maxListAge) { revert SanctionsListStale(block.timestamp - updated, maxListAge); } flags = sanctionsOracle.areSanctioned(who); if (flags.length != who.length) revert OracleAnswerMalformed(); }Needs a signed approval
Some actions need a message signed by an approved address.
The code that does this (checkIntent):function _checkIntent( NewtonMessage.Intent memory intent, bytes memory intentSignature, address actor, bytes memory expectedData, bytes32 expectedSignatureHash ) internal view { if (intent.from != actor) revert ActorMismatch(actor, intent.from); if (intent.to != actor) revert SubjectMismatch(actor, intent.to); if (intent.value != 0) revert IntentValueNotZero(intent.value); if (intent.chainId != block.chainid) revert IntentChainMismatch(intent.chainId); if (keccak256(intent.functionSignature) != expectedSignatureHash) revert IntentSignatureMismatch(); if (keccak256(intent.data) != keccak256(expectedData)) revert IntentActionMismatch(); if (!SignatureChecker.isValidSignatureNow(intent.from, _intentDigest(intent), intentSignature)) { revert IntentSignatureInvalid(); } }Rules for adding or removing liquidity
It decides who can add or remove liquidity, or when.
The code that does this (beforeAddLiquidity):function beforeAddLiquidity( address sender, PoolKey calldata key, IPoolManager.ModifyLiquidityParams calldata params, bytes calldata hookData ) external onlyPoolManager returns (bytes4) { _authorize( sender, key, Action.AddLiquidity, HookIntent.addLiquidityData(key, params), keccak256(bytes(HookIntent.ADD_LIQUIDITY_SIGNATURE)), hookData ); return IHooks.beforeAddLiquidity.selector; }Only approved callers create pools
New pools with this hook can only be created by approved callers, for example its own factory or launcher.
The code that does this (beforeInitialize):function beforeInitialize(address, PoolKey calldata key, uint160 sqrtPriceX96) external view onlyPoolManager returns (bytes4) { PoolId id = key.toId(); if (!poolAllowed[id]) revert PoolNotAllowed(id); if (sqrtPriceX96 != openingPrice[id]) revert WrongOpeningPrice(sqrtPriceX96, openingPrice[id]); return IHooks.beforeInitialize.selector; }No trading before the start
Trades are refused until trading has been opened.
The code that does this (beforeSwap):function beforeSwap(address sender, PoolKey calldata key, IPoolManager.SwapParams calldata, bytes calldata) external view onlyPoolManager returns (bytes4, BeforeSwapDelta, uint24) { PoolId id = key.toId(); if (!tradingOpen[id]) revert TradingClosed(id); _screenOnchain(sender, true); return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0); }
Who controls it: The hook developer can change which routers are trusted. The hook developer can also change: trading, max list age. The hook developer can also call: allow pool, open exit window, close exit window, transfer hook admin, cancel hook admin transfer. The code cannot be changed.
Based on the hook’s published code.
What it can do
Its code executes inside each trade in pools that use it.
It runs before liquidity is removed, so it can delay or refuse LP exits.
It checks every deposit before it goes in.
It runs when a pool is created, often to lock in that pool’s settings.
It runs when someone donates tokens to the pool’s LPs.
Hook history
- Approved 4 times
Latest transactions
- 0xeaba7e7d…78a6c0 block 26,393,440
- 0x79c472a2…7a14f4 block 26,393,278
- 0x8ecd8a33…834582 block 26,393,276
- 0x3da9d108…276ccc block 26,393,244
- Allowed a pool 1 time
- Exited during window 1 time
Settings changes: set the exit window (2 times), set the trading (2 times).
Counted from what the hook recorded on-chain across all its pools, for every action in its published code, plus token transfers in and out of it.