Skip to main content
added 330 characters in body
Source Link

Old question but I hadFor the same problem1st part, the collect function has the modifier

modifier isAuthorizedForToken(uint256 tokenId) {
        require(_isApprovedOrOwner(msg.sender, tokenId), 'Not approved');
}

with _isApprovedOrOwner being part of the ERC721 implementation (check OpenZeppelin doc).

So for a contract to call this function, even with a non-state changing staticcall, it needs to either be the owner or be approved.

For the 2nd part, it seems STATICCALL prevents modifying the state, and because collect tries to change state it reverts, as per EIP-214.

Afaik there's no way to know the UNI v3 fees from inside a smart contract without collecting them. Not sure why such a design it is indeed inconvenient.

Old question but I had the same problem, the collect function has the modifier

modifier isAuthorizedForToken(uint256 tokenId) {
        require(_isApprovedOrOwner(msg.sender, tokenId), 'Not approved');
}

with _isApprovedOrOwner being part of the ERC721 implementation (check OpenZeppelin doc).

So for a contract to call this function, even with a non-state changing staticcall, it needs to either be the owner or be approved.

For the 1st part, the collect function has the modifier

modifier isAuthorizedForToken(uint256 tokenId) {
        require(_isApprovedOrOwner(msg.sender, tokenId), 'Not approved');
}

with _isApprovedOrOwner being part of the ERC721 implementation (check OpenZeppelin doc).

So for a contract to call this function, even with a non-state changing staticcall, it needs to either be the owner or be approved.

For the 2nd part, it seems STATICCALL prevents modifying the state, and because collect tries to change state it reverts, as per EIP-214.

Afaik there's no way to know the UNI v3 fees from inside a smart contract without collecting them. Not sure why such a design it is indeed inconvenient.

Source Link

Old question but I had the same problem, the collect function has the modifier

modifier isAuthorizedForToken(uint256 tokenId) {
        require(_isApprovedOrOwner(msg.sender, tokenId), 'Not approved');
}

with _isApprovedOrOwner being part of the ERC721 implementation (check OpenZeppelin doc).

So for a contract to call this function, even with a non-state changing staticcall, it needs to either be the owner or be approved.