More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60186101 | 17106740 | 531 days ago | IN | 0 ETH | 0.07333802 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
InventoryMinter
Compiler Version
v0.8.15+commit.e14f2714
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol'; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import '@uniswap/v3-core/contracts/libraries/TickMath.sol'; import '@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol'; import "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol"; import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; import "@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol"; import '@uniswap/v3-periphery/contracts/libraries/LiquidityAmounts.sol'; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../BobToken.sol"; import "../interfaces/ILegacyERC20.sol"; import "./OrderLib.sol"; interface IRouter { function fillOrderTo( OrderLib.Order calldata order_, bytes calldata signature, bytes calldata interaction, uint256 makingAmount, uint256 takingAmount, uint256 skipPermitAndThresholdAmount, address target ) external payable returns(uint256 actualMakingAmount, uint256 actualTakingAmount, bytes32 orderHash); function cancelOrder(OrderLib.Order calldata order) external returns(uint256 orderRemaining, bytes32 orderHash); } contract InventoryMinter { using OrderLib for OrderLib.Order; using SafeERC20 for IERC20; event LimitOrder(bytes32 hash); address constant router = address(0x1111111254EEB25477B68fb85Ed929f73A960582); address constant positions = address(0xC36442b4a4522E871399CD717aBDD847Ab11FE88); address public immutable owner; address public immutable token0; address public immutable token1; int24 public immutable tickLower; int24 public immutable tickUpper; uint24 public immutable fee; int256 public immutable price; bytes32 public immutable ROUTER_DOMAIN_SEPARATOR = _routerDomainSeparator(router); uint256 public amount0; uint256 public amount1; uint256 tokenId; OrderLib.Order order0; OrderLib.Order order1; mapping(bytes32 => bool) approvedHashes; constructor(address _token0, address _token1, uint256 _amount0, uint256 _amount1, int24 _tickLower, int24 _tickUpper, uint24 _fee, address _owner, int256 _price) { token0 = _token0; token1 = _token1; amount0 = _amount0; amount1 = _amount1; tickLower = _tickLower; tickUpper = _tickUpper; fee = _fee; owner = _owner; price = _price; ILegacyERC20(token0).approve(address(positions), type(uint256).max); ILegacyERC20(token1).approve(address(positions), type(uint256).max); ILegacyERC20(token0).approve(address(router), type(uint256).max); ILegacyERC20(token1).approve(address(router), type(uint256).max); } function getOrder0() external view returns (bytes32 hash, OrderLib.Order memory order) { order = order0; hash = order.hash(ROUTER_DOMAIN_SEPARATOR); } function getOrder1() external view returns (bytes32 hash, OrderLib.Order memory order) { order = order1; hash = order.hash(ROUTER_DOMAIN_SEPARATOR); } function cancel() external { require(msg.sender == owner); IRouter(router).cancelOrder(order0); IRouter(router).cancelOrder(order1); } function withdraw() external { require(msg.sender == owner); IERC20(token0).safeTransfer(owner, IERC20(token0).balanceOf(address(this))); IERC20(token1).safeTransfer(owner, IERC20(token1).balanceOf(address(this))); } function mint() external { IERC20(token0).safeTransferFrom(msg.sender, address(this), amount0); IERC20(token1).safeTransferFrom(msg.sender, address(this), amount1); uint256 dAmount0; uint256 dAmount1; ( tokenId, , dAmount0, dAmount1 ) = INonfungiblePositionManager(positions).mint(INonfungiblePositionManager.MintParams({ token0: address(token0), token1: address(token1), fee: fee, tickLower: tickLower, tickUpper: tickUpper, amount0Desired: amount0, amount1Desired: amount1, amount0Min: 0, amount1Min: 0, recipient: owner, deadline: block.timestamp })); amount0 -= dAmount0; amount1 -= dAmount1; if (price > 0) { order0 = _openLimitOrder(token0, token1, tokenId, amount0, amount0 * uint256(price)); order1 = _openLimitOrder(token1, token0, tokenId, amount1, amount1 / uint256(price)); } else { order0 = _openLimitOrder(token0, token1, tokenId, amount0, amount0 / uint256(-price)); order1 = _openLimitOrder(token1, token0, tokenId, amount1, amount1 * uint256(-price)); } } function _openLimitOrder(address _token0, address _token1, uint256 _tokenId, uint256 _amount0, uint256 _amount1) internal returns (OrderLib.Order memory order) { if (_amount0 == 0) { return order; } bytes memory postInteraction = abi.encodePacked(address(this), abi.encode(_token0)); order = OrderLib.Order({ salt: uint256(keccak256(abi.encode(address(this)))), makerAsset: _token0, takerAsset: _token1, maker: address(this), receiver: address(this), allowedSender: address(0), makingAmount: _amount0, takingAmount: _amount1, offsets: (postInteraction.length << 224), interactions: postInteraction }); bytes32 hash = order.hash(ROUTER_DOMAIN_SEPARATOR); approvedHashes[hash] = true; emit LimitOrder(hash); } function isValidSignature(bytes32 _hash, bytes memory signature) external view returns (bytes4 magicValue) { require(approvedHashes[_hash]); return this.isValidSignature.selector; } function fillOrderPostInteraction( bytes32 orderHash, address maker, address taker, uint256 makingAmount, uint256 takingAmount, uint256 remainingAmount, bytes memory interactiveData ) external { require(msg.sender == router); (address _token0) = abi.decode(interactiveData, (address)); uint256 dAmount0; uint256 dAmount1; if (token0 == _token0) { (, dAmount0, dAmount1) = INonfungiblePositionManager(positions).increaseLiquidity(INonfungiblePositionManager.IncreaseLiquidityParams({ tokenId: tokenId, amount0Desired: amount0 - makingAmount, amount1Desired: amount1 + takingAmount, amount0Min: 0, amount1Min: amount1 + takingAmount - (price > 0 ? uint256(price) : 0), deadline: block.timestamp })); amount0 = amount0 - makingAmount - dAmount0; amount1 = amount1 + takingAmount - dAmount1; } else { (, dAmount0, dAmount1) = INonfungiblePositionManager(positions).increaseLiquidity(INonfungiblePositionManager.IncreaseLiquidityParams({ tokenId: tokenId, amount0Desired: amount0 + takingAmount, amount1Desired: amount1 - makingAmount, amount0Min: amount0 + takingAmount - (price < 0 ? uint256(-price) : 0), amount1Min: 0, deadline: block.timestamp })); amount0 = amount0 + takingAmount - dAmount0; amount1 = amount1 - makingAmount - dAmount1; } } function increaseLiquidity() external { (, uint256 dAmount0, uint256 dAmount1) = INonfungiblePositionManager(positions).increaseLiquidity(INonfungiblePositionManager.IncreaseLiquidityParams({ tokenId: tokenId, amount0Desired: amount0, amount1Desired: amount1, amount0Min: 0, amount1Min: 0, deadline: block.timestamp })); amount0 -= dAmount0; amount1 -= dAmount1; } function _routerDomainSeparator(address _router) internal view returns (bytes32) { bytes32 hashedName = keccak256(bytes("1inch Aggregation Router")); bytes32 hashedVersion = keccak256(bytes("5")); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); return _buildDomainSeparator(_router, typeHash, hashedName, hashedVersion); } function _buildDomainSeparator( address _router, bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) internal view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, _router)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../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. * * By default, the owner account will be the one that deploys the contract. 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; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @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 { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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 v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Emitted when the owner of the factory is changed /// @param oldOwner The owner before the owner was changed /// @param newOwner The owner after the owner was changed event OwnerChanged(address indexed oldOwner, address indexed newOwner); /// @notice Emitted when a pool is created /// @param token0 The first token of the pool by address sort order /// @param token1 The second token 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 pool The address of the created pool event PoolCreated( address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool ); /// @notice Emitted when a new fee amount is enabled for pool creation via the factory /// @param fee The enabled fee, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); /// @notice Returns the current owner of the factory /// @dev Can be changed by the current owner via setOwner /// @return The address of the factory owner function owner() external view returns (address); /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee /// @return The tick spacing function feeAmountTickSpacing(uint24 fee) external view returns (int24); /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param fee The desired fee for the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments /// are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); /// @notice Updates the owner of the factory /// @dev Must be called by the current owner /// @param _owner The new owner of the factory function setOwner(address _owner) external; /// @notice Enables a fee amount with the given tickSpacing /// @dev Fee amounts may never be removed once enabled /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, int24 tickSpacing) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol'; import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol'; import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol'; import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol'; import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol'; import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol'; import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolErrors, IUniswapV3PoolEvents { }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Errors emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolErrors { error LOK(); error TLU(); error TLM(); error TUM(); error AI(); error M0(); error M1(); error AS(); error IIA(); error L(); error F0(); error F1(); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 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 price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// @return observationIndex The index of the last oracle observation that was written, /// @return observationCardinality The current maximum number of observations stored in the pool, /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// @return feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks /// @return The liquidity at the current price of the pool function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper /// @return liquidityNet how much liquidity changes when the pool price crosses the tick, /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// @return secondsOutside the seconds spent on the other side of the tick from the current tick, /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return liquidity The amount of liquidity in the position, /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// @return initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (0 - denominator) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Safe casting methods /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint160 function toUint160(uint256 y) internal pure returns (uint160 z) { require((z = uint160(y)) == y); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param y The int256 to be downcasted /// @return z The downcasted integer, now type int128 function toInt128(int256 y) internal pure returns (int128 z) { require((z = int128(y)) == y); } /// @notice Cast a uint256 to a int256, revert on overflow /// @param y The uint256 to be casted /// @return z The casted integer, now type int256 function toInt256(uint256 y) internal pure returns (int256 z) { require(y < 2**255); z = int256(y); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import {SafeCast} from './SafeCast.sol'; import {FullMath} from './FullMath.sol'; import {UnsafeMath} from './UnsafeMath.sol'; import {FixedPoint96} from './FixedPoint96.sol'; /// @title Functions based on Q64.96 sqrt price and liquidity /// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas library SqrtPriceMath { using SafeCast for uint256; /// @notice Gets the next sqrt price given a delta of token0 /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the /// price less in order to not send too much output. /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96), /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount). /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token0 to add or remove from virtual reserves /// @param add Whether to add or remove the amount of token0 /// @return The price after adding or removing amount, depending on add function getNextSqrtPriceFromAmount0RoundingUp( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price if (amount == 0) return sqrtPX96; uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; if (add) { unchecked { uint256 product; if ((product = amount * sqrtPX96) / amount == sqrtPX96) { uint256 denominator = numerator1 + product; if (denominator >= numerator1) // always fits in 160 bits return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator)); } } // denominator is checked for overflow return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96) + amount)); } else { unchecked { uint256 product; // if the product overflows, we know the denominator underflows // in addition, we must check that the denominator does not underflow require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product); uint256 denominator = numerator1 - product; return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160(); } } } /// @notice Gets the next sqrt price given a delta of token1 /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the /// price less in order to not send too much output. /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token1 to add, or remove, from virtual reserves /// @param add Whether to add, or remove, the amount of token1 /// @return The price after adding or removing `amount` function getNextSqrtPriceFromAmount1RoundingDown( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // if we're adding (subtracting), rounding down requires rounding the quotient down (up) // in both cases, avoid a mulDiv for most inputs if (add) { uint256 quotient = ( amount <= type(uint160).max ? (amount << FixedPoint96.RESOLUTION) / liquidity : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity) ); return (uint256(sqrtPX96) + quotient).toUint160(); } else { uint256 quotient = ( amount <= type(uint160).max ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity) : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity) ); require(sqrtPX96 > quotient); // always fits 160 bits unchecked { return uint160(sqrtPX96 - quotient); } } } /// @notice Gets the next sqrt price given an input amount of token0 or token1 /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount /// @param liquidity The amount of usable liquidity /// @param amountIn How much of token0, or token1, is being swapped in /// @param zeroForOne Whether the amount in is token0 or token1 /// @return sqrtQX96 The price after adding the input amount to token0 or token1 function getNextSqrtPriceFromInput( uint160 sqrtPX96, uint128 liquidity, uint256 amountIn, bool zeroForOne ) internal pure returns (uint160 sqrtQX96) { require(sqrtPX96 > 0); require(liquidity > 0); // round to make sure that we don't pass the target price return zeroForOne ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true) : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true); } /// @notice Gets the next sqrt price given an output amount of token0 or token1 /// @dev Throws if price or liquidity are 0 or the next price is out of bounds /// @param sqrtPX96 The starting price before accounting for the output amount /// @param liquidity The amount of usable liquidity /// @param amountOut How much of token0, or token1, is being swapped out /// @param zeroForOne Whether the amount out is token0 or token1 /// @return sqrtQX96 The price after removing the output amount of token0 or token1 function getNextSqrtPriceFromOutput( uint160 sqrtPX96, uint128 liquidity, uint256 amountOut, bool zeroForOne ) internal pure returns (uint160 sqrtQX96) { require(sqrtPX96 > 0); require(liquidity > 0); // round to make sure that we pass the target price return zeroForOne ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false) : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false); } /// @notice Gets the amount0 delta between two prices /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper), /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up or down /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices function getAmount0Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) internal pure returns (uint256 amount0) { unchecked { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96; require(sqrtRatioAX96 > 0); return roundUp ? UnsafeMath.divRoundingUp( FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96 ) : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96; } } /// @notice Gets the amount1 delta between two prices /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up, or down /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices function getAmount1Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) internal pure returns (uint256 amount1) { unchecked { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return roundUp ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96) : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } } /// @notice Helper that gets signed token0 delta /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The change in liquidity for which to compute the amount0 delta /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices function getAmount0Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity ) internal pure returns (int256 amount0) { unchecked { return liquidity < 0 ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256() : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256(); } } /// @notice Helper that gets signed token1 delta /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The change in liquidity for which to compute the amount1 delta /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices function getAmount1Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity ) internal pure returns (int256 amount1) { unchecked { return liquidity < 0 ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256() : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256(); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { error T(); error R(); /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { unchecked { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); if (absTick > uint256(int256(MAX_TICK))) revert T(); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { unchecked { // second inequality must be < because the price can never reach the price at the max tick if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R(); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math functions that do not check inputs or outputs /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { /// @notice Returns ceil(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(div(x, y), gt(mod(x, y), 0)) } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; /// @title ERC721 with permit /// @notice Extension to ERC721 that includes a permit function for signature based approvals interface IERC721Permit is IERC721 { /// @notice The permit typehash used in the permit signature /// @return The typehash for the permit function PERMIT_TYPEHASH() external pure returns (bytes32); /// @notice The domain separator used in the permit signature /// @return The domain seperator used in encoding of permit signature function DOMAIN_SEPARATOR() external view returns (bytes32); /// @notice Approve of a specific token ID for spending by spender via signature /// @param spender The account that is being approved /// @param tokenId The ID of the token that is being approved for spending /// @param deadline The deadline timestamp by which the call must be mined for the approve to work /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit( address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; import './IPoolInitializer.sol'; import './IERC721Permit.sol'; import './IPeripheryPayments.sol'; import './IPeripheryImmutableState.sol'; import '../libraries/PoolAddress.sol'; /// @title Non-fungible token for positions /// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. interface INonfungiblePositionManager is IPoolInitializer, IPeripheryPayments, IPeripheryImmutableState, IERC721Metadata, IERC721Enumerable, IERC721Permit { /// @notice Emitted when liquidity is increased for a position NFT /// @dev Also emitted when a token is minted /// @param tokenId The ID of the token for which liquidity was increased /// @param liquidity The amount by which liquidity for the NFT position was increased /// @param amount0 The amount of token0 that was paid for the increase in liquidity /// @param amount1 The amount of token1 that was paid for the increase in liquidity event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when liquidity is decreased for a position NFT /// @param tokenId The ID of the token for which liquidity was decreased /// @param liquidity The amount by which liquidity for the NFT position was decreased /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when tokens are collected for a position NFT /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior /// @param tokenId The ID of the token for which underlying tokens were collected /// @param recipient The address of the account that received the collected tokens /// @param amount0 The amount of token0 owed to the position that was collected /// @param amount1 The amount of token1 owed to the position that was collected event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1); /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions(uint256 tokenId) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @notice Creates a new position wrapped in a NFT /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized /// a method does not exist, i.e. the pool is assumed to be initialized. /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata /// @return tokenId The ID of the token that represents the minted position /// @return liquidity The amount of liquidity for this position /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function mint(MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` /// @param params tokenId The ID of the token for which liquidity is being increased, /// amount0Desired The desired amount of token0 to be spent, /// amount1Desired The desired amount of token1 to be spent, /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check, /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check, /// deadline The time by which the transaction must be included to effect the change /// @return liquidity The new liquidity amount as a result of the increase /// @return amount0 The amount of token0 to acheive resulting liquidity /// @return amount1 The amount of token1 to acheive resulting liquidity function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable returns ( uint128 liquidity, uint256 amount0, uint256 amount1 ); struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Decreases the amount of liquidity in a position and accounts it to the position /// @param params tokenId The ID of the token for which liquidity is being decreased, /// amount The amount by which liquidity will be decreased, /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, /// deadline The time by which the transaction must be included to effect the change /// @return amount0 The amount of token0 accounted to the position's tokens owed /// @return amount1 The amount of token1 accounted to the position's tokens owed function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1); struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens /// must be collected first. /// @param tokenId The ID of the token that is being burned function burn(uint256 tokenId) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Immutable state /// @notice Functions that return immutable state of the router interface IPeripheryImmutableState { /// @return Returns the address of the Uniswap V3 factory function factory() external view returns (address); /// @return Returns the address of WETH9 function WETH9() external view returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Periphery Payments /// @notice Functions to ease deposits and withdrawals of ETH interface IPeripheryPayments { /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH. /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. /// @param amountMinimum The minimum amount of WETH9 to unwrap /// @param recipient The address receiving ETH function unwrapWETH9(uint256 amountMinimum, address recipient) external payable; /// @notice Refunds any ETH balance held by this contract to the `msg.sender` /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps /// that use ether for the input amount function refundETH() external payable; /// @notice Transfers the full amount of a token held by this contract to recipient /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users /// @param token The contract address of the token which will be transferred to `recipient` /// @param amountMinimum The minimum amount of token required for a transfer /// @param recipient The destination address of the token function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Creates and initializes V3 Pools /// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that /// require the pool to exist. interface IPoolInitializer { /// @notice Creates a new pool if it does not exist, then initializes if not initialized /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool /// @param token0 The contract address of token0 of the pool /// @param token1 The contract address of token1 of the pool /// @param fee The fee amount of the v3 pool for the specified token pair /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import '@uniswap/v3-core/contracts/libraries/FullMath.sol'; import '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol'; /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); unchecked { return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); unchecked { return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { unchecked { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); unchecked { return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xa598dd2fba360510c5a8f02f44423a4468e902df5857dbce3ca162a43a3a31ff; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint160( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ) ); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "./proxy/EIP1967Admin.sol"; import "./token/ERC677.sol"; import "./token/ERC20Permit.sol"; import "./token/ERC20MintBurn.sol"; import "./token/ERC20Recovery.sol"; import "./token/ERC20Blocklist.sol"; import "./utils/Claimable.sol"; /** * @title BobToken */ contract BobToken is EIP1967Admin, BaseERC20, ERC677, ERC20Permit, ERC20MintBurn, ERC20Recovery, ERC20Blocklist, Claimable { /** * @dev Creates a proxy implementation for BobToken. * @param _self address of the proxy contract, linked to the deployed implementation, * required for correct EIP712 domain derivation. */ constructor(address _self) ERC20Permit(_self) {} /** * @dev Returns the name of the token. */ function name() public view override returns (string memory) { return "BOB"; } /** * @dev Returns the symbol of the token. */ function symbol() public view override returns (string memory) { return "BOB"; } /** * @dev Tells if caller is the contract owner. * Gives ownership rights to the proxy admin as well. * @return true, if caller is the contract owner or proxy admin. */ function _isOwner() internal view override returns (bool) { return super._isOwner() || _admin() == _msgSender(); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.15; library OrderLib { struct Order { uint256 salt; address makerAsset; address takerAsset; address maker; address receiver; address allowedSender; // equals to Zero address on public orders uint256 makingAmount; uint256 takingAmount; uint256 offsets; // bytes makerAssetData; // bytes takerAssetData; // bytes getMakingAmount; // this.staticcall(abi.encodePacked(bytes, swapTakerAmount)) => (swapMakerAmount) // bytes getTakingAmount; // this.staticcall(abi.encodePacked(bytes, swapMakerAmount)) => (swapTakerAmount) // bytes predicate; // this.staticcall(bytes) => (bool) // bytes permit; // On first fill: permit.1.call(abi.encodePacked(permit.selector, permit.2)) // bytes preInteraction; // bytes postInteraction; bytes interactions; // concat(makerAssetData, takerAssetData, getMakingAmount, getTakingAmount, predicate, permit, preIntercation, postInteraction) } bytes32 constant internal _LIMIT_ORDER_TYPEHASH = keccak256( "Order(" "uint256 salt," "address makerAsset," "address takerAsset," "address maker," "address receiver," "address allowedSender," "uint256 makingAmount," "uint256 takingAmount," "uint256 offsets," "bytes interactions" ")" ); function hash(Order memory order, bytes32 domainSeparator) internal pure returns(bytes32 result) { result = keccak256(abi.encode(_LIMIT_ORDER_TYPEHASH, order.salt, order.makerAsset, order.takerAsset, order.maker, order.receiver, order.allowedSender, order.makingAmount, order.takingAmount, order.offsets, keccak256(order.interactions)) ); result = keccak256(abi.encodePacked("\x19\x01", domainSeparator, result)); } enum DynamicField { MakerAssetData, TakerAssetData, GetMakingAmount, GetTakingAmount, Predicate, Permit, PreInteraction, PostInteraction } function _get(Order memory order, DynamicField field) private pure returns(bytes memory res) { res = order.interactions; uint256 bitShift = uint256(field) << 5; // field * 32 uint256 from = uint32((order.offsets << 32) >> bitShift); uint256 to = uint32(order.offsets >> bitShift); assembly { res := add(res, from) mstore(res, sub(to, from)) } } function makerAssetData(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.MakerAssetData); } function takerAssetData(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.TakerAssetData); } function getMakingAmount(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.GetMakingAmount); } function getTakingAmount(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.GetTakingAmount); } function predicate(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.Predicate); } function permit(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.Permit); } function preInteraction(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.PreInteraction); } function postInteraction(Order memory order) internal pure returns(bytes memory) { return _get(order, DynamicField.PostInteraction); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; interface IBurnableERC20 { function burn(uint256 amount) external; function burnFrom(address user, uint256 amount) external; }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; interface IERC20Permit { function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; function nonces(address owner) external view returns (uint256); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external view returns (bytes32); function SALTED_PERMIT_TYPEHASH() external view returns (bytes32); function receiveWithPermit( address _holder, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) external; function receiveWithSaltedPermit( address _holder, uint256 _value, uint256 _deadline, bytes32 _salt, uint8 _v, bytes32 _r, bytes32 _s ) external; }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; interface IERC677 { function transferAndCall(address to, uint256 amount, bytes calldata data) external; }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; interface IERC677Receiver { function onTokenTransfer(address from, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; interface ILegacyERC20 { function approve(address spender, uint256 amount) external; // returns (bool); function transfer(address to, uint256 amount) external; // returns (bool); function transferFrom(address to, uint256 amount) external; // returns (bool); }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; interface IMintableERC20 { function mint(address to, uint256 amount) external; }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; /** * @title EIP1967Admin * @dev Upgradeable proxy pattern implementation according to minimalistic EIP1967. */ contract EIP1967Admin { // EIP 1967 // bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1) uint256 internal constant EIP1967_ADMIN_STORAGE = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; modifier onlyAdmin() { require(msg.sender == _admin(), "EIP1967Admin: not an admin"); _; } function _admin() internal view returns (address res) { assembly { res := sload(EIP1967_ADMIN_STORAGE) } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.15; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; /** * @title BaseERC20 */ abstract contract BaseERC20 is IERC20, IERC20Metadata { mapping(address => uint256) internal _balances; mapping(address => mapping(address => uint256)) public allowance; uint256 public totalSupply; function name() public view virtual override returns (string memory); function symbol() public view virtual override returns (string memory); function decimals() public view override returns (uint8) { return 18; } function balanceOf(address account) public view virtual override returns (uint256 _balance) { _balance = _balances[account]; assembly { _balance := and(_balance, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } } function transfer(address to, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, to, amount); return true; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { _spendAllowance(from, msg.sender, amount); _transfer(from, to, amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, allowance[msg.sender][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = allowance[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(msg.sender, spender, currentAllowance - subtractedValue); } return true; } function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _decreaseBalance(from, amount); _increaseBalance(to, amount); emit Transfer(from, to, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); totalSupply += amount; _increaseBalance(account, amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _decreaseBalance(account, amount); totalSupply -= amount; emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); allowance[owner][spender] = amount; emit Approval(owner, spender, amount); } function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance[owner][spender]; if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } function _increaseBalance(address _account, uint256 _amount) internal { uint256 balance = _balances[_account]; require(balance < 1 << 255, "ERC20: account frozen"); unchecked { _balances[_account] = balance + _amount; } } function _decreaseBalance(address _account, uint256 _amount) internal { uint256 balance = _balances[_account]; require(balance < 1 << 255, "ERC20: account frozen"); require(balance >= _amount, "ERC20: amount exceeds balance"); unchecked { _balances[_account] = balance - _amount; } } function _decreaseBalanceUnchecked(address _account, uint256 _amount) internal { uint256 balance = _balances[_account]; unchecked { _balances[_account] = balance - _amount; } } function _isFrozen(address _account) internal view returns (bool) { return _balances[_account] >= 1 << 255; } function _freezeBalance(address _account) internal { _balances[_account] |= 1 << 255; } function _unfreezeBalance(address _account) internal { _balances[_account] &= (1 << 255) - 1; } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "../utils/Ownable.sol"; import "./BaseERC20.sol"; /** * @title ERC20Blocklist */ abstract contract ERC20Blocklist is Ownable, BaseERC20 { address public blocklister; event Blocked(address indexed account); event Unblocked(address indexed account); event BlocklisterChanged(address indexed account); /** * @dev Throws if called by any account other than the blocklister. */ modifier onlyBlocklister() { require(msg.sender == blocklister, "Blocklist: caller is not the blocklister"); _; } /** * @dev Checks if account is blocked. * @param _account The address to check. */ function isBlocked(address _account) external view returns (bool) { return _isFrozen(_account); } /** * @dev Adds account to blocklist. * @param _account The address to blocklist. */ function blockAccount(address _account) external onlyBlocklister { _freezeBalance(_account); emit Blocked(_account); } /** * @dev Removes account from blocklist. * @param _account The address to remove from the blocklist. */ function unblockAccount(address _account) external onlyBlocklister { _unfreezeBalance(_account); emit Unblocked(_account); } /** * @dev Updates address of the blocklister account. * Callable only by the contract owner. * @param _newBlocklister address of new blocklister account. */ function updateBlocklister(address _newBlocklister) external onlyOwner { blocklister = _newBlocklister; emit BlocklisterChanged(_newBlocklister); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "../utils/Ownable.sol"; import "./BaseERC20.sol"; import "../interfaces/IMintableERC20.sol"; import "../interfaces/IBurnableERC20.sol"; /** * @title ERC20MintBurn */ abstract contract ERC20MintBurn is IMintableERC20, IBurnableERC20, Ownable, BaseERC20 { mapping(address => uint256) internal permissions; event UpdateMinter(address indexed minter, bool canMint, bool canBurn); function isMinter(address _account) public view returns (bool) { return permissions[_account] & 2 > 0; } function isBurner(address _account) public view returns (bool) { return permissions[_account] & 1 > 0; } /** * @dev Updates mint/burn permissions of the specific account. * Callable only by the contract owner. * @param _account address of the new minter EOA or contract. * @param _canMint true if minting is allowed. * @param _canBurn true if burning is allowed. */ function updateMinter(address _account, bool _canMint, bool _canBurn) external onlyOwner { permissions[_account] = (_canMint ? 2 : 0) + (_canBurn ? 1 : 0); emit UpdateMinter(_account, _canMint, _canBurn); } /** * @dev Mints the specified amount of tokens. * Callable only by one of the minter addresses. * @param _to address of the tokens receiver. * @param _amount amount of tokens to mint. */ function mint(address _to, uint256 _amount) external { require(isMinter(msg.sender), "ERC20MintBurn: not a minter"); _mint(_to, _amount); } /** * @dev Burns tokens from the caller. * Callable only by one of the burner addresses. * @param _value amount of tokens to burn. Should be less than or equal to caller balance. */ function burn(uint256 _value) external virtual { require(isBurner(msg.sender), "ERC20MintBurn: not a burner"); _burn(msg.sender, _value); } /** * @dev Burns pre-approved tokens from the other address. * Callable only by one of the burner addresses. * @param _from account to burn tokens from. * @param _value amount of tokens to burn. Should be less than or equal to account balance. */ function burnFrom(address _from, uint256 _value) external virtual { require(isBurner(msg.sender), "ERC20MintBurn: not a burner"); _spendAllowance(_from, msg.sender, _value); _burn(_from, _value); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "../interfaces/IERC20Permit.sol"; import "./BaseERC20.sol"; import "../utils/EIP712.sol"; /** * @title ERC20Permit */ abstract contract ERC20Permit is IERC20Permit, BaseERC20, EIP712 { // EIP2612 permit typehash bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); // Custom "salted" permit typehash // Works exactly the same as EIP2612 permit, except that includes an additional salt, // which should be explicitly signed by the user, as part of the permit message. bytes32 public constant SALTED_PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline,bytes32 salt)"); mapping(address => uint256) public nonces; constructor(address _self) EIP712(_self, name(), "1") {} function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev Allows to spend holder's unlimited amount by the specified spender according to EIP2612. * The function can be called by anyone, but requires having allowance parameters * signed by the holder according to EIP712. * Note: call to permit can be executed in the front-running transaction sent by other party, * contracts using permit/receiveWithPermit are advised to implement necessary fallbacks for failing permit calls, * avoiding entire transaction failures if possible. * @param _holder The holder's address. * @param _spender The spender's address. * @param _value Allowance value to set as a result of the call. * @param _deadline The deadline timestamp to call the permit function. Must be a timestamp in the future. * Note that timestamps are not precise, malicious miner/validator can manipulate them to some extend. * Assume that there can be a 900 seconds time delta between the desired timestamp and the actual expiration. * @param _v A final byte of signature (ECDSA component). * @param _r The first 32 bytes of signature (ECDSA component). * @param _s The second 32 bytes of signature (ECDSA component). */ function permit( address _holder, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) external { _checkPermit(_holder, _spender, _value, _deadline, _v, _r, _s); _approve(_holder, _spender, _value); } /** * @dev Cheap shortcut for making sequential calls to permit() + transferFrom() functions. * Note: signatures from receiveWithPermit can be re-used in the front-running permit transaction sent by other party, * contracts using permit/receiveWithPermit are advised to implement necessary fallbacks for failing * receiveWithPermit calls, avoiding entire transaction failures if possible. */ function receiveWithPermit( address _holder, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) public virtual { _checkPermit(_holder, msg.sender, _value, _deadline, _v, _r, _s); // we don't make calls to _approve to avoid unnecessary storage writes // however, emitting ERC20 events is still desired emit Approval(_holder, msg.sender, _value); _approve(_holder, msg.sender, 0); _transfer(_holder, msg.sender, _value); } /** * @dev Cheap shortcut for making sequential calls to saltedPermit() + transferFrom() functions. */ function receiveWithSaltedPermit( address _holder, uint256 _value, uint256 _deadline, bytes32 _salt, uint8 _v, bytes32 _r, bytes32 _s ) public virtual { _checkSaltedPermit(_holder, msg.sender, _value, _deadline, _salt, _v, _r, _s); // we don't make calls to _approve to avoid unnecessary storage writes // however, emitting ERC20 events is still desired emit Approval(_holder, msg.sender, _value); _approve(_holder, msg.sender, 0); _transfer(_holder, msg.sender, _value); } function _checkPermit( address _holder, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) private { require(block.timestamp <= _deadline, "ERC20Permit: expired permit"); uint256 nonce = nonces[_holder]++; bytes32 digest = ECDSA.toTypedDataHash( _domainSeparatorV4(), keccak256(abi.encode(PERMIT_TYPEHASH, _holder, _spender, _value, nonce, _deadline)) ); require(_holder == ECDSA.recover(digest, _v, _r, _s), "ERC20Permit: invalid ERC2612 signature"); } function _checkSaltedPermit( address _holder, address _spender, uint256 _value, uint256 _deadline, bytes32 _salt, uint8 _v, bytes32 _r, bytes32 _s ) private { require(block.timestamp <= _deadline, "ERC20Permit: expired permit"); uint256 nonce = nonces[_holder]++; bytes32 digest = ECDSA.toTypedDataHash( _domainSeparatorV4(), keccak256(abi.encode(SALTED_PERMIT_TYPEHASH, _holder, _spender, _value, nonce, _deadline, _salt)) ); require(_holder == ECDSA.recover(digest, _v, _r, _s), "ERC20Permit: invalid signature"); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "@openzeppelin/contracts/utils/Address.sol"; import "../utils/Ownable.sol"; import "../interfaces/IERC677Receiver.sol"; import "./BaseERC20.sol"; /** * @title ERC20Recovery */ abstract contract ERC20Recovery is Ownable, BaseERC20 { event ExecutedRecovery(bytes32 indexed hash, uint256 value); event CancelledRecovery(bytes32 indexed hash); event RequestedRecovery( bytes32 indexed hash, uint256 requestTimestamp, uint256 executionTimestamp, address[] accounts, uint256[] values ); address public recoveryAdmin; address public recoveredFundsReceiver; uint64 public recoveryLimitPercent; uint32 public recoveryRequestTimelockPeriod; uint256 public totalRecovered; bytes32 public recoveryRequestHash; uint256 public recoveryRequestExecutionTimestamp; /** * @dev Throws if called by any account other than the contract owner or recovery admin. */ modifier onlyRecoveryAdmin() { require(_msgSender() == recoveryAdmin || _isOwner(), "Recovery: not authorized for recovery"); _; } /** * @dev Updates the address of the recovery admin account. * Callable only by the contract owner. * Recovery admin is only authorized to request/execute/cancel recovery operations. * The availability, parameters and impact limits of recovery is controlled by the contract owner. * @param _recoveryAdmin address of the new recovery admin account. */ function setRecoveryAdmin(address _recoveryAdmin) external onlyOwner { recoveryAdmin = _recoveryAdmin; } /** * @dev Updates the address of the recovered funds receiver. * Callable only by the contract owner. * Recovered funds receiver will receive ERC20, recovered from lost/unused accounts. * If receiver is a smart contract, it must correctly process a ERC677 callback, sent once on the recovery execution. * @param _recoveredFundsReceiver address of the new recovered funds receiver. */ function setRecoveredFundsReceiver(address _recoveredFundsReceiver) external onlyOwner { recoveredFundsReceiver = _recoveredFundsReceiver; } /** * @dev Updates the max allowed percentage of total supply, which can be recovered. * Limits the impact that could be caused by the recovery admin. * Callable only by the contract owner. * @param _recoveryLimitPercent percentage, as a fraction of 1 ether, should be at most 100%. * In theory, recovery can exceed total supply, if recovered funds are then lost once again, * but in practice, we do not expect totalRecovered to reach such extreme values. */ function setRecoveryLimitPercent(uint64 _recoveryLimitPercent) external onlyOwner { require(_recoveryLimitPercent <= 1 ether, "Recovery: invalid percentage"); recoveryLimitPercent = _recoveryLimitPercent; } /** * @dev Updates the timelock period between submission of the recovery request and its execution. * Any user, who is not willing to accept the recovery, can safely withdraw his tokens within such period. * Callable only by the contract owner. * @param _recoveryRequestTimelockPeriod new timelock period in seconds. */ function setRecoveryRequestTimelockPeriod(uint32 _recoveryRequestTimelockPeriod) external onlyOwner { require(_recoveryRequestTimelockPeriod >= 1 days, "Recovery: too low timelock period"); require(_recoveryRequestTimelockPeriod <= 30 days, "Recovery: too high timelock period"); recoveryRequestTimelockPeriod = _recoveryRequestTimelockPeriod; } /** * @dev Tells if recovery of funds is available, given the current configuration of recovery parameters. * @return true, if at least 1 wei of tokens could be recovered within the available limit. */ function isRecoveryEnabled() external view returns (bool) { return _remainingRecoveryLimit() > 0; } /** * @dev Internal function telling the remaining available limit for recovery. * @return available recovery limit. */ function _remainingRecoveryLimit() internal view returns (uint256) { if (recoveredFundsReceiver == address(0)) { return 0; } uint256 limit = totalSupply * recoveryLimitPercent / 1 ether; if (limit > totalRecovered) { return limit - totalRecovered; } return 0; } /** * @dev Creates a request to recover funds from abandoned/unused accounts. * Only one request could be active at a time. Any pending request would be cancelled and won't take any effect. * Callable only by the contract owner or recovery admin. * @param _accounts list of accounts to recover funds from. * @param _values list of max values to recover from each of the specified account. */ function requestRecovery(address[] calldata _accounts, uint256[] calldata _values) external onlyRecoveryAdmin { require(_accounts.length == _values.length, "Recovery: different lengths"); require(_accounts.length > 0, "Recovery: empty accounts"); uint256 limit = _remainingRecoveryLimit(); require(limit > 0, "Recovery: not enabled"); bytes32 hash = recoveryRequestHash; if (hash != bytes32(0)) { emit CancelledRecovery(hash); } uint256[] memory values = new uint256[](_values.length); uint256 total = 0; for (uint256 i = 0; i < _values.length; i++) { uint256 balance = balanceOf(_accounts[i]); uint256 value = balance < _values[i] ? balance : _values[i]; values[i] = value; total += value; } require(total <= limit, "Recovery: exceed recovery limit"); uint256 executionTimestamp = block.timestamp + recoveryRequestTimelockPeriod; hash = keccak256(abi.encode(executionTimestamp, _accounts, values)); recoveryRequestHash = hash; recoveryRequestExecutionTimestamp = executionTimestamp; emit RequestedRecovery(hash, block.timestamp, executionTimestamp, _accounts, values); } /** * @dev Executes the request to recover funds from abandoned/unused accounts. * Executed request should have exactly the same parameters, as emitted in the RequestedRecovery event. * Request could only be executed once configured timelock was surpassed. * After execution of the request, total amount of recovered funds should not exceed the configured percentage. * Callable only by the contract owner or recovery admin. * @param _accounts list of accounts to recover funds from. * @param _values list of max values to recover from each of the specified account. */ function executeRecovery(address[] calldata _accounts, uint256[] calldata _values) external onlyRecoveryAdmin { uint256 executionTimestamp = recoveryRequestExecutionTimestamp; delete recoveryRequestExecutionTimestamp; require(executionTimestamp > 0, "Recovery: no active recovery request"); require(executionTimestamp <= block.timestamp, "Recovery: request still timelocked"); uint256 limit = _remainingRecoveryLimit(); require(limit > 0, "Recovery: not enabled"); bytes32 storedHash = recoveryRequestHash; delete recoveryRequestHash; bytes32 receivedHash = keccak256(abi.encode(executionTimestamp, _accounts, _values)); require(storedHash == receivedHash, "Recovery: request hashes do not match"); uint256 value = _recoverTokens(_accounts, _values); require(value <= limit, "Recovery: exceed recovery limit"); emit ExecutedRecovery(storedHash, value); } /** * @dev Cancels pending recovery request. * Callable only by the contract owner or recovery admin. */ function cancelRecovery() external onlyRecoveryAdmin { bytes32 hash = recoveryRequestHash; require(hash != bytes32(0), "Recovery: no active recovery request"); delete recoveryRequestHash; delete recoveryRequestExecutionTimestamp; emit CancelledRecovery(hash); } function _recoverTokens(address[] calldata _accounts, uint256[] calldata _values) internal returns (uint256) { uint256 total = 0; address receiver = recoveredFundsReceiver; for (uint256 i = 0; i < _accounts.length; i++) { uint256 balance = balanceOf(_accounts[i]); uint256 value = balance < _values[i] ? balance : _values[i]; total += value; _decreaseBalanceUnchecked(_accounts[i], value); emit Transfer(_accounts[i], receiver, value); } _increaseBalance(receiver, total); totalRecovered += total; if (Address.isContract(receiver)) { require(IERC677Receiver(receiver).onTokenTransfer(address(this), total, new bytes(0))); } return total; } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "../interfaces/IERC677.sol"; import "../interfaces/IERC677Receiver.sol"; import "./BaseERC20.sol"; /** * @title ERC677 */ abstract contract ERC677 is IERC677, BaseERC20 { /** * @dev ERC677 extension to ERC20 transfer. Will notify receiver after transfer completion. * @param _to address of the tokens receiver. * @param _amount amount of tokens to mint. * @param _data extra data to pass in the notification callback. */ function transferAndCall(address _to, uint256 _amount, bytes calldata _data) external override { _transfer(msg.sender, _to, _amount); require(IERC677Receiver(_to).onTokenTransfer(msg.sender, _amount, _data), "ERC677: callback failed"); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./Ownable.sol"; /** * @title Claimable */ contract Claimable is Ownable { address claimingAdmin; /** * @dev Throws if called by any account other than the contract owner or claiming admin. */ modifier onlyClaimingAdmin() { require(_msgSender() == claimingAdmin || _isOwner(), "Claimable: not authorized for claiming"); _; } /** * @dev Updates the address of the claiming admin account. * Callable only by the contract owner. * Claiming admin is only authorized to claim ERC20 tokens or native tokens mistakenly sent to the token contract address. * @param _claimingAdmin address of the new claiming admin account. */ function setClaimingAdmin(address _claimingAdmin) external onlyOwner { claimingAdmin = _claimingAdmin; } /** * @dev Allows to transfer any locked token from this contract. * Callable only by the contract owner or claiming admin. * @param _token address of the token contract, or 0x00..00 for transferring native coins. * @param _to locked tokens receiver address. */ function claimTokens(address _token, address _to) external virtual onlyClaimingAdmin { if (_token == address(0)) { payable(_to).transfer(address(this).balance); } else { uint256 balance = IERC20(_token).balanceOf(address(this)); IERC20(_token).transfer(_to, balance); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.15; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * Adapted from OpenZeppelin library to support address(this) overrides in proxy implementations. */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(address self, string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion, self); _CACHED_THIS = self; _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION, address(this)); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash, address self ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, self)); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.15; import "@openzeppelin/contracts/access/Ownable.sol" as OZOwnable; /** * @title Ownable */ contract Ownable is OZOwnable.Ownable { /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view override { require(_isOwner(), "Ownable: caller is not the owner"); } /** * @dev Tells if caller is the contract owner. * @return true, if caller is the contract owner. */ function _isOwner() internal view virtual returns (bool) { return owner() == _msgSender(); } }
{ "remappings": [ "@base58-solidity/=lib/base58-solidity/contracts/", "@gnosis/=lib/@gnosis/", "@gnosis/auction/=lib/@gnosis/auction/contracts/", "@openzeppelin/=lib/@openzeppelin/contracts/", "@openzeppelin/contracts/=lib/@openzeppelin/contracts/contracts/", "@uniswap/=lib/@uniswap/", "base58-solidity/=lib/base58-solidity/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"},{"internalType":"uint256","name":"_amount0","type":"uint256"},{"internalType":"uint256","name":"_amount1","type":"uint256"},{"internalType":"int24","name":"_tickLower","type":"int24"},{"internalType":"int24","name":"_tickUpper","type":"int24"},{"internalType":"uint24","name":"_fee","type":"uint24"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"int256","name":"_price","type":"int256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"hash","type":"bytes32"}],"name":"LimitOrder","type":"event"},{"inputs":[],"name":"ROUTER_DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amount0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amount1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makingAmount","type":"uint256"},{"internalType":"uint256","name":"takingAmount","type":"uint256"},{"internalType":"uint256","name":"remainingAmount","type":"uint256"},{"internalType":"bytes","name":"interactiveData","type":"bytes"}],"name":"fillOrderPostInteraction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getOrder0","outputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"address","name":"makerAsset","type":"address"},{"internalType":"address","name":"takerAsset","type":"address"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"allowedSender","type":"address"},{"internalType":"uint256","name":"makingAmount","type":"uint256"},{"internalType":"uint256","name":"takingAmount","type":"uint256"},{"internalType":"uint256","name":"offsets","type":"uint256"},{"internalType":"bytes","name":"interactions","type":"bytes"}],"internalType":"struct OrderLib.Order","name":"order","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOrder1","outputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"address","name":"makerAsset","type":"address"},{"internalType":"address","name":"takerAsset","type":"address"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"allowedSender","type":"address"},{"internalType":"uint256","name":"makingAmount","type":"uint256"},{"internalType":"uint256","name":"takingAmount","type":"uint256"},{"internalType":"uint256","name":"offsets","type":"uint256"},{"internalType":"bytes","name":"interactions","type":"bytes"}],"internalType":"struct OrderLib.Order","name":"order","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"increaseLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"magicValue","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tickLower","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tickUpper","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6018610180527f31696e6368204167677265676174696f6e20526f7574657200000000000000006101a05260016101c052603560f81b6101e0527f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6102209081527f5c6cbfb2848b981a8f93044b3530be1fac304ecd5042396ca8729cb8fdd718f3610240527fceebf77a833b30520287ddd9478ff51abbdffa30aa90a8d655dba0e8a79ce0c1610260524661028052731111111254eeb25477b68fb85ed929f73a9605826102a05260a06102008190526102c0604052902061016052348015620000e957600080fd5b5060405162002761380380620027618339810160408190526200010c916200036d565b6001600160a01b0389811660a081905289821660c05260008990556001889055600287810b60e05286900b6101005262ffffff85166101205290831660805261014082905260405163095ea7b360e01b815273c36442b4a4522e871399cd717abdd847ab11fe886004820152600019602482015263095ea7b390604401600060405180830381600087803b158015620001a457600080fd5b505af1158015620001b9573d6000803e3d6000fd5b505060c05160405163095ea7b360e01b815273c36442b4a4522e871399cd717abdd847ab11fe88600482015260001960248201526001600160a01b03909116925063095ea7b39150604401600060405180830381600087803b1580156200021f57600080fd5b505af115801562000234573d6000803e3d6000fd5b505060a05160405163095ea7b360e01b8152731111111254eeb25477b68fb85ed929f73a960582600482015260001960248201526001600160a01b03909116925063095ea7b39150604401600060405180830381600087803b1580156200029a57600080fd5b505af1158015620002af573d6000803e3d6000fd5b505060c05160405163095ea7b360e01b8152731111111254eeb25477b68fb85ed929f73a960582600482015260001960248201526001600160a01b03909116925063095ea7b39150604401600060405180830381600087803b1580156200031557600080fd5b505af11580156200032a573d6000803e3d6000fd5b5050505050505050505050505062000416565b80516001600160a01b03811681146200035557600080fd5b919050565b8051600281900b81146200035557600080fd5b60008060008060008060008060006101208a8c0312156200038d57600080fd5b620003988a6200033d565b9850620003a860208b016200033d565b975060408a0151965060608a01519550620003c660808b016200035a565b9450620003d660a08b016200035a565b935060c08a015162ffffff81168114620003ef57600080fd5b9250620003ff60e08b016200033d565b91506101008a015190509295985092959850929598565b60805160a05160c05160e051610100516101205161014051610160516121e962000578600039600081816102950152818161044c01526115d401526000818161026e015281816106f60152818161076801528181610896015281816109b601528181610ae301528181610c2101528181610c4e01528181610d930152610dc30152600081816102eb01526105880152600081816101cf01526105dc01526000818161020901526105b30152600081816102bc015281816104cc01528181610559015281816107410152818161084f0152818161098f01528181610a9b01528181611012015261108701526000818161013f015281816104910152818161052a01528181610720015281816108710152818161096e01528181610abc01528181610b8d01528181610f330152610fa80152600081816102300152818161062301528181610ec601528181610f0901528181610fe8015261114401526121e96000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c80639906d175116100a2578063d4686e3e11610071578063d4686e3e146102de578063ddca3f43146102e6578063ea8a1af014610321578063f400fde414610329578063fefc632b1461033257600080fd5b80639906d17514610252578063a035b1fe14610269578063ac7f2adb14610290578063d21220a7146102b757600080fd5b80633504ed62116100e95780633504ed62146101af5780633ccfd60b146101c257806355b812a8146101ca57806359c4f905146102045780638da5cb5b1461022b57600080fd5b806306f6b0e21461011b5780630dfe16811461013a5780631249c58b146101795780631626ba7e14610183575b600080fd5b61012361033a565b6040516101319291906119d8565b60405180910390f35b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610131565b610181610480565b005b610196610191366004611b44565b610b1c565b6040516001600160e01b03199091168152602001610131565b6101816101bd366004611ba3565b610b46565b610181610ebb565b6101f17f000000000000000000000000000000000000000000000000000000000000000081565b60405160029190910b8152602001610131565b6101f17f000000000000000000000000000000000000000000000000000000000000000081565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b61025b60005481565b604051908152602001610131565b61025b7f000000000000000000000000000000000000000000000000000000000000000081565b61025b7f000000000000000000000000000000000000000000000000000000000000000081565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101236110b0565b61030d7f000000000000000000000000000000000000000000000000000000000000000081565b60405162ffffff9091168152602001610131565b610181611139565b61025b60015481565b610181611264565b6000610344611900565b60408051610140810182526003805482526004546001600160a01b039081166020840152600554811693830193909352600654831660608301526007548316608083015260085490921660a082015260095460c0820152600a5460e0820152600b54610100820152600c8054919291610120840191906103c390611c2c565b80601f01602080910402602001604051908101604052809291908181526020018280546103ef90611c2c565b801561043c5780601f106104115761010080835404028352916020019161043c565b820191906000526020600020905b81548152906001019060200180831161041f57829003601f168201915b505050505081525050905061047a7f00000000000000000000000000000000000000000000000000000000000000008261134890919063ffffffff16565b91509091565b6000546104bb906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016903390309061146c565b6001546104f6906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016903390309061146c565b60008073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663883164566040518061016001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020017f000000000000000000000000000000000000000000000000000000000000000062ffffff1681526020017f000000000000000000000000000000000000000000000000000000000000000060020b81526020017f000000000000000000000000000000000000000000000000000000000000000060020b81526020016000548152602001600154815260200160008152602001600081526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602001428152506040518263ffffffff1660e01b81526004016106709190611c66565b6080604051808303816000875af115801561068f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b39190611d4f565b600293909355600080549195509293508492915081906106d4908490611da1565b9250508190555080600160008282546106ed9190611da1565b909155505060007f00000000000000000000000000000000000000000000000000000000000000001315610969576107997f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006002546000547f00000000000000000000000000000000000000000000000000000000000000006000546107949190611db8565b6114dd565b805160039081556020820151600480546001600160a01b03199081166001600160a01b039384161790915560408401516005805483169184169190911790556060840151600680548316918416919091179055608084015160078054831691841691909117905560a084015160088054909216921691909117905560c082015160095560e0820151600a55610100820151600b55610120820151600c906108409082611e25565b50506002546001546108bb92507f0000000000000000000000000000000000000000000000000000000000000000917f0000000000000000000000000000000000000000000000000000000000000000916107947f000000000000000000000000000000000000000000000000000000000000000082611ee5565b8051600d9081556020820151600e80546001600160a01b03199081166001600160a01b03938416179091556040840151600f805483169184169190911790556060840151601080548316918416919091179055608084015160118054831691841691909117905560a084015160128054909216921691909117905560c082015160135560e08201516014556101008201516015556101208201516016906109629082611e25565b5050505050565b6109eb7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006002546000547f00000000000000000000000000000000000000000000000000000000000000006109de90611f07565b6000546107949190611ee5565b805160039081556020820151600480546001600160a01b03199081166001600160a01b039384161790915560408401516005805483169184169190911790556060840151600680548316918416919091179055608084015160078054831691841691909117905560a084015160088054909216921691909117905560c082015160095560e0820151600a55610100820151600b55610120820151600c90610a929082611e25565b509050506108bb7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006002546001547f0000000000000000000000000000000000000000000000000000000000000000610b0b90611f07565b6001546107949190611db8565b5050565b60008281526017602052604081205460ff16610b3757600080fd5b50630b135d3f60e11b92915050565b33731111111254eeb25477b68fb85ed929f73a96058214610b6657600080fd5b600081806020019051810190610b7c9190611f23565b9050600080826001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031603610d335773c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d176040518060c0016040528060025481526020018a600054610bfe9190611da1565b815260200189600154610c119190611f47565b81526020016000815260200160007f000000000000000000000000000000000000000000000000000000000000000013610c4c576000610c6e565b7f00000000000000000000000000000000000000000000000000000000000000005b8a600154610c7c9190611f47565b610c869190611da1565b8152602001428152506040518263ffffffff1660e01b8152600401610cab9190611f5f565b6060604051808303816000875af1158015610cca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cee9190611fa3565b6000549194509250839150610d04908990611da1565b610d0e9190611da1565b6000556001548190610d21908890611f47565b610d2b9190611da1565b600155610eaf565b73c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d176040518060c00160405280600254815260200189600054610d779190611f47565b81526020018a600154610d8a9190611da1565b815260200160007f000000000000000000000000000000000000000000000000000000000000000012610dbe576000610de7565b610de77f0000000000000000000000000000000000000000000000000000000000000000611f07565b8a600054610df59190611f47565b610dff9190611da1565b815260200160008152602001428152506040518263ffffffff1660e01b8152600401610e2b9190611f5f565b6060604051808303816000875af1158015610e4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6e9190611fa3565b6000549194509250839150610e84908890611f47565b610e8e9190611da1565b6000556001548190610ea1908990611da1565b610eab9190611da1565b6001555b50505050505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610ef057600080fd5b6040516370a0823160e01b8152306004820152610fcf907f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e9190611fd8565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190611664565b6040516370a0823160e01b81523060048201526110ae907f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015611059573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107d9190611fd8565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190611664565b565b60006110ba611900565b6040805161014081018252600d80548252600e546001600160a01b039081166020840152600f54811693830193909352601054831660608301526011548316608083015260125490921660a082015260135460c082015260145460e082015260155461010082015260168054919291610120840191906103c390611c2c565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461116e57600080fd5b6040516316cd2b7b60e11b8152731111111254eeb25477b68fb85ed929f73a96058290632d9a56f6906111a69060039060040161206e565b60408051808303816000875af11580156111c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e89190612106565b50506040516316cd2b7b60e11b8152731111111254eeb25477b68fb85ed929f73a96058290632d9a56f69061122290600d9060040161206e565b60408051808303816000875af1158015611240573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b189190612106565b6040805160c08101825260025481526000805460208301526001548284015260608201819052608082018190524260a0830152915163219f5d1760e01b8152829173c36442b4a4522e871399cd717abdd847ab11fe889163219f5d17916112cd91600401611f5f565b6060604051808303816000875af11580156112ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113109190611fa3565b9250925050816000808282546113269190611da1565b92505081905550806001600082825461133f9190611da1565b90915550505050565b60007f0a244ca8a150ac294c14fcff9277051ced9a5b23e966a0ff0522e989da23116c836000015184602001518560400151866060015187608001518860a001518960c001518a60e001518b61010001518c61012001518051906020012060405160200161141a9b9a999897969594939291909a8b5260208b01999099526001600160a01b0397881660408b015295871660608a0152938616608089015291851660a088015290931660c086015260e08501929092526101008401919091526101208301526101408201526101600190565b60408051808303601f19018152828252805160209182012061190160f01b8285015260228401959095526042808401959095528151808403909501855260629092019052825192019190912092915050565b6040516001600160a01b03808516602483015283166044820152606481018290526114d79085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611699565b50505050565b6114e5611900565b821561165b57604080516001600160a01b038816602082015260009130910160408051601f1981840301815290829052611522929160200161212a565b60408051808303601f1901815261014083019091523061016083015291508061018081016040516020818303038152906040528051906020012060001c8152602001886001600160a01b03168152602001876001600160a01b03168152602001306001600160a01b03168152602001306001600160a01b0316815260200160006001600160a01b0316815260200185815260200184815260200160e08351901b815260200182815250915060006116027f00000000000000000000000000000000000000000000000000000000000000008461134890919063ffffffff16565b60008181526017602052604090819020805460ff19166001179055519091507f112993d20b38010885e9f8f7159718df33860a96960da0041d4a13b1f1c48622906116509083815260200190565b60405180910390a150505b95945050505050565b6040516001600160a01b03831660248201526044810182905261169490849063a9059cbb60e01b906064016114a0565b505050565b60006116ee826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166117709092919063ffffffff16565b805190915015611694578080602001905181019061170c9190612162565b6116945760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084015b60405180910390fd5b606061177f8484600085611787565b949350505050565b6060824710156117e85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401611767565b600080866001600160a01b031685876040516118049190612184565b60006040518083038185875af1925050503d8060008114611841576040519150601f19603f3d011682016040523d82523d6000602084013e611846565b606091505b509150915061185787838387611862565b979650505050505050565b606083156118d15782516000036118ca576001600160a01b0385163b6118ca5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611767565b508161177f565b61177f83838151156118e65781518083602001fd5b8060405162461bcd60e51b815260040161176791906121a0565b6040518061014001604052806000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001606081525090565b60005b8381101561199b578181015183820152602001611983565b838111156114d75750506000910152565b600081518084526119c4816020860160208601611980565b601f01601f19169290920160200192915050565b828152604060208201528151604082015260006020830151611a0560608401826001600160a01b03169052565b5060408301516001600160a01b03811660808401525060608301516001600160a01b03811660a08401525060808301516001600160a01b03811660c08401525060a08301516001600160a01b03811660e08401525060c08301516101008381019190915260e08401516101208085019190915290840151610140808501919091529084015161016084019190915261165b6101808401826119ac565b634e487b7160e01b600052604160045260246000fd5b600082601f830112611ac857600080fd5b813567ffffffffffffffff80821115611ae357611ae3611aa1565b604051601f8301601f19908116603f01168101908282118183101715611b0b57611b0b611aa1565b81604052838152866020858801011115611b2457600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215611b5757600080fd5b82359150602083013567ffffffffffffffff811115611b7557600080fd5b611b8185828601611ab7565b9150509250929050565b6001600160a01b0381168114611ba057600080fd5b50565b600080600080600080600060e0888a031215611bbe57600080fd5b873596506020880135611bd081611b8b565b95506040880135611be081611b8b565b9450606088013593506080880135925060a0880135915060c088013567ffffffffffffffff811115611c1157600080fd5b611c1d8a828b01611ab7565b91505092959891949750929550565b600181811c90821680611c4057607f821691505b602082108103611c6057634e487b7160e01b600052602260045260246000fd5b50919050565b81516001600160a01b0316815261016081016020830151611c9260208401826001600160a01b03169052565b506040830151611ca9604084018262ffffff169052565b506060830151611cbe606084018260020b9052565b506080830151611cd3608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611d19828501826001600160a01b03169052565b505061014092830151919092015290565b80516fffffffffffffffffffffffffffffffff81168114611d4a57600080fd5b919050565b60008060008060808587031215611d6557600080fd5b84519350611d7560208601611d2a565b6040860151606090960151949790965092505050565b634e487b7160e01b600052601160045260246000fd5b600082821015611db357611db3611d8b565b500390565b6000816000190483118215151615611dd257611dd2611d8b565b500290565b601f82111561169457600081815260208120601f850160051c81016020861015611dfe5750805b601f850160051c820191505b81811015611e1d57828155600101611e0a565b505050505050565b815167ffffffffffffffff811115611e3f57611e3f611aa1565b611e5381611e4d8454611c2c565b84611dd7565b602080601f831160018114611e885760008415611e705750858301515b600019600386901b1c1916600185901b178555611e1d565b600085815260208120601f198616915b82811015611eb757888601518255948401946001909101908401611e98565b5085821015611ed55787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082611f0257634e487b7160e01b600052601260045260246000fd5b500490565b6000600160ff1b8201611f1c57611f1c611d8b565b5060000390565b600060208284031215611f3557600080fd5b8151611f4081611b8b565b9392505050565b60008219821115611f5a57611f5a611d8b565b500190565b600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b600080600060608486031215611fb857600080fd5b611fc184611d2a565b925060208401519150604084015190509250925092565b600060208284031215611fea57600080fd5b5051919050565b60008154611ffe81611c2c565b80855260206001838116801561201b576001811461203557612063565b60ff1985168884015283151560051b880183019550612063565b866000528260002060005b8581101561205b5781548a8201860152908301908401612040565b890184019650505b505050505092915050565b6020815281546020820152600061208f60018401546001600160a01b031690565b6001600160a01b0390811660408401526002840154811660608401526003840154811660808401526004840154811660a084015260058401541660c0830152600683015460e08301526007830154610100830152600883015461012083015261014080830152611f40610160830160098501611ff1565b6000806040838503121561211957600080fd5b505080516020909101519092909150565b6bffffffffffffffffffffffff198360601b16815260008251612154816014850160208701611980565b919091016014019392505050565b60006020828403121561217457600080fd5b81518015158114611f4057600080fd5b60008251612196818460208701611980565b9190910192915050565b602081526000611f4060208301846119ac56fea2646970667358221220ae0dd24b04a3a27b8a62b17481511fe92e6c94df3031a2c5fc583f13da679a7864736f6c634300080f0033000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000001a7836772e554732400000000000000000000000000000000000000000000000000000000000000e4e1c0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89bfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89d0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d8ffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80639906d175116100a2578063d4686e3e11610071578063d4686e3e146102de578063ddca3f43146102e6578063ea8a1af014610321578063f400fde414610329578063fefc632b1461033257600080fd5b80639906d17514610252578063a035b1fe14610269578063ac7f2adb14610290578063d21220a7146102b757600080fd5b80633504ed62116100e95780633504ed62146101af5780633ccfd60b146101c257806355b812a8146101ca57806359c4f905146102045780638da5cb5b1461022b57600080fd5b806306f6b0e21461011b5780630dfe16811461013a5780631249c58b146101795780631626ba7e14610183575b600080fd5b61012361033a565b6040516101319291906119d8565b60405180910390f35b6101617f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b81565b6040516001600160a01b039091168152602001610131565b610181610480565b005b610196610191366004611b44565b610b1c565b6040516001600160e01b03199091168152602001610131565b6101816101bd366004611ba3565b610b46565b610181610ebb565b6101f17ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89d81565b60405160029190910b8152602001610131565b6101f17ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89b81565b6101617f000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d881565b61025b60005481565b604051908152602001610131565b61025b7fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af00081565b61025b7f1c0eb4c27d5b523ca136c0b3b83a4dcac8b70225b38be8507ba1a3f2af03cfca81565b6101617f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b6101236110b0565b61030d7f000000000000000000000000000000000000000000000000000000000000006481565b60405162ffffff9091168152602001610131565b610181611139565b61025b60015481565b610181611264565b6000610344611900565b60408051610140810182526003805482526004546001600160a01b039081166020840152600554811693830193909352600654831660608301526007548316608083015260085490921660a082015260095460c0820152600a5460e0820152600b54610100820152600c8054919291610120840191906103c390611c2c565b80601f01602080910402602001604051908101604052809291908181526020018280546103ef90611c2c565b801561043c5780601f106104115761010080835404028352916020019161043c565b820191906000526020600020905b81548152906001019060200180831161041f57829003601f168201915b505050505081525050905061047a7f1c0eb4c27d5b523ca136c0b3b83a4dcac8b70225b38be8507ba1a3f2af03cfca8261134890919063ffffffff16565b91509091565b6000546104bb906001600160a01b037f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b16903390309061146c565b6001546104f6906001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec716903390309061146c565b60008073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663883164566040518061016001604052807f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b6001600160a01b031681526020017f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76001600160a01b031681526020017f000000000000000000000000000000000000000000000000000000000000006462ffffff1681526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89b60020b81526020017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89d60020b81526020016000548152602001600154815260200160008152602001600081526020017f000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d86001600160a01b03168152602001428152506040518263ffffffff1660e01b81526004016106709190611c66565b6080604051808303816000875af115801561068f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b39190611d4f565b600293909355600080549195509293508492915081906106d4908490611da1565b9250508190555080600160008282546106ed9190611da1565b909155505060007fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af0001315610969576107997f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76002546000547fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af0006000546107949190611db8565b6114dd565b805160039081556020820151600480546001600160a01b03199081166001600160a01b039384161790915560408401516005805483169184169190911790556060840151600680548316918416919091179055608084015160078054831691841691909117905560a084015160088054909216921691909117905560c082015160095560e0820151600a55610100820151600b55610120820151600c906108409082611e25565b50506002546001546108bb92507f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7917f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b916107947fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af00082611ee5565b8051600d9081556020820151600e80546001600160a01b03199081166001600160a01b03938416179091556040840151600f805483169184169190911790556060840151601080548316918416919091179055608084015160118054831691841691909117905560a084015160128054909216921691909117905560c082015160135560e08201516014556101008201516015556101208201516016906109629082611e25565b5050505050565b6109eb7f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76002546000547fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af0006109de90611f07565b6000546107949190611ee5565b805160039081556020820151600480546001600160a01b03199081166001600160a01b039384161790915560408401516005805483169184169190911790556060840151600680548316918416919091179055608084015160078054831691841691909117905560a084015160088054909216921691909117905560c082015160095560e0820151600a55610100820151600b55610120820151600c90610a929082611e25565b509050506108bb7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec77f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b6002546001547fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af000610b0b90611f07565b6001546107949190611db8565b5050565b60008281526017602052604081205460ff16610b3757600080fd5b50630b135d3f60e11b92915050565b33731111111254eeb25477b68fb85ed929f73a96058214610b6657600080fd5b600081806020019051810190610b7c9190611f23565b9050600080826001600160a01b03167f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b6001600160a01b031603610d335773c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d176040518060c0016040528060025481526020018a600054610bfe9190611da1565b815260200189600154610c119190611f47565b81526020016000815260200160007fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af00013610c4c576000610c6e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af0005b8a600154610c7c9190611f47565b610c869190611da1565b8152602001428152506040518263ffffffff1660e01b8152600401610cab9190611f5f565b6060604051808303816000875af1158015610cca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cee9190611fa3565b6000549194509250839150610d04908990611da1565b610d0e9190611da1565b6000556001548190610d21908890611f47565b610d2b9190611da1565b600155610eaf565b73c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d176040518060c00160405280600254815260200189600054610d779190611f47565b81526020018a600154610d8a9190611da1565b815260200160007fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af00012610dbe576000610de7565b610de77fffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af000611f07565b8a600054610df59190611f47565b610dff9190611da1565b815260200160008152602001428152506040518263ffffffff1660e01b8152600401610e2b9190611f5f565b6060604051808303816000875af1158015610e4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6e9190611fa3565b6000549194509250839150610e84908890611f47565b610e8e9190611da1565b6000556001548190610ea1908990611da1565b610eab9190611da1565b6001555b50505050505050505050565b336001600160a01b037f000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d81614610ef057600080fd5b6040516370a0823160e01b8152306004820152610fcf907f000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d8906001600160a01b037f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b16906370a0823190602401602060405180830381865afa158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e9190611fd8565b6001600160a01b037f000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b169190611664565b6040516370a0823160e01b81523060048201526110ae907f000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d8906001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec716906370a0823190602401602060405180830381865afa158015611059573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107d9190611fd8565b6001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7169190611664565b565b60006110ba611900565b6040805161014081018252600d80548252600e546001600160a01b039081166020840152600f54811693830193909352601054831660608301526011548316608083015260125490921660a082015260135460c082015260145460e082015260155461010082015260168054919291610120840191906103c390611c2c565b336001600160a01b037f000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d8161461116e57600080fd5b6040516316cd2b7b60e11b8152731111111254eeb25477b68fb85ed929f73a96058290632d9a56f6906111a69060039060040161206e565b60408051808303816000875af11580156111c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e89190612106565b50506040516316cd2b7b60e11b8152731111111254eeb25477b68fb85ed929f73a96058290632d9a56f69061122290600d9060040161206e565b60408051808303816000875af1158015611240573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b189190612106565b6040805160c08101825260025481526000805460208301526001548284015260608201819052608082018190524260a0830152915163219f5d1760e01b8152829173c36442b4a4522e871399cd717abdd847ab11fe889163219f5d17916112cd91600401611f5f565b6060604051808303816000875af11580156112ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113109190611fa3565b9250925050816000808282546113269190611da1565b92505081905550806001600082825461133f9190611da1565b90915550505050565b60007f0a244ca8a150ac294c14fcff9277051ced9a5b23e966a0ff0522e989da23116c836000015184602001518560400151866060015187608001518860a001518960c001518a60e001518b61010001518c61012001518051906020012060405160200161141a9b9a999897969594939291909a8b5260208b01999099526001600160a01b0397881660408b015295871660608a0152938616608089015291851660a088015290931660c086015260e08501929092526101008401919091526101208301526101408201526101600190565b60408051808303601f19018152828252805160209182012061190160f01b8285015260228401959095526042808401959095528151808403909501855260629092019052825192019190912092915050565b6040516001600160a01b03808516602483015283166044820152606481018290526114d79085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611699565b50505050565b6114e5611900565b821561165b57604080516001600160a01b038816602082015260009130910160408051601f1981840301815290829052611522929160200161212a565b60408051808303601f1901815261014083019091523061016083015291508061018081016040516020818303038152906040528051906020012060001c8152602001886001600160a01b03168152602001876001600160a01b03168152602001306001600160a01b03168152602001306001600160a01b0316815260200160006001600160a01b0316815260200185815260200184815260200160e08351901b815260200182815250915060006116027f1c0eb4c27d5b523ca136c0b3b83a4dcac8b70225b38be8507ba1a3f2af03cfca8461134890919063ffffffff16565b60008181526017602052604090819020805460ff19166001179055519091507f112993d20b38010885e9f8f7159718df33860a96960da0041d4a13b1f1c48622906116509083815260200190565b60405180910390a150505b95945050505050565b6040516001600160a01b03831660248201526044810182905261169490849063a9059cbb60e01b906064016114a0565b505050565b60006116ee826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166117709092919063ffffffff16565b805190915015611694578080602001905181019061170c9190612162565b6116945760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084015b60405180910390fd5b606061177f8484600085611787565b949350505050565b6060824710156117e85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401611767565b600080866001600160a01b031685876040516118049190612184565b60006040518083038185875af1925050503d8060008114611841576040519150601f19603f3d011682016040523d82523d6000602084013e611846565b606091505b509150915061185787838387611862565b979650505050505050565b606083156118d15782516000036118ca576001600160a01b0385163b6118ca5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611767565b508161177f565b61177f83838151156118e65781518083602001fd5b8060405162461bcd60e51b815260040161176791906121a0565b6040518061014001604052806000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001606081525090565b60005b8381101561199b578181015183820152602001611983565b838111156114d75750506000910152565b600081518084526119c4816020860160208601611980565b601f01601f19169290920160200192915050565b828152604060208201528151604082015260006020830151611a0560608401826001600160a01b03169052565b5060408301516001600160a01b03811660808401525060608301516001600160a01b03811660a08401525060808301516001600160a01b03811660c08401525060a08301516001600160a01b03811660e08401525060c08301516101008381019190915260e08401516101208085019190915290840151610140808501919091529084015161016084019190915261165b6101808401826119ac565b634e487b7160e01b600052604160045260246000fd5b600082601f830112611ac857600080fd5b813567ffffffffffffffff80821115611ae357611ae3611aa1565b604051601f8301601f19908116603f01168101908282118183101715611b0b57611b0b611aa1565b81604052838152866020858801011115611b2457600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215611b5757600080fd5b82359150602083013567ffffffffffffffff811115611b7557600080fd5b611b8185828601611ab7565b9150509250929050565b6001600160a01b0381168114611ba057600080fd5b50565b600080600080600080600060e0888a031215611bbe57600080fd5b873596506020880135611bd081611b8b565b95506040880135611be081611b8b565b9450606088013593506080880135925060a0880135915060c088013567ffffffffffffffff811115611c1157600080fd5b611c1d8a828b01611ab7565b91505092959891949750929550565b600181811c90821680611c4057607f821691505b602082108103611c6057634e487b7160e01b600052602260045260246000fd5b50919050565b81516001600160a01b0316815261016081016020830151611c9260208401826001600160a01b03169052565b506040830151611ca9604084018262ffffff169052565b506060830151611cbe606084018260020b9052565b506080830151611cd3608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611d19828501826001600160a01b03169052565b505061014092830151919092015290565b80516fffffffffffffffffffffffffffffffff81168114611d4a57600080fd5b919050565b60008060008060808587031215611d6557600080fd5b84519350611d7560208601611d2a565b6040860151606090960151949790965092505050565b634e487b7160e01b600052601160045260246000fd5b600082821015611db357611db3611d8b565b500390565b6000816000190483118215151615611dd257611dd2611d8b565b500290565b601f82111561169457600081815260208120601f850160051c81016020861015611dfe5750805b601f850160051c820191505b81811015611e1d57828155600101611e0a565b505050505050565b815167ffffffffffffffff811115611e3f57611e3f611aa1565b611e5381611e4d8454611c2c565b84611dd7565b602080601f831160018114611e885760008415611e705750858301515b600019600386901b1c1916600185901b178555611e1d565b600085815260208120601f198616915b82811015611eb757888601518255948401946001909101908401611e98565b5085821015611ed55787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082611f0257634e487b7160e01b600052601260045260246000fd5b500490565b6000600160ff1b8201611f1c57611f1c611d8b565b5060000390565b600060208284031215611f3557600080fd5b8151611f4081611b8b565b9392505050565b60008219821115611f5a57611f5a611d8b565b500190565b600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b600080600060608486031215611fb857600080fd5b611fc184611d2a565b925060208401519150604084015190509250925092565b600060208284031215611fea57600080fd5b5051919050565b60008154611ffe81611c2c565b80855260206001838116801561201b576001811461203557612063565b60ff1985168884015283151560051b880183019550612063565b866000528260002060005b8581101561205b5781548a8201860152908301908401612040565b890184019650505b505050505092915050565b6020815281546020820152600061208f60018401546001600160a01b031690565b6001600160a01b0390811660408401526002840154811660608401526003840154811660808401526004840154811660a084015260058401541660c0830152600683015460e08301526007830154610100830152600883015461012083015261014080830152611f40610160830160098501611ff1565b6000806040838503121561211957600080fd5b505080516020909101519092909150565b6bffffffffffffffffffffffff198360601b16815260008251612154816014850160208701611980565b919091016014019392505050565b60006020828403121561217457600080fd5b81518015158114611f4057600080fd5b60008251612196818460208701611980565b9190910192915050565b602081526000611f4060208301846119ac56fea2646970667358221220ae0dd24b04a3a27b8a62b17481511fe92e6c94df3031a2c5fc583f13da679a7864736f6c634300080f0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000001a7836772e554732400000000000000000000000000000000000000000000000000000000000000e4e1c0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89bfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89d0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d8ffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af000
-----Decoded View---------------
Arg [0] : _token0 (address): 0xB0B195aEFA3650A6908f15CdaC7D92F8a5791B0B
Arg [1] : _token1 (address): 0xdAC17F958D2ee523a2206206994597C13D831ec7
Arg [2] : _amount0 (uint256): 1999985000000000000000000
Arg [3] : _amount1 (uint256): 15000000
Arg [4] : _tickLower (int24): -276325
Arg [5] : _tickUpper (int24): -276323
Arg [6] : _fee (uint24): 100
Arg [7] : _owner (address): 0xd4a3D9Ca00fa1fD8833D560F9217458E61c446d8
Arg [8] : _price (int256): -1000000000000
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 000000000000000000000000b0b195aefa3650a6908f15cdac7d92f8a5791b0b
Arg [1] : 000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7
Arg [2] : 00000000000000000000000000000000000000000001a7836772e55473240000
Arg [3] : 0000000000000000000000000000000000000000000000000000000000e4e1c0
Arg [4] : fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89b
Arg [5] : fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc89d
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000064
Arg [7] : 000000000000000000000000d4a3d9ca00fa1fd8833d560f9217458e61c446d8
Arg [8] : ffffffffffffffffffffffffffffffffffffffffffffffffffffff172b5af000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 27 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.