0G Mainnet
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {ERC20} from "@openzeppelin-v5/token/ERC20/ERC20.sol";
import {IERC20} from "@openzeppelin-v5/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin-v5/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "@openzeppelin-v5/utils/ReentrancyGuard.sol";
interface INPM {
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
function collect(CollectParams calldata params)
external
payable
returns (uint256 amount0, uint256 amount1);
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function ownerOf(uint256 tokenId) external view returns (address);
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
);
}
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
interface IERC721Minimal {
function transferFrom(address from, address to, uint256 tokenId) external;
}
contract ZiaVault is IERC721Receiver, ERC20, ReentrancyGuard {
error NotOwner();
error NotDepositor();
error TokenNotDeposited();
error ZeroAddress();
error DirectTransferNotAllowed();
error ContractPaused();
error ContractNotPaused();
error ContractFrozen();
error ContractNotFrozen();
error TokenAlreadyDeposited();
error TransferDisabled();
error ZeroLiquidity();
error WrongPool();
event Deposited(address indexed depositor, uint256 indexed tokenId, uint128 liquidity);
event Withdrawn(address indexed depositor, uint256 indexed tokenId, uint128 liquidity);
event FeesClaimed(uint256 indexed tokenId, uint256 amount0, uint256 amount1);
event FeeRecipientUpdated(address indexed oldRecipient, address indexed newRecipient);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Paused(address account);
event Unpaused(address account);
event Frozen(address account);
event Unfrozen(address account);
INPM public immutable positionManager;
address public immutable poolToken0;
address public immutable poolToken1;
uint24 public immutable poolFee;
address public owner;
address public feeRecipient;
bool public paused;
bool public frozen;
mapping(uint256 => address) public depositorOf;
mapping(uint256 => uint128) public liquidityOf;
mapping(address => uint256[]) private _depositedTokens;
mapping(uint256 => uint256) private _tokenIndex;
uint256 public totalDeposited;
bool private _depositing;
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
modifier whenNotPaused() {
if (paused) revert ContractPaused();
_;
}
modifier whenNotFrozen() {
if (frozen) revert ContractFrozen();
_;
}
constructor(
address _positionManager,
address _feeRecipient,
address _poolToken0,
address _poolToken1,
uint24 _poolFee,
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) {
if (_positionManager == address(0)) revert ZeroAddress();
if (_feeRecipient == address(0)) revert ZeroAddress();
if (_poolToken0 == address(0)) revert ZeroAddress();
if (_poolToken1 == address(0)) revert ZeroAddress();
positionManager = INPM(_positionManager);
feeRecipient = _feeRecipient;
poolToken0 = _poolToken0;
poolToken1 = _poolToken1;
poolFee = _poolFee;
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
emit FeeRecipientUpdated(address(0), _feeRecipient);
}
function deposit(uint256 tokenId) external nonReentrant whenNotPaused whenNotFrozen {
if (depositorOf[tokenId] != address(0)) revert TokenAlreadyDeposited();
(,, address token0, address token1, uint24 fee,,, uint128 liquidity,,,,) =
positionManager.positions(tokenId);
if (token0 != poolToken0 || token1 != poolToken1 || fee != poolFee) revert WrongPool();
if (liquidity == 0) revert ZeroLiquidity();
depositorOf[tokenId] = msg.sender;
_depositedTokens[msg.sender].push(tokenId);
_tokenIndex[tokenId] = _depositedTokens[msg.sender].length;
liquidityOf[tokenId] = liquidity;
unchecked { ++totalDeposited; }
_depositing = true;
positionManager.safeTransferFrom(msg.sender, address(this), tokenId);
_depositing = false;
_mint(msg.sender, uint256(liquidity));
emit Deposited(msg.sender, tokenId, liquidity);
}
function withdraw(uint256 tokenId) external nonReentrant whenNotFrozen {
if (depositorOf[tokenId] != msg.sender) revert NotDepositor();
_claimFees(tokenId);
uint128 liquidity = liquidityOf[tokenId];
_burn(msg.sender, uint256(liquidity));
delete liquidityOf[tokenId];
_removeToken(msg.sender, tokenId);
delete depositorOf[tokenId];
unchecked { --totalDeposited; }
positionManager.safeTransferFrom(address(this), msg.sender, tokenId);
emit Withdrawn(msg.sender, tokenId, liquidity);
}
function claimFees(uint256 tokenId) external nonReentrant onlyOwner {
_claimFees(tokenId);
}
function claimFeesMultiple(uint256[] calldata tokenIds) external nonReentrant onlyOwner {
for (uint256 i = 0; i < tokenIds.length; ) {
_claimFees(tokenIds[i]);
unchecked { ++i; }
}
}
function setFeeRecipient(address newFeeRecipient) external onlyOwner {
if (newFeeRecipient == address(0)) revert ZeroAddress();
address old = feeRecipient;
feeRecipient = newFeeRecipient;
emit FeeRecipientUpdated(old, newFeeRecipient);
}
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert ZeroAddress();
address old = owner;
owner = newOwner;
emit OwnershipTransferred(old, newOwner);
}
function pause() external onlyOwner {
if (paused) revert ContractPaused();
paused = true;
emit Paused(msg.sender);
}
function unpause() external onlyOwner {
if (!paused) revert ContractNotPaused();
paused = false;
emit Unpaused(msg.sender);
}
function emergencyFreeze() external onlyOwner {
if (frozen) revert ContractFrozen();
frozen = true;
paused = true;
emit Frozen(msg.sender);
}
function emergencyUnfreeze() external onlyOwner {
if (!frozen) revert ContractNotFrozen();
frozen = false;
paused = false;
emit Unfrozen(msg.sender);
}
function getDepositedTokenIds(address depositor) external view returns (uint256[] memory) {
return _depositedTokens[depositor];
}
function depositedCountOf(address depositor) external view returns (uint256) {
return _depositedTokens[depositor].length;
}
function rescueERC20(address token, address to, uint256 amount) external onlyOwner {
if (token == address(this)) revert TransferDisabled();
SafeERC20.safeTransfer(IERC20(token), to, amount);
}
function rescueERC721(address token, address to, uint256 tokenId) external onlyOwner {
if (token == address(positionManager) && depositorOf[tokenId] != address(0)) {
revert TokenNotDeposited();
}
IERC721Minimal(token).transferFrom(address(this), to, tokenId);
}
function rescueETH(address payable to) external onlyOwner {
(bool success,) = to.call{value: address(this).balance}("");
require(success);
}
receive() external payable {}
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external view override returns (bytes4) {
if (!_depositing || msg.sender != address(positionManager)) {
revert DirectTransferNotAllowed();
}
return this.onERC721Received.selector;
}
function _update(address from, address to, uint256 value) internal override {
if (from != address(0) && to != address(0)) revert TransferDisabled();
super._update(from, to, value);
}
function _claimFees(uint256 tokenId) internal {
if (depositorOf[tokenId] == address(0)) revert TokenNotDeposited();
(uint256 amount0, uint256 amount1) = positionManager.collect(
INPM.CollectParams({
tokenId: tokenId,
recipient: feeRecipient,
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
})
);
emit FeesClaimed(tokenId, amount0, amount1);
}
function _removeToken(address depositor, uint256 tokenId) internal {
uint256 idx = _tokenIndex[tokenId];
if (idx == 0) revert TokenNotDeposited();
uint256[] storage tokens = _depositedTokens[depositor];
uint256 lastToken = tokens[tokens.length - 1];
tokens[idx - 1] = lastToken;
_tokenIndex[lastToken] = idx;
tokens.pop();
delete _tokenIndex[tokenId];
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation sets the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the `transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {StorageSlot} from "./StorageSlot.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*
* IMPORTANT: Deprecated. This storage-based reentrancy guard will be removed and replaced
* by the {ReentrancyGuardTransient} variant in v6.0.
*
* @custom:stateless
*/
abstract contract ReentrancyGuard {
using StorageSlot for bytes32;
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant REENTRANCY_GUARD_STORAGE =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_reentrancyGuardStorageSlot().getUint256Slot().value = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
/**
* @dev A `view` only version of {nonReentrant}. Use to block view functions
* from being called, preventing reading from inconsistent contract state.
*
* CAUTION: This is a "view" modifier and does not change the reentrancy
* status. Use it only on view functions. For payable or non-payable functions,
* use the standard {nonReentrant} modifier instead.
*/
modifier nonReentrantView() {
_nonReentrantBeforeView();
_;
}
function _nonReentrantBeforeView() private view {
if (_reentrancyGuardEntered()) {
revert ReentrancyGuardReentrantCall();
}
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
_nonReentrantBeforeView();
// Any calls to nonReentrant after this point will fail
_reentrancyGuardStorageSlot().getUint256Slot().value = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_reentrancyGuardStorageSlot().getUint256Slot().value = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _reentrancyGuardStorageSlot().getUint256Slot().value == ENTERED;
}
function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) {
return REENTRANCY_GUARD_STORAGE;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
if (!_safeTransfer(token, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
if (!_safeTransferFrom(token, from, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _safeTransfer(token, to, value, false);
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _safeTransferFrom(token, from, to, value, false);
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
if (!_safeApprove(token, spender, value, false)) {
if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Oppositely, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity `token.transfer(to, value)` call, 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 to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.transfer.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(to, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
/**
* @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, 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 from The sender of the tokens
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value,
bool bubble
) private returns (bool success) {
bytes4 selector = IERC20.transferFrom.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(from, shr(96, not(0))))
mstore(0x24, and(to, shr(96, not(0))))
mstore(0x44, value)
success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
mstore(0x60, 0)
}
}
/**
* @dev Imitates a Solidity `token.approve(spender, value)` call, 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 spender The spender of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.approve.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(spender, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
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);
}
[
{
"type": "constructor",
"inputs": [
{
"name": "_positionManager",
"type": "address",
"internalType": "address"
},
{
"name": "_feeRecipient",
"type": "address",
"internalType": "address"
},
{
"name": "_poolToken0",
"type": "address",
"internalType": "address"
},
{
"name": "_poolToken1",
"type": "address",
"internalType": "address"
},
{
"name": "_poolFee",
"type": "uint24",
"internalType": "uint24"
},
{
"name": "_name",
"type": "string",
"internalType": "string"
},
{
"name": "_symbol",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "nonpayable"
},
{
"name": "ContractFrozen",
"type": "error",
"inputs": []
},
{
"name": "ContractNotFrozen",
"type": "error",
"inputs": []
},
{
"name": "ContractNotPaused",
"type": "error",
"inputs": []
},
{
"name": "ContractPaused",
"type": "error",
"inputs": []
},
{
"name": "DirectTransferNotAllowed",
"type": "error",
"inputs": []
},
{
"name": "ERC20InsufficientAllowance",
"type": "error",
"inputs": [
{
"name": "spender",
"type": "address",
"internalType": "address"
},
{
"name": "allowance",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "needed",
"type": "uint256",
"internalType": "uint256"
}
]
},
{
"name": "ERC20InsufficientBalance",
"type": "error",
"inputs": [
{
"name": "sender",
"type": "address",
"internalType": "address"
},
{
"name": "balance",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "needed",
"type": "uint256",
"internalType": "uint256"
}
]
},
{
"name": "ERC20InvalidApprover",
"type": "error",
"inputs": [
{
"name": "approver",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "ERC20InvalidReceiver",
"type": "error",
"inputs": [
{
"name": "receiver",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "ERC20InvalidSender",
"type": "error",
"inputs": [
{
"name": "sender",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "ERC20InvalidSpender",
"type": "error",
"inputs": [
{
"name": "spender",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "NotDepositor",
"type": "error",
"inputs": []
},
{
"name": "NotOwner",
"type": "error",
"inputs": []
},
{
"name": "ReentrancyGuardReentrantCall",
"type": "error",
"inputs": []
},
{
"name": "SafeERC20FailedOperation",
"type": "error",
"inputs": [
{
"name": "token",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "TokenAlreadyDeposited",
"type": "error",
"inputs": []
},
{
"name": "TokenNotDeposited",
"type": "error",
"inputs": []
},
{
"name": "TransferDisabled",
"type": "error",
"inputs": []
},
{
"name": "WrongPool",
"type": "error",
"inputs": []
},
{
"name": "ZeroAddress",
"type": "error",
"inputs": []
},
{
"name": "ZeroLiquidity",
"type": "error",
"inputs": []
},
{
"name": "Approval",
"type": "event",
"inputs": [
{
"name": "owner",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "spender",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "Deposited",
"type": "event",
"inputs": [
{
"name": "depositor",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "tokenId",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
},
{
"name": "liquidity",
"type": "uint128",
"indexed": false,
"internalType": "uint128"
}
],
"anonymous": false
},
{
"name": "FeeRecipientUpdated",
"type": "event",
"inputs": [
{
"name": "oldRecipient",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "newRecipient",
"type": "address",
"indexed": true,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "FeesClaimed",
"type": "event",
"inputs": [
{
"name": "tokenId",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
},
{
"name": "amount0",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "amount1",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "Frozen",
"type": "event",
"inputs": [
{
"name": "account",
"type": "address",
"indexed": false,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "OwnershipTransferred",
"type": "event",
"inputs": [
{
"name": "previousOwner",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "newOwner",
"type": "address",
"indexed": true,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "Paused",
"type": "event",
"inputs": [
{
"name": "account",
"type": "address",
"indexed": false,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "Transfer",
"type": "event",
"inputs": [
{
"name": "from",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "to",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "Unfrozen",
"type": "event",
"inputs": [
{
"name": "account",
"type": "address",
"indexed": false,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "Unpaused",
"type": "event",
"inputs": [
{
"name": "account",
"type": "address",
"indexed": false,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "Withdrawn",
"type": "event",
"inputs": [
{
"name": "depositor",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "tokenId",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
},
{
"name": "liquidity",
"type": "uint128",
"indexed": false,
"internalType": "uint128"
}
],
"anonymous": false
},
{
"name": "allowance",
"type": "function",
"inputs": [
{
"name": "owner",
"type": "address",
"internalType": "address"
},
{
"name": "spender",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "approve",
"type": "function",
"inputs": [
{
"name": "spender",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"name": "balanceOf",
"type": "function",
"inputs": [
{
"name": "account",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "claimFees",
"type": "function",
"inputs": [
{
"name": "tokenId",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "claimFeesMultiple",
"type": "function",
"inputs": [
{
"name": "tokenIds",
"type": "uint256[]",
"internalType": "uint256[]"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "decimals",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint8",
"internalType": "uint8"
}
],
"stateMutability": "view"
},
{
"name": "deposit",
"type": "function",
"inputs": [
{
"name": "tokenId",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "depositedCountOf",
"type": "function",
"inputs": [
{
"name": "depositor",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "depositorOf",
"type": "function",
"inputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "emergencyFreeze",
"type": "function",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "emergencyUnfreeze",
"type": "function",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "feeRecipient",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "frozen",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "view"
},
{
"name": "getDepositedTokenIds",
"type": "function",
"inputs": [
{
"name": "depositor",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256[]",
"internalType": "uint256[]"
}
],
"stateMutability": "view"
},
{
"name": "liquidityOf",
"type": "function",
"inputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint128",
"internalType": "uint128"
}
],
"stateMutability": "view"
},
{
"name": "name",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"name": "onERC721Received",
"type": "function",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
{
"name": "",
"type": "bytes4",
"internalType": "bytes4"
}
],
"stateMutability": "view"
},
{
"name": "owner",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "pause",
"type": "function",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "paused",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "view"
},
{
"name": "poolFee",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint24",
"internalType": "uint24"
}
],
"stateMutability": "view"
},
{
"name": "poolToken0",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "poolToken1",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "positionManager",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract INPM"
}
],
"stateMutability": "view"
},
{
"name": "rescueERC20",
"type": "function",
"inputs": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "to",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "rescueERC721",
"type": "function",
"inputs": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "to",
"type": "address",
"internalType": "address"
},
{
"name": "tokenId",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "rescueETH",
"type": "function",
"inputs": [
{
"name": "to",
"type": "address",
"internalType": "address payable"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "setFeeRecipient",
"type": "function",
"inputs": [
{
"name": "newFeeRecipient",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "symbol",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"name": "totalDeposited",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "totalSupply",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "transfer",
"type": "function",
"inputs": [
{
"name": "to",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"name": "transferFrom",
"type": "function",
"inputs": [
{
"name": "from",
"type": "address",
"internalType": "address"
},
{
"name": "to",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"name": "transferOwnership",
"type": "function",
"inputs": [
{
"name": "newOwner",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "unpause",
"type": "function",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "withdraw",
"type": "function",
"inputs": [
{
"name": "tokenId",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "receive",
"stateMutability": "payable"
}
]0x608060405260043610610246575f3560e01c8063791b98bc11610131578063b169760e116100ac578063dd62ed3e1161007c578063f2fde38b11610062578063f2fde38b14610785578063f3d4b942146107a4578063ff50abdc146107b8575f80fd5b8063dd62ed3e14610722578063e74b981b14610766575f80fd5b8063b169760e1461069c578063b2118a8d146106d0578063b6b55f25146106ef578063d5a154f41461070e575f80fd5b806395d89b4111610101578063a73bf6df116100e7578063a73bf6df1461062b578063a9059cbb1461065e578063ac68a7481461067d575f80fd5b806395d89b41146105eb578063a4d5e1ff146105ff575f80fd5b8063791b98bc146105665780637df325e1146105995780638456cb59146105b85780638da5cb5b146105cc575f80fd5b8063313ce567116101c15780635c975abb116101915780635fd6c0ab116101775780635fd6c0ab146104df57806367ba6b53146104fe57806370a0823114610532575f80fd5b80635c975abb146104735780635f49a32c14610493575f80fd5b8063313ce567146103da5780633f4ba83a146103f557806346904840146104095780634758af8a14610440575f80fd5b8063095ea7b31161021657806318160ddd116101fc57806318160ddd1461037e57806323b872dd1461039c5780632e1a7d4d146103bb575f80fd5b8063095ea7b31461030f578063150b7a021461032e575f80fd5b806304824e7014610251578063054f7d9c1461027257806306fdde03146102a7578063089fe6aa146102c8575f80fd5b3661024d57005b5f80fd5b34801561025c575f80fd5b5061027061026b366004611cb8565b6107cd565b005b34801561027d575f80fd5b5060065461029290600160a81b900460ff1681565b60405190151581526020015b60405180910390f35b3480156102b2575f80fd5b506102bb610857565b60405161029e9190611cda565b3480156102d3575f80fd5b506102fb7f000000000000000000000000000000000000000000000000000000000000271081565b60405162ffffff909116815260200161029e565b34801561031a575f80fd5b50610292610329366004611d26565b6108e7565b348015610339575f80fd5b5061034d610348366004611d50565b610900565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200161029e565b348015610389575f80fd5b506002545b60405190815260200161029e565b3480156103a7575f80fd5b506102926103b6366004611de7565b61096d565b3480156103c6575f80fd5b506102706103d5366004611e25565b610990565b3480156103e5575f80fd5b506040516012815260200161029e565b348015610400575f80fd5b50610270610b63565b348015610414575f80fd5b50600654610428906001600160a01b031681565b6040516001600160a01b03909116815260200161029e565b34801561044b575f80fd5b506104287f000000000000000000000000c77fbd3824cc68e612b26114d176879addc2946381565b34801561047e575f80fd5b5060065461029290600160a01b900460ff1681565b34801561049e575f80fd5b506104c76104ad366004611e25565b60086020525f90815260409020546001600160801b031681565b6040516001600160801b03909116815260200161029e565b3480156104ea575f80fd5b506102706104f9366004611e3c565b610bfb565b348015610509575f80fd5b50610428610518366004611e25565b60076020525f90815260409020546001600160a01b031681565b34801561053d575f80fd5b5061038e61054c366004611cb8565b6001600160a01b03165f9081526020819052604090205490565b348015610571575f80fd5b506104287f0000000000000000000000005143ba6007c197b4cf66c20601b9db97e0f98c6a81565b3480156105a4575f80fd5b506102706105b3366004611de7565b610c8b565b3480156105c3575f80fd5b50610270610d92565b3480156105d7575f80fd5b50600554610428906001600160a01b031681565b3480156105f6575f80fd5b506102bb610e2b565b34801561060a575f80fd5b5061061e610619366004611cb8565b610e3a565b60405161029e9190611eab565b348015610636575f80fd5b506104287f0000000000000000000000001cd0690ff9a693f5ef2dd976660a8dafc81a109c81565b348015610669575f80fd5b50610292610678366004611d26565b610ea3565b348015610688575f80fd5b50610270610697366004611e25565b610eb0565b3480156106a7575f80fd5b5061038e6106b6366004611cb8565b6001600160a01b03165f9081526009602052604090205490565b3480156106db575f80fd5b506102706106ea366004611de7565b610f15565b3480156106fa575f80fd5b50610270610709366004611e25565b610f79565b348015610719575f80fd5b5061027061133a565b34801561072d575f80fd5b5061038e61073c366004611eee565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b348015610771575f80fd5b50610270610780366004611cb8565b6113cd565b348015610790575f80fd5b5061027061079f366004611cb8565b611470565b3480156107af575f80fd5b50610270611513565b3480156107c3575f80fd5b5061038e600b5481565b6005546001600160a01b031633146107f8576040516330cd747160e01b815260040160405180910390fd5b5f816001600160a01b0316476040515f6040518083038185875af1925050503d805f8114610841576040519150601f19603f3d011682016040523d82523d5f602084013e610846565b606091505b5050905080610853575f80fd5b5050565b60606003805461086690611f25565b80601f016020809104026020016040519081016040528092919081815260200182805461089290611f25565b80156108dd5780601f106108b4576101008083540402835291602001916108dd565b820191905f5260205f20905b8154815290600101906020018083116108c057829003601f168201915b5050505050905090565b5f336108f48185856115bf565b60019150505b92915050565b600c545f9060ff16158061093d5750336001600160a01b037f0000000000000000000000005143ba6007c197b4cf66c20601b9db97e0f98c6a1614155b1561095b57604051633ee6509d60e01b815260040160405180910390fd5b50630a85bd0160e11b95945050505050565b5f3361097a8582856115cc565b61098585858561164d565b506001949350505050565b6109986116aa565b600654600160a81b900460ff16156109c357604051634051e96160e01b815260040160405180910390fd5b5f818152600760205260409020546001600160a01b031633146109f957604051633cc50b4560e01b815260040160405180910390fd5b610a02816116d8565b5f818152600860205260409020546001600160801b0316610a23338261182f565b5f82815260086020526040902080546fffffffffffffffffffffffffffffffff19169055610a513383611863565b5f828152600760205260409081902080546001600160a01b0319169055600b80545f1901905551632142170760e11b8152306004820152336024820152604481018390526001600160a01b037f0000000000000000000000005143ba6007c197b4cf66c20601b9db97e0f98c6a16906342842e0e906064015f604051808303815f87803b158015610ae0575f80fd5b505af1158015610af2573d5f803e3d5ffd5b50506040516001600160801b03841681528492503391507f07b03e311473c1939a1fefecdf08517eedbe848e20a7d5f4ac265ec4bae8c7a09060200160405180910390a350610b6060017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b50565b6005546001600160a01b03163314610b8e576040516330cd747160e01b815260040160405180910390fd5b600654600160a01b900460ff16610bb85760405163dcdde9dd60e01b815260040160405180910390fd5b6006805460ff60a01b191690556040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa906020015b60405180910390a1565b610c036116aa565b6005546001600160a01b03163314610c2e576040516330cd747160e01b815260040160405180910390fd5b5f5b81811015610c6157610c59838383818110610c4d57610c4d611f5d565b905060200201356116d8565b600101610c30565b5061085360017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b6005546001600160a01b03163314610cb6576040516330cd747160e01b815260040160405180910390fd5b7f0000000000000000000000005143ba6007c197b4cf66c20601b9db97e0f98c6a6001600160a01b0316836001600160a01b0316148015610d0c57505f818152600760205260409020546001600160a01b031615155b15610d2a57604051639dda579960e01b815260040160405180910390fd5b6040516323b872dd60e01b81523060048201526001600160a01b038381166024830152604482018390528416906323b872dd906064015f604051808303815f87803b158015610d77575f80fd5b505af1158015610d89573d5f803e3d5ffd5b50505050505050565b6005546001600160a01b03163314610dbd576040516330cd747160e01b815260040160405180910390fd5b600654600160a01b900460ff1615610de85760405163ab35696f60e01b815260040160405180910390fd5b6006805460ff60a01b1916600160a01b1790556040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25890602001610bf1565b60606004805461086690611f25565b6001600160a01b0381165f90815260096020908152604091829020805483518184028101840190945280845260609392830182828015610e9757602002820191905f5260205f20905b815481526020019060010190808311610e83575b50505050509050919050565b5f336108f481858561164d565b610eb86116aa565b6005546001600160a01b03163314610ee3576040516330cd747160e01b815260040160405180910390fd5b610eec816116d8565b610b6060017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b6005546001600160a01b03163314610f40576040516330cd747160e01b815260040160405180910390fd5b306001600160a01b03841603610f695760405163a24e573d60e01b815260040160405180910390fd5b610f74838383611954565b505050565b610f816116aa565b600654600160a01b900460ff1615610fac5760405163ab35696f60e01b815260040160405180910390fd5b600654600160a81b900460ff1615610fd757604051634051e96160e01b815260040160405180910390fd5b5f818152600760205260409020546001600160a01b03161561100c57604051637857757960e01b815260040160405180910390fd5b5f805f807f0000000000000000000000005143ba6007c197b4cf66c20601b9db97e0f98c6a6001600160a01b03166399fbab88866040518263ffffffff1660e01b815260040161105e91815260200190565b61018060405180830381865afa15801561107a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061109e9190611fba565b505050509750505095509550955050507f0000000000000000000000001cd0690ff9a693f5ef2dd976660a8dafc81a109c6001600160a01b0316846001600160a01b031614158061112157507f000000000000000000000000c77fbd3824cc68e612b26114d176879addc294636001600160a01b0316836001600160a01b031614155b8061115657507f000000000000000000000000000000000000000000000000000000000000271062ffffff168262ffffff1614155b15611174576040516369e489f560e11b815260040160405180910390fd5b806001600160801b03165f0361119d57604051630200e8a960e31b815260040160405180910390fd5b5f8581526007602090815260408083208054336001600160a01b03199091168117909155808452600983528184208054600181810183558287528587209091018b905590548a8652600a85528386205560089093529281902080546fffffffffffffffffffffffffffffffff19166001600160801b038616179055600b805483019055600c805460ff191690921790915551632142170760e11b81526004810191909152306024820152604481018690526001600160a01b037f0000000000000000000000005143ba6007c197b4cf66c20601b9db97e0f98c6a16906342842e0e906064015f604051808303815f87803b158015611299575f80fd5b505af11580156112ab573d5f803e3d5ffd5b5050600c805460ff19169055506112cd9050336001600160801b038316611989565b6040516001600160801b0382168152859033907f1101ae99036692e99100b857ab62c3fcdac65cfdc42b08739812e2e2bbaec38a9060200160405180910390a350505050610b6060017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b6005546001600160a01b03163314611365576040516330cd747160e01b815260040160405180910390fd5b600654600160a81b900460ff1661138f57604051630547ea2560e51b815260040160405180910390fd5b6006805461ffff60a01b191690556040513381527f4feb53e305297ab8fb8f3420c95ea04737addc254a7270d8fc4605d2b9c61dba90602001610bf1565b6005546001600160a01b031633146113f8576040516330cd747160e01b815260040160405180910390fd5b6001600160a01b03811661141f5760405163d92e233d60e01b815260040160405180910390fd5b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907faaebcf1bfa00580e41d966056b48521fa9f202645c86d4ddf28113e617c1b1d3905f90a35050565b6005546001600160a01b0316331461149b576040516330cd747160e01b815260040160405180910390fd5b6001600160a01b0381166114c25760405163d92e233d60e01b815260040160405180910390fd5b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6005546001600160a01b0316331461153e576040516330cd747160e01b815260040160405180910390fd5b600654600160a81b900460ff161561156957604051634051e96160e01b815260040160405180910390fd5b6006805461ffff60a01b191675010100000000000000000000000000000000000000001790556040513381527f8a5c4736a33c7b7f29a2c34ea9ff9608afc5718d56f6fd6dcbd2d3711a1a491390602001610bf1565b610f7483838360016119bd565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f19811015611647578181101561163957604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b61164784848484035f6119bd565b50505050565b6001600160a01b03831661167657604051634b637e8f60e11b81525f6004820152602401611630565b6001600160a01b03821661169f5760405163ec442f0560e01b81525f6004820152602401611630565b610f74838383611a8f565b6116b2611ad8565b60027f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b5f818152600760205260409020546001600160a01b031661170c57604051639dda579960e01b815260040160405180910390fd5b604080516080810182528281526006546001600160a01b03908116602083019081526001600160801b0383850181815260608501828152955163fc6f786560e01b815294516004860152915183166024850152905181166044840152925190921660648201525f9182917f0000000000000000000000005143ba6007c197b4cf66c20601b9db97e0f98c6a9091169063fc6f78659060840160408051808303815f875af11580156117bf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117e39190612093565b91509150827f36da8462f185ec951096ed2767d3e52c056722ce16fa06ce6ec719a08e0277008383604051611822929190918252602082015260400190565b60405180910390a2505050565b6001600160a01b03821661185857604051634b637e8f60e11b81525f6004820152602401611630565b610853825f83611a8f565b5f818152600a60205260408120549081900361189257604051639dda579960e01b815260040160405180910390fd5b6001600160a01b0383165f908152600960205260408120805490919082906118bc906001906120c9565b815481106118cc576118cc611f5d565b905f5260205f200154905080826001856118e691906120c9565b815481106118f6576118f6611f5d565b5f918252602080832090910192909255828152600a909152604090208390558154829080611926576119266120dc565b600190038181905f5260205f20015f90559055600a5f8581526020019081526020015f205f90555050505050565b6119618383836001611b1c565b610f7457604051635274afe760e01b81526001600160a01b0384166004820152602401611630565b6001600160a01b0382166119b25760405163ec442f0560e01b81525f6004820152602401611630565b6108535f8383611a8f565b6001600160a01b0384166119e65760405163e602df0560e01b81525f6004820152602401611630565b6001600160a01b038316611a0f57604051634a1406b160e11b81525f6004820152602401611630565b6001600160a01b038085165f908152600160209081526040808320938716835292905220829055801561164757826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051611a8191815260200190565b60405180910390a350505050565b6001600160a01b03831615801590611aaf57506001600160a01b03821615155b15611acd5760405163a24e573d60e01b815260040160405180910390fd5b610f74838383611b7e565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0054600203611b1a57604051633ee5aeb560e01b815260040160405180910390fd5b565b60405163a9059cbb60e01b5f8181526001600160a01b038616600452602485905291602083604481808b5af1925060015f51148316611b72578383151615611b66573d5f823e3d81fd5b5f873b113d1516831692505b60405250949350505050565b6001600160a01b038316611ba8578060025f828254611b9d91906120f0565b90915550611c189050565b6001600160a01b0383165f9081526020819052604090205481811015611bfa5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401611630565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b038216611c3457600280548290039055611c52565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611c9791815260200190565b60405180910390a3505050565b6001600160a01b0381168114610b60575f80fd5b5f60208284031215611cc8575f80fd5b8135611cd381611ca4565b9392505050565b5f602080835283518060208501525f5b81811015611d0657858101830151858201604001528201611cea565b505f604082860101526040601f19601f8301168501019250505092915050565b5f8060408385031215611d37575f80fd5b8235611d4281611ca4565b946020939093013593505050565b5f805f805f60808688031215611d64575f80fd5b8535611d6f81611ca4565b94506020860135611d7f81611ca4565b935060408601359250606086013567ffffffffffffffff80821115611da2575f80fd5b818801915088601f830112611db5575f80fd5b813581811115611dc3575f80fd5b896020828501011115611dd4575f80fd5b9699959850939650602001949392505050565b5f805f60608486031215611df9575f80fd5b8335611e0481611ca4565b92506020840135611e1481611ca4565b929592945050506040919091013590565b5f60208284031215611e35575f80fd5b5035919050565b5f8060208385031215611e4d575f80fd5b823567ffffffffffffffff80821115611e64575f80fd5b818501915085601f830112611e77575f80fd5b813581811115611e85575f80fd5b8660208260051b8501011115611e99575f80fd5b60209290920196919550909350505050565b602080825282518282018190525f9190848201906040850190845b81811015611ee257835183529284019291840191600101611ec6565b50909695505050505050565b5f8060408385031215611eff575f80fd5b8235611f0a81611ca4565b91506020830135611f1a81611ca4565b809150509250929050565b600181811c90821680611f3957607f821691505b602082108103611f5757634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52603260045260245ffd5b8051611f7c81611ca4565b919050565b805162ffffff81168114611f7c575f80fd5b8051600281900b8114611f7c575f80fd5b80516001600160801b0381168114611f7c575f80fd5b5f805f805f805f805f805f806101808d8f031215611fd6575f80fd5b8c516bffffffffffffffffffffffff81168114611ff1575f80fd5b9b50611fff60208e01611f71565b9a5061200d60408e01611f71565b995061201b60608e01611f71565b985061202960808e01611f81565b975061203760a08e01611f93565b965061204560c08e01611f93565b955061205360e08e01611fa4565b94506101008d015193506101208d015192506120726101408e01611fa4565b91506120816101608e01611fa4565b90509295989b509295989b509295989b565b5f80604083850312156120a4575f80fd5b505080516020909101519092909150565b634e487b7160e01b5f52601160045260245ffd5b818103818111156108fa576108fa6120b5565b634e487b7160e01b5f52603160045260245ffd5b808201808211156108fa576108fa6120b556