// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) 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 FailedInnerCall();
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)
pragma solidity ^0.8.20;
import {IERC721Receiver} from "../IERC721Receiver.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or
* {IERC721-setApprovalForAll}.
*/
abstract contract ERC721Holder is IERC721Receiver {
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {
return this.onERC721Received.selector;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 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.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 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);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @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.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
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].
*
* CAUTION: See Security Considerations above.
*/
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
pragma solidity ^0.8.17;
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
interface IERC20Z is IERC20Metadata {
/// @notice TokenInfo struct returned by the information function
struct TokenInfo {
/// @notice The collection address
address collection;
/// @notice The token ID
uint256 tokenId;
/// @notice The creator address
address creator;
}
/// @notice Event for when the ERC1155s are directly converted to ERC20Zs
/// @param erc20z ERC20Z Address
/// @param amount20z ERC20Z Amount
/// @param collection Collection address
/// @param tokenId ID for the ERC1155 token swapped
/// @param amount1155 Amount of 1155 converted
/// @param recipient Recipient of the conversion
event ConvertedTo20z(address indexed erc20z, uint256 amount20z, address collection, uint256 tokenId, uint256 amount1155, address recipient);
/// @notice Event for when ERC20Zs are directly converted to ERC1155
/// @param erc20z ERC20Z Address
/// @param amount20z ERC20Z Amount
/// @param collection Collection address
/// @param tokenId ID for the ERC1155 token swapped
/// @param amount1155 Amount of 1155 converted
/// @param recipient Recipient of the conversion
event ConvertedTo1155(address indexed erc20z, uint256 amount20z, address collection, uint256 tokenId, uint256 amount1155, address recipient);
/// @notice Event for when the secondary market is activated
/// @param token0 Token 0 for uniswap liquidity
/// @param amount0 Amount 0 for uniswap liquidity
/// @param token1 Token 1 for uniswap liquidity
/// @param amount1 Amount 1 for uniswap liquidity
/// @param fee Uniswap fee amount
/// @param positionId ERC721 Position ID for the default liquidity
/// @param lpLiquidity amount of lp liquidity held by this contract
/// @param erc20Excess ERC20 excess amount burned
/// @param erc1155Excess ERC1155 excess amount burned
event SecondaryMarketActivated(
address indexed token0,
uint256 indexed amount0,
address token1,
uint256 amount1,
uint256 fee,
uint256 positionId,
uint256 lpLiquidity,
uint256 erc20Excess,
uint256 erc1155Excess
);
/// @notice Event for when admin mint NFTs are received
/// @param quantity the amount received
event ReceivedAdminMintNFTs(uint256 quantity);
/// @notice Errors when attempts to reactivate
error AlreadyActivatedCannotReactivate();
/// @notice ERC1155 Ids do not match values length
error IDsDoNotMatchValuesLength();
/// @notice Passing in wrong ERC1155 token id to swap
error TokenIdNotValidToSwap();
/// @notice Action sent with ERC1155 data call is not known
error UnknownReceiveActionDataCall();
/// @notice Only supports receiving ERC721 Pool NFTs
error OnlySupportReceivingERC721UniswapPoolNFTs();
/// @notice Error when trying to swap ERC1155 to ERC20Z without the market being started.
error SecondaryMarketHasNotYetStarted();
/// @notice Only supports recieving ERC1155 associated with ERC20Z NFTs.
error OnlySupportReceivingERC1155AssociatedZoraNFT();
/// @notice Unauthorized to call this function
error OnlySaleStrategy();
/// @notice Pool creation failed
error PoolCreationFailed();
/// @notice Params are invalid
error InvalidParams();
/// @notice Insufficient balance
error InsufficientBalance();
/// @notice Invalid amount of ERC20z tokens
error InvalidAmount20z();
/// @notice Invalid ERC20z transfer
error Invalid20zTransfer();
/// @notice Recipient address cannot be zero
error RecipientAddressZero();
/// @notice Token URI
function tokenURI() external view returns (string memory);
/// @notice Token information
function tokenInfo() external view returns (TokenInfo memory);
/// @notice Returns the ERC20Z contract URI
function contractURI() external view returns (string memory);
/// @notice Token liquidity information getter
function tokenLiquidityInfo() external view returns (address pool, uint256 initialLiquidityPositionId);
/// @notice Initialize the ERC20Z token
/// @param collection The collection address
/// @param tokenId The token ID
/// @param name The token name
/// @param symbol The token symbol
function initialize(address collection, uint256 tokenId, string memory name, string memory symbol) external returns (address);
/// @notice Activate the ERC20Z token
/// @param erc20TotalSupply The total supply of the ERC20 token
/// @param erc20Reserve The reserve of the ERC20 token
/// @param erc20Liquidity The liquidity of the ERC20 token
/// @param erc20Excess The excess of the ERC20 token
/// @param erc1155Excess The excess of the ERC1155 token
function activate(uint256 erc20TotalSupply, uint256 erc20Reserve, uint256 erc20Liquidity, uint256 erc20Excess, uint256 erc1155Excess) external;
/// @notice Convert 1155 to ERC20z tokens
/// @param amount1155 The amount of 1155 tokens to convert
/// @param recipient The recipient address
function wrap(uint256 amount1155, address recipient) external;
/// @notice Convert ERC20z to 1155 tokens
/// @param amount20z The amount of ERC20z tokens to convert
/// @param recipient The recipient address
function unwrap(uint256 amount20z, address recipient) external;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
interface INonfungiblePositionManager {
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
/// @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);
/// @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);
/// @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 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
);
function approve(address to, uint256 tokenId) external;
function transferFrom(address from, address to, uint256 tokenId) external;
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/// @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);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {IWETH} from "./IWETH.sol";
import {INonfungiblePositionManager} from "./uniswap/INonfungiblePositionManager.sol";
interface IRoyalties {
/// @notice RoyaltyClaim Event
/// @param collection The 1155 collection address
/// @param tokenId The 1155 collection token ID
/// @param creator The creator address
/// @param recipient The recipient address
/// @param positionAddress The Uniswap V3 position address
/// @param positionId The Uniswap V3 position id
/// @param token0 Token0 address
/// @param token0Amount The token0 amount
/// @param token1 Token1 address
/// @param token1Amount The token1 amount
event RoyaltyClaim(
address indexed collection,
uint256 indexed tokenId,
address indexed creator,
address recipient,
address positionAddress,
uint256 positionId,
address token0,
uint256 token0Amount,
address token1,
uint256 token1Amount
);
/// @notice UniswapTokenDeposited Event
/// @param erc20zAddress The ERC20Z address
/// @param positionAddress The Uniswap V3 position address
/// @param positionId The Uniswap V3 position id
event RoyaltyDeposit(address indexed erc20zAddress, address positionAddress, uint256 positionId);
/// @notice Only ERC20z address can call this function
error OnlyErc20z();
/// @notice Params cannot be zero
error ParamsCannotBeZero();
/// @notice Creator must be set
error CreatorMustBeSet();
/// @notice Only creator can call
error OnlyCreatorCanCall();
/// @notice Address cannot be zero
error AddressCannotBeZero();
/// @notice Only WETH can send ETH
error OnlyWeth();
/// @notice ERC721 Sender for Royalties needs to be the NFT Position Manager
error ERC721SenderRoyaltiesNeedsToBePositionManager();
/// @notice If the contract is already initialized
error AlreadyInitialized();
/// @notice if a zero address is passed
error AddressZero();
/// @notice Claim royalties for a creator
/// @param erc20z The associated erc20z token
/// @param recipient The recipient address
function claim(address erc20z, address payable recipient) external;
/// @notice Claim royalties for a creator
/// @param erc20z The associated erc20z token
function claimFor(address erc20z) external;
/// @notice Returns the total recipient fee based on a given amount
/// @param amount the amount
function getFee(uint256 amount) external view returns (uint256);
/// @notice The address of WETH
function WETH() external returns (IWETH);
/// @notice The Uniswap V3 nonfungible position manager address
function nonfungiblePositionManager() external returns (INonfungiblePositionManager);
/// @notice The total unclaimed fees for an ERC20z token
/// @param erc20z The ERC20z address
function getUnclaimedFees(address erc20z) external view returns (UnclaimedFees memory);
/// @notice The total unclaimed fees for a batch of ERC20z tokens
/// @param erc20z The ERC20z addresses
function getUnclaimedFeesBatch(address[] calldata erc20z) external view returns (UnclaimedFees[] memory);
struct UnclaimedFees {
address token0;
address token1;
uint128 token0Amount;
uint128 token1Amount;
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
interface IUniswapV3Pool {
/// @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);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IWETH {
function deposit() external payable;
function withdraw(uint256 wad) external;
function approve(address guy, uint256 wad) external returns (bool);
function transfer(address dst, uint256 wad) external returns (bool);
function transferFrom(address src, address dst, uint256 wad) external returns (bool);
function balanceOf(address guy) external view returns (uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IZora1155 {
struct TokenData {
string uri;
uint256 maxSupply;
uint256 totalMinted;
}
function getTokenInfo(uint256 tokenId) external view returns (TokenData memory);
function reduceSupply(uint256 tokenId, uint256 maxSupply) external;
function createReferrals(uint256 tokenId) external view returns (address);
function firstMinters(uint256 tokenId) external view returns (address);
function getCreatorRewardRecipient(uint256 tokenId) external view returns (address);
function adminMint(address recipient, uint256 tokenId, uint256 quantity, bytes memory data) external;
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function uri(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @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 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].
*/
abstract contract ReentrancyGuard {
// 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;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = 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();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = 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 _status == ENTERED;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IWETH} from "../interfaces/IWETH.sol";
import {INonfungiblePositionManager} from "../interfaces/uniswap/INonfungiblePositionManager.sol";
import {IUniswapV3Pool} from "../interfaces/uniswap/IUniswapV3Pool.sol";
import {IERC20Z} from "../interfaces/IERC20Z.sol";
import {IZora1155} from "../interfaces/IZora1155.sol";
import {IRoyalties} from "../interfaces/IRoyalties.sol";
/*
░░░░░░░░░░░░░░
░░▒▒░░░░░░░░░░░░░░░░░░░░
░░▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░
░░▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░
░▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░
░▓▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░░
░▓▓▓▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░░░
░▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░
░▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░
░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░
░░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░
░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░░░░░░▒▒▒▒▒░░
░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░
░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░░
OURS TRULY,
*/
/// @title Royalties
/// @notice Manages the royalty distribution for Zora 1155 secondary markets on Uniswap V3
/// @author @isabellasmallcombe @kulkarohan
contract Royalties is IRoyalties, ReentrancyGuard, ERC721Holder {
using SafeERC20 for IERC20;
IWETH public WETH;
INonfungiblePositionManager public nonfungiblePositionManager;
address payable public feeRecipient;
uint256 public feeBps;
mapping(address erc20z => uint256 positionId) public positionsByErc20z;
/// @notice Initializes the Royalties contract with chain-specific addresses
/// @param _weth The WETH address
/// @param _nonfungiblePositionManager The Uniswap V3 nonfungible position manager address
/// @param _feeRecipient The fee recipient address
/// @param _feeBps The fee basis points
function initialize(IWETH _weth, INonfungiblePositionManager _nonfungiblePositionManager, address payable _feeRecipient, uint256 _feeBps) external {
if (address(WETH) != address(0)) {
revert AlreadyInitialized();
}
_requireNotAddressZero(address(_weth));
_requireNotAddressZero(address(_nonfungiblePositionManager));
_requireNotAddressZero(_feeRecipient);
WETH = _weth;
nonfungiblePositionManager = _nonfungiblePositionManager;
feeRecipient = _feeRecipient;
feeBps = _feeBps;
}
/// @notice Claim royalties for a creator
/// @param erc20z ERC20Z address to claim royalties from
/// @param recipient The recipient address
function claim(address erc20z, address payable recipient) external nonReentrant {
_requireNotAddressZero(recipient);
(address payable creator, uint256 positionId, IERC20Z.TokenInfo memory tokenInfo) = _getInfoForERC20Z(erc20z);
if (msg.sender != creator) {
revert OnlyCreatorCanCall();
}
_claim(tokenInfo, positionId, creator, recipient);
}
/// @notice Claim royalties for a creator
/// @param erc20z ERC20Z address to claim royalties from
function claimFor(address erc20z) external nonReentrant {
(address payable creator, uint256 positionId, IERC20Z.TokenInfo memory tokenInfo) = _getInfoForERC20Z(erc20z);
_claim(tokenInfo, positionId, creator, creator);
}
/// @notice Get information for a given erc20z token
/// @param erc20z erc20z token contract address to get information for
function _getInfoForERC20Z(address erc20z) internal view returns (address payable creator, uint256 positionId, IERC20Z.TokenInfo memory tokenInfo) {
positionId = positionsByErc20z[erc20z];
tokenInfo = IERC20Z(erc20z).tokenInfo();
creator = payable(IZora1155(tokenInfo.collection).getCreatorRewardRecipient(tokenInfo.tokenId));
if (creator == address(0)) {
revert CreatorMustBeSet();
}
}
/// @notice Run the underlying claim function
/// @param tokenInfo token information for the token to claim from
/// @param positionId position id for the claim token
/// @param creator creator for the token
/// @param recipient recipient for the reward tokens
function _claim(IERC20Z.TokenInfo memory tokenInfo, uint256 positionId, address creator, address payable recipient) internal {
(address token0, address token1, uint256 amount0, uint256 amount1) = _collect(positionId);
_transfer(token0, amount0, recipient);
_transfer(token1, amount1, recipient);
emit RoyaltyClaim({
collection: tokenInfo.collection,
tokenId: tokenInfo.tokenId,
creator: creator,
recipient: recipient,
positionAddress: address(nonfungiblePositionManager),
positionId: positionId,
token0: token0 == address(WETH) ? address(0) : token0,
token0Amount: amount0,
token1: token1 == address(WETH) ? address(0) : token1,
token1Amount: amount1
});
}
/// @notice Collect Uniswap V3 LP position rewards
/// @param positionId The Uniswap V3 position token id
function _collect(uint256 positionId) internal returns (address token0, address token1, uint256 amount0, uint256 amount1) {
(, , token0, token1, , , , , , , , ) = nonfungiblePositionManager.positions(positionId);
INonfungiblePositionManager.CollectParams memory params = INonfungiblePositionManager.CollectParams({
tokenId: positionId,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
});
(amount0, amount1) = nonfungiblePositionManager.collect(params);
}
/// @notice Transfer ERC20z or ETH to a recipient
/// @param token The token address
/// @param amount The token amount
/// @param recipient The recipient address
function _transfer(address token, uint256 amount, address payable recipient) internal {
if (amount > 0) {
uint256 fee = getFee(amount);
uint256 amountRemaining = amount - fee;
if (token == address(WETH)) {
WETH.withdraw(amount);
Address.sendValue(feeRecipient, fee);
Address.sendValue(recipient, amountRemaining);
} else {
IERC20(token).safeTransfer(feeRecipient, fee);
IERC20(token).safeTransfer(recipient, amountRemaining);
}
}
}
/// @notice Returns the total recipient fee based on a given amount
/// @param amount the amount
function getFee(uint256 amount) public view returns (uint256) {
return (amount * feeBps) / 10_000;
}
/// @notice The total unclaimed fees for an ERC20z token
/// @param erc20z The ERC20z address
function getUnclaimedFees(address erc20z) public view returns (UnclaimedFees memory) {
uint256 positionId = positionsByErc20z[erc20z];
(
,
,
address token0,
address token1,
,
,
,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
) = nonfungiblePositionManager.positions(positionId);
(address pool, ) = IERC20Z(erc20z).tokenLiquidityInfo();
uint256 feeGrowthGlobal0 = IUniswapV3Pool(pool).feeGrowthGlobal0X128();
uint256 feeGrowthGlobal1 = IUniswapV3Pool(pool).feeGrowthGlobal1X128();
uint128 accruedFees0 = uint128(((feeGrowthGlobal0 - feeGrowthInside0LastX128) * liquidity) / 2 ** 128);
uint128 accruedFees1 = uint128(((feeGrowthGlobal1 - feeGrowthInside1LastX128) * liquidity) / 2 ** 128);
return UnclaimedFees({token0: token0, token1: token1, token0Amount: tokensOwed0 + accruedFees0, token1Amount: tokensOwed1 + accruedFees1});
}
/// @notice The total unclaimed fees for a batch of ERC20z tokens
/// @param erc20z The ERC20z addresses
function getUnclaimedFeesBatch(address[] calldata erc20z) external view returns (UnclaimedFees[] memory) {
UnclaimedFees[] memory unclaimedFees = new UnclaimedFees[](erc20z.length);
for (uint256 i; i < erc20z.length; ++i) {
unclaimedFees[i] = getUnclaimedFees(erc20z[i]);
}
return unclaimedFees;
}
/// @notice Reverts if the address is address(0)
/// @param _address The address to check
function _requireNotAddressZero(address _address) internal pure {
if (_address == address(0)) {
revert AddressZero();
}
}
/// @notice Receive ETH withdrawn from WETH
receive() external payable {
if (msg.sender != address(WETH)) {
revert OnlyWeth();
}
}
/// @notice Handles receiving a Uniswap V3 LP position
/// @param operator The address which initiated the transfer
/// @param from The address which previously owned the token
/// @param positionId The ID of the Uniswap V3 position
/// @param data Additional data with no specified format
/// @return bytes4 The function selector to confirm the transfer was accepted
function onERC721Received(address operator, address from, uint256 positionId, bytes memory data) public virtual override returns (bytes4) {
if (msg.sender != address(nonfungiblePositionManager)) {
revert ERC721SenderRoyaltiesNeedsToBePositionManager();
}
(, , address token0, address token1, , , , , , , , ) = nonfungiblePositionManager.positions(positionId);
// If from token owner is not a part of the pair, revert.
// This is not possible for WETH so we only check the ERC20Z part.
if (from != token0 && from != token1) {
revert OnlyErc20z();
}
positionsByErc20z[from] = positionId;
emit RoyaltyDeposit({erc20zAddress: from, positionAddress: address(nonfungiblePositionManager), positionId: positionId});
return super.onERC721Received(operator, from, positionId, data);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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;
/**
* @dev An operation with an ERC20 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 {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @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 {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
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.
*/
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.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @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);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// 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 cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
{
"compilationTarget": {
"src/royalties/Royalties.sol": "Royalties"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": [
":@openzeppelin/=node_modules/@openzeppelin/",
":@zoralabs/protocol-rewards/=node_modules/@zoralabs/protocol-rewards/",
":@zoralabs/shared-contracts/=node_modules/@zoralabs/shared-contracts/src/",
":ds-test/=node_modules/ds-test/src/",
":forge-std/=node_modules/forge-std/src/",
":solady/=node_modules/solady/src/"
],
"viaIR": true
}
[{"inputs":[],"name":"AddressCannotBeZero","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AddressZero","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"CreatorMustBeSet","type":"error"},{"inputs":[],"name":"ERC721SenderRoyaltiesNeedsToBePositionManager","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"OnlyCreatorCanCall","type":"error"},{"inputs":[],"name":"OnlyErc20z","type":"error"},{"inputs":[],"name":"OnlyWeth","type":"error"},{"inputs":[],"name":"ParamsCannotBeZero","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"positionAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"positionId","type":"uint256"},{"indexed":false,"internalType":"address","name":"token0","type":"address"},{"indexed":false,"internalType":"uint256","name":"token0Amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"uint256","name":"token1Amount","type":"uint256"}],"name":"RoyaltyClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc20zAddress","type":"address"},{"indexed":false,"internalType":"address","name":"positionAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"positionId","type":"uint256"}],"name":"RoyaltyDeposit","type":"event"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc20z","type":"address"},{"internalType":"address payable","name":"recipient","type":"address"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"erc20z","type":"address"}],"name":"claimFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc20z","type":"address"}],"name":"getUnclaimedFees","outputs":[{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint128","name":"token0Amount","type":"uint128"},{"internalType":"uint128","name":"token1Amount","type":"uint128"}],"internalType":"struct IRoyalties.UnclaimedFees","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"erc20z","type":"address[]"}],"name":"getUnclaimedFeesBatch","outputs":[{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint128","name":"token0Amount","type":"uint128"},{"internalType":"uint128","name":"token1Amount","type":"uint128"}],"internalType":"struct IRoyalties.UnclaimedFees[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IWETH","name":"_weth","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"_nonfungiblePositionManager","type":"address"},{"internalType":"address payable","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_feeBps","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nonfungiblePositionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"positionId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"erc20z","type":"address"}],"name":"positionsByErc20z","outputs":[{"internalType":"uint256","name":"positionId","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]