Verified contractPartialMIT
DualPoolHook
Address0x0000005bb4df4109bf356a585c8b8ea70fcbaac0
- Balance
0 ETH
- Transactions
11
- Compiler
solc 0.8.26
- Same code
3 more contracts
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,589,269
- Creation transaction
- 0xdf805db7ff…943fbeee71
74 files
The source code is large: one file is shown at a time. Choose a file in the list.
- src/alf/DualPoolHook.solmain61.45 KB
- lib/blocknumberish/src/BlockNumberish.sol3.12 KB
- lib/openzeppelin-contracts/contracts/access/Ownable.sol3.1 KB
- lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol2.48 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol4.45 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol193 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol182 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol12.21 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol684 B
- lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol13.31 KB
- lib/openzeppelin-contracts/contracts/utils/Context.sol963 B
- lib/openzeppelin-contracts/contracts/utils/ReentrancyGuardTransient.sol2.85 KB
- lib/openzeppelin-contracts/contracts/utils/TransientSlot.sol5.08 KB
- lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol871 B
- lib/solady/src/utils/FixedPointMathLib.sol55.69 KB
- lib/v4-core/src/interfaces/IExtsload.sol1.02 KB
- lib/v4-core/src/interfaces/IExttload.sol699 B
- lib/v4-core/src/interfaces/IHooks.sol8.23 KB
- lib/v4-core/src/interfaces/IPoolManager.sol12.84 KB
- lib/v4-core/src/interfaces/IProtocolFees.sol2.49 KB
- lib/v4-core/src/interfaces/callback/IUnlockCallback.sol488 B
- lib/v4-core/src/interfaces/external/IERC20Minimal.sol3.04 KB
- lib/v4-core/src/interfaces/external/IERC6909Claims.sol3.16 KB
- lib/v4-core/src/libraries/BitMath.sol2.61 KB
- lib/v4-core/src/libraries/CurrencyReserves.sol1.29 KB
- lib/v4-core/src/libraries/CustomRevert.sol5.17 KB
- lib/v4-core/src/libraries/FixedPoint128.sol297 B
- lib/v4-core/src/libraries/FixedPoint96.sol366 B
- lib/v4-core/src/libraries/FullMath.sol5.46 KB
- lib/v4-core/src/libraries/Hooks.sol16.51 KB
- lib/v4-core/src/libraries/LPFeeLibrary.sol3.6 KB
- lib/v4-core/src/libraries/LiquidityMath.sol742 B
- lib/v4-core/src/libraries/Lock.sol930 B
- lib/v4-core/src/libraries/NonzeroDeltaCount.sol1.46 KB
- lib/v4-core/src/libraries/ParseBytes.sol1.2 KB
- lib/v4-core/src/libraries/Position.sol4.81 KB
- lib/v4-core/src/libraries/ProtocolFeeLibrary.sol2.11 KB
- lib/v4-core/src/libraries/SafeCast.sol2.27 KB
- lib/v4-core/src/libraries/SqrtPriceMath.sol14.08 KB
- lib/v4-core/src/libraries/StateLibrary.sol16.03 KB
- lib/v4-core/src/libraries/SwapMath.sol6.97 KB
- lib/v4-core/src/libraries/TickMath.sol12.38 KB
- lib/v4-core/src/libraries/TransientStateLibrary.sol2.36 KB
- lib/v4-core/src/libraries/UnsafeMath.sol1.17 KB
- lib/v4-core/src/types/BalanceDelta.sol2.34 KB
- lib/v4-core/src/types/BeforeSwapDelta.sol1.47 KB
- lib/v4-core/src/types/Currency.sol5.46 KB
- lib/v4-core/src/types/PoolId.sol539 B
- lib/v4-core/src/types/PoolKey.sol805 B
- lib/v4-core/src/types/PoolOperation.sol907 B
- lib/v4-periphery/src/base/DeltaResolver.sol5.8 KB
- lib/v4-periphery/src/base/ImmutableState.sol818 B
- lib/v4-periphery/src/interfaces/IImmutableState.sol365 B
- lib/v4-periphery/src/libraries/ActionConstants.sol1.04 KB
- lib/v4-periphery/src/libraries/LiquidityAmounts.sol3.8 KB
- src/alf/base/BaseALFHook.sol5.8 KB
- src/alf/base/OwnedALFHook.sol4.44 KB
- src/alf/base/PoolVault.sol59.85 KB
- src/alf/base/vault/MultiAssetShareMath.sol4.07 KB
- src/alf/interfaces/IALFHook.sol3.77 KB
- src/alf/interfaces/IHookStats.sol3.16 KB
- src/alf/libraries/FeeLib.sol1.55 KB
- src/alf/libraries/InventoryLib.sol20.51 KB
- src/alf/libraries/SettlementLib.sol4.95 KB
- src/alf/types/ActiveLiquidity.sol4.4 KB
- src/alf/types/DepositGate.sol1.75 KB
- src/alf/types/Distribution.sol8.33 KB
- src/alf/types/Inventory.sol11.04 KB
- src/alf/types/JITLock.sol5.38 KB
- src/alf/types/Liveness.sol2.19 KB
- src/alf/types/Shares.sol14.9 KB
- src/alf/types/VaultId.sol981 B
- src/base/BaseHook.sol7.13 KB
src/alf/types/ActiveLiquidity.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {PoolId} from "@uniswap/v4-core/src/types/PoolId.sol";
/// @dev Transient-storage namespace seed for the active per-bucket JIT liquidity array. Combined
/// with a `PoolId` to derive a per-pool base slot; see {activeLiquidityFor}.
bytes32 constant ACTIVE_LIQUIDITY_NAMESPACE = keccak256("dualpoolhook.activeliq.v1");
/// @title ActiveLiquidity
/// @author Uniswap Labs
/// @notice The transient-storage base slot for a pool's per-bucket JIT liquidity, as a type-driven
/// value. A JIT hook derives one `ActiveLiquidity` per swap cycle via {activeLiquidityFor},
/// records each deployed bucket's liquidity with {store} during `beforeSwap`, and reads it
/// back with {takeAndClear} during `afterSwap` to size the inverse `modifyLiquidity`.
///
/// The slot for bucket `i` is `base + i`, so a single keccak per cycle yields the base and
/// every per-bucket access is a plain addition plus one `tstore`/`tload`. Transient storage
/// is used because the values live only for the duration of one `beforeSwap`/`afterSwap`
/// pair, which avoids the cold/warm SSTORE penalty (~22K cold, ~5K warm) per bucket that
/// persistent storage would incur.
///
/// ## Load-and-clear
///
/// {takeAndClear} zeroes each slot on read rather than relying on end-of-transaction
/// auto-clear. Transient storage scopes to the transaction, not the v4 unlock, so for
/// multiple swaps on the same pool within one transaction a stale value would otherwise
/// persist across cycles: if bucket `i` deployed `liq = 100` in swap 1 and the price moved
/// so bucket `i` deploys `liq = 0` in swap 2, the deploy path skips the write (it only
/// {store}s when `liq > 0`), leaving slot `i` at `100` from swap 1. Without the clear,
/// swap 2's teardown would read `100` and try to remove a position that no longer exists,
/// reverting the swap. {store} drops zero writes itself, so a zeroed slot unambiguously
/// means "no position deployed" regardless of caller discipline: the invariant is
/// self-enforcing rather than relying on every caller to skip zero stores.
/// @custom:security-contact [email protected]
type ActiveLiquidity is bytes32;
using {store, takeAndClear} for ActiveLiquidity global;
/// @notice Derive the active-liquidity base slot for `poolId`.
/// @dev One keccak per JIT cycle; per-bucket slots are this base plus the bucket index.
/// @param poolId The pool whose JIT liquidity slots to address.
/// @return The per-pool transient base slot.
function activeLiquidityFor(PoolId poolId) pure returns (ActiveLiquidity) {
return ActiveLiquidity.wrap(keccak256(abi.encode(ACTIVE_LIQUIDITY_NAMESPACE, poolId)));
}
/// @notice Record bucket `i`'s deployed liquidity in transient storage.
/// @dev Writes to slot `base + i`. The addition wraps in the unlikely event the keccak base is
/// near `type(uint256).max`, matching the v4 transient-namespace convention; the bucket index
/// is bounded well below that. A zero `liq` returns early without touching the slot, so a
/// zeroed slot unambiguously means "no position deployed for this bucket" and the load-and-clear
/// invariant holds without depending on callers to skip zero stores.
/// @param self The pool's active-liquidity base slot.
/// @param i The bucket index.
/// @param liq The liquidity deployed for the bucket.
function store(ActiveLiquidity self, uint256 i, uint128 liq) {
if (liq == 0) return;
bytes32 base = ActiveLiquidity.unwrap(self);
assembly ("memory-safe") {
tstore(add(base, i), liq)
}
}
/// @notice Read bucket `i`'s recorded liquidity and clear the slot in one step.
/// @dev Reads slot `base + i` then zeroes it (see the type-level "Load-and-clear" note). Returns
/// `0` for any bucket that was never {store}d this cycle.
/// @param self The pool's active-liquidity base slot.
/// @param i The bucket index.
/// @return liq The liquidity recorded for the bucket, or `0` if none.
function takeAndClear(ActiveLiquidity self, uint256 i) returns (uint128 liq) {
bytes32 base = ActiveLiquidity.unwrap(self);
assembly ("memory-safe") {
let slot := add(base, i)
liq := tload(slot)
tstore(slot, 0)
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@uniswap/v4-core/=lib/v4-core/",
"@uniswap/v4-periphery/=lib/v4-periphery/",
"@uniswap/blocknumberish/=lib/blocknumberish/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@protocol-fees/=lib/protocol-fees/src/",
"forge-std/=lib/forge-std/src/",
"solmate/=lib/v4-core/lib/solmate/",
"solady/=lib/solady/src/",
"v4-core/=lib/v4-core/src/",
"permit2/=lib/v4-periphery/lib/permit2/",
"lib/fluid-contracts-public/:lib/openzeppelin-contracts/=lib/fluid-contracts-public/lib/openzeppelin-contracts/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@eth-optimism-bedrock/=lib/protocol-fees/lib/optimism/packages/contracts-bedrock/",
"BokkyPooBahsDateTimeLibrary/=lib/protocol-fees/lib/BokkyPooBahsDateTimeLibrary/",
"blocknumberish/=lib/blocknumberish/src/",
"briefcase/=lib/briefcase/src/",
"dao-signer/=lib/protocol-fees/lib/dao-signer/",
"ds-test/=lib/protocol-fees/lib/solmate/lib/ds-test/src/",
"eas-contracts/=lib/protocol-fees/lib/dao-signer/lib/eas-contracts/contracts/",
"erc4626-tests/=lib/fluid-contracts-public/lib/erc4626-tests/",
"fluid-contracts-public/=lib/fluid-contracts-public/contracts/",
"forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"kontrol-cheatcodes/=lib/protocol-fees/lib/optimism/packages/contracts-bedrock/lib/kontrol-cheatcodes/src/",
"lib-keccak/=lib/protocol-fees/lib/optimism/packages/contracts-bedrock/lib/lib-keccak/contracts/",
"murky/=lib/protocol-fees/lib/murky/",
"openzeppelin-contracts-upgradeable/=lib/fluid-contracts-public/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts-v5/=lib/protocol-fees/lib/optimism/packages/contracts-bedrock/lib/openzeppelin-contracts-v5/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"optimism/=lib/protocol-fees/lib/optimism/",
"pancake-v3-contracts/=lib/pancake-v3-contracts/",
"protocol-fees/=lib/protocol-fees/",
"safe-contracts/=lib/protocol-fees/lib/optimism/packages/contracts-bedrock/lib/safe-contracts/",
"scripts/libraries/Config.sol=lib/protocol-fees/lib/optimism/packages/contracts-bedrock/scripts/libraries/Config.sol",
"solady-v0.0.245/=lib/protocol-fees/lib/optimism/packages/contracts-bedrock/lib/solady-v0.0.245/src/",
"src/AgreementAnchor.sol=lib/protocol-fees/lib/dao-signer/src/AgreementAnchor.sol",
"src/AgreementAnchorFactory.sol=lib/protocol-fees/lib/dao-signer/src/AgreementAnchorFactory.sol",
"src/interfaces/IAgreementAnchorFactory.sol=lib/protocol-fees/lib/dao-signer/src/interfaces/IAgreementAnchorFactory.sol",
"tstorish/=lib/tstorish/src/",
"v2-core/=lib/v2-core/contracts/",
"v3-core/=lib/v3-core/",
"v4-periphery/=lib/v4-periphery/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.