Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| Transfer | 24508512 | 31 days ago | 0.00473625 ETH | ||||
| Fund From Hook | 24508512 | 31 days ago | 0.06352159 ETH | ||||
| Transfer | 24508512 | 31 days ago | 0.06825785 ETH | ||||
| Transfer | 24441899 | 40 days ago | 0.000085 ETH | ||||
| Fund From Hook | 24441899 | 40 days ago | 0.00114 ETH | ||||
| Transfer | 24441899 | 40 days ago | 0.001225 ETH | ||||
| Transfer | 24379803 | 49 days ago | 0.00302525 ETH | ||||
| Fund From Hook | 24379803 | 49 days ago | 0.04057395 ETH | ||||
| Transfer | 24379803 | 49 days ago | 0.0435992 ETH | ||||
| Transfer | 24357338 | 52 days ago | 0.00043973 ETH | ||||
| Fund From Hook | 24357338 | 52 days ago | 0.00589757 ETH | ||||
| Transfer | 24357338 | 52 days ago | 0.00633731 ETH | ||||
| Transfer | 24330136 | 55 days ago | 0.00091851 ETH | ||||
| Fund From Hook | 24330136 | 55 days ago | 0.01231886 ETH | ||||
| Transfer | 24330136 | 55 days ago | 0.01323738 ETH | ||||
| Transfer | 24330134 | 55 days ago | 0.00354184 ETH | ||||
| Fund From Hook | 24330134 | 55 days ago | 0.04750233 ETH | ||||
| Transfer | 24330134 | 55 days ago | 0.05104417 ETH | ||||
| Transfer | 24228820 | 70 days ago | 0.00123737 ETH | ||||
| Fund From Hook | 24228820 | 70 days ago | 0.01659535 ETH | ||||
| Transfer | 24228820 | 70 days ago | 0.01783272 ETH | ||||
| Transfer | 24205949 | 73 days ago | 0.00002486 ETH | ||||
| Fund From Hook | 24205949 | 73 days ago | 0.00033349 ETH | ||||
| Transfer | 24205949 | 73 days ago | 0.00035835 ETH | ||||
| Transfer | 24172335 | 77 days ago | 0.0017939 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
ActionFundingHook
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
Yes with 10000 runs
Other Settings:
prague EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {BaseHook} from "v4-periphery/src/utils/BaseHook.sol";
import {Hooks} from "v4-core/src/libraries/Hooks.sol";
import {IHooks} from "v4-core/src/interfaces/IHooks.sol";
import {IPoolManager} from "v4-core/src/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/src/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "v4-core/src/types/PoolId.sol";
import {SwapParams} from "v4-core/src/types/PoolOperation.sol";
import {BeforeSwapDelta, BeforeSwapDeltaLibrary, toBeforeSwapDelta} from "v4-core/src/types/BeforeSwapDelta.sol";
import {BalanceDelta, BalanceDeltaLibrary} from "v4-core/src/types/BalanceDelta.sol";
import {Currency, CurrencyLibrary} from "v4-core/src/types/Currency.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
interface IBUXAction {
function fundFromHook(uint256 hourly, uint256 daily) external payable;
}
/**
* @title ActionFundingHook
* @author BUX Team
* @notice Uniswap v4 hook that captures fees from BUX/ETH swaps
*/
contract ActionFundingHook is BaseHook, Ownable2Step {
using PoolIdLibrary for PoolKey;
using BalanceDeltaLibrary for BalanceDelta;
using SafeCast for uint256;
using SafeCast for int256;
// ============ Constants ============
uint256 private constant BPS_DENOMINATOR = 10_000;
uint256 private constant TOTAL_BPS_MAX = 2_000; // 20% hard cap
// Uniswap v4 hook return selectors
bytes4 private constant BEFORE_SWAP_RETURNS_SELECTOR = 0x575e24b4;
bytes4 private constant AFTER_SWAP_RETURNS_SELECTOR = 0xb47b2fb1;
// ============ Errors ============
error InvalidPool();
error InvalidConfig();
error TransferFailed();
error ExceedsSwapAmount();
error ZeroAddress();
error NotBuxEthPool();
error PoolNotAllowed();
error FeesTooHigh();
error ExactOutputNotSupported();
// ============ Events ============
event FeesUpdated(uint16 hourlyBps, uint16 dailyBps, uint16 devBps);
event RecipientsUpdated(address action, address devFeeSplitter);
event PoolAllowed(bytes32 indexed poolId, bool allowed);
event AllowlistToggled(bool enabled);
event FeesToggled(bool enabled);
event ActionFundingFailed(uint256 amount, bytes reason); // L-02 fix: Track failed action funding
event StuckETHRecovered(address indexed to, uint256 amount); // Recovery for failed action funding
event FeeRealized(
bytes32 indexed poolId,
bool ethWasSpecified,
uint256 ethMoved,
uint256 feeTaken,
uint256 hourlyPortion,
uint256 dailyPortion,
uint256 devPortion
);
// ============ Immutable State ============
address public immutable buxToken;
Currency private immutable _cBux;
Currency private constant _cEth = Currency.wrap(address(0));
// ============ Mutable State ============
address payable public action;
address payable public devFeeSplitter;
uint16 public hourlyBps;
uint16 public dailyBps;
uint16 public devBps;
bool public feesEnabled = true;
bool public allowlistEnabled;
uint256 public allowedPoolCount;
mapping(PoolId => bool) public allowedPools;
struct PendingFees {
uint256 totalFee;
uint256 ethSpecified;
PoolId poolId;
}
PendingFees private _pendingFees;
// ============ Constructor ============
constructor(
IPoolManager _poolManager,
address _buxToken,
address payable _action,
address payable _devFeeSplitter,
uint16 _hourlyBps,
uint16 _dailyBps,
uint16 _devBps,
address initialOwner
) BaseHook(_poolManager) Ownable(initialOwner) {
if (_buxToken == address(0)) revert ZeroAddress();
if (_action == address(0)) revert ZeroAddress();
if (_devFeeSplitter == address(0)) revert ZeroAddress();
buxToken = _buxToken;
_cBux = Currency.wrap(_buxToken);
_setFeesInternal(_hourlyBps, _dailyBps, _devBps);
action = _action;
devFeeSplitter = _devFeeSplitter;
// Validate hook permissions after deployment
Hooks.validateHookPermissions(IHooks(address(this)), getHookPermissions());
}
// ============ Hook Configuration ============
function getHookPermissions() public pure override returns (Hooks.Permissions memory p) {
p.beforeSwap = true;
p.afterSwap = true;
p.beforeSwapReturnDelta = true;
p.afterSwapReturnDelta = true;
}
// ============ Admin Functions ============
function setAllowlistEnabled(bool enabled) external onlyOwner {
allowlistEnabled = enabled;
emit AllowlistToggled(enabled);
}
function setFees(uint16 _hourlyBps, uint16 _dailyBps, uint16 _devBps) external onlyOwner {
_setFeesInternal(_hourlyBps, _dailyBps, _devBps);
}
function _setFeesInternal(uint16 _hourlyBps, uint16 _dailyBps, uint16 _devBps) internal {
uint256 total = uint256(_hourlyBps) + uint256(_dailyBps) + uint256(_devBps);
if (total > TOTAL_BPS_MAX) revert FeesTooHigh();
hourlyBps = _hourlyBps;
dailyBps = _dailyBps;
devBps = _devBps;
emit FeesUpdated(_hourlyBps, _dailyBps, _devBps);
}
function setRecipients(address payable _action, address payable _devFeeSplitter) external onlyOwner {
if (_action == address(0)) revert ZeroAddress();
if (_devFeeSplitter == address(0)) revert ZeroAddress();
action = _action;
devFeeSplitter = _devFeeSplitter;
emit RecipientsUpdated(_action, _devFeeSplitter);
}
function setFeesEnabled(bool enabled) external onlyOwner {
feesEnabled = enabled;
emit FeesToggled(enabled);
}
function allowPool(PoolKey calldata key, bool allowed) external onlyOwner {
PoolId id = key.toId();
bool wasAllowed = allowedPools[id];
if (allowed != wasAllowed) {
allowedPools[id] = allowed;
if (allowed) {
allowedPoolCount++;
// Auto-enable allowlist when first pool is added
if (allowedPoolCount == 1 && !allowlistEnabled) {
allowlistEnabled = true;
emit AllowlistToggled(true);
}
} else if (allowedPoolCount > 0) {
allowedPoolCount--;
}
emit PoolAllowed(PoolId.unwrap(id), allowed);
}
}
function isPoolAllowed(PoolKey calldata key) external view returns (bool) {
if (!_isAllowlistActive()) return true;
return allowedPools[key.toId()];
}
function recoverStuckETH(address to) external onlyOwner {
if (to == address(0)) revert ZeroAddress();
uint256 balance = address(this).balance;
if (balance == 0) revert TransferFailed();
(bool success,) = to.call{value: balance}("");
if (!success) revert TransferFailed();
emit StuckETHRecovered(to, balance);
}
function _beforeSwap(
address, // sender
PoolKey calldata key,
SwapParams calldata params,
bytes calldata // hookData
) internal override returns (bytes4, BeforeSwapDelta, uint24) {
_checkBuxEthPool(key);
if (params.amountSpecified > 0) {
revert ExactOutputNotSupported();
}
if (!feesEnabled || _getTotalBps() == 0) {
return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
bool isSellingBuxForEth = _isSellingBuxForEth(key, params);
if (isSellingBuxForEth) {
return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
bool ethIsInput = params.zeroForOne ? _isEth(key.currency0) : _isEth(key.currency1);
if (!ethIsInput) {
return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
uint256 ethSpecified = _abs(params.amountSpecified);
uint256 fee = _computeFee(ethSpecified);
if (fee >= ethSpecified) revert ExceedsSwapAmount();
if (fee > uint256(uint128(type(int128).max))) revert InvalidConfig();
PoolId poolId = key.toId();
_pendingFees = PendingFees({
totalFee: fee,
ethSpecified: ethSpecified,
poolId: poolId
});
int128 specifiedDelta = int128(uint128(fee));
return (
BEFORE_SWAP_RETURNS_SELECTOR,
toBeforeSwapDelta(specifiedDelta, int128(0)),
0
);
}
function _afterSwap(
address, // sender
PoolKey calldata key,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata // hookData
) internal override returns (bytes4, int128) {
_checkBuxEthPool(key);
if (!feesEnabled || _getTotalBps() == 0) {
return (IHooks.afterSwap.selector, int128(0));
}
PoolId poolId = key.toId();
bool isSellingBuxForEth = _isSellingBuxForEth(key, params);
if (isSellingBuxForEth) {
int128 ethDelta = _isEth(key.currency0) ? delta.amount0() : delta.amount1();
uint256 ethOutput = _abs128(ethDelta);
uint256 fee = _computeFee(ethOutput);
if (fee > uint256(uint128(type(int128).max))) revert InvalidConfig();
if (fee > 0) {
poolManager.take(_cEth, address(this), fee);
_forwardSplitAndEmit(poolId, false, ethOutput, fee);
return (AFTER_SWAP_RETURNS_SELECTOR, int128(uint128(fee)));
}
return (IHooks.afterSwap.selector, int128(0));
}
bool ethIsUnspecified = params.zeroForOne ? _isEth(key.currency1) : _isEth(key.currency0);
if (ethIsUnspecified) {
int128 ethDelta = _isEth(key.currency0) ? delta.amount0() : delta.amount1();
uint256 ethMoved = _abs128(ethDelta);
uint256 fee = _computeFee(ethMoved);
if (fee > uint256(uint128(type(int128).max))) revert InvalidConfig();
if (fee > 0) {
poolManager.take(_cEth, address(this), fee);
_forwardSplitAndEmit(poolId, false, ethMoved, fee);
return (AFTER_SWAP_RETURNS_SELECTOR, int128(uint128(fee)));
}
return (IHooks.afterSwap.selector, int128(0));
} else {
if (_pendingFees.totalFee > 0) {
uint256 fee = _pendingFees.totalFee;
uint256 ethSpecified = _pendingFees.ethSpecified;
PoolId pendingPoolId = _pendingFees.poolId;
_pendingFees = PendingFees({
totalFee: 0,
ethSpecified: 0,
poolId: PoolId.wrap(bytes32(0))
});
poolManager.take(_cEth, address(this), fee);
_forwardSplitAndEmit(pendingPoolId, true, ethSpecified, fee);
}
return (IHooks.afterSwap.selector, int128(0));
}
}
function _isSellingBuxForEth(PoolKey calldata key, SwapParams calldata params) private pure returns (bool) {
bool buxIsCurrency0 = Currency.unwrap(key.currency0) != address(0);
bool buxIsCurrency1 = Currency.unwrap(key.currency1) != address(0);
if (params.zeroForOne) {
return buxIsCurrency0 && !buxIsCurrency1;
} else {
return buxIsCurrency1 && !buxIsCurrency0;
}
}
function _checkBuxEthPool(PoolKey calldata key) private view {
bool c0IsEth = _isEth(key.currency0);
bool c1IsEth = _isEth(key.currency1);
if (c0IsEth == c1IsEth) revert NotBuxEthPool();
Currency buxSide = c0IsEth ? key.currency1 : key.currency0;
if (Currency.unwrap(buxSide) != buxToken) revert NotBuxEthPool();
if (_isAllowlistActive()) {
if (!allowedPools[key.toId()]) revert PoolNotAllowed();
}
}
function _computeFee(uint256 amount) private view returns (uint256) {
unchecked {
return amount * _getTotalBps() / BPS_DENOMINATOR;
}
}
function _getTotalBps() private view returns (uint256) {
return uint256(hourlyBps) + uint256(dailyBps) + uint256(devBps);
}
function _forwardSplitAndEmit(
PoolId poolId,
bool ethWasSpecified,
uint256 ethMoved,
uint256 fee
) private {
if (fee == 0) {
emit FeeRealized(PoolId.unwrap(poolId), ethWasSpecified, ethMoved, 0, 0, 0, 0);
return;
}
uint256 totalBps = _getTotalBps();
uint256 hourlyAmt = fee * hourlyBps / totalBps;
uint256 dailyAmt = fee * dailyBps / totalBps;
uint256 devAmt = fee - hourlyAmt - dailyAmt;
if (hourlyAmt + dailyAmt > 0) {
(bool ok1, bytes memory returnData) = action.call{value: (hourlyAmt + dailyAmt)}(
abi.encodeWithSelector(IBUXAction.fundFromHook.selector, hourlyAmt, dailyAmt)
);
if (!ok1) {
emit ActionFundingFailed(hourlyAmt + dailyAmt, returnData);
}
}
if (devAmt > 0) {
(bool ok2, ) = devFeeSplitter.call{value: devAmt}("");
if (!ok2) revert TransferFailed();
}
emit FeeRealized(
PoolId.unwrap(poolId),
ethWasSpecified,
ethMoved,
fee,
hourlyAmt,
dailyAmt,
devAmt
);
}
function _isAllowlistActive() private view returns (bool) {
return allowlistEnabled || allowedPoolCount > 0;
}
function _isEth(Currency c) private pure returns (bool) {
return Currency.unwrap(c) == address(0);
}
function _abs(int256 x) private pure returns (uint256) {
return uint256(x < 0 ? -x : x);
}
function _abs128(int128 x) private pure returns (uint256) {
return uint256(int256(x < 0 ? -x : x));
}
receive() external payable {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
import {BeforeSwapDelta} from "@uniswap/v4-core/src/types/BeforeSwapDelta.sol";
import {ImmutableState} from "../base/ImmutableState.sol";
import {ModifyLiquidityParams, SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
/// @title Base Hook
/// @notice abstract contract for hook implementations
abstract contract BaseHook is IHooks, ImmutableState {
error HookNotImplemented();
constructor(IPoolManager _manager) ImmutableState(_manager) {
validateHookAddress(this);
}
/// @notice Returns a struct of permissions to signal which hook functions are to be implemented
/// @dev Used at deployment to validate the address correctly represents the expected permissions
/// @return Permissions struct
function getHookPermissions() public pure virtual returns (Hooks.Permissions memory);
/// @notice Validates the deployed hook address agrees with the expected permissions of the hook
/// @dev this function is virtual so that we can override it during testing,
/// which allows us to deploy an implementation to any address
/// and then etch the bytecode into the correct address
function validateHookAddress(BaseHook _this) internal pure virtual {
Hooks.validateHookPermissions(_this, getHookPermissions());
}
/// @inheritdoc IHooks
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96)
external
onlyPoolManager
returns (bytes4)
{
return _beforeInitialize(sender, key, sqrtPriceX96);
}
function _beforeInitialize(address, PoolKey calldata, uint160) internal virtual returns (bytes4) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick)
external
onlyPoolManager
returns (bytes4)
{
return _afterInitialize(sender, key, sqrtPriceX96, tick);
}
function _afterInitialize(address, PoolKey calldata, uint160, int24) internal virtual returns (bytes4) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _beforeAddLiquidity(sender, key, params, hookData);
}
function _beforeAddLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _beforeRemoveLiquidity(sender, key, params, hookData);
}
function _beforeRemoveLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external onlyPoolManager returns (bytes4, BalanceDelta) {
return _afterAddLiquidity(sender, key, params, delta, feesAccrued, hookData);
}
function _afterAddLiquidity(
address,
PoolKey calldata,
ModifyLiquidityParams calldata,
BalanceDelta,
BalanceDelta,
bytes calldata
) internal virtual returns (bytes4, BalanceDelta) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external onlyPoolManager returns (bytes4, BalanceDelta) {
return _afterRemoveLiquidity(sender, key, params, delta, feesAccrued, hookData);
}
function _afterRemoveLiquidity(
address,
PoolKey calldata,
ModifyLiquidityParams calldata,
BalanceDelta,
BalanceDelta,
bytes calldata
) internal virtual returns (bytes4, BalanceDelta) {
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata hookData)
external
onlyPoolManager
returns (bytes4, BeforeSwapDelta, uint24)
{
return _beforeSwap(sender, key, params, hookData);
}
function _beforeSwap(address, PoolKey calldata, SwapParams calldata, bytes calldata)
internal
virtual
returns (bytes4, BeforeSwapDelta, uint24)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterSwap(
address sender,
PoolKey calldata key,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata hookData
) external onlyPoolManager returns (bytes4, int128) {
return _afterSwap(sender, key, params, delta, hookData);
}
function _afterSwap(address, PoolKey calldata, SwapParams calldata, BalanceDelta, bytes calldata)
internal
virtual
returns (bytes4, int128)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function beforeDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _beforeDonate(sender, key, amount0, amount1, hookData);
}
function _beforeDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
/// @inheritdoc IHooks
function afterDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external onlyPoolManager returns (bytes4) {
return _afterDonate(sender, key, amount0, amount1, hookData);
}
function _afterDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
internal
virtual
returns (bytes4)
{
revert HookNotImplemented();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "../types/PoolKey.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {SafeCast} from "./SafeCast.sol";
import {LPFeeLibrary} from "./LPFeeLibrary.sol";
import {BalanceDelta, toBalanceDelta, BalanceDeltaLibrary} from "../types/BalanceDelta.sol";
import {BeforeSwapDelta, BeforeSwapDeltaLibrary} from "../types/BeforeSwapDelta.sol";
import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {ModifyLiquidityParams, SwapParams} from "../types/PoolOperation.sol";
import {ParseBytes} from "./ParseBytes.sol";
import {CustomRevert} from "./CustomRevert.sol";
/// @notice V4 decides whether to invoke specific hooks by inspecting the least significant bits
/// of the address that the hooks contract is deployed to.
/// For example, a hooks contract deployed to address: 0x0000000000000000000000000000000000002400
/// has the lowest bits '10 0100 0000 0000' which would cause the 'before initialize' and 'after add liquidity' hooks to be used.
library Hooks {
using LPFeeLibrary for uint24;
using Hooks for IHooks;
using SafeCast for int256;
using BeforeSwapDeltaLibrary for BeforeSwapDelta;
using ParseBytes for bytes;
using CustomRevert for bytes4;
uint160 internal constant ALL_HOOK_MASK = uint160((1 << 14) - 1);
uint160 internal constant BEFORE_INITIALIZE_FLAG = 1 << 13;
uint160 internal constant AFTER_INITIALIZE_FLAG = 1 << 12;
uint160 internal constant BEFORE_ADD_LIQUIDITY_FLAG = 1 << 11;
uint160 internal constant AFTER_ADD_LIQUIDITY_FLAG = 1 << 10;
uint160 internal constant BEFORE_REMOVE_LIQUIDITY_FLAG = 1 << 9;
uint160 internal constant AFTER_REMOVE_LIQUIDITY_FLAG = 1 << 8;
uint160 internal constant BEFORE_SWAP_FLAG = 1 << 7;
uint160 internal constant AFTER_SWAP_FLAG = 1 << 6;
uint160 internal constant BEFORE_DONATE_FLAG = 1 << 5;
uint160 internal constant AFTER_DONATE_FLAG = 1 << 4;
uint160 internal constant BEFORE_SWAP_RETURNS_DELTA_FLAG = 1 << 3;
uint160 internal constant AFTER_SWAP_RETURNS_DELTA_FLAG = 1 << 2;
uint160 internal constant AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG = 1 << 1;
uint160 internal constant AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG = 1 << 0;
struct Permissions {
bool beforeInitialize;
bool afterInitialize;
bool beforeAddLiquidity;
bool afterAddLiquidity;
bool beforeRemoveLiquidity;
bool afterRemoveLiquidity;
bool beforeSwap;
bool afterSwap;
bool beforeDonate;
bool afterDonate;
bool beforeSwapReturnDelta;
bool afterSwapReturnDelta;
bool afterAddLiquidityReturnDelta;
bool afterRemoveLiquidityReturnDelta;
}
/// @notice Thrown if the address will not lead to the specified hook calls being called
/// @param hooks The address of the hooks contract
error HookAddressNotValid(address hooks);
/// @notice Hook did not return its selector
error InvalidHookResponse();
/// @notice Additional context for ERC-7751 wrapped error when a hook call fails
error HookCallFailed();
/// @notice The hook's delta changed the swap from exactIn to exactOut or vice versa
error HookDeltaExceedsSwapAmount();
/// @notice Utility function intended to be used in hook constructors to ensure
/// the deployed hooks address causes the intended hooks to be called
/// @param permissions The hooks that are intended to be called
/// @dev permissions param is memory as the function will be called from constructors
function validateHookPermissions(IHooks self, Permissions memory permissions) internal pure {
if (
permissions.beforeInitialize != self.hasPermission(BEFORE_INITIALIZE_FLAG)
|| permissions.afterInitialize != self.hasPermission(AFTER_INITIALIZE_FLAG)
|| permissions.beforeAddLiquidity != self.hasPermission(BEFORE_ADD_LIQUIDITY_FLAG)
|| permissions.afterAddLiquidity != self.hasPermission(AFTER_ADD_LIQUIDITY_FLAG)
|| permissions.beforeRemoveLiquidity != self.hasPermission(BEFORE_REMOVE_LIQUIDITY_FLAG)
|| permissions.afterRemoveLiquidity != self.hasPermission(AFTER_REMOVE_LIQUIDITY_FLAG)
|| permissions.beforeSwap != self.hasPermission(BEFORE_SWAP_FLAG)
|| permissions.afterSwap != self.hasPermission(AFTER_SWAP_FLAG)
|| permissions.beforeDonate != self.hasPermission(BEFORE_DONATE_FLAG)
|| permissions.afterDonate != self.hasPermission(AFTER_DONATE_FLAG)
|| permissions.beforeSwapReturnDelta != self.hasPermission(BEFORE_SWAP_RETURNS_DELTA_FLAG)
|| permissions.afterSwapReturnDelta != self.hasPermission(AFTER_SWAP_RETURNS_DELTA_FLAG)
|| permissions.afterAddLiquidityReturnDelta != self.hasPermission(AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG)
|| permissions.afterRemoveLiquidityReturnDelta
!= self.hasPermission(AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG)
) {
HookAddressNotValid.selector.revertWith(address(self));
}
}
/// @notice Ensures that the hook address includes at least one hook flag or dynamic fees, or is the 0 address
/// @param self The hook to verify
/// @param fee The fee of the pool the hook is used with
/// @return bool True if the hook address is valid
function isValidHookAddress(IHooks self, uint24 fee) internal pure returns (bool) {
// The hook can only have a flag to return a hook delta on an action if it also has the corresponding action flag
if (!self.hasPermission(BEFORE_SWAP_FLAG) && self.hasPermission(BEFORE_SWAP_RETURNS_DELTA_FLAG)) return false;
if (!self.hasPermission(AFTER_SWAP_FLAG) && self.hasPermission(AFTER_SWAP_RETURNS_DELTA_FLAG)) return false;
if (!self.hasPermission(AFTER_ADD_LIQUIDITY_FLAG) && self.hasPermission(AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG))
{
return false;
}
if (
!self.hasPermission(AFTER_REMOVE_LIQUIDITY_FLAG)
&& self.hasPermission(AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG)
) return false;
// If there is no hook contract set, then fee cannot be dynamic
// If a hook contract is set, it must have at least 1 flag set, or have a dynamic fee
return address(self) == address(0)
? !fee.isDynamicFee()
: (uint160(address(self)) & ALL_HOOK_MASK > 0 || fee.isDynamicFee());
}
/// @notice performs a hook call using the given calldata on the given hook that doesn't return a delta
/// @return result The complete data returned by the hook
function callHook(IHooks self, bytes memory data) internal returns (bytes memory result) {
bool success;
assembly ("memory-safe") {
success := call(gas(), self, 0, add(data, 0x20), mload(data), 0, 0)
}
// Revert with FailedHookCall, containing any error message to bubble up
if (!success) CustomRevert.bubbleUpAndRevertWith(address(self), bytes4(data), HookCallFailed.selector);
// The call was successful, fetch the returned data
assembly ("memory-safe") {
// allocate result byte array from the free memory pointer
result := mload(0x40)
// store new free memory pointer at the end of the array padded to 32 bytes
mstore(0x40, add(result, and(add(returndatasize(), 0x3f), not(0x1f))))
// store length in memory
mstore(result, returndatasize())
// copy return data to result
returndatacopy(add(result, 0x20), 0, returndatasize())
}
// Length must be at least 32 to contain the selector. Check expected selector and returned selector match.
if (result.length < 32 || result.parseSelector() != data.parseSelector()) {
InvalidHookResponse.selector.revertWith();
}
}
/// @notice performs a hook call using the given calldata on the given hook
/// @return int256 The delta returned by the hook
function callHookWithReturnDelta(IHooks self, bytes memory data, bool parseReturn) internal returns (int256) {
bytes memory result = callHook(self, data);
// If this hook wasn't meant to return something, default to 0 delta
if (!parseReturn) return 0;
// A length of 64 bytes is required to return a bytes4, and a 32 byte delta
if (result.length != 64) InvalidHookResponse.selector.revertWith();
return result.parseReturnDelta();
}
/// @notice modifier to prevent calling a hook if they initiated the action
modifier noSelfCall(IHooks self) {
if (msg.sender != address(self)) {
_;
}
}
/// @notice calls beforeInitialize hook if permissioned and validates return value
function beforeInitialize(IHooks self, PoolKey memory key, uint160 sqrtPriceX96) internal noSelfCall(self) {
if (self.hasPermission(BEFORE_INITIALIZE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeInitialize, (msg.sender, key, sqrtPriceX96)));
}
}
/// @notice calls afterInitialize hook if permissioned and validates return value
function afterInitialize(IHooks self, PoolKey memory key, uint160 sqrtPriceX96, int24 tick)
internal
noSelfCall(self)
{
if (self.hasPermission(AFTER_INITIALIZE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.afterInitialize, (msg.sender, key, sqrtPriceX96, tick)));
}
}
/// @notice calls beforeModifyLiquidity hook if permissioned and validates return value
function beforeModifyLiquidity(
IHooks self,
PoolKey memory key,
ModifyLiquidityParams memory params,
bytes calldata hookData
) internal noSelfCall(self) {
if (params.liquidityDelta > 0 && self.hasPermission(BEFORE_ADD_LIQUIDITY_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeAddLiquidity, (msg.sender, key, params, hookData)));
} else if (params.liquidityDelta <= 0 && self.hasPermission(BEFORE_REMOVE_LIQUIDITY_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeRemoveLiquidity, (msg.sender, key, params, hookData)));
}
}
/// @notice calls afterModifyLiquidity hook if permissioned and validates return value
function afterModifyLiquidity(
IHooks self,
PoolKey memory key,
ModifyLiquidityParams memory params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) internal returns (BalanceDelta callerDelta, BalanceDelta hookDelta) {
if (msg.sender == address(self)) return (delta, BalanceDeltaLibrary.ZERO_DELTA);
callerDelta = delta;
if (params.liquidityDelta > 0) {
if (self.hasPermission(AFTER_ADD_LIQUIDITY_FLAG)) {
hookDelta = BalanceDelta.wrap(
self.callHookWithReturnDelta(
abi.encodeCall(
IHooks.afterAddLiquidity, (msg.sender, key, params, delta, feesAccrued, hookData)
),
self.hasPermission(AFTER_ADD_LIQUIDITY_RETURNS_DELTA_FLAG)
)
);
callerDelta = callerDelta - hookDelta;
}
} else {
if (self.hasPermission(AFTER_REMOVE_LIQUIDITY_FLAG)) {
hookDelta = BalanceDelta.wrap(
self.callHookWithReturnDelta(
abi.encodeCall(
IHooks.afterRemoveLiquidity, (msg.sender, key, params, delta, feesAccrued, hookData)
),
self.hasPermission(AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA_FLAG)
)
);
callerDelta = callerDelta - hookDelta;
}
}
}
/// @notice calls beforeSwap hook if permissioned and validates return value
function beforeSwap(IHooks self, PoolKey memory key, SwapParams memory params, bytes calldata hookData)
internal
returns (int256 amountToSwap, BeforeSwapDelta hookReturn, uint24 lpFeeOverride)
{
amountToSwap = params.amountSpecified;
if (msg.sender == address(self)) return (amountToSwap, BeforeSwapDeltaLibrary.ZERO_DELTA, lpFeeOverride);
if (self.hasPermission(BEFORE_SWAP_FLAG)) {
bytes memory result = callHook(self, abi.encodeCall(IHooks.beforeSwap, (msg.sender, key, params, hookData)));
// A length of 96 bytes is required to return a bytes4, a 32 byte delta, and an LP fee
if (result.length != 96) InvalidHookResponse.selector.revertWith();
// dynamic fee pools that want to override the cache fee, return a valid fee with the override flag. If override flag
// is set but an invalid fee is returned, the transaction will revert. Otherwise the current LP fee will be used
if (key.fee.isDynamicFee()) lpFeeOverride = result.parseFee();
// skip this logic for the case where the hook return is 0
if (self.hasPermission(BEFORE_SWAP_RETURNS_DELTA_FLAG)) {
hookReturn = BeforeSwapDelta.wrap(result.parseReturnDelta());
// any return in unspecified is passed to the afterSwap hook for handling
int128 hookDeltaSpecified = hookReturn.getSpecifiedDelta();
// Update the swap amount according to the hook's return, and check that the swap type doesn't change (exact input/output)
if (hookDeltaSpecified != 0) {
bool exactInput = amountToSwap < 0;
amountToSwap += hookDeltaSpecified;
if (exactInput ? amountToSwap > 0 : amountToSwap < 0) {
HookDeltaExceedsSwapAmount.selector.revertWith();
}
}
}
}
}
/// @notice calls afterSwap hook if permissioned and validates return value
function afterSwap(
IHooks self,
PoolKey memory key,
SwapParams memory params,
BalanceDelta swapDelta,
bytes calldata hookData,
BeforeSwapDelta beforeSwapHookReturn
) internal returns (BalanceDelta, BalanceDelta) {
if (msg.sender == address(self)) return (swapDelta, BalanceDeltaLibrary.ZERO_DELTA);
int128 hookDeltaSpecified = beforeSwapHookReturn.getSpecifiedDelta();
int128 hookDeltaUnspecified = beforeSwapHookReturn.getUnspecifiedDelta();
if (self.hasPermission(AFTER_SWAP_FLAG)) {
hookDeltaUnspecified += self.callHookWithReturnDelta(
abi.encodeCall(IHooks.afterSwap, (msg.sender, key, params, swapDelta, hookData)),
self.hasPermission(AFTER_SWAP_RETURNS_DELTA_FLAG)
).toInt128();
}
BalanceDelta hookDelta;
if (hookDeltaUnspecified != 0 || hookDeltaSpecified != 0) {
hookDelta = (params.amountSpecified < 0 == params.zeroForOne)
? toBalanceDelta(hookDeltaSpecified, hookDeltaUnspecified)
: toBalanceDelta(hookDeltaUnspecified, hookDeltaSpecified);
// the caller has to pay for (or receive) the hook's delta
swapDelta = swapDelta - hookDelta;
}
return (swapDelta, hookDelta);
}
/// @notice calls beforeDonate hook if permissioned and validates return value
function beforeDonate(IHooks self, PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
internal
noSelfCall(self)
{
if (self.hasPermission(BEFORE_DONATE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.beforeDonate, (msg.sender, key, amount0, amount1, hookData)));
}
}
/// @notice calls afterDonate hook if permissioned and validates return value
function afterDonate(IHooks self, PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
internal
noSelfCall(self)
{
if (self.hasPermission(AFTER_DONATE_FLAG)) {
self.callHook(abi.encodeCall(IHooks.afterDonate, (msg.sender, key, amount0, amount1, hookData)));
}
}
function hasPermission(IHooks self, uint160 flag) internal pure returns (bool) {
return uint160(address(self)) & flag != 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {ModifyLiquidityParams, SwapParams} from "../types/PoolOperation.sol";
import {BeforeSwapDelta} from "../types/BeforeSwapDelta.sol";
/// @notice V4 decides whether to invoke specific hooks by inspecting the least significant bits
/// of the address that the hooks contract is deployed to.
/// For example, a hooks contract deployed to address: 0x0000000000000000000000000000000000002400
/// has the lowest bits '10 0100 0000 0000' which would cause the 'before initialize' and 'after add liquidity' hooks to be used.
/// See the Hooks library for the full spec.
/// @dev Should only be callable by the v4 PoolManager.
interface IHooks {
/// @notice The hook called before the state of a pool is initialized
/// @param sender The initial msg.sender for the initialize call
/// @param key The key for the pool being initialized
/// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96
/// @return bytes4 The function selector for the hook
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) external returns (bytes4);
/// @notice The hook called after the state of a pool is initialized
/// @param sender The initial msg.sender for the initialize call
/// @param key The key for the pool being initialized
/// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96
/// @param tick The current tick after the state of a pool is initialized
/// @return bytes4 The function selector for the hook
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick)
external
returns (bytes4);
/// @notice The hook called before liquidity is added
/// @param sender The initial msg.sender for the add liquidity call
/// @param key The key for the pool
/// @param params The parameters for adding liquidity
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after liquidity is added
/// @param sender The initial msg.sender for the add liquidity call
/// @param key The key for the pool
/// @param params The parameters for adding liquidity
/// @param delta The caller's balance delta after adding liquidity; the sum of principal delta, fees accrued, and hook delta
/// @param feesAccrued The fees accrued since the last time fees were collected from this position
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterAddLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external returns (bytes4, BalanceDelta);
/// @notice The hook called before liquidity is removed
/// @param sender The initial msg.sender for the remove liquidity call
/// @param key The key for the pool
/// @param params The parameters for removing liquidity
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after liquidity is removed
/// @param sender The initial msg.sender for the remove liquidity call
/// @param key The key for the pool
/// @param params The parameters for removing liquidity
/// @param delta The caller's balance delta after removing liquidity; the sum of principal delta, fees accrued, and hook delta
/// @param feesAccrued The fees accrued since the last time fees were collected from this position
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterRemoveLiquidity(
address sender,
PoolKey calldata key,
ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external returns (bytes4, BalanceDelta);
/// @notice The hook called before a swap
/// @param sender The initial msg.sender for the swap call
/// @param key The key for the pool
/// @param params The parameters for the swap
/// @param hookData Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BeforeSwapDelta The hook's delta in specified and unspecified currencies. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
/// @return uint24 Optionally override the lp fee, only used if three conditions are met: 1. the Pool has a dynamic fee, 2. the value's 2nd highest bit is set (23rd bit, 0x400000), and 3. the value is less than or equal to the maximum fee (1 million)
function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata hookData)
external
returns (bytes4, BeforeSwapDelta, uint24);
/// @notice The hook called after a swap
/// @param sender The initial msg.sender for the swap call
/// @param key The key for the pool
/// @param params The parameters for the swap
/// @param delta The amount owed to the caller (positive) or owed to the pool (negative)
/// @param hookData Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return int128 The hook's delta in unspecified currency. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterSwap(
address sender,
PoolKey calldata key,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata hookData
) external returns (bytes4, int128);
/// @notice The hook called before donate
/// @param sender The initial msg.sender for the donate call
/// @param key The key for the pool
/// @param amount0 The amount of token0 being donated
/// @param amount1 The amount of token1 being donated
/// @param hookData Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after donate
/// @param sender The initial msg.sender for the donate call
/// @param key The key for the pool
/// @param amount0 The amount of token0 being donated
/// @param amount1 The amount of token1 being donated
/// @param hookData Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function afterDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Currency} from "../types/Currency.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {IHooks} from "./IHooks.sol";
import {IERC6909Claims} from "./external/IERC6909Claims.sol";
import {IProtocolFees} from "./IProtocolFees.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {PoolId} from "../types/PoolId.sol";
import {IExtsload} from "./IExtsload.sol";
import {IExttload} from "./IExttload.sol";
import {ModifyLiquidityParams, SwapParams} from "../types/PoolOperation.sol";
/// @notice Interface for the PoolManager
interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload, IExttload {
/// @notice Thrown when a currency is not netted out after the contract is unlocked
error CurrencyNotSettled();
/// @notice Thrown when trying to interact with a non-initialized pool
error PoolNotInitialized();
/// @notice Thrown when unlock is called, but the contract is already unlocked
error AlreadyUnlocked();
/// @notice Thrown when a function is called that requires the contract to be unlocked, but it is not
error ManagerLocked();
/// @notice Pools are limited to type(int16).max tickSpacing in #initialize, to prevent overflow
error TickSpacingTooLarge(int24 tickSpacing);
/// @notice Pools must have a positive non-zero tickSpacing passed to #initialize
error TickSpacingTooSmall(int24 tickSpacing);
/// @notice PoolKey must have currencies where address(currency0) < address(currency1)
error CurrenciesOutOfOrderOrEqual(address currency0, address currency1);
/// @notice Thrown when a call to updateDynamicLPFee is made by an address that is not the hook,
/// or on a pool that does not have a dynamic swap fee.
error UnauthorizedDynamicLPFeeUpdate();
/// @notice Thrown when trying to swap amount of 0
error SwapAmountCannotBeZero();
///@notice Thrown when native currency is passed to a non native settlement
error NonzeroNativeValue();
/// @notice Thrown when `clear` is called with an amount that is not exactly equal to the open currency delta.
error MustClearExactPositiveDelta();
/// @notice Emitted when a new pool is initialized
/// @param id The abi encoded hash of the pool key struct for the new pool
/// @param currency0 The first currency of the pool by address sort order
/// @param currency1 The second currency of the pool by address sort order
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param hooks The hooks contract address for the pool, or address(0) if none
/// @param sqrtPriceX96 The price of the pool on initialization
/// @param tick The initial tick of the pool corresponding to the initialized price
event Initialize(
PoolId indexed id,
Currency indexed currency0,
Currency indexed currency1,
uint24 fee,
int24 tickSpacing,
IHooks hooks,
uint160 sqrtPriceX96,
int24 tick
);
/// @notice Emitted when a liquidity position is modified
/// @param id The abi encoded hash of the pool key struct for the pool that was modified
/// @param sender The address that modified the pool
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param liquidityDelta The amount of liquidity that was added or removed
/// @param salt The extra data to make positions unique
event ModifyLiquidity(
PoolId indexed id, address indexed sender, int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt
);
/// @notice Emitted for swaps between currency0 and currency1
/// @param id The abi encoded hash of the pool key struct for the pool that was modified
/// @param sender The address that initiated the swap call, and that received the callback
/// @param amount0 The delta of the currency0 balance of the pool
/// @param amount1 The delta of the currency1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of the price of the pool after the swap
/// @param fee The swap fee in hundredths of a bip
event Swap(
PoolId indexed id,
address indexed sender,
int128 amount0,
int128 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick,
uint24 fee
);
/// @notice Emitted for donations
/// @param id The abi encoded hash of the pool key struct for the pool that was donated to
/// @param sender The address that initiated the donate call
/// @param amount0 The amount donated in currency0
/// @param amount1 The amount donated in currency1
event Donate(PoolId indexed id, address indexed sender, uint256 amount0, uint256 amount1);
/// @notice All interactions on the contract that account deltas require unlocking. A caller that calls `unlock` must implement
/// `IUnlockCallback(msg.sender).unlockCallback(data)`, where they interact with the remaining functions on this contract.
/// @dev The only functions callable without an unlocking are `initialize` and `updateDynamicLPFee`
/// @param data Any data to pass to the callback, via `IUnlockCallback(msg.sender).unlockCallback(data)`
/// @return The data returned by the call to `IUnlockCallback(msg.sender).unlockCallback(data)`
function unlock(bytes calldata data) external returns (bytes memory);
/// @notice Initialize the state for a given pool ID
/// @dev A swap fee totaling MAX_SWAP_FEE (100%) makes exact output swaps impossible since the input is entirely consumed by the fee
/// @param key The pool key for the pool to initialize
/// @param sqrtPriceX96 The initial square root price
/// @return tick The initial tick of the pool
function initialize(PoolKey memory key, uint160 sqrtPriceX96) external returns (int24 tick);
/// @notice Modify the liquidity for the given pool
/// @dev Poke by calling with a zero liquidityDelta
/// @param key The pool to modify liquidity in
/// @param params The parameters for modifying the liquidity
/// @param hookData The data to pass through to the add/removeLiquidity hooks
/// @return callerDelta The balance delta of the caller of modifyLiquidity. This is the total of both principal, fee deltas, and hook deltas if applicable
/// @return feesAccrued The balance delta of the fees generated in the liquidity range. Returned for informational purposes
/// @dev Note that feesAccrued can be artificially inflated by a malicious actor and integrators should be careful using the value
/// For pools with a single liquidity position, actors can donate to themselves to inflate feeGrowthGlobal (and consequently feesAccrued)
/// atomically donating and collecting fees in the same unlockCallback may make the inflated value more extreme
function modifyLiquidity(PoolKey memory key, ModifyLiquidityParams memory params, bytes calldata hookData)
external
returns (BalanceDelta callerDelta, BalanceDelta feesAccrued);
/// @notice Swap against the given pool
/// @param key The pool to swap in
/// @param params The parameters for swapping
/// @param hookData The data to pass through to the swap hooks
/// @return swapDelta The balance delta of the address swapping
/// @dev Swapping on low liquidity pools may cause unexpected swap amounts when liquidity available is less than amountSpecified.
/// Additionally note that if interacting with hooks that have the BEFORE_SWAP_RETURNS_DELTA_FLAG or AFTER_SWAP_RETURNS_DELTA_FLAG
/// the hook may alter the swap input/output. Integrators should perform checks on the returned swapDelta.
function swap(PoolKey memory key, SwapParams memory params, bytes calldata hookData)
external
returns (BalanceDelta swapDelta);
/// @notice Donate the given currency amounts to the in-range liquidity providers of a pool
/// @dev Calls to donate can be frontrun adding just-in-time liquidity, with the aim of receiving a portion donated funds.
/// Donors should keep this in mind when designing donation mechanisms.
/// @dev This function donates to in-range LPs at slot0.tick. In certain edge-cases of the swap algorithm, the `sqrtPrice` of
/// a pool can be at the lower boundary of tick `n`, but the `slot0.tick` of the pool is already `n - 1`. In this case a call to
/// `donate` would donate to tick `n - 1` (slot0.tick) not tick `n` (getTickAtSqrtPrice(slot0.sqrtPriceX96)).
/// Read the comments in `Pool.swap()` for more information about this.
/// @param key The key of the pool to donate to
/// @param amount0 The amount of currency0 to donate
/// @param amount1 The amount of currency1 to donate
/// @param hookData The data to pass through to the donate hooks
/// @return BalanceDelta The delta of the caller after the donate
function donate(PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
external
returns (BalanceDelta);
/// @notice Writes the current ERC20 balance of the specified currency to transient storage
/// This is used to checkpoint balances for the manager and derive deltas for the caller.
/// @dev This MUST be called before any ERC20 tokens are sent into the contract, but can be skipped
/// for native tokens because the amount to settle is determined by the sent value.
/// However, if an ERC20 token has been synced and not settled, and the caller instead wants to settle
/// native funds, this function can be called with the native currency to then be able to settle the native currency
function sync(Currency currency) external;
/// @notice Called by the user to net out some value owed to the user
/// @dev Will revert if the requested amount is not available, consider using `mint` instead
/// @dev Can also be used as a mechanism for free flash loans
/// @param currency The currency to withdraw from the pool manager
/// @param to The address to withdraw to
/// @param amount The amount of currency to withdraw
function take(Currency currency, address to, uint256 amount) external;
/// @notice Called by the user to pay what is owed
/// @return paid The amount of currency settled
function settle() external payable returns (uint256 paid);
/// @notice Called by the user to pay on behalf of another address
/// @param recipient The address to credit for the payment
/// @return paid The amount of currency settled
function settleFor(address recipient) external payable returns (uint256 paid);
/// @notice WARNING - Any currency that is cleared, will be non-retrievable, and locked in the contract permanently.
/// A call to clear will zero out a positive balance WITHOUT a corresponding transfer.
/// @dev This could be used to clear a balance that is considered dust.
/// Additionally, the amount must be the exact positive balance. This is to enforce that the caller is aware of the amount being cleared.
function clear(Currency currency, uint256 amount) external;
/// @notice Called by the user to move value into ERC6909 balance
/// @param to The address to mint the tokens to
/// @param id The currency address to mint to ERC6909s, as a uint256
/// @param amount The amount of currency to mint
/// @dev The id is converted to a uint160 to correspond to a currency address
/// If the upper 12 bytes are not 0, they will be 0-ed out
function mint(address to, uint256 id, uint256 amount) external;
/// @notice Called by the user to move value from ERC6909 balance
/// @param from The address to burn the tokens from
/// @param id The currency address to burn from ERC6909s, as a uint256
/// @param amount The amount of currency to burn
/// @dev The id is converted to a uint160 to correspond to a currency address
/// If the upper 12 bytes are not 0, they will be 0-ed out
function burn(address from, uint256 id, uint256 amount) external;
/// @notice Updates the pools lp fees for the a pool that has enabled dynamic lp fees.
/// @dev A swap fee totaling MAX_SWAP_FEE (100%) makes exact output swaps impossible since the input is entirely consumed by the fee
/// @param key The key of the pool to update dynamic LP fees for
/// @param newDynamicLPFee The new dynamic pool LP fee
function updateDynamicLPFee(PoolKey memory key, uint24 newDynamicLPFee) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Currency} from "./Currency.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {PoolIdLibrary} from "./PoolId.sol";
using PoolIdLibrary for PoolKey global;
/// @notice Returns the key for identifying a pool
struct PoolKey {
/// @notice The lower currency of the pool, sorted numerically
Currency currency0;
/// @notice The higher currency of the pool, sorted numerically
Currency currency1;
/// @notice The pool LP fee, capped at 1_000_000. If the highest bit is 1, the pool has a dynamic fee and must be exactly equal to 0x800000
uint24 fee;
/// @notice Ticks that involve positions must be a multiple of tick spacing
int24 tickSpacing;
/// @notice The hooks of the pool
IHooks hooks;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "./PoolKey.sol";
type PoolId is bytes32;
/// @notice Library for computing the ID of a pool
library PoolIdLibrary {
/// @notice Returns value equal to keccak256(abi.encode(poolKey))
function toId(PoolKey memory poolKey) internal pure returns (PoolId poolId) {
assembly ("memory-safe") {
// 0xa0 represents the total size of the poolKey struct (5 slots of 32 bytes)
poolId := keccak256(poolKey, 0xa0)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
/// @notice Parameter struct for `ModifyLiquidity` pool operations
struct ModifyLiquidityParams {
// the lower and upper tick of the position
int24 tickLower;
int24 tickUpper;
// how to modify the liquidity
int256 liquidityDelta;
// a value to set if you want unique liquidity positions at the same range
bytes32 salt;
}
/// @notice Parameter struct for `Swap` pool operations
struct SwapParams {
/// Whether to swap token0 for token1 or vice versa
bool zeroForOne;
/// The desired input amount if negative (exactIn), or the desired output amount if positive (exactOut)
int256 amountSpecified;
/// The sqrt price at which, if reached, the swap will stop executing
uint160 sqrtPriceLimitX96;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Return type of the beforeSwap hook.
// Upper 128 bits is the delta in specified tokens. Lower 128 bits is delta in unspecified tokens (to match the afterSwap hook)
type BeforeSwapDelta is int256;
// Creates a BeforeSwapDelta from specified and unspecified
function toBeforeSwapDelta(int128 deltaSpecified, int128 deltaUnspecified)
pure
returns (BeforeSwapDelta beforeSwapDelta)
{
assembly ("memory-safe") {
beforeSwapDelta := or(shl(128, deltaSpecified), and(sub(shl(128, 1), 1), deltaUnspecified))
}
}
/// @notice Library for getting the specified and unspecified deltas from the BeforeSwapDelta type
library BeforeSwapDeltaLibrary {
/// @notice A BeforeSwapDelta of 0
BeforeSwapDelta public constant ZERO_DELTA = BeforeSwapDelta.wrap(0);
/// extracts int128 from the upper 128 bits of the BeforeSwapDelta
/// returned by beforeSwap
function getSpecifiedDelta(BeforeSwapDelta delta) internal pure returns (int128 deltaSpecified) {
assembly ("memory-safe") {
deltaSpecified := sar(128, delta)
}
}
/// extracts int128 from the lower 128 bits of the BeforeSwapDelta
/// returned by beforeSwap and afterSwap
function getUnspecifiedDelta(BeforeSwapDelta delta) internal pure returns (int128 deltaUnspecified) {
assembly ("memory-safe") {
deltaUnspecified := signextend(15, delta)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {SafeCast} from "../libraries/SafeCast.sol";
/// @dev Two `int128` values packed into a single `int256` where the upper 128 bits represent the amount0
/// and the lower 128 bits represent the amount1.
type BalanceDelta is int256;
using {add as +, sub as -, eq as ==, neq as !=} for BalanceDelta global;
using BalanceDeltaLibrary for BalanceDelta global;
using SafeCast for int256;
function toBalanceDelta(int128 _amount0, int128 _amount1) pure returns (BalanceDelta balanceDelta) {
assembly ("memory-safe") {
balanceDelta := or(shl(128, _amount0), and(sub(shl(128, 1), 1), _amount1))
}
}
function add(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
int256 res0;
int256 res1;
assembly ("memory-safe") {
let a0 := sar(128, a)
let a1 := signextend(15, a)
let b0 := sar(128, b)
let b1 := signextend(15, b)
res0 := add(a0, b0)
res1 := add(a1, b1)
}
return toBalanceDelta(res0.toInt128(), res1.toInt128());
}
function sub(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
int256 res0;
int256 res1;
assembly ("memory-safe") {
let a0 := sar(128, a)
let a1 := signextend(15, a)
let b0 := sar(128, b)
let b1 := signextend(15, b)
res0 := sub(a0, b0)
res1 := sub(a1, b1)
}
return toBalanceDelta(res0.toInt128(), res1.toInt128());
}
function eq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
return BalanceDelta.unwrap(a) == BalanceDelta.unwrap(b);
}
function neq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
return BalanceDelta.unwrap(a) != BalanceDelta.unwrap(b);
}
/// @notice Library for getting the amount0 and amount1 deltas from the BalanceDelta type
library BalanceDeltaLibrary {
/// @notice A BalanceDelta of 0
BalanceDelta public constant ZERO_DELTA = BalanceDelta.wrap(0);
function amount0(BalanceDelta balanceDelta) internal pure returns (int128 _amount0) {
assembly ("memory-safe") {
_amount0 := sar(128, balanceDelta)
}
}
function amount1(BalanceDelta balanceDelta) internal pure returns (int128 _amount1) {
assembly ("memory-safe") {
_amount1 := signextend(15, balanceDelta)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20Minimal} from "../interfaces/external/IERC20Minimal.sol";
import {CustomRevert} from "../libraries/CustomRevert.sol";
type Currency is address;
using {greaterThan as >, lessThan as <, greaterThanOrEqualTo as >=, equals as ==} for Currency global;
using CurrencyLibrary for Currency global;
function equals(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) == Currency.unwrap(other);
}
function greaterThan(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) > Currency.unwrap(other);
}
function lessThan(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) < Currency.unwrap(other);
}
function greaterThanOrEqualTo(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) >= Currency.unwrap(other);
}
/// @title CurrencyLibrary
/// @dev This library allows for transferring and holding native tokens and ERC20 tokens
library CurrencyLibrary {
/// @notice Additional context for ERC-7751 wrapped error when a native transfer fails
error NativeTransferFailed();
/// @notice Additional context for ERC-7751 wrapped error when an ERC20 transfer fails
error ERC20TransferFailed();
/// @notice A constant to represent the native currency
Currency public constant ADDRESS_ZERO = Currency.wrap(address(0));
function transfer(Currency currency, address to, uint256 amount) internal {
// altered from https://github.com/transmissions11/solmate/blob/44a9963d4c78111f77caa0e65d677b8b46d6f2e6/src/utils/SafeTransferLib.sol
// modified custom error selectors
bool success;
if (currency.isAddressZero()) {
assembly ("memory-safe") {
// Transfer the ETH and revert if it fails.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
// revert with NativeTransferFailed, containing the bubbled up error as an argument
if (!success) {
CustomRevert.bubbleUpAndRevertWith(to, bytes4(0), NativeTransferFailed.selector);
}
} else {
assembly ("memory-safe") {
// Get a pointer to some free memory.
let fmp := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(fmp, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(fmp, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
mstore(add(fmp, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.
success :=
and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), currency, 0, fmp, 68, 0, 32)
)
// Now clean the memory we used
mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `to` were stored here
mstore(add(fmp, 0x20), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
mstore(add(fmp, 0x40), 0) // 4 bytes of `amount` were stored here
}
// revert with ERC20TransferFailed, containing the bubbled up error as an argument
if (!success) {
CustomRevert.bubbleUpAndRevertWith(
Currency.unwrap(currency), IERC20Minimal.transfer.selector, ERC20TransferFailed.selector
);
}
}
}
function balanceOfSelf(Currency currency) internal view returns (uint256) {
if (currency.isAddressZero()) {
return address(this).balance;
} else {
return IERC20Minimal(Currency.unwrap(currency)).balanceOf(address(this));
}
}
function balanceOf(Currency currency, address owner) internal view returns (uint256) {
if (currency.isAddressZero()) {
return owner.balance;
} else {
return IERC20Minimal(Currency.unwrap(currency)).balanceOf(owner);
}
}
function isAddressZero(Currency currency) internal pure returns (bool) {
return Currency.unwrap(currency) == Currency.unwrap(ADDRESS_ZERO);
}
function toId(Currency currency) internal pure returns (uint256) {
return uint160(Currency.unwrap(currency));
}
// If the upper 12 bytes are non-zero, they will be zero-ed out
// Therefore, fromId() and toId() are not inverses of each other
function fromId(uint256 id) internal pure returns (Currency) {
return Currency.wrap(address(uint160(id)));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {IImmutableState} from "../interfaces/IImmutableState.sol";
/// @title Immutable State
/// @notice A collection of immutable state variables, commonly used across multiple contracts
contract ImmutableState is IImmutableState {
/// @inheritdoc IImmutableState
IPoolManager public immutable poolManager;
/// @notice Thrown when the caller is not PoolManager
error NotPoolManager();
/// @notice Only allow calls from the PoolManager contract
modifier onlyPoolManager() {
if (msg.sender != address(poolManager)) revert NotPoolManager();
_;
}
constructor(IPoolManager _poolManager) {
poolManager = _poolManager;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {CustomRevert} from "./CustomRevert.sol";
/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
using CustomRevert for bytes4;
error SafeCastOverflow();
/// @notice Cast a uint256 to a uint160, revert on overflow
/// @param x The uint256 to be downcasted
/// @return y The downcasted integer, now type uint160
function toUint160(uint256 x) internal pure returns (uint160 y) {
y = uint160(x);
if (y != x) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a uint128, revert on overflow
/// @param x The uint256 to be downcasted
/// @return y The downcasted integer, now type uint128
function toUint128(uint256 x) internal pure returns (uint128 y) {
y = uint128(x);
if (x != y) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a int128 to a uint128, revert on overflow or underflow
/// @param x The int128 to be casted
/// @return y The casted integer, now type uint128
function toUint128(int128 x) internal pure returns (uint128 y) {
if (x < 0) SafeCastOverflow.selector.revertWith();
y = uint128(x);
}
/// @notice Cast a int256 to a int128, revert on overflow or underflow
/// @param x The int256 to be downcasted
/// @return y The downcasted integer, now type int128
function toInt128(int256 x) internal pure returns (int128 y) {
y = int128(x);
if (y != x) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a int256, revert on overflow
/// @param x The uint256 to be casted
/// @return y The casted integer, now type int256
function toInt256(uint256 x) internal pure returns (int256 y) {
y = int256(x);
if (y < 0) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a int128, revert on overflow
/// @param x The uint256 to be downcasted
/// @return The downcasted integer, now type int128
function toInt128(uint256 x) internal pure returns (int128) {
if (x >= 1 << 127) SafeCastOverflow.selector.revertWith();
return int128(int256(x));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {CustomRevert} from "./CustomRevert.sol";
/// @notice Library of helper functions for a pools LP fee
library LPFeeLibrary {
using LPFeeLibrary for uint24;
using CustomRevert for bytes4;
/// @notice Thrown when the static or dynamic fee on a pool exceeds 100%.
error LPFeeTooLarge(uint24 fee);
/// @notice An lp fee of exactly 0b1000000... signals a dynamic fee pool. This isn't a valid static fee as it is > MAX_LP_FEE
uint24 public constant DYNAMIC_FEE_FLAG = 0x800000;
/// @notice the second bit of the fee returned by beforeSwap is used to signal if the stored LP fee should be overridden in this swap
// only dynamic-fee pools can return a fee via the beforeSwap hook
uint24 public constant OVERRIDE_FEE_FLAG = 0x400000;
/// @notice mask to remove the override fee flag from a fee returned by the beforeSwaphook
uint24 public constant REMOVE_OVERRIDE_MASK = 0xBFFFFF;
/// @notice the lp fee is represented in hundredths of a bip, so the max is 100%
uint24 public constant MAX_LP_FEE = 1000000;
/// @notice returns true if a pool's LP fee signals that the pool has a dynamic fee
/// @param self The fee to check
/// @return bool True of the fee is dynamic
function isDynamicFee(uint24 self) internal pure returns (bool) {
return self == DYNAMIC_FEE_FLAG;
}
/// @notice returns true if an LP fee is valid, aka not above the maximum permitted fee
/// @param self The fee to check
/// @return bool True of the fee is valid
function isValid(uint24 self) internal pure returns (bool) {
return self <= MAX_LP_FEE;
}
/// @notice validates whether an LP fee is larger than the maximum, and reverts if invalid
/// @param self The fee to validate
function validate(uint24 self) internal pure {
if (!self.isValid()) LPFeeTooLarge.selector.revertWith(self);
}
/// @notice gets and validates the initial LP fee for a pool. Dynamic fee pools have an initial fee of 0.
/// @dev if a dynamic fee pool wants a non-0 initial fee, it should call `updateDynamicLPFee` in the afterInitialize hook
/// @param self The fee to get the initial LP from
/// @return initialFee 0 if the fee is dynamic, otherwise the fee (if valid)
function getInitialLPFee(uint24 self) internal pure returns (uint24) {
// the initial fee for a dynamic fee pool is 0
if (self.isDynamicFee()) return 0;
self.validate();
return self;
}
/// @notice returns true if the fee has the override flag set (2nd highest bit of the uint24)
/// @param self The fee to check
/// @return bool True of the fee has the override flag set
function isOverride(uint24 self) internal pure returns (bool) {
return self & OVERRIDE_FEE_FLAG != 0;
}
/// @notice returns a fee with the override flag removed
/// @param self The fee to remove the override flag from
/// @return fee The fee without the override flag set
function removeOverrideFlag(uint24 self) internal pure returns (uint24) {
return self & REMOVE_OVERRIDE_MASK;
}
/// @notice Removes the override flag and validates the fee (reverts if the fee is too large)
/// @param self The fee to remove the override flag from, and then validate
/// @return fee The fee without the override flag set (if valid)
function removeOverrideFlagAndValidate(uint24 self) internal pure returns (uint24 fee) {
fee = self.removeOverrideFlag();
fee.validate();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Parses bytes returned from hooks and the byte selector used to check return selectors from hooks.
/// @dev parseSelector also is used to parse the expected selector
/// For parsing hook returns, note that all hooks return either bytes4 or (bytes4, 32-byte-delta) or (bytes4, 32-byte-delta, uint24).
library ParseBytes {
function parseSelector(bytes memory result) internal pure returns (bytes4 selector) {
// equivalent: (selector,) = abi.decode(result, (bytes4, int256));
assembly ("memory-safe") {
selector := mload(add(result, 0x20))
}
}
function parseFee(bytes memory result) internal pure returns (uint24 lpFee) {
// equivalent: (,, lpFee) = abi.decode(result, (bytes4, int256, uint24));
assembly ("memory-safe") {
lpFee := mload(add(result, 0x60))
}
}
function parseReturnDelta(bytes memory result) internal pure returns (int256 hookReturn) {
// equivalent: (, hookReturnDelta) = abi.decode(result, (bytes4, int256));
assembly ("memory-safe") {
hookReturn := mload(add(result, 0x40))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Library for reverting with custom errors efficiently
/// @notice Contains functions for reverting with custom errors with different argument types efficiently
/// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with
/// `CustomError.selector.revertWith()`
/// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately
library CustomRevert {
/// @dev ERC-7751 error for wrapping bubbled up reverts
error WrappedError(address target, bytes4 selector, bytes reason, bytes details);
/// @dev Reverts with the selector of a custom error in the scratch space
function revertWith(bytes4 selector) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
revert(0, 0x04)
}
}
/// @dev Reverts with a custom error with an address argument in the scratch space
function revertWith(bytes4 selector, address addr) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with an int24 argument in the scratch space
function revertWith(bytes4 selector, int24 value) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, signextend(2, value))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with a uint160 argument in the scratch space
function revertWith(bytes4 selector, uint160 value) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, and(value, 0xffffffffffffffffffffffffffffffffffffffff))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with two int24 arguments
function revertWith(bytes4 selector, int24 value1, int24 value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), signextend(2, value1))
mstore(add(fmp, 0x24), signextend(2, value2))
revert(fmp, 0x44)
}
}
/// @dev Reverts with a custom error with two uint160 arguments
function revertWith(bytes4 selector, uint160 value1, uint160 value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
revert(fmp, 0x44)
}
}
/// @dev Reverts with a custom error with two address arguments
function revertWith(bytes4 selector, address value1, address value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
revert(fmp, 0x44)
}
}
/// @notice bubble up the revert message returned by a call and revert with a wrapped ERC-7751 error
/// @dev this method can be vulnerable to revert data bombs
function bubbleUpAndRevertWith(
address revertingContract,
bytes4 revertingFunctionSelector,
bytes4 additionalContext
) internal pure {
bytes4 wrappedErrorSelector = WrappedError.selector;
assembly ("memory-safe") {
// Ensure the size of the revert data is a multiple of 32 bytes
let encodedDataSize := mul(div(add(returndatasize(), 31), 32), 32)
let fmp := mload(0x40)
// Encode wrapped error selector, address, function selector, offset, additional context, size, revert reason
mstore(fmp, wrappedErrorSelector)
mstore(add(fmp, 0x04), and(revertingContract, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(
add(fmp, 0x24),
and(revertingFunctionSelector, 0xffffffff00000000000000000000000000000000000000000000000000000000)
)
// offset revert reason
mstore(add(fmp, 0x44), 0x80)
// offset additional context
mstore(add(fmp, 0x64), add(0xa0, encodedDataSize))
// size revert reason
mstore(add(fmp, 0x84), returndatasize())
// revert reason
returndatacopy(add(fmp, 0xa4), 0, returndatasize())
// size additional context
mstore(add(fmp, add(0xa4, encodedDataSize)), 0x04)
// additional context
mstore(
add(fmp, add(0xc4, encodedDataSize)),
and(additionalContext, 0xffffffff00000000000000000000000000000000000000000000000000000000)
)
revert(fmp, add(0xe4, encodedDataSize))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for claims over a contract balance, wrapped as a ERC6909
interface IERC6909Claims {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OperatorSet(address indexed owner, address indexed operator, bool approved);
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
event Transfer(address caller, address indexed from, address indexed to, uint256 indexed id, uint256 amount);
/*//////////////////////////////////////////////////////////////
FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Owner balance of an id.
/// @param owner The address of the owner.
/// @param id The id of the token.
/// @return amount The balance of the token.
function balanceOf(address owner, uint256 id) external view returns (uint256 amount);
/// @notice Spender allowance of an id.
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @return amount The allowance of the token.
function allowance(address owner, address spender, uint256 id) external view returns (uint256 amount);
/// @notice Checks if a spender is approved by an owner as an operator
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @return approved The approval status.
function isOperator(address owner, address spender) external view returns (bool approved);
/// @notice Transfers an amount of an id from the caller to a receiver.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Transfers an amount of an id from a sender to a receiver.
/// @param sender The address of the sender.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Approves an amount of an id to a spender.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
/// @notice Sets or removes an operator for the caller.
/// @param operator The address of the operator.
/// @param approved The approval status.
/// @return bool True, always
function setOperator(address operator, bool approved) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Currency} from "../types/Currency.sol";
import {PoolId} from "../types/PoolId.sol";
import {PoolKey} from "../types/PoolKey.sol";
/// @notice Interface for all protocol-fee related functions in the pool manager
interface IProtocolFees {
/// @notice Thrown when protocol fee is set too high
error ProtocolFeeTooLarge(uint24 fee);
/// @notice Thrown when collectProtocolFees or setProtocolFee is not called by the controller.
error InvalidCaller();
/// @notice Thrown when collectProtocolFees is attempted on a token that is synced.
error ProtocolFeeCurrencySynced();
/// @notice Emitted when the protocol fee controller address is updated in setProtocolFeeController.
event ProtocolFeeControllerUpdated(address indexed protocolFeeController);
/// @notice Emitted when the protocol fee is updated for a pool.
event ProtocolFeeUpdated(PoolId indexed id, uint24 protocolFee);
/// @notice Given a currency address, returns the protocol fees accrued in that currency
/// @param currency The currency to check
/// @return amount The amount of protocol fees accrued in the currency
function protocolFeesAccrued(Currency currency) external view returns (uint256 amount);
/// @notice Sets the protocol fee for the given pool
/// @param key The key of the pool to set a protocol fee for
/// @param newProtocolFee The fee to set
function setProtocolFee(PoolKey memory key, uint24 newProtocolFee) external;
/// @notice Sets the protocol fee controller
/// @param controller The new protocol fee controller
function setProtocolFeeController(address controller) external;
/// @notice Collects the protocol fees for a given recipient and currency, returning the amount collected
/// @dev This will revert if the contract is unlocked
/// @param recipient The address to receive the protocol fees
/// @param currency The currency to withdraw
/// @param amount The amount of currency to withdraw
/// @return amountCollected The amount of currency successfully withdrawn
function collectProtocolFees(address recipient, Currency currency, uint256 amount)
external
returns (uint256 amountCollected);
/// @notice Returns the current protocol fee controller address
/// @return address The current protocol fee controller address
function protocolFeeController() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for functions to access any storage slot in a contract
interface IExtsload {
/// @notice Called by external contracts to access granular pool state
/// @param slot Key of slot to sload
/// @return value The value of the slot as bytes32
function extsload(bytes32 slot) external view returns (bytes32 value);
/// @notice Called by external contracts to access granular pool state
/// @param startSlot Key of slot to start sloading from
/// @param nSlots Number of slots to load into return value
/// @return values List of loaded values.
function extsload(bytes32 startSlot, uint256 nSlots) external view returns (bytes32[] memory values);
/// @notice Called by external contracts to access sparse pool state
/// @param slots List of slots to SLOAD from.
/// @return values List of loaded values.
function extsload(bytes32[] calldata slots) external view returns (bytes32[] memory values);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @notice Interface for functions to access any transient storage slot in a contract
interface IExttload {
/// @notice Called by external contracts to access transient storage of the contract
/// @param slot Key of slot to tload
/// @return value The value of the slot as bytes32
function exttload(bytes32 slot) external view returns (bytes32 value);
/// @notice Called by external contracts to access sparse transient pool state
/// @param slots List of slots to tload
/// @return values List of loaded values
function exttload(bytes32[] calldata slots) external view returns (bytes32[] memory values);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Minimal ERC20 interface for Uniswap
/// @notice Contains a subset of the full ERC20 interface that is used in Uniswap V3
interface IERC20Minimal {
/// @notice Returns an account's balance in the token
/// @param account The account for which to look up the number of tokens it has, i.e. its balance
/// @return The number of tokens held by the account
function balanceOf(address account) external view returns (uint256);
/// @notice Transfers the amount of token from the `msg.sender` to the recipient
/// @param recipient The account that will receive the amount transferred
/// @param amount The number of tokens to send from the sender to the recipient
/// @return Returns true for a successful transfer, false for an unsuccessful transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/// @notice Returns the current allowance given to a spender by an owner
/// @param owner The account of the token owner
/// @param spender The account of the token spender
/// @return The current allowance granted by `owner` to `spender`
function allowance(address owner, address spender) external view returns (uint256);
/// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount`
/// @param spender The account which will be allowed to spend a given amount of the owners tokens
/// @param amount The amount of tokens allowed to be used by `spender`
/// @return Returns true for a successful approval, false for unsuccessful
function approve(address spender, uint256 amount) external returns (bool);
/// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender`
/// @param sender The account from which the transfer will be initiated
/// @param recipient The recipient of the transfer
/// @param amount The amount of the transfer
/// @return Returns true for a successful transfer, false for unsuccessful
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`.
/// @param from The account from which the tokens were sent, i.e. the balance decreased
/// @param to The account to which the tokens were sent, i.e. the balance increased
/// @param value The amount of tokens that were transferred
event Transfer(address indexed from, address indexed to, uint256 value);
/// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes.
/// @param owner The account that approved spending of its tokens
/// @param spender The account for which the spending allowance was modified
/// @param value The new allowance from the owner to the spender
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
/// @title IImmutableState
/// @notice Interface for the ImmutableState contract
interface IImmutableState {
/// @notice The Uniswap v4 PoolManager contract
function poolManager() external view returns (IPoolManager);
}{
"remappings": [
"@openzeppelin/contracts@4.9.6/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@chainlink/=lib/chainlink-evm/",
"forge-std/=lib/forge-std/src/",
"v4-core/=lib/v4-periphery/lib/v4-core/",
"v4-periphery/=lib/v4-periphery/",
"solmate/=lib/solmate/src/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"chainlink-evm/=lib/chainlink-evm/",
"chainlink/=lib/chainlink/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"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/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"permit2/=lib/v4-periphery/lib/permit2/"
],
"optimizer": {
"enabled": true,
"runs": 10000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IPoolManager","name":"_poolManager","type":"address"},{"internalType":"address","name":"_buxToken","type":"address"},{"internalType":"address payable","name":"_action","type":"address"},{"internalType":"address payable","name":"_devFeeSplitter","type":"address"},{"internalType":"uint16","name":"_hourlyBps","type":"uint16"},{"internalType":"uint16","name":"_dailyBps","type":"uint16"},{"internalType":"uint16","name":"_devBps","type":"uint16"},{"internalType":"address","name":"initialOwner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ExactOutputNotSupported","type":"error"},{"inputs":[],"name":"ExceedsSwapAmount","type":"error"},{"inputs":[],"name":"FeesTooHigh","type":"error"},{"inputs":[],"name":"HookNotImplemented","type":"error"},{"inputs":[],"name":"InvalidConfig","type":"error"},{"inputs":[],"name":"InvalidPool","type":"error"},{"inputs":[],"name":"NotBuxEthPool","type":"error"},{"inputs":[],"name":"NotPoolManager","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"PoolNotAllowed","type":"error"},{"inputs":[],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"reason","type":"bytes"}],"name":"ActionFundingFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"AllowlistToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"poolId","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"ethWasSpecified","type":"bool"},{"indexed":false,"internalType":"uint256","name":"ethMoved","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeTaken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"hourlyPortion","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dailyPortion","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"devPortion","type":"uint256"}],"name":"FeeRealized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"FeesToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"hourlyBps","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"dailyBps","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"devBps","type":"uint16"}],"name":"FeesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"poolId","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"allowed","type":"bool"}],"name":"PoolAllowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"action","type":"address"},{"indexed":false,"internalType":"address","name":"devFeeSplitter","type":"address"}],"name":"RecipientsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StuckETHRecovered","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"action","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"BalanceDelta","name":"delta","type":"int256"},{"internalType":"BalanceDelta","name":"feesAccrued","type":"int256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterAddLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"BalanceDelta","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterDonate","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"internalType":"int24","name":"tick","type":"int24"}],"name":"afterInitialize","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"BalanceDelta","name":"delta","type":"int256"},{"internalType":"BalanceDelta","name":"feesAccrued","type":"int256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterRemoveLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"BalanceDelta","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"int256","name":"amountSpecified","type":"int256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct SwapParams","name":"params","type":"tuple"},{"internalType":"BalanceDelta","name":"delta","type":"int256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"afterSwap","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"internalType":"bool","name":"allowed","type":"bool"}],"name":"allowPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allowedPoolCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"PoolId","name":"","type":"bytes32"}],"name":"allowedPools","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowlistEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeAddLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeDonate","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"name":"beforeInitialize","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"int256","name":"liquidityDelta","type":"int256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ModifyLiquidityParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeRemoveLiquidity","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"int256","name":"amountSpecified","type":"int256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct SwapParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"beforeSwap","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"},{"internalType":"BeforeSwapDelta","name":"","type":"int256"},{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buxToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dailyBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"devBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"devFeeSplitter","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feesEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHookPermissions","outputs":[{"components":[{"internalType":"bool","name":"beforeInitialize","type":"bool"},{"internalType":"bool","name":"afterInitialize","type":"bool"},{"internalType":"bool","name":"beforeAddLiquidity","type":"bool"},{"internalType":"bool","name":"afterAddLiquidity","type":"bool"},{"internalType":"bool","name":"beforeRemoveLiquidity","type":"bool"},{"internalType":"bool","name":"afterRemoveLiquidity","type":"bool"},{"internalType":"bool","name":"beforeSwap","type":"bool"},{"internalType":"bool","name":"afterSwap","type":"bool"},{"internalType":"bool","name":"beforeDonate","type":"bool"},{"internalType":"bool","name":"afterDonate","type":"bool"},{"internalType":"bool","name":"beforeSwapReturnDelta","type":"bool"},{"internalType":"bool","name":"afterSwapReturnDelta","type":"bool"},{"internalType":"bool","name":"afterAddLiquidityReturnDelta","type":"bool"},{"internalType":"bool","name":"afterRemoveLiquidityReturnDelta","type":"bool"}],"internalType":"struct Hooks.Permissions","name":"p","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"hourlyBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"name":"isPoolAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolManager","outputs":[{"internalType":"contract IPoolManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"recoverStuckETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setAllowlistEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_hourlyBps","type":"uint16"},{"internalType":"uint16","name":"_dailyBps","type":"uint16"},{"internalType":"uint16","name":"_devBps","type":"uint16"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setFeesEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_action","type":"address"},{"internalType":"address payable","name":"_devFeeSplitter","type":"address"}],"name":"setRecipients","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60e0604052346102c857604051601f61285e38819003918201601f19168301916001600160401b038311848410176102cc57808492610100946040528339810103126102c8578051906001600160a01b03821682036102c857610064602082016102e0565b91610071604083016102e0565b61007d606084016102e0565b610089608085016102f4565b9061009660a086016102f4565b936100af60e06100a860c089016102f4565b97016102e0565b906080526100c46100be610324565b3061039c565b6001600160a01b031680156102b557600180546001600160a01b03199081169091555f8054918216831781556001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3600354926001600160a01b0387169081156102a6576001600160a01b03169182156102a6576001600160a01b03169687156102a65760a05260c05261ffff821661ffff851661016f8183610303565b916107d061018261ffff8a168095610303565b11610297577fb3ef341b591e573ddca7176a74bb92c8e453cce6d6885fcd6a544c2385d3811f9260609260405192835260208301526040820152a1600280546001600160a01b031990811692909217905560c09490941b61ffff60c01b1660b09390931b61ffff60b01b1660a09190911b61ffff60a01b1666ffffffffffffff60a01b1990921691909117600160d01b1790921691909117171760035561022a6100be610324565b6040516122fa9081610564823960805181818161055601528181610605015281816106720152818161096301528181610aa601528181610e4c015281816110480152818161188d01528181611a1b0152611b61015260a0518181816101bd0152611ca0015260c051815050f35b63192069c360e31b5f5260045ffd5b63d92e233d60e01b5f5260045ffd5b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b03821682036102c857565b519061ffff821682036102c857565b9190820180921161031057565b634e487b7160e01b5f52601160045260245ffd5b604051906101c082016001600160401b038111838210176102cc576040525f82525f60208301525f60408301525f60608301525f60808301525f60a08301525f6101008301525f6101208301525f6101808301525f6101a08301526001610160838260c08201528260e0820152826101408201520152565b908051151561200083161515149081159161054b575b8115610533575b811561051b575b8115610503575b81156104eb575b81156104d4575b81156104bd575b81156104a5575b811561048d575b8115610475575b811561045d575b8115610445575b811561042e575b5061040e5750565b630732d7b560e51b5f9081526001600160a01b0391909116600452602490fd5b6101a091500151151560018216151514155f610406565b905061018081015115156002831615151415906103ff565b905061016081015115156004831615151415906103f8565b905061014081015115156008831615151415906103f1565b905061012081015115156010831615151415906103ea565b905061010081015115156020831615151415906103e3565b905060e081015115156040831615151415906103dc565b905060c081015115156080831615151415906103d5565b905060a08101511515610100831615151415906103ce565b905060808101511515610200831615151415906103c7565b905060608101511515610400831615151415906103c0565b905060408101511515610800831615151415906103b9565b905060208101511515611000831615151415906103b256fe608080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c90816303a349d0146111ac575080630a7a1c4d1461118657806316de1335146110b35780631a1909b81461109657806321d0ee701461102b578063259982e51461102b57806335ad512c14611005578063534c6bcb14610eb9578063575e24b414610dce5780636899cb7014610d015780636c2bbe7e14610a875780636fe7e6eb14610cc9578063715018a614610c3257806378b2c17914610c0e57806379ba509714610b3e5780638da5cb5b14610b1957806394c8e4ff14610af45780639f063efc14610a87578063a64e4f8a14610a62578063a901dd92146109c8578063b47b2fb1146108e5578063b6a8b0fa14610538578063c4e833ce1461079e578063c8b07bbc1461077a578063d256ba1314610756578063d7644ba2146106bb578063d8428c6314610696578063dc4c90d314610653578063dc98354e146105cc578063e1b4af6914610538578063e30c397814610512578063f2fde38b1461048d578063f9fb0d61146101e55763fa8059bd1461019e575f61000f565b346101e1575f6003193601126101e15760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b5f80fd5b346101e157600319360160c081126101e15760a0136101e15760a4358015158082036101e15761021361154b565b60405161021f816113c6565b6004356001600160a01b03811681036101e15781526024356001600160a01b03811681036101e157602082015260443562ffffff811681036101e15760408201526064358060020b81036101e1576060820152608435906001600160a01b03821682036101e15760a09160808201522091825f52600560205260ff60405f205416151582036102aa57005b825f52600560205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541660ff84161790555f14610405576004547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146103d8577fffd6b273759f7508bd33a1c3257f39164ac152e6b691745925bffd026a23719e91600180602093018060045514806103c8575b610353575b604051908152a2005b7b010000000000000000000000000000000000000000000000000000007fffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffff60035416176003557f66538806474f0d93f78ec4085a1d343732ef04874ebdcb6608a2841f4a83738a8260405160018152a161034a565b5060ff60035460d81c1615610345565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6004548015801561043c575b505060207fffd6b273759f7508bd33a1c3257f39164ac152e6b691745925bffd026a23719e9161034a565b6103d8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160045560207fffd6b273759f7508bd33a1c3257f39164ac152e6b691745925bffd026a23719e610411565b346101e15760206003193601126101e1576001600160a01b036104ae6111d7565b6104b661154b565b16807fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001556001600160a01b035f54167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227005f80a3005b346101e1575f6003193601126101e15760206001600160a01b0360015416604051908152f35b346101e1576105463661136e565b5050505050506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fae18210a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e15760e06003193601126101e1576105e56111d7565b5060a06023193601126101e1576105fa611339565b506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e15760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346101e15760a06003193601126101e15760206106b1611519565b6040519015158152f35b346101e15760206003193601126101e1577f66538806474f0d93f78ec4085a1d343732ef04874ebdcb6608a2841f4a83738a60206106f761135f565b6106ff61154b565b15156003547fffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffff7bff0000000000000000000000000000000000000000000000000000008360d81b16911617600355604051908152a1005b346101e1575f6003193601126101e157602061ffff60035460a01c16604051908152f35b346101e1575f6003193601126101e157602061ffff60035460b01c16604051908152f35b346101e1575f6003193601126101e1576040516101c0810181811067ffffffffffffffff8211176108b8576101c0916020916040525f8152818101905f8252604081015f8152606082015f8152608083015f815260a084015f815260c0850160e08601906101008701925f84526101208801945f86526101408901966101608a01986101a06101808c019b5f8d52019b5f8d52600186526001875260018a5260018b526040519d8e915f835251151591015251151560408d015251151560608c015251151560808b015251151560a08a015251151560c089015251151560e08801525115156101008701525115156101208601525115156101408501525115156101608401525115156101808301525115156101a0820152f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b346101e1576101606003193601126101e1576108ff6111d7565b5060a06023193601126101e15760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101e1576101443567ffffffffffffffff81116101e157610957903690600401611201565b50506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036105a457604061099761012435611797565b7fffffffff00000000000000000000000000000000000000000000000000000000835192168252600f0b6020820152f35b346101e15760206003193601126101e1577fc97260ffb3df6b903cdfd59e3b5b21a896404903a8e8a83bf60ba3fca365fbe56020610a0461135f565b610a0c61154b565b15156003547fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff7aff00000000000000000000000000000000000000000000000000008360d01b16911617600355604051908152a1005b346101e1575f6003193601126101e157602060ff60035460d01c166040519015158152f35b346101e157610a95366112b1565b505050505050506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e157602060ff60035460d81c166040519015158152f35b346101e1575f6003193601126101e15760206001600160a01b035f5416604051908152f35b346101e1575f6003193601126101e157336001600160a01b036001541603610be2577fffffffffffffffffffffffff0000000000000000000000000000000000000000600154166001555f54337fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f556001600160a01b033391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346101e1575f6003193601126101e157602061ffff60035460c01c16604051908152f35b346101e1575f6003193601126101e157610c4a61154b565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000600154166001555f6001600160a01b0381547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101e1576101006003193601126101e157610ce36111d7565b5060a06023193601126101e157610cf8611339565b506105fa61134f565b346101e15760206003193601126101e157610d1a6111d7565b610d2261154b565b6001600160a01b038116908115610da65747908115610d7e575f80808481945af1610d4b61143f565b5015610d7e5760207fc73c324be59ab5c3423c6082e423e01ea8b8ebd04b5d3bee040f4d04150975c791604051908152a2005b7f90b8ec18000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fd92e233d000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1576101406003193601126101e157610de86111d7565b5060a06023193601126101e15760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101e1576101243567ffffffffffffffff81116101e157610e40903690600401611201565b50506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036105a457606062ffffff610e8061157f565b907fffffffff00000000000000000000000000000000000000000000000000000000604094939451941684526020840152166040820152f35b346101e15760606003193601126101e15760043561ffff8116908181036101e1576024359161ffff8316918284036101e1576044359261ffff8416918285036101e157610f0461154b565b6107d0610f1a84610f15858861155e565b61155e565b11610fdd577fb3ef341b591e573ddca7176a74bb92c8e453cce6d6885fcd6a544c2385d3811f9577ffff000000000000000000000000000000000000000000006060967fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff75ffff000000000000000000000000000000000000000079ffff0000000000000000000000000000000000000000000000006003549360c01b169560a01b169116179160b01b16171760035560405192835260208301526040820152a1005b7fc9034e18000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e15760206001600160a01b0360035416604051908152f35b346101e1576110393661122f565b50505050506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e1576020600454604051908152f35b346101e15760406003193601126101e1576110cc6111d7565b602435906001600160a01b0382168092036101e1576001600160a01b03906110f261154b565b16908115610da6578015610da657816040917fb46243848fd4cfcaa63343d3207d276896a2fb784a5bba9c37f737170bf5fe42937fffffffffffffffffffffffff00000000000000000000000000000000000000006002541617600255807fffffffffffffffffffffffff0000000000000000000000000000000000000000600354161760035582519182526020820152a1005b346101e1575f6003193601126101e15760206001600160a01b0360025416604051908152f35b346101e15760206003193601126101e1576020906004355f526005825260ff60405f20541615158152f35b600435906001600160a01b03821682036101e157565b35906001600160a01b03821682036101e157565b9181601f840112156101e15782359167ffffffffffffffff83116101e157602083818601950101116101e157565b906101606003198301126101e1576004356001600160a01b03811681036101e1579160a06023198201126101e15760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101e15760c491610144359067ffffffffffffffff82116101e1576112ad91600401611201565b9091565b906101a06003198301126101e1576004356001600160a01b03811681036101e1579160a06023198201126101e15760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101e15760c49161014435916101643591610184359067ffffffffffffffff82116101e1576112ad91600401611201565b60c435906001600160a01b03821682036101e157565b60e435908160020b82036101e157565b6004359081151582036101e157565b6101206003198201126101e1576004356001600160a01b03811681036101e1579160a06023198301126101e15760249160c4359160e43591610104359067ffffffffffffffff82116101e1576112ad91600401611201565b60a0810190811067ffffffffffffffff8211176108b857604052565b6060810190811067ffffffffffffffff8211176108b857604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176108b857604052565b3d15611497573d9067ffffffffffffffff82116108b8576040519161148c60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601846113fe565b82523d5f602084013e565b606090565b91908260a09103126101e1576040516114b4816113c6565b80926114bf816111ed565b82526114cd602082016111ed565b6020830152604081013562ffffff811681036101e15760408301526060810135908160020b82036101e15760809160608401520135906001600160a01b03821682036101e15760800152565b611521611c3b565b156115465760a061153336600461149c565b205f52600560205260ff60405f20541690565b600190565b6001600160a01b035f54163303610be257565b919082018092116103d857565b356001600160a01b03811681036101e15790565b6115896024611c56565b60e4355f811361176f5760ff60035460d01c16158015611760575b61171b576115b460c46024611d84565b61171b5760c43580151581036101e15715611744576024356001600160a01b038116908181036101e15750155b1561171b575f811215611715577f800000000000000000000000000000000000000000000000000000000000000081146103d8575f03905b612710611624611d59565b83020491808310156116ed576f7fffffffffffffffffffffffffffffff83116116c55760a061165436602461149c565b20908160408051611664816113e2565b8681528360208201520152836006556007556008557fffffffffffffffffffffffffffffffff000000000000000000000000000000007f575e24b4000000000000000000000000000000000000000000000000000000009260801b16905f90565b7f35be3ac8000000000000000000000000000000000000000000000000000000005f5260045ffd5b7ff2e64e60000000000000000000000000000000000000000000000000000000005f5260045ffd5b90611619565b507f575e24b400000000000000000000000000000000000000000000000000000000905f905f90565b6044356001600160a01b038116908181036101e15750156115e1565b50611769611d59565b156115a4565b7f21b865b3000000000000000000000000000000000000000000000000000000005f5260045ffd5b906117a26024611c56565b6003549160ff5f9360d01c16158015611c2c575b611c045760a06117c736602461149c565b20906117d560c46024611d84565b611ada5760c4358015158103611aba5715611abe576044356001600160a01b038116908181036119ae5750155b156119b257602435906001600160a01b0382168083036119ae5761182d92506119a65760801d611e19565b612710611838611d59565b820204916f7fffffffffffffffffffffffffffffff831161197e5782611880575050507fb47b2fb1000000000000000000000000000000000000000000000000000000009190565b9091936001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016803b1561197a576040517f0b0d9c090000000000000000000000000000000000000000000000000000000081525f6004820152306024820152604481018790529082908290606490829084905af1801561196f579086939291611951575b50509161191792611e7f565b6fffffffffffffffffffffffffffffffff7fb47b2fb1000000000000000000000000000000000000000000000000000000009216600f0b90565b818093945061195f916113fe565b61196c579081859261190b565b80fd5b6040513d84823e3d90fd5b5080fd5b6004857f35be3ac8000000000000000000000000000000000000000000000000000000008152fd5b600f0b611e19565b8580fd5b5050600654806119e3575b507fb47b2fb1000000000000000000000000000000000000000000000000000000009190565b600754906008549184604080516119f9816113e2565b8281528260208201520152846006558460075584600855846001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016803b1561197a576040517f0b0d9c090000000000000000000000000000000000000000000000000000000081525f6004820152306024820152604481018590529082908290606490829084905af1801561196f57611aa5575b5050611a9f926120ab565b5f6119bd565b81611aaf916113fe565b611aba57845f611a94565b8480fd5b6024356001600160a01b038116908181036119ae575015611802565b602435906001600160a01b0382168083036101e157611b0092506119a65760801d611e19565b612710611b0b611d59565b820204916f7fffffffffffffffffffffffffffffff83116116c55782611b53575050507fb47b2fb1000000000000000000000000000000000000000000000000000000009190565b909193506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691823b156101e1576040517f0b0d9c090000000000000000000000000000000000000000000000000000000081525f600482018190523060248301526044820187905290938490606490829084905af1918215611bf957611917938693611be9575b50611e7f565b5f611bf3916113fe565b5f611be3565b6040513d5f823e3d90fd5b507fb47b2fb10000000000000000000000000000000000000000000000000000000091505f90565b50611c35611d59565b156117b6565b60ff60035460d81c168015611c4d5790565b50600454151590565b6001600160a01b03611c678261156b565b161560208201906001600160a01b03611c7f8361156b565b16158114611d225715611d4a57611c959061156b565b6001600160a01b03807f000000000000000000000000000000000000000000000000000000000000000016911603611d2257611ccf611c3b565b611cd65750565b611ce360a091369061149c565b205f52600560205260ff60405f20541615611cfa57565b7ff31017e5000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f59861114000000000000000000000000000000000000000000000000000000005f5260045ffd5b50611d548161156b565b611c95565b611d8160035461ffff611d76818360b01c16828460a01c1661155e565b9160c01c169061155e565b90565b906001600160a01b03611d968361156b565b1615906001600160a01b03611daf60208415950161156b565b1615918215913580151581036101e15715611dd457505081611dcf575090565b905090565b915080925091611dcf575090565b8115611dec570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b80600f0b905f82125f14611e5857507fffffffffffffffffffffffffffffffff8000000000000000000000000000000081146103d8575f035b600f0b90565b9050611e52565b818102929181159184041417156103d857565b919082039182116103d857565b9190811561205e57611e8f611d59565b91611ec060035493611eb061ffff611eb583611eb0838a60a01c1688611e5f565b611de2565b9660b01c1684611e5f565b611ed381611ece8685611e72565b611e72565b91611ede828661155e565b611f60575b82611f34575b907f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b879460c0949392604051945f8652602086015260408501526060840152608083015260a0820152a2565b9291905f808080856001600160a01b03600354165af1611f5261143f565b5015610d7e57909192611ee9565b5f806001600160a01b0360025416611f78858961155e565b6040519060208201917ff9c5953f0000000000000000000000000000000000000000000000000000000083528a602482015287604482015260448152611fbf6064826113fe565b51925af1611fcb61143f565b9015611fd8575b50611ee3565b7fddf0cec8d61eeec6fe055e08f55f110e71d545695ac7f03f1994f81aa09ffcb7906060612006858961155e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060405195869485526040828601528051918291826040880152018686015e5f85828601015201168101030190a15f611fd2565b7f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b87915060c090604051905f825260208201525f60408201525f60608201525f60808201525f60a0820152a2565b91908115612276576120bb611d59565b916120dc60035493611eb061ffff611eb583611eb0838a60a01c1688611e5f565b6120ea81611ece8685611e72565b916120f5828661155e565b612178575b8261214c575b907f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b879460c09493926040519460018652602086015260408501526060840152608083015260a0820152a2565b9291905f808080856001600160a01b03600354165af161216a61143f565b5015610d7e57909192612100565b5f806001600160a01b0360025416612190858961155e565b6040519060208201917ff9c5953f0000000000000000000000000000000000000000000000000000000083528a6024820152876044820152604481526121d76064826113fe565b51925af16121e361143f565b90156121f0575b506120fa565b7fddf0cec8d61eeec6fe055e08f55f110e71d545695ac7f03f1994f81aa09ffcb790606061221e858961155e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060405195869485526040828601528051918291826040880152018686015e5f85828601015201168101030190a15f6121ea565b7f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b87915060c090604051906001825260208201525f60408201525f60608201525f60808201525f60a0820152a256fea2646970667358221220572765f1f0b48b1b7e15a2f0874b0f802119f2e53f90de6aa023aa048257489264736f6c634300081e0033000000000000000000000000000000000004444c5dc75cb358380d2e3de08a90000000000000000000000000b6cbffeab1434a0d73f1706c1389378325febb96000000000000000000000000ee94957c2821b122f9e0c69805a5ba05132d1990000000000000000000000000003347e13f13ff4fd5d14ad6cffe8fe15319c9160000000000000000000000000000000000000000000000000000000000000316000000000000000000000000000000000000000000000000000000000000015e000000000000000000000000000000000000000000000000000000000000005500000000000000000000000007e1f6b7f9574be75bb76e0e1ecb75681a5e8cca
Deployed Bytecode
0x608080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c90816303a349d0146111ac575080630a7a1c4d1461118657806316de1335146110b35780631a1909b81461109657806321d0ee701461102b578063259982e51461102b57806335ad512c14611005578063534c6bcb14610eb9578063575e24b414610dce5780636899cb7014610d015780636c2bbe7e14610a875780636fe7e6eb14610cc9578063715018a614610c3257806378b2c17914610c0e57806379ba509714610b3e5780638da5cb5b14610b1957806394c8e4ff14610af45780639f063efc14610a87578063a64e4f8a14610a62578063a901dd92146109c8578063b47b2fb1146108e5578063b6a8b0fa14610538578063c4e833ce1461079e578063c8b07bbc1461077a578063d256ba1314610756578063d7644ba2146106bb578063d8428c6314610696578063dc4c90d314610653578063dc98354e146105cc578063e1b4af6914610538578063e30c397814610512578063f2fde38b1461048d578063f9fb0d61146101e55763fa8059bd1461019e575f61000f565b346101e1575f6003193601126101e15760206040516001600160a01b037f000000000000000000000000b6cbffeab1434a0d73f1706c1389378325febb96168152f35b5f80fd5b346101e157600319360160c081126101e15760a0136101e15760a4358015158082036101e15761021361154b565b60405161021f816113c6565b6004356001600160a01b03811681036101e15781526024356001600160a01b03811681036101e157602082015260443562ffffff811681036101e15760408201526064358060020b81036101e1576060820152608435906001600160a01b03821682036101e15760a09160808201522091825f52600560205260ff60405f205416151582036102aa57005b825f52600560205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541660ff84161790555f14610405576004547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146103d8577fffd6b273759f7508bd33a1c3257f39164ac152e6b691745925bffd026a23719e91600180602093018060045514806103c8575b610353575b604051908152a2005b7b010000000000000000000000000000000000000000000000000000007fffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffff60035416176003557f66538806474f0d93f78ec4085a1d343732ef04874ebdcb6608a2841f4a83738a8260405160018152a161034a565b5060ff60035460d81c1615610345565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6004548015801561043c575b505060207fffd6b273759f7508bd33a1c3257f39164ac152e6b691745925bffd026a23719e9161034a565b6103d8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160045560207fffd6b273759f7508bd33a1c3257f39164ac152e6b691745925bffd026a23719e610411565b346101e15760206003193601126101e1576001600160a01b036104ae6111d7565b6104b661154b565b16807fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001556001600160a01b035f54167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227005f80a3005b346101e1575f6003193601126101e15760206001600160a01b0360015416604051908152f35b346101e1576105463661136e565b5050505050506001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a901633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fae18210a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e15760e06003193601126101e1576105e56111d7565b5060a06023193601126101e1576105fa611339565b506001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a901633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e15760206040516001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a90168152f35b346101e15760a06003193601126101e15760206106b1611519565b6040519015158152f35b346101e15760206003193601126101e1577f66538806474f0d93f78ec4085a1d343732ef04874ebdcb6608a2841f4a83738a60206106f761135f565b6106ff61154b565b15156003547fffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffff7bff0000000000000000000000000000000000000000000000000000008360d81b16911617600355604051908152a1005b346101e1575f6003193601126101e157602061ffff60035460a01c16604051908152f35b346101e1575f6003193601126101e157602061ffff60035460b01c16604051908152f35b346101e1575f6003193601126101e1576040516101c0810181811067ffffffffffffffff8211176108b8576101c0916020916040525f8152818101905f8252604081015f8152606082015f8152608083015f815260a084015f815260c0850160e08601906101008701925f84526101208801945f86526101408901966101608a01986101a06101808c019b5f8d52019b5f8d52600186526001875260018a5260018b526040519d8e915f835251151591015251151560408d015251151560608c015251151560808b015251151560a08a015251151560c089015251151560e08801525115156101008701525115156101208601525115156101408501525115156101608401525115156101808301525115156101a0820152f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b346101e1576101606003193601126101e1576108ff6111d7565b5060a06023193601126101e15760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101e1576101443567ffffffffffffffff81116101e157610957903690600401611201565b50506001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a901633036105a457604061099761012435611797565b7fffffffff00000000000000000000000000000000000000000000000000000000835192168252600f0b6020820152f35b346101e15760206003193601126101e1577fc97260ffb3df6b903cdfd59e3b5b21a896404903a8e8a83bf60ba3fca365fbe56020610a0461135f565b610a0c61154b565b15156003547fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff7aff00000000000000000000000000000000000000000000000000008360d01b16911617600355604051908152a1005b346101e1575f6003193601126101e157602060ff60035460d01c166040519015158152f35b346101e157610a95366112b1565b505050505050506001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a901633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e157602060ff60035460d81c166040519015158152f35b346101e1575f6003193601126101e15760206001600160a01b035f5416604051908152f35b346101e1575f6003193601126101e157336001600160a01b036001541603610be2577fffffffffffffffffffffffff0000000000000000000000000000000000000000600154166001555f54337fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f556001600160a01b033391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346101e1575f6003193601126101e157602061ffff60035460c01c16604051908152f35b346101e1575f6003193601126101e157610c4a61154b565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000600154166001555f6001600160a01b0381547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101e1576101006003193601126101e157610ce36111d7565b5060a06023193601126101e157610cf8611339565b506105fa61134f565b346101e15760206003193601126101e157610d1a6111d7565b610d2261154b565b6001600160a01b038116908115610da65747908115610d7e575f80808481945af1610d4b61143f565b5015610d7e5760207fc73c324be59ab5c3423c6082e423e01ea8b8ebd04b5d3bee040f4d04150975c791604051908152a2005b7f90b8ec18000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fd92e233d000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1576101406003193601126101e157610de86111d7565b5060a06023193601126101e15760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c3601126101e1576101243567ffffffffffffffff81116101e157610e40903690600401611201565b50506001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a901633036105a457606062ffffff610e8061157f565b907fffffffff00000000000000000000000000000000000000000000000000000000604094939451941684526020840152166040820152f35b346101e15760606003193601126101e15760043561ffff8116908181036101e1576024359161ffff8316918284036101e1576044359261ffff8416918285036101e157610f0461154b565b6107d0610f1a84610f15858861155e565b61155e565b11610fdd577fb3ef341b591e573ddca7176a74bb92c8e453cce6d6885fcd6a544c2385d3811f9577ffff000000000000000000000000000000000000000000006060967fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff75ffff000000000000000000000000000000000000000079ffff0000000000000000000000000000000000000000000000006003549360c01b169560a01b169116179160b01b16171760035560405192835260208301526040820152a1005b7fc9034e18000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e15760206001600160a01b0360035416604051908152f35b346101e1576110393661122f565b50505050506001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a901633036105a4577f0a85dc29000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101e1575f6003193601126101e1576020600454604051908152f35b346101e15760406003193601126101e1576110cc6111d7565b602435906001600160a01b0382168092036101e1576001600160a01b03906110f261154b565b16908115610da6578015610da657816040917fb46243848fd4cfcaa63343d3207d276896a2fb784a5bba9c37f737170bf5fe42937fffffffffffffffffffffffff00000000000000000000000000000000000000006002541617600255807fffffffffffffffffffffffff0000000000000000000000000000000000000000600354161760035582519182526020820152a1005b346101e1575f6003193601126101e15760206001600160a01b0360025416604051908152f35b346101e15760206003193601126101e1576020906004355f526005825260ff60405f20541615158152f35b600435906001600160a01b03821682036101e157565b35906001600160a01b03821682036101e157565b9181601f840112156101e15782359167ffffffffffffffff83116101e157602083818601950101116101e157565b906101606003198301126101e1576004356001600160a01b03811681036101e1579160a06023198201126101e15760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101e15760c491610144359067ffffffffffffffff82116101e1576112ad91600401611201565b9091565b906101a06003198301126101e1576004356001600160a01b03811681036101e1579160a06023198201126101e15760249160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c8301126101e15760c49161014435916101643591610184359067ffffffffffffffff82116101e1576112ad91600401611201565b60c435906001600160a01b03821682036101e157565b60e435908160020b82036101e157565b6004359081151582036101e157565b6101206003198201126101e1576004356001600160a01b03811681036101e1579160a06023198301126101e15760249160c4359160e43591610104359067ffffffffffffffff82116101e1576112ad91600401611201565b60a0810190811067ffffffffffffffff8211176108b857604052565b6060810190811067ffffffffffffffff8211176108b857604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176108b857604052565b3d15611497573d9067ffffffffffffffff82116108b8576040519161148c60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601846113fe565b82523d5f602084013e565b606090565b91908260a09103126101e1576040516114b4816113c6565b80926114bf816111ed565b82526114cd602082016111ed565b6020830152604081013562ffffff811681036101e15760408301526060810135908160020b82036101e15760809160608401520135906001600160a01b03821682036101e15760800152565b611521611c3b565b156115465760a061153336600461149c565b205f52600560205260ff60405f20541690565b600190565b6001600160a01b035f54163303610be257565b919082018092116103d857565b356001600160a01b03811681036101e15790565b6115896024611c56565b60e4355f811361176f5760ff60035460d01c16158015611760575b61171b576115b460c46024611d84565b61171b5760c43580151581036101e15715611744576024356001600160a01b038116908181036101e15750155b1561171b575f811215611715577f800000000000000000000000000000000000000000000000000000000000000081146103d8575f03905b612710611624611d59565b83020491808310156116ed576f7fffffffffffffffffffffffffffffff83116116c55760a061165436602461149c565b20908160408051611664816113e2565b8681528360208201520152836006556007556008557fffffffffffffffffffffffffffffffff000000000000000000000000000000007f575e24b4000000000000000000000000000000000000000000000000000000009260801b16905f90565b7f35be3ac8000000000000000000000000000000000000000000000000000000005f5260045ffd5b7ff2e64e60000000000000000000000000000000000000000000000000000000005f5260045ffd5b90611619565b507f575e24b400000000000000000000000000000000000000000000000000000000905f905f90565b6044356001600160a01b038116908181036101e15750156115e1565b50611769611d59565b156115a4565b7f21b865b3000000000000000000000000000000000000000000000000000000005f5260045ffd5b906117a26024611c56565b6003549160ff5f9360d01c16158015611c2c575b611c045760a06117c736602461149c565b20906117d560c46024611d84565b611ada5760c4358015158103611aba5715611abe576044356001600160a01b038116908181036119ae5750155b156119b257602435906001600160a01b0382168083036119ae5761182d92506119a65760801d611e19565b612710611838611d59565b820204916f7fffffffffffffffffffffffffffffff831161197e5782611880575050507fb47b2fb1000000000000000000000000000000000000000000000000000000009190565b9091936001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a9016803b1561197a576040517f0b0d9c090000000000000000000000000000000000000000000000000000000081525f6004820152306024820152604481018790529082908290606490829084905af1801561196f579086939291611951575b50509161191792611e7f565b6fffffffffffffffffffffffffffffffff7fb47b2fb1000000000000000000000000000000000000000000000000000000009216600f0b90565b818093945061195f916113fe565b61196c579081859261190b565b80fd5b6040513d84823e3d90fd5b5080fd5b6004857f35be3ac8000000000000000000000000000000000000000000000000000000008152fd5b600f0b611e19565b8580fd5b5050600654806119e3575b507fb47b2fb1000000000000000000000000000000000000000000000000000000009190565b600754906008549184604080516119f9816113e2565b8281528260208201520152846006558460075584600855846001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a9016803b1561197a576040517f0b0d9c090000000000000000000000000000000000000000000000000000000081525f6004820152306024820152604481018590529082908290606490829084905af1801561196f57611aa5575b5050611a9f926120ab565b5f6119bd565b81611aaf916113fe565b611aba57845f611a94565b8480fd5b6024356001600160a01b038116908181036119ae575015611802565b602435906001600160a01b0382168083036101e157611b0092506119a65760801d611e19565b612710611b0b611d59565b820204916f7fffffffffffffffffffffffffffffff83116116c55782611b53575050507fb47b2fb1000000000000000000000000000000000000000000000000000000009190565b909193506001600160a01b037f000000000000000000000000000000000004444c5dc75cb358380d2e3de08a901691823b156101e1576040517f0b0d9c090000000000000000000000000000000000000000000000000000000081525f600482018190523060248301526044820187905290938490606490829084905af1918215611bf957611917938693611be9575b50611e7f565b5f611bf3916113fe565b5f611be3565b6040513d5f823e3d90fd5b507fb47b2fb10000000000000000000000000000000000000000000000000000000091505f90565b50611c35611d59565b156117b6565b60ff60035460d81c168015611c4d5790565b50600454151590565b6001600160a01b03611c678261156b565b161560208201906001600160a01b03611c7f8361156b565b16158114611d225715611d4a57611c959061156b565b6001600160a01b03807f000000000000000000000000b6cbffeab1434a0d73f1706c1389378325febb9616911603611d2257611ccf611c3b565b611cd65750565b611ce360a091369061149c565b205f52600560205260ff60405f20541615611cfa57565b7ff31017e5000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f59861114000000000000000000000000000000000000000000000000000000005f5260045ffd5b50611d548161156b565b611c95565b611d8160035461ffff611d76818360b01c16828460a01c1661155e565b9160c01c169061155e565b90565b906001600160a01b03611d968361156b565b1615906001600160a01b03611daf60208415950161156b565b1615918215913580151581036101e15715611dd457505081611dcf575090565b905090565b915080925091611dcf575090565b8115611dec570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b80600f0b905f82125f14611e5857507fffffffffffffffffffffffffffffffff8000000000000000000000000000000081146103d8575f035b600f0b90565b9050611e52565b818102929181159184041417156103d857565b919082039182116103d857565b9190811561205e57611e8f611d59565b91611ec060035493611eb061ffff611eb583611eb0838a60a01c1688611e5f565b611de2565b9660b01c1684611e5f565b611ed381611ece8685611e72565b611e72565b91611ede828661155e565b611f60575b82611f34575b907f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b879460c0949392604051945f8652602086015260408501526060840152608083015260a0820152a2565b9291905f808080856001600160a01b03600354165af1611f5261143f565b5015610d7e57909192611ee9565b5f806001600160a01b0360025416611f78858961155e565b6040519060208201917ff9c5953f0000000000000000000000000000000000000000000000000000000083528a602482015287604482015260448152611fbf6064826113fe565b51925af1611fcb61143f565b9015611fd8575b50611ee3565b7fddf0cec8d61eeec6fe055e08f55f110e71d545695ac7f03f1994f81aa09ffcb7906060612006858961155e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060405195869485526040828601528051918291826040880152018686015e5f85828601015201168101030190a15f611fd2565b7f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b87915060c090604051905f825260208201525f60408201525f60608201525f60808201525f60a0820152a2565b91908115612276576120bb611d59565b916120dc60035493611eb061ffff611eb583611eb0838a60a01c1688611e5f565b6120ea81611ece8685611e72565b916120f5828661155e565b612178575b8261214c575b907f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b879460c09493926040519460018652602086015260408501526060840152608083015260a0820152a2565b9291905f808080856001600160a01b03600354165af161216a61143f565b5015610d7e57909192612100565b5f806001600160a01b0360025416612190858961155e565b6040519060208201917ff9c5953f0000000000000000000000000000000000000000000000000000000083528a6024820152876044820152604481526121d76064826113fe565b51925af16121e361143f565b90156121f0575b506120fa565b7fddf0cec8d61eeec6fe055e08f55f110e71d545695ac7f03f1994f81aa09ffcb790606061221e858961155e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060405195869485526040828601528051918291826040880152018686015e5f85828601015201168101030190a15f6121ea565b7f397d719100f6ee3d1ee1a0aa98cacb59b7a5cd51ca646352ff607da26c7c1b87915060c090604051906001825260208201525f60408201525f60608201525f60808201525f60a0820152a256fea2646970667358221220572765f1f0b48b1b7e15a2f0874b0f802119f2e53f90de6aa023aa048257489264736f6c634300081e0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000004444c5dc75cb358380d2e3de08a90000000000000000000000000b6cbffeab1434a0d73f1706c1389378325febb96000000000000000000000000ee94957c2821b122f9e0c69805a5ba05132d1990000000000000000000000000003347e13f13ff4fd5d14ad6cffe8fe15319c9160000000000000000000000000000000000000000000000000000000000000316000000000000000000000000000000000000000000000000000000000000015e000000000000000000000000000000000000000000000000000000000000005500000000000000000000000007e1f6b7f9574be75bb76e0e1ecb75681a5e8cca
-----Decoded View---------------
Arg [0] : _poolManager (address): 0x000000000004444c5dc75cB358380D2e3dE08A90
Arg [1] : _buxToken (address): 0xb6cbFfeab1434a0D73F1706c1389378325feBB96
Arg [2] : _action (address): 0xEE94957C2821B122F9e0c69805A5BA05132d1990
Arg [3] : _devFeeSplitter (address): 0x003347e13F13ff4fd5d14AD6CFfE8Fe15319c916
Arg [4] : _hourlyBps (uint16): 790
Arg [5] : _dailyBps (uint16): 350
Arg [6] : _devBps (uint16): 85
Arg [7] : initialOwner (address): 0x07e1F6B7f9574be75Bb76e0E1eCB75681A5e8CCa
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000004444c5dc75cb358380d2e3de08a90
Arg [1] : 000000000000000000000000b6cbffeab1434a0d73f1706c1389378325febb96
Arg [2] : 000000000000000000000000ee94957c2821b122f9e0c69805a5ba05132d1990
Arg [3] : 000000000000000000000000003347e13f13ff4fd5d14ad6cffe8fe15319c916
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000316
Arg [5] : 000000000000000000000000000000000000000000000000000000000000015e
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000055
Arg [7] : 00000000000000000000000007e1f6b7f9574be75bb76e0e1ecb75681a5e8cca
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.