Skip to content
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/base/BaseALFHook.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
import {BaseHook} from "../../base/BaseHook.sol";
import {DeltaResolver} from "@uniswap/v4-periphery/src/base/DeltaResolver.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {IALFHook, ALFHookData} from "../interfaces/IALFHook.sol";
import {IHookStats} from "../interfaces/IHookStats.sol";

/// @title BaseALFHook
/// @author Uniswap Labs
/// @notice Abstract base contract for ALF hooks. Provides hookData resolution, settlement
///         helpers, and the IALFHook interface. Quoters extend this and implement _price()
///         with their pricing logic.
/// @dev Follows the same BaseHook + DeltaResolver dual-inheritance pattern as BaseTokenWrapperHook.
/// @custom:security-contact [email protected]
abstract contract BaseALFHook is BaseHook, DeltaResolver, IALFHook {
    /// @dev Gas budget declared for `getIndicativeQuote` staticcalls. Returned by `maxGas()`.
    uint32 private immutable _maxGas;

    /// @param _poolManager The Uniswap v4 PoolManager.
    /// @param maxGas_      Gas budget declared for `getIndicativeQuote` staticcalls.
    constructor(IPoolManager _poolManager, uint32 maxGas_) BaseHook(_poolManager) {
        _maxGas = maxGas_;
    }

    // ──── IALFHook ────

    /// @inheritdoc IALFHook
    function maxGas() external view override returns (uint32) {
        return _maxGas;
    }

    /// @notice ERC-165 advertisement for the interfaces this contract implements.
    /// @dev Stateless implementation (no inherited `ERC165` storage). Advertises `IALFHook`,
    ///      `IHooks` (implemented via `BaseHook`), and `IERC165`. Subclasses that implement
    ///      additional interfaces should override this and OR-in their own selectors.
    function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
        return interfaceId == type(IALFHook).interfaceId || interfaceId == type(IHooks).interfaceId
            || interfaceId == type(IERC165).interfaceId;
    }

    /// @inheritdoc IALFHook
    function getIndicativeQuote(PoolKey calldata key, bool zeroForOne, int256 amountSpecified, bytes calldata hookData)
        external
        view
        virtual
        override
        returns (uint256 outputAmount)
    {
        (bool isAttested, address attester) = _resolveHookData(hookData);
        return _price(key, zeroForOne, amountSpecified, isAttested, attester);
    }

    /// @inheritdoc IALFHook
    function isLive() external view virtual override returns (bool);

    // ──── Reserves (default: no off-pool reserves) ────

    /// @inheritdoc IHookStats
    function getReserves(PoolKey calldata) external view virtual override returns (uint256, uint256) {
        return (0, 0);
    }

    /// @inheritdoc IHookStats
    function getEffectiveLiquidity(PoolKey calldata) external view virtual override returns (uint256, uint256) {
        return (0, 0);
    }

    // ──── Price-bounded simulation (default: unsupported) ────

    /// @inheritdoc IALFHook
    function swapToPrice(PoolKey calldata, bool, int256, uint160, bytes calldata)
        external
        view
        virtual
        override
        returns (uint256, uint256)
    {
        return (0, 0);
    }

    // ──── Internal: HookData Resolution ────

    /// @dev Decode ALFHookData and resolve attestation. The base implementation does not
    ///      verify attestations; subclasses that want attestation support override
    ///      `_resolveAttestation` with their own verification logic.
    function _resolveHookData(bytes calldata hookData) internal view returns (bool isAttested, address attester) {
        if (hookData.length == 0) return (false, address(0));
        ALFHookData memory hd = abi.decode(hookData, (ALFHookData));
        (isAttested, attester) = _resolveAttestation(hd.attestationData);
    }

    /// @dev Resolve attestation from raw bytes. Default returns (false, address(0)).
    ///      Subclasses can override to verify attestationData against their own signer.
    function _resolveAttestation(bytes memory) internal view virtual returns (bool isAttested, address attester) {
        return (false, address(0));
    }

    // ──── Pricing extension point (default: no indicative quote) ────

    /// @dev Indicative pricing backing the default {getIndicativeQuote}. Defaults to 0: the
    ///      IALFHook "cannot price this swap" path. Quoter subclasses override with their curve
    ///      (e.g. `SpreadQuoterBase` simulates against the pool's static fee). Hooks that price
    ///      against bespoke liquidity (e.g. `DualPoolHook`) override `getIndicativeQuote`
    ///      directly instead, leaving this dormant.
    function _price(PoolKey calldata, bool, int256, bool, address) internal view virtual returns (uint256) {
        return 0;
    }

    // ──── DeltaResolver: _pay ────

    /// @inheritdoc DeltaResolver
    /// @dev Pays the PoolManager using v4's `Currency.transfer` rather than OZ `SafeERC20`, by
    ///      design: this matches v4 periphery's `DeltaResolver` convention (the destination is the
    ///      trusted PoolManager during an unlock, and `Currency.transfer` handles native ETH and
    ///      the no-return-value ERC-20 quirk in the same path).
    function _pay(Currency token, address, uint256 amount) internal virtual override {
        token.transfer(address(poolManager), amount);
    }
}
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.